*** Issue of the topic: please be detailed explaining your issue**
Hello. I’m newbies.
I use Arduino and Raspberry. And I connected by serial communication(ttyUSB0).
Arduino sends several bytes of data. like this 90 165 1 1 0 1 …
(there is no space, “;” and “,”)
I want to store bytes in an int array. and i want to check the saved value.
I saw “header1 match”, but not “header2 match”
I did a search last week. But i could not find the answer.
Please help me T.T
*** Please post configurations (if applicable):**
Items configuration related to the issue
String TestLogData "Log Data [%s]" {serial="/dev/ttyUSB0@9600"}
Rules code related to the issue
rule "Received Log Data"
when
Item TestLogData received update
then
var List<Integer> LogData = TestLogData.state.toString.getBytes()
var Number header1
var Number header2
header1 = LogData.get(0)
header2 = LogData.get(1)
if (header1 == 0x5A)
{
logInfo("Debug", "header1 match")
}
if (header2 == 0xA5)
{
logInfo("Debug", "header2 match")
}
If logs where generated please post these here using code fences:
rule "Received Log Data"
when
Item TestLogData received update
then
var List<Integer> LogData = TestLogData.state.toString.getBytes()
var Number header1
var Number header2
logInfo("TestLogData", TestLogData.toString)
header1 = LogData.get(0)
header2 = LogData.get(1)
if (header1 == 0x5A) {
logInfo("Debug", "header1 match")
}
if (header2 == 0xA5) {
logInfo("Debug", "header2 match")
}
end
I added a logInfo to print the whole string
What does the log show when you receive data?
Only the first byte is recognised properly, have you checked that your receiving serial port is configured properly especially the parity and end bits?