Closed goofyx closed 2 years ago
Thanks for reporting the issue. I was able to reproduce. "The same situation is that when Pymata4 function can't found Pymata4(arduino_instance_id=1), it will connect to the first Arduino USB port it can." I believe this is fixed with release 1.12 that I just published to pypi:
sudo pip3 install pymata4 --upgrade
I could not recreate the other items you describe, but this fix may resolve the other issues too.
Could you please test this release and let me know if it solves the issues for you.
Almost perfect ;)
If I have only one device connected /dev/ttyACM0
with specific arduino_instance_id=14
pymata4 working great at this moment with board14 = pymata4.Pymata4(arduino_instance_id=14)
But with multi arduino connected to the device like that :
I have error:
pymata4: Version 1.12
Copyright (c) 2020 Alan Yorinks All Rights Reserved.
Opening all potential serial ports...
/dev/ttyACM3
/dev/ttyACM2
/dev/ttyACM1
/dev/ttyACM0
Waiting 4 seconds(arduino_wait) for Arduino devices to reset...
Searching for an Arduino configured with an arduino_instance = 14
Traceback (most recent call last):
File "/home/goofyx/Projekty/firmData/pymata4/examples/hc-sr04_distance_sensor.py", line 66, in <module>
board14 = pymata4.Pymata4(arduino_instance_id=14)
File "/home/goofyx/.local/lib/python3.9/site-packages/pymata4/pymata4.py", line 235, in __init__
self._find_arduino()
File "/home/goofyx/.local/lib/python3.9/site-packages/pymata4/pymata4.py", line 400, in _find_arduino
raise RuntimeError(f'arduino_instance_id does not match the '
RuntimeError: arduino_instance_id does not match the value on the board.
I found in sources in pymata4.py that in my case problems was in else
condition which raise error on line 399-401:
399: else:
400: raise RuntimeError(f'arduino_instance_id does not match the '
401: f'value on the board.')
I hashed this lines and i think it's start to works. But probably is not good solution.
I was able to reproduce what you are seeing and I believe I have fixed the issue with release 1.13. I configured my test system with:
/dev/ttyACM2 is arduino_instance_id=16
/dev/ttyACM1 is arduino_instance_id=15
/dev/ttyACM0 is arduino_instance_id=14
I ran a test script and here is the output:
afy@theLab:~$ python3 p4b.py
pymata4: Version 1.13
Copyright (c) 2020 Alan Yorinks All Rights Reserved.
Opening all potential serial ports...
/dev/ttyACM2
/dev/ttyACM1
/dev/ttyACM0
Waiting 4 seconds(arduino_wait) for Arduino devices to reset...
Searching for an Arduino configured with an arduino_instance = 14
Arduino compatible device found and connected to /dev/ttyACM0
Retrieving Arduino Firmware ID...
Arduino Firmware ID: 1.2 FirmataExpress.ino
Retrieving analog map...
Auto-discovery complete. Found 30 Digital Pins and 12 Analog Pins
elapsed time 0.16091609001159668
Again, could you please test this release and let me know if it solves the issues for you? Thanks.
I tested pymata4 v.1.13 with 4 and 15 arduino devices and at this moment it's look very good :) Thank you very much.
pymata4: Version 1.13
Copyright (c) 2020 Alan Yorinks All Rights Reserved.
Opening all potential serial ports...
/dev/ttyACM3
/dev/ttyACM2
/dev/ttyACM1
/dev/ttyACM0
Waiting 4 seconds(arduino_wait) for Arduino devices to reset...
Searching for an Arduino configured with an arduino_instance = 14
Arduino compatible device found and connected to /dev/ttyACM0
Retrieving Arduino Firmware ID...
Arduino Firmware ID: 1.2 FirmataExpress.ino
Retrieving analog map...
Auto-discovery complete. Found 20 Digital Pins and 6 Analog Pins
pymata4: Version 1.13
Copyright (c) 2020 Alan Yorinks All Rights Reserved.
Opening all potential serial ports...
/dev/ttyACM3
/dev/ttyACM2
/dev/ttyACM1
/dev/ttyACM0
Waiting 4 seconds(arduino_wait) for Arduino devices to reset...
Searching for an Arduino configured with an arduino_instance = 15
Arduino compatible device found and connected to /dev/ttyACM1
Retrieving Arduino Firmware ID...
Arduino Firmware ID: 1.2 FirmataExpress.ino
Retrieving analog map...
Auto-discovery complete. Found 20 Digital Pins and 6 Analog Pins
pymata4: Version 1.13
Copyright (c) 2020 Alan Yorinks All Rights Reserved.
Opening all potential serial ports...
/dev/ttyACM3
/dev/ttyACM2
/dev/ttyACM1
/dev/ttyACM0
Waiting 4 seconds(arduino_wait) for Arduino devices to reset...
Searching for an Arduino configured with an arduino_instance = 16
Arduino compatible device found and connected to /dev/ttyACM2
Retrieving Arduino Firmware ID...
Arduino Firmware ID: 1.2 FirmataExpress.ino
Retrieving analog map...
Auto-discovery complete. Found 20 Digital Pins and 6 Analog Pins
pymata4: Version 1.13
Copyright (c) 2020 Alan Yorinks All Rights Reserved.
Opening all potential serial ports...
/dev/ttyACM3
/dev/ttyACM2
/dev/ttyACM1
/dev/ttyACM0
Waiting 4 seconds(arduino_wait) for Arduino devices to reset...
Searching for an Arduino configured with an arduino_instance = 17
Arduino compatible device found and connected to /dev/ttyACM3
Retrieving Arduino Firmware ID...
Arduino Firmware ID: 1.2 FirmataExpress.ino
Retrieving analog map...
Auto-discovery complete. Found 20 Digital Pins and 6 Analog Pins
Thanks for letting me know. I am closing this issue.
I have project with more than 50 arduino's (and will be more) connected to 7 Odroid XU and RaspBerry PI and I have big problem with auto connection to it. Every Arduino has own arduino_instance_id which is greater than 10. In python I am using something like that: (more dynamic, but idea it's that)
board25 = pymata4.Pymata4(arduino_instance_id=25)
and everything work good for situation then arduino with arduino_instance_id=25 is connected and working, but if I disconnect thats board Pymata4(arduino_instance_id=25) will connect to the first Arduino he can connect. The same situation is that when Pymata4 function can't found Pymata4(arduino_instance_id=1) it will connect to the first Arduino USB port it can.Simple example:
For testing: /dev/ttyACM0 is arduino_instance_id=14 with hc-sr501 /dev/ttyACM1 is arduino_instance_id =15 with some led
When I use
pymata4.Pymata4(arduino_instance_id=14)
,pymata4.Pymata4(arduino_instance_id=15)
and both Arduino is connected everything working good. But if i disconect /dev/ttyACM0pymata4.Pymata4(arduino_instance_id=14)
connecting to the /dev/ttyACM1 andpymata4.Pymata4(arduino_instance_id=15)
will return error (what is ok)serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
Maybe I am doing something wrong. Thanks for any help.