If the editor cant see the ttyACM0 then I doubt the python can, BUT that doesn't explain why its jumping ports like it is.
A really janky fix is to catch when it cant open ACM0 and try ACM1
Something like replacing Lines 223 through 226 of python/FlowMonitor.py with
Code:
if flowMetersEnabld :
if self.alaIsAlive is False:
debug( "resetting Arduino" )
self.dispatch.resetAlaMode()
try:
self.arduino = serial.Serial(self.port,9600,timeout=.5)
except:
if self.port == "/dev/ttyACM0":
self.arduino = serial.Serial("/dev/ttyACM1",9600,timeout=.5)
Is the first time you had to hit the reset button?
I'm trying to see if there is a way to reset the Uno programmatically from the pytho, there is for the alamode board, but it might not work for UNO
Nothing pops up right now but I will keep looking, I might have to be a sketch change that if it doesn't get a response back in xx seconds then reset itself, but if the sketch isn't running until the reset button is pressed then even that wont fix this
This the the first time Ive actually just hit reset on the Arduino as before that I used to reboot the pi and power down the Arduino.I never thought to just reset the Arduino until last night so tried it and it worked.
Today its stopped again and this is the log file since last nights pour.
2020-05-23 22:01:39 RPINTS: got a pour: P;-1;3;54
Pourpour on pin: 3, count: 54, conversion: 575, amount: 0.093913043478261, amountUnit: ml, user: N/A
2020-05-23 22:01:44 RPINTS: restarting fan timer after pour
2020-05-23 22:01:44 RPINTS: count update: RPU:FLOW:3=54:-1
2020-05-23 22:01:44 RPINTS: Reset Tap during loop Pin 3 0
2020-05-23 22:01:46 RPINTS: Sending Status;NOTOK;-1;0;0;0;0;0;|
2020-05-24 01:13:38 RPINTS: unknown message: k;
2020-05-24 01:13:38 RPINTS: Sending Status;NOTOK;-1;0;0;0;0;0;|
('Unexpected error:', <class 'serial.serialutil.SerialException'>)
Traceback (most recent call last):
File "/var/www/html/python/FlowMonitor.py", line 269, in monitor
msg = self.readline_notimeout()
File "/var/www/html/python/FlowMonitor.py", line 74, in readline_notimeout
c = self.arduino.read(1)
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 501, in read
'device reports readiness to read but returned no data '
SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
2020-05-24 01:14:49 RPINTS: flowmonitor aborted, restarting...
2020-05-24 01:14:49 RPINTS: NOT resetting Arduino
2020-05-24 01:14:49 RPINTS: waiting for Arduino to come alive
2020-05-24 01:14:50 RPINTS: serial connection stopped...
2020-05-24 01:14:50 RPINTS: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
2020-05-24 01:14:51 RPINTS: flowmonitor aborted, restarting...
2020-05-24 01:14:51 RPINTS: resetting Arduino
2020-05-24 01:14:52 RPINTS: serial connection stopped...
2020-05-24 01:14:52 RPINTS: [Errno 2] could not open port /dev/ttyACM1: [Errno 2] No such file or directory: '/dev/ttyACM1'
2020-05-24 01:14:53 RPINTS: flowmonitor aborted, restarting...
2020-05-24 01:14:53 RPINTS: resetting Arduino
I tried resetting the Arduino with the reset button again but it didn't work. So I stopped the flowmon, tried to upload the Arduino and it now says Serial port /dev/ACM1 not found, did you select the right one from the tools.Serial port menu. However the serial port menu is greyed out.
I then typed dmesg in terminal and get this
[168557.339208] usb 1-1.1.3: new full-speed USB device number 60 using dwc_otg
[168557.493099] usb 1-1.1.3: New USB device found, idVendor=2341, idProduct=0043, bcdDevice= 0.01
[168557.493111] usb 1-1.1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[168557.493115] usb 1-1.1.3: Manufacturer: Arduino (
www.arduino.cc)
[168557.493120] usb 1-1.1.3: SerialNumber: 85730313836351805031
[168557.494204] cdc_acm 1-1.1.3:1.0: ttyACM1: USB ACM device
[192362.745119] usb 1-1.1.3: USB disconnect, device number 60
[192363.194778] usb 1-1.1.3: new full-speed USB device number 61 using dwc_otg
[192363.294785] usb 1-1.1.3: device descriptor read/64, error -32
[192363.514771] usb 1-1.1.3: device descriptor read/64, error -32
[192363.734843] usb 1-1.1.3: new full-speed USB device number 62 using dwc_otg
[192363.834854] usb 1-1.1.3: device descriptor read/64, error -32
[192364.054829] usb 1-1.1.3: device descriptor read/64, error -32
[192364.176864] usb 1-1.1-port3: attempt power cycle
[192364.834842] usb 1-1.1.3: new full-speed USB device number 63 using dwc_otg
[192365.274849] usb 1-1.1.3: device not accepting address 63, error -32
[192365.374860] usb 1-1.1.3: new full-speed USB device number 64 using dwc_otg
[192365.814847] usb 1-1.1.3: device not accepting address 64, error -32
EDIT- So after numerous reboots of the Arduino nothing happened and serial was still grey. So I unplugged the usb cable to the Arduino and plugged it back in and rebooted the pi and now ACM0 is showing again. (Does plugging the usb cable into different ports change this as I did try doing that?)
Stopped flowmon uploaded the sketch, and started flowmon again..but no pours. Then I reset the Arduino and it works. So it seems as if after I re upload the sketch I have to reset the Arduino before it works again. Heres the log from the upload then restart of the Arduino. (But it won't be working tomorrow no doubt)
2020-05-24 16:48:46 RPINTS: valve update: RPU:VALVE:0=0
2020-05-24 16:48:50 RPINTS: valve update: RPU:VALVE:1=0
2020-05-24 16:48:50 RPINTS: valve update: RPU:VALVE:2=0
2020-05-24 16:48:50 RPINTS: valve update: RPU:VALVE:3=0
2020-05-24 16:48:50 RPINTS: Could not import RFID Reader, RFID disabled. Assuming SPI not installed/configured
2020-05-24 16:48:52 RPINTS: starting setup...
2020-05-24 16:48:52 RPINTS: resetting alamode to try to force it to listen to us...
2020-05-24 16:48:53 RPINTS: giving it a short break to wake up again...
2020-05-24 16:48:55 RPINTS: reflashing Arduino via:
/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -patmega328p -calamode -P/dev/ttyACM0 -b115200 -D -Uflash:w:/var/www/html//arduino/raspberrypints/raspberrypints.cpp.hex:i
2020-05-24 16:49:00 RPINTS:
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f
avrdude: reading input file "/var/www/html//arduino/raspberrypints/raspberrypints.cpp.hex"
avrdude: writing flash (11866 bytes):
Writing | ################################################## | 100% 2.28s
avrdude: 11866 bytes of flash written
avrdude: verifying flash memory against /var/www/html//arduino/raspberrypints/raspberrypints.cpp.hex:
avrdude: load data flash data from input file /var/www/html//arduino/raspberrypints/raspberrypints.cpp.hex:
avrdude: input file /var/www/html//arduino/raspberrypints/raspberrypints.cpp.hex contains 11866 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 1.69s
avrdude: verifying ...
avrdude: 11866 bytes of flash verified
avrdude done. Thank you.
2020-05-24 16:49:00 RPINTS: starting WS server
2020-05-24 16:49:00 RPINTS: starting device monitors...
2020-05-24 16:49:00 RPINTS: starting command server
2020-05-24 16:49:00 RPINTS: starting fan control
2020-05-24 16:49:00 RPINTS: resetting Arduino
2020-05-24 16:49:00 RPINTS: Fan Control fanControl1 is Running
2020-05-24 16:49:00 RPINTS: Not Configured to run Fan
2020-05-24 16:49:01 RPINTS: 1Wire Temperature Thread 1 is Running
2020-05-24 16:49:01 RPINTS: waiting for Arduino to come alive
2020-05-24 16:54:24 RPINTS: Arduino alive...
2020-05-24 16:54:24 RPINTS: getting config data for Arduino
2020-05-24 16:54:24 RPINTS: Arduino config, about to send: C:4:3:4:5:6:0:200:25:25:50:0:0:1|
2020-05-24 16:54:24 RPINTS: Waiting for Config Response
2020-05-24 16:54:24 RPINTS: Arduino says: C:4:3:4:5:6:0:200:25:25:50:0:0:1|
2020-05-24 16:54:24 RPINTS: listening to Arduino
2020-05-24 16:54:24 RPINTS: Sending Status;NOTOK;-1;0;0;0;0;0;|
2020-05-24 16:55:33 RPINTS: got a update: U;-1;3;51
2020-05-24 16:55:33 RPINTS: Sending Status;NOTOK;-1;0;0;0;0;0;|
2020-05-24 16:55:36 RPINTS: got a pour: P;-1;3;98
Pourpour on pin: 3, count: 98, conversion: 575, amount: 0.1704347826087, amountUnit: ml, user: N/A
2020-05-24 16:55:37 RPINTS: restarting fan timer after pour
2020-05-24 16:55:37 RPINTS: count update: RPU:FLOW:3=98:-1
2020-05-24 16:55:37 RPINTS: Reset Tap during loop Pin 3 0
2020-05-24 16:55:39 RPINTS: Sending Status;NOTOK;-1;0;0;0;0;0;|