B4J Question Error with asyncstreamstext

HARRY

Active Member
Licensed User
Longtime User
The following error occurs only in debug mode, not in release mode.

Line 138 = End Sub

B4X:
Sub Stream1_NewText (Text As String)  'receive information from the IntelMeterSupport node
    pos1=Text.IndexOf(s)
    mcode=Text.SubString2(0,pos1)
    If  mcode=3 Then                'Registration
        DoRegistration(Text)
    else if mcode=4 Then            'Movement
        GetWebcam
    else if mcode=5 Then            'Date/time
        mcode=6
        Stream2.Write(mcode & s &  Text.SubString(2) & CRLF    )
    End If
End Sub

The log reads:
Error occurred on line: 138 (Main)
Program terminated (StartMessageLoop was not called).
java.lang.RuntimeException: java.io.EOFException
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at anywheresoftware.b4a.BA$2.run(BA.java:202)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:113)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:136)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:79)
at anywheresoftware.b4a.Shell
BA.raiseEvent2(ShellBA.java:92)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:70)
at b4j.example.main.main(main.java:29)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:221)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:79)
... 16 more
java.lang.RuntimeException: java.util.NoSuchElementException
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:70)
at b4j.example.main.main(main.java:29)
Caused by: java.util.NoSuchElementException
at java
.util.LinkedList.removeFirst(LinkedList.java:270)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:320)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:79)
... 3 more
[/CODE]

Stream1 is sent from an Arduino computer with the following code:
.
B4X:
 String message = "";
      message = mcode +  s + tempinside + s + lightinside + s + humidityinside +  s +  outside.temp  + s + outside.humidity + s + outside.pressure + s + outside.lowbat + s + outside.voltage + s + newreg.elecconsumption + s + interval + s + minute  + s + hour + s + year + s + month + s + week + s + day + s + newreg.eleccount + s + newreg.gascount + s;
      WiFly.println(message);

Am I doing something wrong?

Harry
 

HARRY

Active Member
Licensed User
Longtime User
Hi Erel,
For your information: I use B4J 5.00 and the latest B4J-Bridge ( downloaded last sunday).
The program runs fine in release mode; I only want to use debug mode to find out why GPIO digitalinput does not work, the state change event is not activated.
The device is a Raspberry B3, running on the latest Debian Jessie version ( downloaded last sunday).
I have uploaded the project.
Harry
 

Attachments

  • DomoServer.zip
    6 KB · Views: 172
Upvote 0

HARRY

Active Member
Licensed User
Longtime User
Hi Erel,

Using B4R will be difficult, if not impossible. I don't use Arduino hardware but Jeelabs. That microprocessor has all 4 ports populated with RTC module, UART module supporting a WiFi module, and a combined PIR, humidity and temperatrure module using two ports. Moreover it communicates via RF with two other microprocessors.

I am not an expert, but I don't see how memory fragmentation could occur only when the Raspberry is running in debug mode and never when the Raspberry is running in release mode. The 'Arduino' doesn't know how the Raspberry is running or does it?

I tested with B4J v5.50 beta, with the same result, so errors in debug mode.

Any more ideas?

Harry
 
Upvote 0

HARRY

Active Member
Licensed User
Longtime User
Hi Erel,

I changed the Arduino program adding message.reserve(200), assuming that this will reduce the risk of memory fragmentation as no new string has to be built and allocated in memory each time an element is added.

Anyhow, with this change there is no improvement; still the same error. Strange is that the first message is received correctly. The second message which arrives after+/- 12 seconds fails. This is a constant behaviour.

I will proceed with the Release mode.

Thanks for the time you have spent to my problem.

Harry
 
Upvote 0
Top