Re: [3.1]How serial send 0xa5a5 so correctly received & tested in 4byte structure?

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...

Firstly, #A5A5 is only two bytes long. Each #A5 is just one byte long.

Secondly, the serial_puts() routine only sends the lower (least significant) 8-bits (a byte) from each element in the sequence. This means that if the first element is #A5A5, it only sends the rightmost #A5 byte. To fix this, change the definition of 'sync' to ...

constant sync = {#A5, #A5} -- a TWO byte header sync marker. 

If you need a FOUR byte marker then use {#A5,#A5,#A5,#A5} maybe.

Thanks Derek, makes sense! I think I'd need {#A,#5,#A,#5} to yield the expected 4 byte 0xA5A5 ?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu