-
Notifications
You must be signed in to change notification settings - Fork 147
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
How do I bypass FirmataEthernet if the network is down #112
Comments
When you say "FirmataEthernet" do you mean "StandardFirmataEthernet" or some other firmware? |
Yes, @soundanalogous. |
There is currently no way to fall back to a different transport so if the network is down then you will not be able to communicate with the Arduino using firmata.js / johnny-five when running the StandardFirmataEthernet firmware. Your question is difficult to answer without some understanding of how everything is wired up. |
Ok, I'll try to explain the use-case in points. This is the current working Setup
The above is already working but we have the following struggles: My thought to fix this is to add some code before
But this has some problems in it:
My approach is obviously wrong, I hope I can get some pointers on what the best approach would be. |
Also about the logic for
I was thinking to put it in between some if statement, like this
For thisVariableToBeSetToTrueWhenConnectedToNode, I was hoping that I could change this variable through node so the code inside will be bypassed. Unless there is a function like Firmata.noconnection() that I can use. |
This thread really belongs in the firmata/arduino repo since it is an issue with the way Ethernet is handled on the firmware side. There are a few issues that make implementing this challenging. The most significant issue is there is currently no way to immediately know when the Ethernet connection is down. This means data will continue to be buffered and when the buffer overflows will cause significant delays in code execution. It also means that when the connection is re-established you will get some portion of the previously buffered data. This aligns with what you described in a previous comment:
This thread goes into some of these issues and offers some potential solutions, one of which is contingent on a future update to the Arduino Ethernet library. However, there may be some things you can do in StandardFirmataEthernet:
// if this returns false, the connection is down
// (but this state is not known for some amount of time)
if (Ethernet.maintain()) {
stream.maintain(Ethernet.localIP());
} else {
// add your code for managing switches here
} |
Thanks for the reply @soundanalogous, am going to try that out on Monday morning my time. |
Hi,
First of all, I love Firmata. We are using FirmataEthernet together with Node + Johnny Five to manage the lights, curtains, projector screens, etc in our Building. But we have a problem that we can't crack.
When the network is down in our building, we are not able to turn on & off the lights using regular light switches. This has not happened at all here but it is a use-case that could happen.
I was trying to add some digital input reads in the loop to check for switch changes but it somehow makes the jhonny-five unusable.
Could I get some direction on how to solve this problem?
PS: Apologies if I put this question in the wrong place.
Thanks Before
Julian
The text was updated successfully, but these errors were encountered: