Solved: binary serial input problem
:sign0085:
I have a problem with evaluating the serial incomming stream.
I am trying to tune my GPS mouse
I can:
- open the serial port
- send binary commands to the mouse
now the problem:
The mouse is sending permanently the NMEA string to the com port.
When I send a binary command to the mouse it returns the binary string as confirmation. This binary string is just somewhere in the middle of the NMEA string.
I am not interrested in the NMEA string evaluation, I just want to find the binary data.
I am successfull sending the array "Dim command(56) as byte" to the mouse.
Why is the code below not working??
Thanks for your help
Christoph
:sign0085:
I have a problem with evaluating the serial incomming stream.
I am trying to tune my GPS mouse
I can:
- open the serial port
- send binary commands to the mouse
now the problem:
The mouse is sending permanently the NMEA string to the com port.
When I send a binary command to the mouse it returns the binary string as confirmation. This binary string is just somewhere in the middle of the NMEA string.
I am not interrested in the NMEA string evaluation, I just want to find the binary data.
I am successfull sending the array "Dim command(56) as byte" to the mouse.
Why is the code below not working??
Thanks for your help
Christoph
B4X:
Sub serial1_OnCom
if serial1.inbuffercount > 10 then
buffer() = serial1.InputArray 'take the serial data into buffer
' search the array for the code sequence
' stored in the array command()
for i = 0 to (ArrayLen (buffer())-7)
' only check the first 6 bytes
for j = 0 to 5
last.text= buffer(i+j)
if buffer(i+j) <> command(j) then exit
next j
if j = 5 then
select buffer(i+6)
case 2
last.text= "command OK"
mode.text= "Pedestrian"
case 3
last.text= "command OK"
mode.text= "Automotive"
case 6
last.text= "command OK"
mode.text= "Airborne <2g"
case else
last.text= "FAILED"
mode.text= ""
end select
exit
end if
next
end if
End Sub
Last edited: