File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -72,10 +72,19 @@ class PingDevice(object):
7272 return self .iodev .write (data )
7373
7474 ##
75- # @brief Make sure there is a device on and read some initial data
75+ # @brief initialize the device communication interface. A serial break signal
76+ # is sent to the device followed by 'U' (0x55) to begin the autobaurate procedure
77+ # on the device. Some data is then read from the device to verify communications
78+ #
79+ # @param baudrate: the baudrate to use. if None, the baudrate will not
80+ # be changed (default is 115200)
7681 #
7782 # @return True if the device replies with expected data, False otherwise
78- def initialize (self ):
83+ def initialize (self , baudrate = None ):
84+ if baudrate is not None :
85+ self .iodev .baudrate = baudrate
86+ self .iodev .send_break ()
87+ self .iodev .write ("U" .encode ("utf-8" ))
7988 return self .request (definitions .COMMON_PROTOCOL_VERSION ) is not None
8089
8190 ##
Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ class Ping1D(PingDevice):
2929
3030 return self .wait_message ([m_id ], timeout )
3131
32- def initialize (self ):
33- if not PingDevice .initialize (self ):
32+ def initialize (self , baudrate = None ):
33+ if not PingDevice .initialize (self , baudrate ):
3434 return False
3535 if self .legacyRequest (definitions .PING1D_GENERAL_INFO ) is None :
3636 return False
You can’t perform that action at this time.
0 commit comments