-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Unless I've missed something in the compact enough documentation, I believe I've hit a bug in the code.
When running an application using go-mavlink with correctly configured serial port settings against a PX4 unit for the very first time after system boot, the following panic occurs. Subsequent runs always work without problems.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1bea18]
goroutine 7 [running]:
github.com/ungerik/go-mavlink.parseCrc1(0x24ec00, 0x1cd8000, 0x1c28f48, 0x1c662c4, 0x1c1a301)
/home/ebu/go/pkg/mod/github.com/ungerik/go-mavlink@v0.0.0-20140323091708-bbb6e8af8322/mavlink-helper.go:128 +0x40
github.com/ungerik/go-mavlink.GetMavParser.func1(0x1c28f00, 0x1c1a300, 0x0, 0x0)
/home/ebu/go/pkg/mod/github.com/ungerik/go-mavlink@v0.0.0-20140323091708-bbb6e8af8322/mavlink.go:108 +0xe0
...
The code at mavlink-helper.go:128 is in parseCrc1(...):
pInternal.packet.crcAccumulate(messageCrcs[pInternal.packet.Msg.ID()])
...and quick troubleshooting indicates that the pInternal.packet.Msg is indeed nil on this first ever call.
Since further invocations of the code work, this probably has something to do with initializing the Pixhawk or its messaging.
Checking for a nil .Msg field and returning an ErrInvalidChecksum seems to work, but this was just a test, I don't know that that would be the correct error.