Resource busy error when connected to USB port
I have a code that tries to connect to a USB ECG device for continuous data transfer:
import serial
s = serial.Serial()
s.port = "/dev/tty.my-device"
s.open()
When I run this code, I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "create_port.py", line 7, in <module>
s.open()
File "/Users/dimachy/anaconda/lib/python2.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.my-device'
I've tried working on the code with sudo without success. I tried to make the USB service inactive in the network settings on my computer, which also did not change the above error.
When I go through the available ports using the code from Thomas, answer here:
List of available COM ports with Python
I found that only one port is available, which is listed as a bluetooth port. The /dev/tty.my-device port is not shown in this scan.
When an ECG device is connected via USB, it immediately starts transferring data (it does not require a device call to start). I am guessing it might have something to do with the "Resource busy" error I am getting above.
I'm very new to network programming, so I'm probably missing something obvious. Anyone have any suggestions?
source to share
You can try to see the processes that are using this "file" (on Unix systems, all serial devices are just files to read). Try using a fuser to list the processes that are using your file. http://en.wikipedia.org/wiki/Fuser_(Unix)
In your case, something like this: $ fuser / dev / tty.my-device
source to share