Hello,
I am trying to read a constant stream of HEX data using RS485 breakout board. I would like to find a blocks of data starting with ‘05 10’ and the next 20 registers after it. I am using hardware.uart57.readblob() command and adding the datas into a main blob. I found a command to find values from an array but is there any find commands for blobs?
Regards,
Kevin.
Unfortunately not, but don’t forget that blobs can be used array-style, so you can iterate through the bytes looking for 05, then check the next byte is 10, and if it is read the next 20 or 40 bytes (whether 8- or 16-bit registers).
Something like (off the top of my head):
`foreach (index, byte in myBlob) {
if (byte == 05) {
if (index < myBlob.len() - 1) {
local val = myBlob[index + 1];
if (val == 10) {
// Read next xx bytes...
}
}
}
}`
I will try the code. Do you have a code to clear the blob for example.
if (blob.len() >= 200)
then clear the blob for blob[0] to blob[199]
Thank you very much.