|
ping-python
A python implementation of the Blue Robotics Ping messaging protocol and a device API for the Blue Robotics Ping1D echosounder.
|


Public Member Functions | |
| def | __init__ |
| def | read |
| Consume rx buffer data until a new message is successfully decoded. More... | |
| def | write |
| Write data to device. | |
| def | initialize |
| Make sure there is a device on the line and read some initial data Return True if the device replies with expected data Return False otherwise. | |
| def | request |
| Request the given message ID Return response if it is rxed within timeout period, None otherwise TODO handle nack to exit without blocking. | |
| def | waitReply |
| Wait for the device to send a message with the desired message_id for timeout s Return True if a valid message is received from the device with the desired message_id before the timeout period expires Return False otherwise. | |
| def | handleMessage |
| Handle an incoming messge from the device Extract message fields into self attributes. | |
| def | __repr__ |
| Dump object into string representation. | |
| def | get_fw_version |
| Request a message from the device If there is no reply return None, otherwise return a dictionary of the updated values. More... | |
| def | get_device_id |
| The device ID. More... | |
| def | get_voltage_5 |
| The 5V rail voltage. More... | |
| def | get_speed_of_sound |
| The speed of sound used for distance calculations. More... | |
| def | get_range |
| The scan range for acoustic measurements. More... | |
| def | get_mode_auto |
| The current operating mode of the device. More... | |
| def | get_ping_rate |
| The interval between acoustic measurements. More... | |
| def | get_gain_index |
| The current gain setting. More... | |
| def | get_pulse_usec |
| The duration of the acoustic activation/transmission. More... | |
| def | get_general_info |
| General information. More... | |
| def | get_distance_simple |
| The distance to target with confidence estimate. More... | |
| def | get_distance |
| Returns a dictionary of the reply payload. More... | |
| def | get_processor_temperature |
| Temperature of the device cpu. More... | |
| def | get_pcb_temperature |
| Temperature of the on-board thermistor. More... | |
| def | get_profile |
| A profile produced from a single acoustic measurement. More... | |
| def | get_protocol_version |
| The protocol version Returns a dictionary of the reply payload. More... | |
| def | set_device_id |
| Write a new control, and read the values back from the device If verify is true, fail if the values read back from the device do not match the controls that were written Return True on success Return False on failure to read values back or on verification failure. More... | |
| def | set_range |
| Set the scan range for acoustic measurements. More... | |
| def | set_speed_of_sound |
| Set the speed of sound used for distance calculations. More... | |
| def | set_mode_auto |
| Set automatic or manual mode. More... | |
| def | set_ping_rate |
| The interval between acoustic measurements. More... | |
| def | set_gain_index |
| Set the current gain selection. More... | |
| def | set_ping_enable |
| Enable or disable acoustic measurements. More... | |
Public Attributes | |
| iodev | |
| Serial object for device communication. | |
| parser | |
| A helper class to take care of decoding the input stream. | |
| my_id | |
| device id of this Ping1D object, used for dst_device_id in outgoing messages | |
| def Ping.Ping1D.Ping1D.get_device_id | ( | self | ) |
The device ID.
Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_distance | ( | self | ) |
Returns a dictionary of the reply payload.
| def Ping.Ping1D.Ping1D.get_distance_simple | ( | self | ) |
The distance to target with confidence estimate.
Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_fw_version | ( | self | ) |
Request a message from the device If there is no reply return None, otherwise return a dictionary of the updated values.
Device information Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_gain_index | ( | self | ) |
The current gain setting.
Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_general_info | ( | self | ) |
General information.
Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_mode_auto | ( | self | ) |
The current operating mode of the device.
Manual mode allows for manual selection of the gain and scan range. Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_pcb_temperature | ( | self | ) |
Temperature of the on-board thermistor.
Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_ping_rate | ( | self | ) |
The interval between acoustic measurements.
Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_processor_temperature | ( | self | ) |
Temperature of the device cpu.
Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_profile | ( | self | ) |
A profile produced from a single acoustic measurement.
The data returned is an array of response strength at even intervals across the scan region. The scan region defined the region between <scan_start> and <scan_start + scan_length> millimeters away from the transducer. A distance measurement to the target is also provided. Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_protocol_version | ( | self | ) |
The protocol version Returns a dictionary of the reply payload.
| def Ping.Ping1D.Ping1D.get_pulse_usec | ( | self | ) |
The duration of the acoustic activation/transmission.
Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_range | ( | self | ) |
The scan range for acoustic measurements.
Measurements returned by the device will lie in the range (scan_start, scan_start + scan_length). Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_speed_of_sound | ( | self | ) |
The speed of sound used for distance calculations.
Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.get_voltage_5 | ( | self | ) |
The 5V rail voltage.
Returns a dictionary of the reply payload
| def Ping.Ping1D.Ping1D.read | ( | self | ) |
Consume rx buffer data until a new message is successfully decoded.
| def Ping.Ping1D.Ping1D.set_device_id | ( | self, | |
| device_id, | |||
verify = True |
|||
| ) |
Write a new control, and read the values back from the device If verify is true, fail if the values read back from the device do not match the controls that were written Return True on success Return False on failure to read values back or on verification failure.
Set the device ID.
| device_id | - Device ID (0-254). 255 is reserved for broadcast messages. |
| def Ping.Ping1D.Ping1D.set_gain_index | ( | self, | |
| gain_index, | |||
verify = True |
|||
| ) |
Set the current gain selection.
| gain_index | - 0: 0.6dB, 1: 1.8dB, 2: 5.5dB, 3: 12.9dB, 4: 30.2dB, 5: 66.1dB, 6: 144dB |
| def Ping.Ping1D.Ping1D.set_mode_auto | ( | self, | |
| mode_auto, | |||
verify = True |
|||
| ) |
Set automatic or manual mode.
Manual mode allows for manual selection of the gain and scan range.
| mode_auto | - 0: manual mode. 1: auto mode. |
| def Ping.Ping1D.Ping1D.set_ping_enable | ( | self, | |
| enable, | |||
verify = True |
|||
| ) |
Enable or disable acoustic measurements.
| enable | - 0: Disable, 1: Enable. |
| def Ping.Ping1D.Ping1D.set_ping_rate | ( | self, | |
| ping_rate, | |||
verify = True |
|||
| ) |
The interval between acoustic measurements.
| ping_rate | - Units: ms; The interval between acoustic measurements. |
| def Ping.Ping1D.Ping1D.set_range | ( | self, | |
| scan_start, | |||
| scan_length, | |||
verify = True |
|||
| ) |
Set the scan range for acoustic measurements.
| scan_start | - Units: mm; Set the scan range for acoustic measurements. |
| scan_length | - Units: mm; The length of the scan range. |
| def Ping.Ping1D.Ping1D.set_speed_of_sound | ( | self, | |
| speed_of_sound, | |||
verify = True |
|||
| ) |
Set the speed of sound used for distance calculations.
| speed_of_sound | - Units: mm/s; The speed of sound in the measurement medium. ~1,500,000 mm/s for water. |
1.8.6