Skip to content

Commit c655704

Browse files
nkpro2000srbessman
authored andcommitted
Fix test_uart
1 parent 6720530 commit c655704

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tests/test_uart.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
WRITE_DATA = 0x55
2222
TXD2 = "LA1"
2323
RXD2 = "SQ1"
24-
PWM_FERQUENCY = UART._baudrate
24+
PWM_FERQUENCY = UART._baudrate // 2
2525
MICROSECONDS = 1e-6
2626
RELTOL = 0.05
2727
# Number of expected logic level changes.
@@ -59,13 +59,14 @@ def test_configure(la: LogicAnalyzer, uart: UART):
5959
uart.write_byte(WRITE_DATA)
6060
la.stop()
6161
(txd2,) = la.fetch_data()
62-
start_to_stop = 1 + 8 + 1
62+
start_to_stop = 9
6363
period = (txd2[-1] - txd2[0]) / start_to_stop
64+
6465
assert (period * MICROSECONDS) ** -1 == pytest.approx(baudrate, rel=RELTOL)
6566

6667

6768
def test_write_byte(la: LogicAnalyzer, uart: UART):
68-
la.capture(3, block=False)
69+
la.capture(1, block=False)
6970
uart.write_byte(WRITE_DATA)
7071
la.stop()
7172
(txd2,) = la.fetch_data()
@@ -74,7 +75,7 @@ def test_write_byte(la: LogicAnalyzer, uart: UART):
7475

7576

7677
def test_write_int(la: LogicAnalyzer, uart: UART):
77-
la.capture(3, block=False)
78+
la.capture(1, block=False)
7879
uart.write_int((WRITE_DATA << 8) | WRITE_DATA)
7980
la.stop()
8081
(txd2,) = la.fetch_data()
@@ -85,10 +86,10 @@ def test_write_int(la: LogicAnalyzer, uart: UART):
8586
def test_read_byte(pwm: PWMGenerator, uart: UART):
8687
value = uart.read_byte()
8788

88-
assert value in (0, 0xFF)
89+
assert value in (0x55, 0xAA)
8990

9091

9192
def test_read_int(pwm: PWMGenerator, uart: UART):
9293
value = uart.read_int()
9394

94-
assert value in (0, 0xFFFF)
95+
assert value in (0x5555, 0x55AA, 0xAA55, 0xAAAA)

0 commit comments

Comments
 (0)