DroneKit: Failed to connect to /dev/tty.usbmodem1411 : 'Serial' object has no attribute 'setBaudrate'

喜欢而已 提交于 2019-12-01 10:09:48

问题


Following the DroneKit instructions, I was able to run the hello.py code from their QuickStart guide: http://python.dronekit.io/guide/quick_start.html.

However, when I try to run their basic mission example, I get the setBaudrate error in the title:

$ python mission_basic.py --connect=/dev/tty.usbmodem1411

Connecting to vehicle on: /dev/tty.usbmodem1411
Traceback (most recent call last):
  File "mission_basic.py", line 23, in <module>
    vehicle = connect(args.connect, wait_ready=True)
  File "/Library/Python/2.7/site-packages/dronekit/__init__.py", line 2344, in connect
    handler = MAVConnection(ip, baud=baud, source_system=source_system)
  File "/Library/Python/2.7/site-packages/dronekit/mavlink.py", line 37, in __init__
    self.master = mavutil.mavlink_connection(ip, baud=baud, source_system=source_system)
  File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 1106, in mavlink_connection
    return mavserial(device, baud=baud, source_system=source_system, autoreconnect=autoreconnect, use_native=use_native)  
  File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 735, in __init__
    self.set_baudrate(self.baud)
  File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 746, in set_baudrate
    self.port.setBaudrate(baudrate)
AttributeError: 'Serial' object has no attribute 'setBaudrate'

Note: tty.usbmodem1411 is my USB cable running straight from my Mac running Yosemite to the APM. I have also tried with the 3DR telemetry kit with the same results. I have also tried adding in the baud rate option with the same result.


UPDATE: Using the link's patch that 陳昭宇 gave resolved my baud rate issue; however, I still had an issue with never finding a heartbeat. This issue was also because of the pyserial update. Using the older pyserial solution that Tim Ryan provided fixed both problems.


回答1:


Fin, it looks like pySerial 3.0 was released in the past week which changes its API. pymavlink (used by DroneKit-Python) requires pySerial 2.0. I've filed an issue and will work to resolve it.

In the meantime, try pip install "pySerial>=2.0,<=2.9999" and see if this resolves your problem.




回答2:


In the new python setBaudrate() looks removed from class SerialBase. Please refer a similar issue of mavlink.




回答3:


Shot in the dark here, so apologies if this doesn't fix your problem, but I've suspicions that it will.

You need to install FTDI Drivers (https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/mac)

I had similar issues creating a serial connection over USB, using python, between my Arduino and my Mac running Mavericks and subsequently El Capitan. (Worked out of the box on Ubuntu, if you're afraid to mess with your fancy Mac) Expect this to break after an OSX upgrade. (Thanks Apple) It will also only work on the USB port that you specified during this process. So choose wisely ;)

Hope this helps. I lost days to this issue.



来源:https://stackoverflow.com/questions/34602168/dronekit-failed-to-connect-to-dev-tty-usbmodem1411-serial-object-has-no-at

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!