ping-python
A python implementation of the Blue Robotics Ping messaging protocol and a device API for the Blue Robotics Ping1D echosounder.
 All Classes Functions Variables
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Ping.PingMessage.PingMessage Class Reference
Inheritance diagram for Ping.PingMessage.PingMessage:
Inheritance graph
[legend]
Collaboration diagram for Ping.PingMessage.PingMessage:
Collaboration graph
[legend]

Public Member Functions

def __init__
 Messge constructor. More...
 
def packMsgData
 Pack object attributes into self.msgData (bytearray) More...
 
def unpackMsgData
 Unpack a bytearray into object attributes.
 
def calculateChecksum
 Calculate the checksum from the internal bytearray self.msgData.
 
def updateChecksum
 Update the object checksum value. More...
 
def verifyChecksum
 Verify that the object checksum attribute is equal to the checksum calculated according to the internal bytearray self.msgData.
 
def getPayloadFormat
 Get the python struct formatting string for the message payload. More...
 
def __repr__
 Dump object into string representation. More...
 

Public Attributes

 message_id
 The message id.
 
 request_id
 The request id for request messages.
 
 payload_length
 Number of bytes in the message payload.
 
 dst_device_id
 The message destination.
 
 src_device_id
 The message source.
 
 checksum
 The message checksum.
 
 msgData
 The raw data buffer for this message update with packMsgData()
 
 name
 The name of this message.
 
 payload_format
 The struct formatting string for the message payload.
 
 payload_field_names
 The field names of this message.
 

Static Public Attributes

tuple start_1 = ord("B")
 header start byte 1
 
tuple start_2 = ord("R")
 header start byte 2
 
string header_format = "BBHHBB"
 header struct format
 
string checksum_format = "H"
 checksum struct format
 
string endianess = "<"
 data endianness for struct formatting
 
tuple header_field_names
 names of the header fields More...
 
int headerLength = 8
 number of bytes in a header
 
int checksumLength = 2
 number of bytes in a checksum
 

Constructor & Destructor Documentation

def Ping.PingMessage.PingMessage.__init__ (   self,
  id = 0,
  msgData = None 
)

Messge constructor.

request:

1 m = PingMessage()
2 m.request_id = m_id
3 m.packMsgData()
4 write(m.msgData)
Ex set:
1 m = PingMessage(PING1D_SET_RANGE)
2 m.start_mm = 1000
3 m.length_mm = 2000
4 m.update_checksum()
5 write(m.msgData)
Ex receive:
1 m = PingMessage(rxByteArray)
2 if m.message_id == PING1D_RANGE
3  start_mm = m.start_mm
4  length_mm = m.length_mm

Member Function Documentation

def Ping.PingMessage.PingMessage.__repr__ (   self)

Dump object into string representation.

Returns
string representation of the object
def Ping.PingMessage.PingMessage.getPayloadFormat (   self)

Get the python struct formatting string for the message payload.

Returns
the payload struct format string
def Ping.PingMessage.PingMessage.packMsgData (   self)

Pack object attributes into self.msgData (bytearray)

Returns
self.msgData
def Ping.PingMessage.PingMessage.updateChecksum (   self)

Update the object checksum value.

Returns
the object checksum value

Member Data Documentation

tuple Ping.PingMessage.PingMessage.header_field_names
static
Initial value:
1 = (
2  "start_1",
3  "start_2",
4  "payload_length",
5  "message_id",
6  "src_device_id",
7  "dst_device_id")

names of the header fields


The documentation for this class was generated from the following file: