Skip to content

Commit 6720530

Browse files
nkpro2000srbessman
authored andcommitted
Update verifying subcommands
1 parent 62dd9e9 commit 6720530

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pslab/bus/uart.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,18 @@ def _set_uart_mode(self, pd: int, st: int):
133133
error_message.append("Parity and data selection bits must be 2-bits.")
134134
if st not in (0, 1):
135135
error_message.append("Stop bits select must be a bit.")
136-
137-
self._device.send_byte(CP.UART_2)
138-
self._device.send_byte(CP.SET_MODE)
139-
140136
# Verifying whether the firmware support current subcommand.
141-
if self._device.get_byte() == 4:
142-
self._device.send_byte((pd << 1) | st)
143-
self._device.get_ack()
144-
self._save_config(mode=(pd, st))
145-
else:
137+
if self._device.version not in ["PSLab V6"]:
146138
raise RuntimeError(
147139
"This firmware version doesn't support this functionality."
148140
)
149141

142+
self._device.send_byte(CP.UART_2)
143+
self._device.send_byte(CP.SET_MODE)
144+
self._device.send_byte((pd << 1) | st)
145+
self._device.get_ack()
146+
self._save_config(mode=(pd, st))
147+
150148
def _read_uart_status(self) -> int:
151149
"""Return whether receive buffer has data.
152150

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy