0

I've been using the pyserial library to talk with my Arduinos without issue on my year old mac mini. I bought a new mac mini last week, which apparently has usb 3.0 ports by default now, and I'm having no luck talking to my Arduinos. I get this message each time I attempt to talk to my serial devices on the new mac:

    ser_dev = serial.Serial(port, timeout=TIMEOUT, writeTimeout=TIMEOUT, baudrate=9600)
  File "/Library/Python/2.7/site-packages/serial/serialutil.py", line 282, in __init__
    self.open()
  File "/Library/Python/2.7/site-packages/serial/serialposix.py", line 289, in open
    self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
OSError: [Errno 16] Resource busy: '/dev/tty.usbmodem1314171'

I can take my Arduino to my old computer, plug it in, execute the same commands and it connects perfectly.

Does anyone have a guess as to what could be going on here? It seems to be a hardware difference. I'm using the same version of python, pyserial, and OS X on both computers.

Update:

I was able to get it to work by changing the baud rate from 9600 to 115200. Maybe that's a strange requirement of USB 3.0, I'm not sure. It's only able to see my USB devices every-other attempt, however. Any guess on this?

config = {}
config['timeout'] = 0.1
config['writeTimeout'] = 0.1
config['baudrate'] = 115200
with serial.Serial('/dev/cu.usbmodem1314171', **config) as x:

    x.write('*idn?\n')
    print x.readlines()
nick_name
  • 1,353
  • 3
  • 24
  • 39
  • 1
    The first time you have executed the script it worked or just failed? – Ramon Moraes Oct 24 '15 at 19:50
  • It always fails on one computer and never fails on the other. – nick_name Oct 24 '15 at 19:58
  • 1
    Could you run `lsof | grep 'usb*'` or `lsof | grep 'tty*'` to check what is using this tty? – Ramon Moraes Oct 24 '15 at 20:02
  • 1
    Also. Do you have any usb device besides arduino on the new mac? This is one of the two [answer here](http://stackoverflow.com/questions/12866572/rxtx-on-mac-serial-port-already-in-use) that worked. Check it out. – Ramon Moraes Oct 24 '15 at 20:04
  • @vyscond Okay, so I was able to get it to connect every other attempt by setting the baud rate to 115200 from 9600 (on the Arduino and pyserial). Why is it every other time now? – nick_name Oct 24 '15 at 20:14
  • 1
    can't tell Sir. never played around with an arduino :/ – Ramon Moraes Oct 24 '15 at 20:15

0 Answers0