-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples for Python client library #53
Conversation
So examples work inside package or standalone.
|
||
with PySerialDriver(args.serial_port[0], args.baud[0]) as driver: | ||
with Handler(driver.read, driver.write) as handler: | ||
udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe throw the socket in a with statement?
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as udp
... but nevermind, because python sockets don't implement context manager apparently. Might be good to have a close on the socket just to be proper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe, I tried that first too. I like this method mentioned in the SO thread:
from contextlib import closing
import socket
with closing(socket.socket()) as s:
print s
sound good?
Looks good to me! |
Looking. |
args = parser.parse_args() | ||
|
||
# Open a connection to Piksi using the default baud rate (1Mbaud) | ||
with PySerialDriver(args.port[0], 1000000) as driver: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: baud_rate = 1000000
.
just a few nits. otherwise fine to merge. |
Examples for Python client library
An example of how we may want to incorporate examples using the python client library.
Adds two examples:
In this case I needed something to send SBP over UDB so it can be fed into MAVProxy and eventually make its way into the telemetry stream up to a ArduPilot quadcopter (so we can use just one pair of radios for corrections and telemetry).