1111MAX_TC_FRAME_SIZE = 248
1212MAX_TC_FRAME_PAYLOAD_SIZE = 241
1313LONG_FRAME_COUNT = 64
14+ PING_PONG_EXCHANGE_COUNT = 32
15+ PING_PONG_EXCHANGE_MAX_SECONDS = 60.0
1416
1517
1618def _assert_no_warnings (fprime_test_api ):
@@ -40,9 +42,7 @@ def test_link_one_to_two_64_max_tc_frames(
4042 received = b""
4143
4244 for frame in frames :
43- assert len (frame ) == MAX_TC_FRAME_SIZE
44- assert data_port_one .write (frame ) == len (frame )
45- data_port_one .flush ()
45+ data_port_one .write (frame )
4646 received += data_port_two .read_all ()
4747 # A 252-byte LoRa packet has about 902ms time-on-air according to
4848 # Semtech calculator at SF8/125 kHz/CR 4/5
@@ -69,11 +69,9 @@ def test_link_two_to_one_64_max_tc_frames(
6969 received = b""
7070
7171 for frame in frames :
72- assert len (frame ) == MAX_TC_FRAME_SIZE
73- assert data_port_two .write (frame ) == len (frame )
74- # See comment in one-to-two test
75- data_port_two .flush ()
72+ data_port_two .write (frame )
7673 received += data_port_one .read_all ()
74+ # See comment in one-to-two test
7775 time .sleep (1.0 )
7876
7977 received += data_port_one .read (len (sent ) - len (received ))
@@ -84,3 +82,36 @@ def test_link_two_to_one_64_max_tc_frames(
8482 )
8583 finally :
8684 _assert_no_warnings (fprime_test_api )
85+
86+
87+ def test_ping_pong_one_two (fprime_test_api , data_port_one , data_port_two ):
88+ try :
89+ exchanges = [
90+ (
91+ _tc_frame (bytes ([packet_number ]) * MAX_TC_FRAME_PAYLOAD_SIZE ),
92+ _tc_frame (
93+ bytes ([packet_number + PING_PONG_EXCHANGE_COUNT ])
94+ * MAX_TC_FRAME_PAYLOAD_SIZE
95+ ),
96+ )
97+ for packet_number in range (PING_PONG_EXCHANGE_COUNT )
98+ ]
99+ received = []
100+
101+ start = time .monotonic ()
102+ for outbound , reply in exchanges :
103+ data_port_one .write (outbound )
104+ received .append (data_port_two .read (len (outbound )))
105+
106+ data_port_two .write (reply )
107+ received .append (data_port_one .read (len (reply )))
108+ elapsed = time .monotonic () - start
109+
110+ assert received == [packet for exchange in exchanges for packet in exchange ]
111+ assert elapsed < PING_PONG_EXCHANGE_MAX_SECONDS , (
112+ f"Expected { PING_PONG_EXCHANGE_COUNT * 2 } max-size packets to "
113+ f"exchange in less than { PING_PONG_EXCHANGE_MAX_SECONDS :.1f} s, "
114+ f"took { elapsed :.1f} s"
115+ )
116+ finally :
117+ _assert_no_warnings (fprime_test_api )
0 commit comments