-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arduino Mega gets input buffer overflown with initial pin state requests #27
Comments
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. |
I use an Arduino Mega2560 running StandardFirmataPlus. |
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. |
Now I've tried to run it with StandardFirmata (instead of StandardFirmataPlus):
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. |
Now I've also implemented what's behind the link you posted: Now it works fine. Only the following errors are still being output:
But that should not be a problem. By the way: It works with both StandardFirmataPlus and StandardFirmata. |
Hi @Tf19, Could you please verify if the fix I applied to the master branch works for you? |
Unfortunately it does not work:
|
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. |
Add delay after every 14 pin capability requests in order to prevent overflow of the input buffer on devices with numerous pins. Execute event handling in a dedicated thread so that delays in handling do not suspend processing of incoming bytes. Fix kurbatov#27
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.
2. "java.lang.ArrayIndexOutOfBoundsException" and "Connection timeout". This type of exception was reported sometimes.
I hope that these information could help to fix the problem. |
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
That's the fix you mentioned above. Running StandardFirmata(Plus) I just get the following error:
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) |
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. |
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.
Sometimes it appears five times, sometimes eight times and sometimes it does not appear at all. |
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. |
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:
where Hope it will clairify the way the error should be fixed for good. |
I'm sorry if I do something completely wrong. But the following code does not work for me:
`public static void main(String[] args) {
I know it should do nothing but connect to the Arduino anyway. But already the timer expires:
The text was updated successfully, but these errors were encountered: