Ignore data
Hi everyone
I have an RF receiver connected in serial with the BS2 and I use it to send a word size dara (16bit). Is there a way for the BS2 to ignore the data in the case of lost bits in the transmission, which means that the data received is less than 16 bits ?
Thanks
I have an RF receiver connected in serial with the BS2 and I use it to send a word size dara (16bit). Is there a way for the BS2 to ignore the data in the case of lost bits in the transmission, which means that the data received is less than 16 bits ?
Thanks
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
a VAR Word
main:
SERIN 0, 16780,5000, Timeout, [noparse][[/noparse]DEC a]
DEBUG ?a
GOTO main
timeout:
DEBUG "timeout"
RETURN
If I send a signal with BS1 which is connected directly to a BS2' pin, I get the signal (for example the number 65535). Through RF communication between BS1 and BS2 on the DEBUG I get 535, 5535 and rarely 65535. What I want is the 535 or 5535 to be disregarded.
Asynchronous serial data transmission is a byte-oriented protocol, so you will need to read the data in as bytes, regardless of what you want to do with it later on down the line. Here is your program changed to accomodate byte input, then stored it in a WORD sized variable:
/code
a VAR Word
main:
'·············································· 8 bits only··· 8 bits only
SERIN 0, 16780,5000, Timeout, [noparse][[/noparse]a.highbyte,·· a.lowbyte]
DEBUG ?a.highbyte 'Display just the top end
GOTO main
timeout:
DEBUG "timed out"
GOTO main
END
code/
If that's not exactly what you were looking to do, you may need to use the SHIFT function to dump the bits you want to eliminate:
a = a >> 8 'Dump 8 low bits into the bit-bucket near the Black Hole at the right
a = a << 8 'Re-align the data back to where it was
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I will try to reduce the baud rate and to separate the the word into bytes, but the thing is that sending a synchronization byte I can get the signal as appropriate.
SEROUT 0, 16780, [noparse][[/noparse]126,("A"),DEC a] 'transmitter
SERIN 0, 16780,5000, Timeout, [noparse][[/noparse]WAIT ("A"),DEC a] 'receiver
The problem is that as the instruction waits for synchronization, it never times out. Is there a way to make it to time out or this is not supported by BS2?