PICO high speed serial problem


Author Message
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1996
Posted: 01:38pm 19 Jun 2024      

  ElectroPI said  
How are you checking to see when your 8 bytes have been received? I assume you're reading the serial buffer using the INPUT$ command?


Well 8 bytes is the maximum but the packets can be shorter.

If there is data in the buffer, I read one character.
if the character = &HAA, that's my header so this could be a packet

Read the next character
If the character = my_node_address then looks like it's for me. If not, continue to read the data anyway (to empty the buffer) but don't do anything with it.

Read the next character
In my case, this is a control byte;upper nibble = command, lower nibble = # of data-bytes to follow.

Read each data-byte

Final byte is checksum

Perform checksum and if all is good, execute the command on the Pico
TX a status byte indicating good/bad checksum and other status info

Go back and wait for more
Edited 2024-06-19 23:42 by PhenixRising