Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit 3932d5b

Browse files
author
Daniel Campora
committed
serial.py: Use uart.wait_tx_done() during send_receive().
1 parent 673fbe0 commit 3932d5b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

uModbus/serial.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ def _send_receive(self, modbus_pdu, slave_addr, count):
7171
crc = self._calculate_crc16(serial_pdu)
7272
serial_pdu.extend(crc)
7373

74-
self._uart.read() # flush the Rx FIFO
74+
# flush the Rx FIFO
75+
self._uart.read()
7576
if self._ctrlPin:
7677
self._ctrlPin(1)
7778
self._uart.write(serial_pdu)
78-
time.sleep_ms(2)
79-
while not self._uart.tx_done():
80-
time.sleep_ms(2)
79+
while not self._uart.wait_tx_done(2):
80+
machine.idle()
8181
if self._ctrlPin:
8282
self._ctrlPin(0)
8383

0 commit comments

Comments
 (0)