Hi all,
Been finding answers here for a while so thought i'd ask. Looking for help on delimiter byte as i am finding it very hard to get every incoming string. I have added a packet sequence id to incoming data so I know i am missing about 1 in every 25 packets.
Hardware: multiple tags > UHF radio router > crossover cable > Ethernet shield > AtMega328P > HC05 (BT) > App
As I am writing both sides, I can add or change start and end bytes. I have also slowed down the code to allow for the slow serial connection between processor and BT module. Currently I am stripping off the begin and end TCP session packets as well as an XOR checksum and any \r's/\n's so the inbound packets should look like this:
$G,5,889EC082819C,R,53649,-97,12,69B2,92520A15,4,B,0,3,0,2,84,0100504301971001545375*
Using a serial monitor in place of the BT module, the data to that point is checked and good. When multiple packets arrive at processor from radio router buffer, they are still sent out one at a time.
Several comma separated fields have a varying number of characters, in fact the number of fields change in different modes as well. So I can't read a set number of bytes and I can't I can't check what characters are inside until I've read.
Assuming i stick with '*' as the packet delimiter, the byte to be entered in the BTclient designer (also tried setting as part of Screen 1 initialise) should be 42, or maybe 0042 (x2A). I have tried this and many others but continue to miss it occasionally. If the buffer can do over a hundred bytes and the clock cycle on the app is so much faster than the slow serial feed to the BT module, it should work.
I have had some success with joining the previous read to the current read if the current read doesn't contain a '$'. Also tried splitting the inbound packet at '*' into a list then checking the second index for a complete or partial string. I don't like this though as it is a fudge not a fix. The delimiter functions sounds ideal to make sue I read each packet correctly but I guess I have missed something.
Any advice greatly appreciated, thanks,
Ben.