(Read 306 times)
Oct 15, 2020, 11:10 am
is there a way to run bridge.begin() in another thread so it wont block?
my issue is that my Arduino is connected to several I2C devices.
and because it uses interrupt for the i2C i cant reach them from a timer until the bridge ends the bring up.
for some reason on first power up the bridge will take all most a full minute to get up.
with regards, Dor.
Oct 15, 2020, 07:37 pm
There isn't a non-blocking form of bridge.begin(), nor does Arduino normally support multiple threads. I have read of people porting FreeRTOS to Arduino, and with that you could start a thread to initialize the bridge, but that sounds like overkill.
The issue that you are running into is not so much that bridge.begin() takes a long time sometimes, it's that it takes a minute for the Linux side of the Yun to boot up, bridge.begin() establishes communications with the Linux side, and that cannot happen until the Linux side is up and running, hence the delay the first time you call if after power up. Rather than trying to do other things while bridge.begin() is waiting for Linux, how about not calling bridge.begin() until you know Linux is ready?
If you are using the original version of the Yun, there is a handshake line between GP19 on the Linux processor, and pin 7 on the sketch side. I have used this signal to let the sketch know when Linux is fully booted, as described starting
with the discussion continuing through that thread.
In that thread, I'm just using the handshake line to influence a status LED and waiting in setup() until it is ready before calling bridge.begin(), but you could instead look for that signal to become ready inside loop(), and call bridge.begin once it's active. This would let you do other things while the LInux side is booting.
This is assuming you are using an original version of the Yun. If you have a Yun Rev 2, there is no handshake signal, and you will have to come up with another idea. The Rev 2 still has the SPI lines connected between processors so you can load sketches over the network, so maybe you can use one of those lines as suggested in