Python Forum
Python error on mentioned Arduino port name
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python error on mentioned Arduino port name
#5
(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.
Reply


Messages In This Thread
RE: Python error on mentioned Arduino port name - by dghosal - Aug-22-2023, 03:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to Get Arduino sensor data over to excel using Python. eh5713 1 1,800 Dec-01-2022, 01:52 PM
Last Post: deanhystad
  python serial port barryjo 2 1,709 Dec-27-2021, 11:09 PM
Last Post: barryjo
  is there a way to mention port range or search for port dynamically with qConnection Creepy 0 1,526 Sep-09-2021, 03:15 PM
Last Post: Creepy
  Unknown error occurred: Port not found NewBeie 0 1,469 Aug-27-2020, 08:50 PM
Last Post: NewBeie
  Port my python program to Raspberry pi seamlessly Hassibayub 1 1,990 Jun-29-2020, 12:58 PM
Last Post: snippsat
  Can't transmit serial fast Python to Arduino pyserial mRKlean 0 2,400 Mar-29-2020, 08:12 PM
Last Post: mRKlean
  About Arduino and Python usb webcam tuts Simurg 1 2,204 Mar-20-2020, 07:25 PM
Last Post: Larz60+
  Help Graphing Arduino Data Real Time in Python nschulz 0 2,581 Mar-12-2020, 06:15 PM
Last Post: nschulz
  Arduino / Python Environment Setup - PIP stevealbright 0 2,292 Feb-24-2019, 10:48 PM
Last Post: stevealbright
  Arduino Read Update Datetime from Python jambuna35 0 2,537 Feb-03-2019, 05:13 PM
Last Post: jambuna35

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020