Logic Machine Forum
Restart USB device? - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Restart USB device? (/showthread.php?tid=3247)



Restart USB device? - baggins - 24.03.2021

Hi,

On a LM4 I have an Arduino connected to the USB bus. The Arduino gets its power from the USB bus and acts as a serial device.

Every now and then, the Arduino gets stuck (for reasons that I have not figured out yet) and sends no more data to the LM.

I have two options then:
  1. unplug the Arduino from the USB bus and plug it back in, which restarts it
  2. reboot LM which has the same effect
I now have a scheduled script which checks every 5 minutes if the Arduino data get updated. If not, an Alert is sent and I then usually reboot the LM remotely.

I could change this script to reboot LM automatically but I wonder if there is a less intrusive way to restart the Arduino by manipulating the USB bus.

Thanks for your help.


RE: Restart USB device? - admin - 24.03.2021

Arduino usually has automatic reset when the serial port is open. Check if restarting the script helps. You should also enable watchdog in your Arduino so it will reset itself if it hangs somewhere in the program.


RE: Restart USB device? - baggins - 24.03.2021

(24.03.2021, 09:51)admin Wrote: Arduino usually has automatic reset when the serial port is open. Check if restarting the script helps. You should also enable watchdog in your Arduino so it will reset itself if it hangs somewhere in the program.

I suppose by 'script' you mean the script that reads the Arduino data? That is also a scheduled script, so it gets restarted every 5 minutes... It does not reset the Arduino.
As for the watchdog: I have no real knowledge about Arduino's so I will have to inquire with the third party who provided the Arduino...
Thanks.