Reputation: 1
sorry for my basic question, but I am new to python. I'm trying to read data off an IMU connected through a com port to my PC. I've tried the script:
import serial
ser = serial.Serial('COM9', 115200, timeout=None)
while True:
data = ser.readline()
but i got the following error:
File "", line 2, in File "C:\Program Files (x86)\miControl\mPLC\Python25\lib\site-packages\serial\serialutil.py", line 171, in init self.open() File "C:\Program Files (x86)\miControl\mPLC\Python25\lib\site-packages\serial\serialwin32.py", line 53, in open raise SerialException("could not open port %s: %s" % (self.portstr, msg)) serial.serialutil.SerialException: could not open port COM9: (5, 'CreateFile', 'Access is denied.')
was wondering how can I connect the IMU properly and then read the data, knowing that each new data line starts with 'AA 55'
thanks in advance.
Upvotes: 0
Views: 127
Reputation: 8831
The 'Access is denied' error is what you have to solve. Either the Windows account you're using does not have privileges to access the port, or another program is using the port. I would suggest to try to run this as administrator to make sure the permissions are not an issue. Second check if you don't have other programs open that use the port.
Upvotes: 0