[diag] handle errors of TransmitPacket() (#11076)

`TransmitPacket()` should return an error from platform Radio
implementation, as for example Radio can be in incorrect state.

If error occurs, increase `mSentErrorInvalidStatePackets` stat.

Add wrong state case to tests and fix `diag repeat stop` called
too lata.

Signed-off-by: Maciej Baczmanski <[email protected]>
This commit is contained in:
Maciej Baczmański
2025-01-09 10:47:40 -08:00
committed by GitHub
parent e7f8f75320
commit d7a266856f
6 changed files with 46 additions and 14 deletions
+21 -3
View File
@@ -62,6 +62,7 @@ expect "received packets: 0"
expect "sent success packets: 10"
expect "sent error cca packets: 0"
expect "sent error abort packets: 0"
expect "sent error invalid state packets: 0"
expect "sent error others packets: 0"
expect "first received packet: rssi=0, lqi=0"
expect "last received packet: rssi=0, lqi=0"
@@ -89,6 +90,7 @@ expect "received packets: 20"
expect "sent success packets: 0"
expect "sent error cca packets: 0"
expect "sent error abort packets: 0"
expect "sent error invalid state packets: 0"
expect "sent error others packets: 0"
expect "first received packet: rssi=-20, lqi=0"
expect "last received packet: rssi=-20, lqi=0"
@@ -112,6 +114,7 @@ expect -r {received packets: \d+}
expect "sent success packets: 0"
expect "sent error cca packets: 0"
expect "sent error abort packets: 0"
expect "sent error invalid state packets: 0"
expect "sent error others packets: 0"
expect "first received packet: rssi=-20, lqi=0"
expect "last received packet: rssi=-20, lqi=0"
@@ -140,6 +143,21 @@ send_user "input odd length test\n"
send "diag frame 123\n"
expect "Error"
send "diag radio sleep\n"
expect_line "Done"
send "diag radio disable\n"
expect_line "Done"
send "diag send 10 10\n"
expect "Error 13: InvalidState"
send "diag radio enable\n"
expect_line "Done"
send "diag radio receive\n"
expect_line "Done"
send_user "shortest frame test\n"
send "diag frame 112233\n"
expect "Done"
@@ -151,6 +169,9 @@ send "diag frame 112233445566778899001122334455667788990011223344556677889900112
expect "Done"
send "diag repeat 1\n"
expect "Done"
sleep 3
send "diag repeat stop\n"
expect "Done"
send "diag repeat stop\n"
expect "Done"
@@ -173,9 +194,6 @@ expect "Done"
send "diag send 1\n"
expect "Done"
send "diag repeat stop\n"
expect "Done"
send "diag channel 11\n"
expect_line "Done"
+1
View File
@@ -58,6 +58,7 @@ class TestDiag(thread_cert.TestCase):
'sent success packets: 0\r\n'
'sent error cca packets: 0\r\n'
'sent error abort packets: 0\r\n'
'sent error invalid state packets: 0\r\n'
'sent error others packets: 0\r\n'
'first received packet: rssi=0, lqi=0\r\n'
'last received packet: rssi=0, lqi=0\r\n',