Aduino strange errors

Hi 

I sometimes ( not always ) get some strange errors in the Arduino service.

I think it is some type of timing issue.

Using this little script sometimes reproduce the error. 

arduino = Runtime.start("arduino","Arduino")
arduino.connect("COM8")
 
Not a very complicated script.  I sent a No-worky from Eclipse. Not 100% sure if that work.
I tried adding a sleep(5) before the connect and then it works.
 
A small part of the logfile when this occurs:
 
00:11:53.540 [python.interpreter.3] WARN  c.myrobotlab.framework.Service - no such method Serial.publishPortNames(ArrayList) :  - attempting upcasting
00:11:53.541 [python.interpreter.3] WARN  c.myrobotlab.framework.Service - searching through 213 methods
00:11:53.544 [python.interpreter.3] INFO  class org.myrobotlab.io.FileIO - looking for /resource/Arduino/MrlComm/MrlComm.ino
00:11:53.583 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [arduino/publishStatus ---> gui/onStatus]
00:11:53.584 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [arduino/publishState ---> gui/onState]
00:11:53.781 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [arduino.serial/publishStatus ---> gui/onStatus]
00:11:53.782 [AWT-EventQueue-0] INFO  c.myrobotlab.framework.Service - subscribe [arduino.serial/publishState ---> gui/onState]
00:11:57.553 [python.interpreter.3] INFO  c.myrobotlab.framework.Status - connect to port COM4 115200|8|1|0
00:11:57.554 [python.interpreter.3] INFO  class org.myrobotlab.service.Serial - creating org.myrobotlab.serial.PortJSSC port COM4 115200|8|1|0
00:11:57.555 [python.interpreter.3] INFO  c.myrobotlab.framework.Status - created  port COM4 115200|8|1|0 - goodtimes
00:11:57.587 [python.interpreter.3] INFO  c.myrobotlab.framework.Status - arduino.serial publishConnect COM4
00:11:57.604 [python.interpreter.3] INFO  class org.myrobotlab.service.Serial - setParams 115200 8 1 0
00:11:57.619 [COM4.portListener 1] INFO  class org.myrobotlab.serial.Port - listening on port COM4
00:11:57.643 [python.interpreter.3] ERROR c.myrobotlab.framework.Service - serial open threw
java.lang.NullPointerException: null
at org.myrobotlab.service.Arduino.connect(Arduino.java:430) [bin/:na]
at org.myrobotlab.service.Arduino.connect(Arduino.java:392) [bin/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_66]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_66]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_66]
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186) [jython-2.7.0.jar:na]
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204) [jython-2.7.0.jar:na]
at org.python.core.PyObject.__call__(PyObject.java:478) [jython-2.7.0.jar:na]
at org.python.core.PyObject.__call__(PyObject.java:482) [jython-2.7.0.jar:na]
at org.python.core.PyMethod.__call__(PyMethod.java:141) [jython-2.7.0.jar:na]
at org.python.pycode._pyx3.f$0(<string>:3) [jython-2.7.0.jar:na]
at org.python.pycode._pyx3.call_function(<string>) [jython-2.7.0.jar:na]
at org.python.core.PyTableCode.call(PyTableCode.java:167) [jython-2.7.0.jar:na]
at org.python.core.PyCode.call(PyCode.java:18) [jython-2.7.0.jar:na]
at org.python.core.Py.runCode(Py.java:1386) [jython-2.7.0.jar:na]
at org.python.core.Py.exec(Py.java:1430) [jython-2.7.0.jar:na]
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:267) [jython-2.7.0.jar:na]
at org.myrobotlab.service.Python$PIThread.run(Python.java:161) [bin/:na]
00:11:57.647 [python.interpreter.3] ERROR c.myrobotlab.framework.Service - arduino error 
----------------------------------
 
I have also seen this seen a strange behaviour where the Arduino service creates two tabs, and one of them say "Arduino does not have a user interface". The other tab is empty without any text. So neither show the normal Arduino GUI. It only happens sometimes, so it's probably also some timing issue.
 
 
 
This is the logfile from when the second type of error occurs:
 
[python] [INFO] exec(String) 
arduino = Runtime.create("arduino","Arduino")
arduino.connect("COM3")
[python.interpreter.3] [INFO] Runtime.createService arduino
[python.interpreter.3] [INFO] getMessageSet loading 259 non-sub-routable methods
[python.interpreter.3] [INFO] cfg file C:\MRL4\myrobotlab\.myrobotlab\arduino.json does not exist
[python.interpreter.3] [WARN] no such method Runtime.registered(Arduino) :  - attempting upcasting
[python.interpreter.3] [WARN] searching through 253 methods
[gui] [WARN] no such method SwingGui.addTab(Arduino) :  - attempting upcasting
[gui] [WARN] searching through 186 methods
[python] [WARN] no such method Python.onRegistered(Arduino) :  - attempting upcasting
[python] [WARN] searching through 169 methods
[python] [INFO] exec(String) 
from org.myrobotlab.service import Arduino
arduino = Runtime.getService("arduino")
[gui] [WARN] no such method RuntimeGui.onRegistered(Arduino) :  - attempting upcasting
[gui] [WARN] searching through 78 methods
[python.interpreter.3] [INFO] Runtime.createService arduino.serial
[python.interpreter.3] [INFO] getMessageSet loading 213 non-sub-routable methods
[python.interpreter.3] [INFO] found reservation exchanging reservedKey arduino.serial for actual name arduino.serial
[python.interpreter.3] [INFO] cfg file C:\MRL4\myrobotlab\.myrobotlab\arduino.serial.json does not exist
[python.interpreter.3] [WARN] no such method Runtime.registered(Serial) :  - attempting upcasting
[python.interpreter.3] [WARN] searching through 253 methods
[python.interpreter.3] [INFO] loading class: org.myrobotlab.serial.PortJSSC
[gui] [WARN] no such method SwingGui.addTab(Serial) :  - attempting upcasting
[gui] [WARN] searching through 186 methods
[gui] [WARN] no such method RuntimeGui.onRegistered(Serial) :  - attempting upcasting
[gui] [WARN] searching through 78 methods
[python] [WARN] no such method Python.onRegistered(Serial) :  - attempting upcasting
[python] [WARN] searching through 169 methods
[python] [INFO] exec(String) 
from org.myrobotlab.service import Serial
arduino_serial = Runtime.getService("arduino.serial")
[AWT-EventQueue-0] [ERROR] getNewInstance failed
[AWT-EventQueue-0] [INFO] could not construct a org.myrobotlab.swing.ArduinoGui object - creating generic template
[python.interpreter.3] [WARN] no such method Serial.publishPortNames(ArrayList) :  - attempting upcasting
[python.interpreter.3] [WARN] searching through 213 methods
[python.interpreter.3] [INFO] looking for /resource/Arduino/MrlComm/MrlComm.ino
[AWT-EventQueue-0] [INFO] subscribe [arduino/publishStatus ---> gui/onStatus]
[AWT-EventQueue-0] [INFO] subscribe [arduino/publishState ---> gui/onState]
[python.interpreter.3] [INFO] connect to port COM3 115200|8|1|0
[python.interpreter.3] [INFO] creating org.myrobotlab.serial.PortJSSC port COM3 115200|8|1|0
[python.interpreter.3] [INFO] created  port COM3 115200|8|1|0 - goodtimes
[python.interpreter.3] [ERROR] serial open threw
[python.interpreter.3] [ERROR] arduino error could not open port COM3  rate 115200 dataBits 8 stopBits 1 parity 0
[AWT-EventQueue-0] [INFO] subscribe [arduino.serial/publishStatus ---> gui/onStatus]
[AWT-EventQueue-0] [INFO] subscribe [arduino.serial/publishState ---> gui/onState]
[AWT-EventQueue-0] [INFO] C:\Users\Mats.Viola-Dator\Documents\MatsRobotlab\Arduino.py
 

 


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
GroG's picture

Mats !

Hmmm ... looking through your noWorkys - the Errors are comments on my source ..

I tried 5 times with your test but could not generate the errors.

 
16:11:05.472 [main] ERROR c.m.f.r.ServiceData [ServiceData.java:163] Class name org.myrobotlab.service.Bno055 not equal to the ServiceType's name org.myrobotlab.service.Mpu6050
* remove all serviceData.json you can find - they can be in a variety of different places
 
 ERROR c.m.f.Service [Arduino.java:1364] error serial
 * we are out of sync on this - as Arduino.java line 1364 is a comment on my source .. :(
 
I checked in some changes in Arduino - they enable heartbeat right after connection - there was some problems with the method existing in a different method - now they are appropriately in the callbacks.
 
I don't think it will change your situation - but ... it might - check out and re-create the problem then at least our source will be in sync.
 
Hold Tight !
 
moz4r's picture

I don't know if it is related

I don't know if it is related to your problem, but i can reproduce this :

NOK ( arduino won't connect )
i01 = Runtime.createAndStart("i01", "InMoov")
i01.startRightHand("COM3")

OK
right = Runtime.createAndStart("i01.right", "Arduino")
i01 = Runtime.createAndStart("i01", "InMoov")
right.connect("COM3")