feat: add Ground Station UART baseline
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package protocol
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRCFrameRoundTrip(t *testing.T) {
|
||||
input := RCFrame{Sequence: 42, Timestamp: 123456}
|
||||
for i := range input.Channels {
|
||||
input.Channels[i] = int16(i*100 - 750)
|
||||
}
|
||||
|
||||
got, err := DecodeRC(EncodeRC(input))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != input {
|
||||
t.Fatalf("round trip mismatch: got %#v want %#v", got, input)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRCFrameRejectsBadCRC(t *testing.T) {
|
||||
packet := EncodeRC(RCFrame{})
|
||||
packet[Header] ^= 1
|
||||
if _, err := DecodeRC(packet); err == nil {
|
||||
t.Fatal("expected CRC error")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user