Skip to content

Commit 0d1459d

Browse files
committed
device: update initialize to signal an initialization sequence to the device
1 parent 053d2f2 commit 0d1459d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

generate/templates/device.py.in

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff 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
##

generate/templates/ping1d.py.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)