Differentiate the versions of each message
Closed this issue · 5 comments
There are several messages with the same Class ID and Message ID but a different length.
CFG-MSG for example:
The messages.go
adds a numeric suffix to differentiate them, but in decode.go
, the switch
cannot differentiate them.
I think that a Length()
method should be added to the Message
interface.
But the Length
field in the XML file is not easy to handle.
What are your thoughts about this issue and how do you want to handle it?
By the way, how is the xml file generated?
Can be tested with:
package ubx
import (
"bytes"
"reflect"
"testing"
)
func TestCanDecodeCorrectCfgMsgType(t *testing.T) {
originalMsg := CfgMsg2{MsgClass: 0xF0, MsgID: 0x9} // GBS
var b bytes.Buffer
err := Encode(&b, originalMsg)
if err != nil {
t.Error(err)
}
msg, err := Decode(b.Bytes())
if err != nil {
t.Error(err)
}
pointerToOriginalMsg := &originalMsg
if reflect.TypeOf(msg) != reflect.TypeOf(pointerToOriginalMsg) {
t.Error("Bad msg type")
}
cfgMsg := msg.(*CfgMsg2)
if cfgMsg.MsgClass != 0xF0 {
t.Errorf("Bad MsgClass. Should be 0xF0, actually is: %xd", cfgMsg.MsgClass)
}
if cfgMsg.MsgID != 0x9 {
t.Errorf("Bad MsgID. Should be 0x9, actually is: %xd", cfgMsg.MsgID)
}
}
the xml was 'generated' by one of my staff putting in a month of monk's work transliterating the pdf and looking at the bitfield pictures. ublox claimed there was no internal source, or they just didnt want to make it available. given the quality of thee protocol design that doesnt surprise me.
the xml was 'generated' by one of my staff putting in a month of monk's work transliterating the pdf and looking at the bitfield pictures
Ouch! That's a large amount of work!
I have tried the genmsg
branch and the issue seems to be already resolved.