Hello All,
I am setting up a command link with an acknowledge.
this code hangs instead of displaying the timeout message.
I am setting up a command link with an acknowledge.
this code hangs instead of displaying the timeout message.
B4X:
Sub AStream_NewData (buffer() As Byte)
checkbyte1 = buffer(0)
checkbyte2 = buffer(1)
checkbyte3 = buffer(2)
End Sub
B4X:
Sub timer1_tick
timeout = 1
End Sub
B4X:
Sub send_CMD_String (address As Int, CMD As Int, DAT As Int)
Dim sb As StringBuilder
Dim cmd_String As String
Dim buffer() As Byte
sb.Initialize
sb.append(Chr(address)). append(Chr(CMD)) .append(Chr(DAT))
cmd_String = sb.ToString
buffer=cmd_String.GetBytes("ISO-8859-1")
timeout = 0
timer1.Initialize("Timer1", 500)
timer1.Enabled = True
Do While timeout=0
AStream.Write(buffer)
If (checkbyte1 = address) And (checkbyte2 = CMD) And (checkbyte3=DAT) Then Exit
Loop
If (checkbyte1 <> address) Or (checkbyte2 <> CMD) Or (checkbyte3 <> DAT) Then
ToastMessageShow ("COMMUNICATION ERROR", True)
End If
End Sub