mirror of
https://github.com/jwetzell/free-d-go.git
synced 2026-08-31 11:38:57 +00:00
switch to fixed size array
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
func main() {
|
||||
|
||||
messageBytes := []byte{0xd1, 0x01, 0x5a, 0x00, 0x00, 0x2d, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x7f, 0xff, 0x40, 0x7f, 0xff, 0x80, 0x7f, 0xff,
|
||||
messageBytes := [29]byte{0xd1, 0x01, 0x5a, 0x00, 0x00, 0x2d, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x7f, 0xff, 0x40, 0x7f, 0xff, 0x80, 0x7f, 0xff,
|
||||
0xc0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x00, 0x00, 50,
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,13 @@ func main() {
|
||||
if err != nil {
|
||||
slog.Error("error reading from UDP", "err", err)
|
||||
} else if length > 0 {
|
||||
message, err := freeD.Decode(buffer[0:length])
|
||||
if length != 29 {
|
||||
slog.Warn("received UDP packet with unexpected length", "length", length)
|
||||
continue
|
||||
}
|
||||
var messageBytes [29]byte
|
||||
copy(messageBytes[:], buffer[0:length])
|
||||
message, err := freeD.Decode(messageBytes)
|
||||
if err != nil {
|
||||
slog.Error("error decoding", "err", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user