I am parsing byte arrays that contain a number of binary encoded messages (the whole 0-255 range) and I need to find start and end of messages and eliminate some byte stuffing. The data comes through WiFi and I have to process it as it comes. At the other end of the WiFi link is a serial device that sends data at 9600 bauds, so the data rate is not very high (probably 300-600 bytes/sec average, but the longer the messages, the less time I have to process them)
Doing it character by character with a for() loop is actually not fast enough to run on an inexpensive tablet (runs well on a Moto-X 4 and very well on a Pixel 2 but not well at all on a 5 year old XT1096 phone or the Fire tablet).
I have tried to cast the data to a string and use string matching and IndexOf() but that does not work, I suspect that the binary data containing zeros messes with strings that are normally null-terminated.
I should mention that after the messages are split, they still need to be decoded and displayed and at the moment, that takes about as long as the message splitting itself even though I am just putting text into labels (no fancy graphics).
Interestingly, the same algorithm runs very well in C on a 12 MHz 8 bit microcontroller driving an LCD
While for this app I could live with the requirement for a relatively modern device, I would like to explore a little bit for better ways to do it and
I thought regular expressions would probably help but apparently the RegEx.Matcher does not like binary data.
Any suggestion appreciated.
Doing it character by character with a for() loop is actually not fast enough to run on an inexpensive tablet (runs well on a Moto-X 4 and very well on a Pixel 2 but not well at all on a 5 year old XT1096 phone or the Fire tablet).
I have tried to cast the data to a string and use string matching and IndexOf() but that does not work, I suspect that the binary data containing zeros messes with strings that are normally null-terminated.
I should mention that after the messages are split, they still need to be decoded and displayed and at the moment, that takes about as long as the message splitting itself even though I am just putting text into labels (no fancy graphics).
Interestingly, the same algorithm runs very well in C on a 12 MHz 8 bit microcontroller driving an LCD
While for this app I could live with the requirement for a relatively modern device, I would like to explore a little bit for better ways to do it and
I thought regular expressions would probably help but apparently the RegEx.Matcher does not like binary data.
Any suggestion appreciated.