ArduPilot / ArduPilot/pymavlink

mavlink_connection returns SerialException with COM connection over Bluetooth

Open
#261 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
730
Forks
741
Avg merge
4d 10h
Merged PRs (30d)
7

Description

Hello.

I am trying to use dronekit-python with Bluetooth teremetry on windows.
But dronekit-python returns error bellow.
```
Traceback (most recent call last):
File ".\receiver.py", line 173, in
main()
File ".\receiver.py", line 140, in main
drone = connect_drone()
File ".\receiver.py", line 23, in connect_drone
heartbeat_timeout=300)
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\dronekit-2.9.1-py3.7.egg\dronekit\__init__.py", line 3152, in connect
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\dronekit-2.9.1-py3.7.egg\dronekit\mavlink.py", line 130, in __init__
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\pymavlink-2.3.4-py3.7.egg\pymavlink\mavutil.py", line 1638, in mavlink_connection
force_connected=force_connected)
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\pymavlink-2.3.4-py3.7.egg\pymavlink\mavutil.py", line 917, in __init__
raise e
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\pymavlink-2.3.4-py3.7.egg\pymavlink\mavutil.py", line 914, in __init__
dsrdtr=False, rtscts=False, xonxoff=False)
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\serial\serialwin32.py", line 31, in __init__
super(Serial, self).__init__(*args, **kwargs)
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\serial\serialutil.py", line 240, in __init__
self.open()
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\serial\serialwin32.py", line 62, in open
raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'com6': OSError(22, 'Element not found.', None, 1168)
```

To research cause, I wrote and execute simple pyserial code.
```
import serial
import time
s = serial.Serial()
s.baudrate = 56700
s.port = 'com6'
s.open()
time.sleep(10)
s.close()
s = serial.Serial("com6", 1200, timeout=0, dsrdtr=False, rtscts=False, xonxoff=False)
time.sleep(10)
s.close()
```
But it does not return error.

So I think cause is pymavlink, I execute instruction bellow.
`m = mavutil.mavlink_connection("com6", baud=57600)`
And this execution returns error bellow.
```
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\pymavlink-2.3.4-py3.7.egg\pymavlink\mavutil.py", line 1638, in mavlink_connection
force_connected=force_connected)
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\pymavlink-2.3.4-py3.7.egg\pymavlink\mavutil.py", line 917, in __init__
raise e
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\pymavlink-2.3.4-py3.7.egg\pymavlink\mavutil.py", line 914, in __init__
dsrdtr=False, rtscts=False, xonxoff=False)
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\serial\serialwin32.py", line 31, in __init__
super(Serial, self).__init__(*args, **kwargs)
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\serial\serialutil.py", line 240, in __init__
self.open()
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\serial\serialwin32.py", line 62, in open
raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'com6': OSError(22, 'The semaphore timeout period has expired.', None, 121)
```
```
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\pymavlink-2.3.4-py3.7.egg\pymavlink\mavutil.py", line 1638, in mavlink_connection
force_connected=force_connected)
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\pymavlink-2.3.4-py3.7.egg\pymavlink\mavutil.py", line 917, in __init__
raise e
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\pymavlink-2.3.4-py3.7.egg\pymavlink\mavutil.py", line 914, in __init__
dsrdtr=False, rtscts=False, xonxoff=False)
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\serial\serialwin32.py", line 31, in __init__
super(Serial, self).__init__(*args, **kwargs)
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\serial\serialutil.py", line 240, in __init__
self.open()
File "C:\Users\otsuka\AppData\Local\Programs\Python\Python37\lib\site-packages\serial\serialwin32.py", line 62, in open
raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'com6': OSError(22, 'Element not found.', None, 1168)
```

Mission Planner can connect without some error.
Could you tell me some solution?

Environment list
- WIndows 10 Pro 1809
- pymavlink 2.3.4
- pyserial 3.4
- dronekit-python installed by setup.py
- HC-05 Bluetooth module for Pixhawk
- Intel Wireless Bluetooth on PC

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with mavutil.mavlink_connection("com6", baud=57600), then compare it with the direct pyserial example. Inspect pymavlink/mavutil.py around lines 914-917 and 1638, along with the reported serialwin32.py path, to identify the differing serial parameters or Windows Bluetooth behavior. Done means the cause is confirmed and a regression test or documented resolution covers the failing connection.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.