Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SerialException: [Errno 16] could not open port /dev/ttyACM0: [Errno 16] Device or resource busy: '/dev/ttyACM0' #45

Closed
sentry-io bot opened this issue Feb 1, 2019 · 5 comments
Labels
enhancement This builds on top of an existing feature p: normal Normal priority
Milestone

Comments

@sentry-io
Copy link

sentry-io bot commented Feb 1, 2019

Sentry Issue: PROS-CLI-3-30

OSError: [Errno 16] Device or resource busy: '/dev/ttyACM0'
  File "serial/serialposix.py", line 265, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)

SerialException: [Errno 16] could not open port /dev/ttyACM0: [Errno 16] Device or resource busy: '/dev/ttyACM0'
  File "pros/cli/upload.py", line 94, in upload
    ser = DirectPort(port)
  File "pros/serial/ports/direct_port.py", line 20, in __init__
    self.serial: serial.Serial = create_serial_port(port_name=port_name, timeout=kwargs.pop('timeout', 1.0))
  File "pros/serial/ports/direct_port.py", line 11, in create_serial_port
    parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE)
  File "serial/serialutil.py", line 240, in __init__
    self.open()
  File "serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))

SerialException: [Errno 16] could not open port /dev/ttyACM0: [Errno 16] Device or resource busy: '/dev/ttyACM0'

This should be just catching the exception properly and suppressing it. We should add some hints to why we can't open the port:

  • someone already has it
  • user is not part of dialout group
@HotelCalifornia
Copy link
Contributor

user is not part of dialout group

This typically results in Errno 13 (lack of permission) rather than this device or resource busy one

@HotelCalifornia HotelCalifornia added enhancement This builds on top of an existing feature p: normal Normal priority labels Feb 1, 2019
@baylessj
Copy link
Contributor

baylessj commented Feb 1, 2019

I also experience this issue when uploading on ubuntu. The workaround I've found is to run sudo chmod a+rw /dev/ttyACM0 every time that I connect my computer to the brain, but it is a bit frustrating to have to run that every time.

I'm guessing there's got to be some sort of option to set these read/write permissions automatically upon plugin, but I haven't explored that option yet.

@edjubuh
Copy link
Member

edjubuh commented Feb 1, 2019

Yes, add yourself to the dialout group

@Octogonapus
Copy link

Octogonapus commented Feb 1, 2019

sudo usermod -a -G dialout salmon, for example. Then restart.

@HotelCalifornia
Copy link
Contributor

I also experience this issue when uploading on ubuntu.

Strictly speaking, that's technically a separate thing.

Yes, add yourself to the dialout group

This can be done with sudo usermod -a -G dialout <your_username>. I've seen this issue crop up enough times that we should probably make a note of it somewhere on purduesigbots/pros-docs.

@edjubuh edjubuh added this to the 3.1.4 milestone Feb 1, 2019
edjubuh added a commit that referenced this issue Feb 18, 2019
#### Summary:
Detect Linux conditions for ConnectionRefusedException when trying to open the serial port

#### Motivation:
Better error messages that won't get sent to us in Sentry

##### References (optional):
Closes #45 

#### Test Plan:
- [x] Still works for Windows when Firmware Utility is open
- [x] See better error message when you're not part of dialout group
- [x] See better error message when you already have the port open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This builds on top of an existing feature p: normal Normal priority
Projects
None yet
Development

No branches or pull requests

4 participants