Hi,
If I use "Sub AStreams_NewData (Buffer() As Byte)" subroutine and
I receive next data stream: $ModeAcknowledge:1* the program will work.
But when I get a shorter data stream for example : $ModeAckno:4* my program will stoped.What is the difference beetween two messages?
Thanks, Joe
There is the error message, and logs:
$PMode:1*
$ModeAcknowledge:1*
Mode
$PMode:2*
$ModeAcknowled:2*
Mode
$PMode:3*
$ModeAcknowl:3*
Mode
$PMode:4*
$ModeAckno:4*
main_astreams_newdata (java line: 367)
java.lang.StringIndexOutOfBoundsException
at java.lang.String.substring(String.java:1579)
at tcp.joe.home.main._astreams_newdata(main.java:367)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.BA$1.run(BA.java:210)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4644)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)
java.lang.StringIndexOutOfBoundsException
If I use "Sub AStreams_NewData (Buffer() As Byte)" subroutine and
I receive next data stream: $ModeAcknowledge:1* the program will work.
But when I get a shorter data stream for example : $ModeAckno:4* my program will stoped.What is the difference beetween two messages?
Thanks, Joe
B4X:
Sub AStreams_NewData (Buffer() As Byte)
Dim msg As String
msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
Log(msg)
If msg.SubString2(1,5) ="Mode" Then
Log (msg.SubString2(1,5))
End If
msg = ""
End Sub
$PMode:1*
$ModeAcknowledge:1*
Mode
$PMode:2*
$ModeAcknowled:2*
Mode
$PMode:3*
$ModeAcknowl:3*
Mode
$PMode:4*
$ModeAckno:4*
main_astreams_newdata (java line: 367)
java.lang.StringIndexOutOfBoundsException
at java.lang.String.substring(String.java:1579)
at tcp.joe.home.main._astreams_newdata(main.java:367)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.BA$1.run(BA.java:210)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4644)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)
java.lang.StringIndexOutOfBoundsException