Using two serial ports as a bi-directional pipe
Don French
Posts: 126
I want to use a BS2 with two serial connections and pass all bytes coming in either port out the other port. I tried the using the timeout feature of SERIN, as in the following:
Baud CON 84
Timeout CON 2
DO
SERIN RX\RTS,Baud, Timeout, NoData1, [noparse][[/noparse]dataByte]
SEROUT 16, Baud, [noparse][[/noparse]dataByte]
NoData1:
SERIN 16, Baud, Timeout, NoData2 [noparse][[/noparse]dataByte]
SEROUT TX\RTS, Baud, [noparse][[/noparse]dataByte]
NoData2:
LOOP
With a timeout value of 1, no characters are ever transmitted. With a timeout value of 2, it does fairly well, only dropping every third or fourth character. With a timeout of 3 and higher it drops about 3 out of every 4 characters.
Is there a way to do this that drops no characters? FWIW, I am using a HomeWork board and using the programming port for one port and a XBee RF modem for the other port.
Baud CON 84
Timeout CON 2
DO
SERIN RX\RTS,Baud, Timeout, NoData1, [noparse][[/noparse]dataByte]
SEROUT 16, Baud, [noparse][[/noparse]dataByte]
NoData1:
SERIN 16, Baud, Timeout, NoData2 [noparse][[/noparse]dataByte]
SEROUT TX\RTS, Baud, [noparse][[/noparse]dataByte]
NoData2:
LOOP
With a timeout value of 1, no characters are ever transmitted. With a timeout value of 2, it does fairly well, only dropping every third or fourth character. With a timeout of 3 and higher it drops about 3 out of every 4 characters.
Is there a way to do this that drops no characters? FWIW, I am using a HomeWork board and using the programming port for one port and a XBee RF modem for the other port.
Comments
Another problem you have is that it looks like you're trying to recieve (and pass on) one byte at a time. Each byte takes 1 mSec (at 9600 baud) to be recieved, but the SERIN statement takes like 500 uSec to execute. So there's a LOT of time there the BS2 is not 'listenting'.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Since the BASIC Stamp cannot monitor and receive Serial streams from more than one port at a time I don’t see how it could be done with a BASIC Stamp unless you have a large external FIFO buffer, but again, this wouldn’t be using what you have.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
http://www.rhombus-tek.com/co-processors.html
The "Simple Multi-Tasking" processor has a recieve-only UART buffer built in.
You get info from it using SHIFTIN/SHIFTOUT.
That's pretty cool and not very expensive either! Thanks!
-- Don