Code Monkey home page Code Monkey logo

Comments (14)

kurbatov avatar kurbatov commented on June 3, 2024

That looks like specified port has a device on but that device doesn't respond to firmata messages.

Please, make sure that firmata is uploaded to the arduino board.

If you run this under linux (most probably not your case judging by the port name), your user may require additional permissions to interact with USB and serial ports.

If this doesn't help, please, provide more context as to what did you do, what did you try and where it went the unexpected way.

from firmata4j.

Tf19 avatar Tf19 commented on June 3, 2024

I use an Arduino Mega2560 running StandardFirmataPlus.

from firmata4j.

kurbatov avatar kurbatov commented on June 3, 2024

Unfortunately I don't have a chance to test Arduino Mega with StandardFirmataPlus against firmata4j.

I have seen an attempt to fix an issue with Arduino Mega among the forks. As far as I can recollect I backported it but that could be lost later on due to refactorings. I would appreciate if you check if that fix works for you and make a pull request if it does.

Another thing I can suggest is trying whether it works with just StandardFirmata.

from firmata4j.

Tf19 avatar Tf19 commented on June 3, 2024

Now I've tried to run it with StandardFirmata (instead of StandardFirmataPlus):

Dez 18, 2018 4:05:47 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice handleEvent
WARNUNG: event error handler not implemented. will ignore event
Dez 18, 2018 4:05:48 PM org.firmata4j.firmata.FirmataDevice onProtocolReceive
WARNUNG: Current version of firmata protocol on device (2.5) differs from version supported by frimata4j (2.3). Though these are compatible you may experience some issues.
java.lang.InterruptedException: Connection timeout
at org.firmata4j.firmata.FirmataDevice.ensureInitializationIsDone(FirmataDevice.java:153)
at arduino4j.Testklasse.main(Testklasse.java:14)

I think only the last issues are interesting. From this I conclude that the communication now basically works. I will look at the link you posted later.

from firmata4j.

Tf19 avatar Tf19 commented on June 3, 2024

Now I've also implemented what's behind the link you posted: Now it works fine. Only the following errors are still being output:

[firmata-parser-thread] WARN org.firmata4j.firmata.FirmataDevice - Current version of firmata protocol on device (2.5) differs from version supported by frimata4j (2.3). Though these are compatible you may experience some issues.

Encoders not supported by firmware

But that should not be a problem.

By the way: It works with both StandardFirmataPlus and StandardFirmata.

from firmata4j.

kurbatov avatar kurbatov commented on June 3, 2024

Hi @Tf19,

Could you please verify if the fix I applied to the master branch works for you?

from firmata4j.

Tf19 avatar Tf19 commented on June 3, 2024

Unfortunately it does not work:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
java.lang.InterruptedException: Connection timeout
at org.firmata4j.firmata.FirmataDevice.ensureInitializationIsDone(FirmataDevice.java:153)
at arduino4j.Testklasse.main(Testklasse.java:15)

from firmata4j.

kurbatov avatar kurbatov commented on June 3, 2024

So there is no way for me to fix this because I don't have a piece of hardware to test on.

If you can trace this error further down and fix, I would appreciate your help.

from firmata4j.

firefly917 avatar firefly917 commented on June 3, 2024

@centic9

This problem also happened when I used the board of Mega 2560 (ATMEGA16U2). Two different boards were all tested and they gave the same problem whether using the firmware of "StandardFirmataPlus" or "StandardFirmata".

When I test the example of "Visualization" (https://github.com/kurbatov/firmata4j#visualization).

Two exceptions were reported.

1. "Connection timeout". This type of exception was always reported.

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
java.lang.InterruptedException: Connection timeout
	at org.firmata4j.firmata.FirmataDevice.ensureInitializationIsDone(FirmataDevice.java:184)
	at Main.main(Main.java:20)

2. "java.lang.ArrayIndexOutOfBoundsException" and "Connection timeout". This type of exception was reported sometimes.

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "firmata-parser-thread" java.lang.ArrayIndexOutOfBoundsException: 1
	at org.firmata4j.firmata.parser.PinStateParsingState.process(PinStateParsingState.java:53)
	at org.firmata4j.fsm.FiniteStateMachine.process(FiniteStateMachine.java:146)
	at org.firmata4j.fsm.FiniteStateMachine.process(FiniteStateMachine.java:171)
	at org.firmata4j.fsm.FiniteStateMachine.process(FiniteStateMachine.java:157)
	at org.firmata4j.firmata.parser.FirmataParser$JobRunner.run(FirmataParser.java:91)
	at java.lang.Thread.run(Thread.java:748)
java.lang.InterruptedException: Connection timeout
	at org.firmata4j.firmata.FirmataDevice.ensureInitializationIsDone(FirmataDevice.java:184)
	at Main.main(Main.java:20)

I hope that these information could help to fix the problem.

from firmata4j.

Tf19 avatar Tf19 commented on June 3, 2024

Hi,

finally I found some time to try it again: I use again the Arduino Mega2560 (with both StandardFirmata and StandardFirmataPlus). In org.firmata4j.firmata.FirmataDevice.java I edited the following lines
starting at line 371:

sendMessage(FirmataMessageFactory.pinStateRequest(pinId));
/* If the pin count is too high (i.e. Arduino Mega), then
* too many firmata requests in a row can overflow the
* device's serial input buffer.
* One solution is to yield a little time between
* requests to allow the device to respond. The response may
* then safely sit in the host's much larger serial input
* buffer until it is dealt with by onPinStateReceive
*/
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
// ignore
}
if (pinId > 0 && pinId % 14 == 0) {

That's the fix you mentioned above.

Running StandardFirmata(Plus) I just get the following error:

[firmata-event-handler-1] WARN org.firmata4j.firmata.FirmataDevice - Current version of firmata protocol on device (2.5) differs from version supported by firmata4j (2.3). Though these are compatible you may experience some issues.

I can do a pull request if you want, but you can also add those three lines by yourself (that would be faster I think)

from firmata4j.

kurbatov avatar kurbatov commented on June 3, 2024

Hi @Tf19,

I didn't apply that exact fix because it introduced delay into initialisation of all boards no matter how many pins they had.

Since Arduino UNO has no problems initializing 14 pins in a row, I assumed that delaying after every 14 pin state requests should be enough even for bigger boards (the bigger a board, the better controller). However I have failed to pick the right duration of the delay as I don't have boards other than UNO.

So if it doesn't bother you too much, could you please tweak the duration of sleep at line 381 and see if it will be sufficient to delay once in a while rather than every time?

Regarding the warning message you got: the board has a firmware that implements the newer Firmata protocol than firmata4j does. Those versions are compatible though firmata4j lacks support for the new features that were added in 2.4 and 2.5 versions of Firmata. Support of newer features is subject of the further development. Although everything that is available in firmata4j API should work fine.

from firmata4j.

Tf19 avatar Tf19 commented on June 3, 2024

The value for line 381 I ascertained now is at least 81 ms. But that's the absolutely minimum. Therefore, you should probably set the value a bit higher.
In addition, sometimes I get this error:

[firmata-parser-thread] WARN org.firmata4j.fsm.FiniteStateMachine - Event handler is not registered for error:null. The event is ignored.

Sometimes it appears five times, sometimes eight times and sometimes it does not appear at all.
I use the code from the readme-file.

from firmata4j.

kurbatov avatar kurbatov commented on June 3, 2024

Thank you for the research. I'm going to set that 100 ms.

As for the missing event handler, it will probably require some further investigation and first of all improvement of the logging of that particular case.

from firmata4j.

kurbatov avatar kurbatov commented on June 3, 2024

I've pushed the fix for the delay and improvement for logging of missing event handler. Now I expect it will log additional info along the following lines:

  Unknown control token has been received. Skipping. 0xXX

where 0xXX would be the byte that Arduino sends to the client.

Hope it will clairify the way the error should be fixed for good.

from firmata4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.