-
Notifications
You must be signed in to change notification settings - Fork 30
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
update for abr function #82
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
|
||
from brping import Ping1D | ||
import time | ||
import argparse | ||
|
||
##Parse Command line options | ||
############################ | ||
|
||
parser = argparse.ArgumentParser(description="Ping python library example.") | ||
parser.add_argument('--device', action="store", required=True, type=str, help="Ping device port.") | ||
args = parser.parse_args() | ||
|
||
#Make a new Ping | ||
myPing = Ping1D(args.device) | ||
|
||
baudrates = [9600, 115200] | ||
|
||
while (True): | ||
for baudrate in baudrates: | ||
if not myPing.initialize(baudrate): | ||
print("failed to initialize at %d bps", baudrate) | ||
exit(1) | ||
print("ok") | ||
time.sleep(0.01) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,10 +72,19 @@ class PingDevice(object): | |
return self.iodev.write(data) | ||
|
||
## | ||
# @brief Make sure there is a device on and read some initial data | ||
# @brief initialize the device communication interface. A serial break signal | ||
# is sent to the device followed by 'U' (0x55) to begin the autobaurate procedure | ||
# on the device. Some data is then read from the device to verify communications | ||
# | ||
# @param baudrate: the baudrate to use. if None, the baudrate will not | ||
# be changed (default is 115200) | ||
# | ||
# @return True if the device replies with expected data, False otherwise | ||
def initialize(self): | ||
def initialize(self, baudrate=None): | ||
if baudrate is not None: | ||
self.iodev.baudrate = baudrate | ||
self.iodev.send_break() | ||
self.iodev.write("U".encode("utf-8")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that this should be ascii, since it's the U char that we want, and not the utf-8 representation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks correct on the wire with a probe (0x55), I will try ascii though |
||
return self.request(definitions.COMMON_PROTOCOL_VERSION) is not None | ||
|
||
## | ||
|
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.
When will this finish ?
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.
when you push ctrl + c like
ping
, or the sensor fails to communicate