Aug-22-2023, 03:31 PM
(Aug-22-2023, 02:38 PM)deanhystad Wrote: Please post entire error message and trace. Provide links for an special packages used. Is this the package you are using?
https://pypi.org/project/arduino-python3/
If so, the arguments to this call are in the wrong order.
arduino = Arduino(board_port, baud_rate)baud rate comes first because board_port is an optional argument.
Hi, thanks.
This was the entire error message:
line 5
line 9
line 14
line 18
Traceback (most recent call last):
File "/Users/QuasarGroup/Documents/CI/GUI_Arduino/arduino_test_with_python.py", line 40, in <module>
main()
File "/Users/QuasarGroup/Documents/CI/GUI_Arduino/arduino_test_with_python.py", line 20, in main
arduino = Arduino(board_port, baud_rate)
File "/Users/QuasarGroup/anaconda3/lib/python3.10/site-packages/Arduino/arduino.py", line 130, in __init__
sr = serial.Serial(port, baud, timeout=timeout)
File "/Users/QuasarGroup/anaconda3/lib/python3.10/site-packages/serial/serialutil.py", line 222, in __init__
self.port = port
File "/Users/QuasarGroup/anaconda3/lib/python3.10/site-packages/serial/serialutil.py", line 268, in port
raise ValueError('"port" must be None or a string, not {}'.format(type(port)))
ValueError: "port" must be None or a string, not <class 'int'>
and Yes, that link was correct.
Thanks for suggesting changing the order, but, putting board_port after baud_rate still didn't solve the issue, although the message changed as follows:
line 5
line 9
line 14
line 18
Traceback (most recent call last):
File "/Users/QuasarGroup/anaconda3/lib/python3.10/site-packages/serial/serialposix.py", line 322, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
OSError: [Errno 16] Resource busy: '/dev/cu.usbmodem14201'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/QuasarGroup/Documents/CI/GUI_Arduino/arduino_test_with_python.py", line 40, in <module>
main()
File "/Users/QuasarGroup/Documents/CI/GUI_Arduino/arduino_test_with_python.py", line 20, in main
arduino = Arduino(baud_rate,board_port)
File "/Users/QuasarGroup/anaconda3/lib/python3.10/site-packages/Arduino/arduino.py", line 130, in __init__
sr = serial.Serial(port, baud, timeout=timeout)
File "/Users/QuasarGroup/anaconda3/lib/python3.10/site-packages/serial/serialutil.py", line 244, in __init__
self.open()
File "/Users/QuasarGroup/anaconda3/lib/python3.10/site-packages/serial/serialposix.py", line 325, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 16] could not open port /dev/cu.usbmodem14201: [Errno 16] Resource busy: '/dev/cu.usbmodem14201'
Now, I don't get why it says busy! I just checked with my Arduino IDE, and upload a program; the "/dev/cu.usbmodem14201" port is correctly assigned to the Arduino Leonardo board. It works fine there, but not with python API?
Thanks.