I need to receive 2-byte coded unusual and this routine works pretty chaotic. Is the problem in the deletion of the buffer? When an error occurs get a message on the screen:
An error has occurred in sub: main_astreams_nevdata (java line: 465)
java.lang.ArrayIndexOutOfBoundsException: length = 1; Index = 1
An error has occurred in sub: main_astreams_nevdata (java line: 465)
java.lang.ArrayIndexOutOfBoundsException: length = 1; Index = 1
B4X:
Sub Astreams_NewData (Buffer() As Byte)
Dim r As Int = 0
r = ((Bit.ShiftRight(Buffer(0),4) * 100) + (Bit.ShiftRight(Buffer(1),4) * 10) + (Bit.And(Buffer(1),15))) * 2
skbValue_ValueChanged(r, False) 'Sub that refreshes the LED bar
End Sub