diff --git a/skylab/skylab.go b/skylab/skylab.go index 9f6fb5f..e10f8f7 100644 --- a/skylab/skylab.go +++ b/skylab/skylab.go @@ -82,7 +82,7 @@ func ToCanFrame(p Packet) (id uint32, data []byte, err error) { // internal structure for partially decoding json object. type jsonRawEvent struct { - Timestamp float64 + Timestamp uint32 Id uint32 Name string Data json.RawMessage @@ -90,10 +90,10 @@ type jsonRawEvent struct { // BusEvent is a timestamped Skylab packet type BusEvent struct { - Timestamp float64 `json:"ts"` - Id uint64 `json:"id"` - Name string `json:"name"` - Data Packet `json:"data"` + Timestamp uint32 `json:"ts"` + Id uint32 `json:"id"` + Name string `json:"name"` + Data Packet `json:"data"` } func (e *BusEvent) MarshalJSON() (b []byte, err error) { @@ -123,7 +123,7 @@ func (e *BusEvent) UnmarshalJSON(b []byte) error { } e.Timestamp = jRaw.Timestamp - e.Id = uint64(jRaw.Id) + e.Id = jRaw.Id e.Data, err = FromJson(jRaw.Id, jRaw.Data) e.Name = e.Data.String() @@ -154,7 +154,7 @@ func (e *BusEvent) UnmarshalMsg(b []byte) ([]byte, error) { return remain, err } e.Timestamp = rawEv.Timestamp - e.Id = uint64(rawEv.Id) + e.Id = rawEv.Id e.Data, err = FromCanFrame(rawEv.Id, rawEv.Data) e.Name = e.Data.String() @@ -164,7 +164,6 @@ func (e *BusEvent) UnmarshalMsg(b []byte) ([]byte, error) { // we need to be able to parse the JSON as well. this is done using the // generator since we can use the switch/case thing since it's the fastest - type UnknownIdError struct { id uint64 } diff --git a/skylab/skylab_msgp.go b/skylab/skylab_msgp.go index de18675..628df20 100644 --- a/skylab/skylab_msgp.go +++ b/skylab/skylab_msgp.go @@ -4,9 +4,9 @@ package skylab // internal structure for handling type msgpRawEvent struct { - Timestamp float64 `msg:"ts"` - Id uint32 `msg:"id"` - Data []byte `msg:"data"` + Timestamp uint32 `msg:"ts"` + Id uint32 `msg:"id"` + Data []byte `msg:"data"` } // internal structure to represent a raw can packet over the network. diff --git a/skylab/skylab_msgp_gen.go b/skylab/skylab_msgp_gen.go index 02ef345..1557840 100644 --- a/skylab/skylab_msgp_gen.go +++ b/skylab/skylab_msgp_gen.go @@ -25,7 +25,7 @@ func (z *msgpRawEvent) DecodeMsg(dc *msgp.Reader) (err error) { } switch msgp.UnsafeString(field) { case "ts": - z.Timestamp, err = dc.ReadFloat64() + z.Timestamp, err = dc.ReadUint32() if err != nil { err = msgp.WrapError(err, "Timestamp") return @@ -61,7 +61,7 @@ func (z *msgpRawEvent) EncodeMsg(en *msgp.Writer) (err error) { if err != nil { return } - err = en.WriteFloat64(z.Timestamp) + err = en.WriteUint32(z.Timestamp) if err != nil { err = msgp.WrapError(err, "Timestamp") return @@ -95,7 +95,7 @@ func (z *msgpRawEvent) MarshalMsg(b []byte) (o []byte, err error) { // map header, size 3 // string "ts" o = append(o, 0x83, 0xa2, 0x74, 0x73) - o = msgp.AppendFloat64(o, z.Timestamp) + o = msgp.AppendUint32(o, z.Timestamp) // string "id" o = append(o, 0xa2, 0x69, 0x64) o = msgp.AppendUint32(o, z.Id) @@ -124,7 +124,7 @@ func (z *msgpRawEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { } switch msgp.UnsafeString(field) { case "ts": - z.Timestamp, bts, err = msgp.ReadFloat64Bytes(bts) + z.Timestamp, bts, err = msgp.ReadUint32Bytes(bts) if err != nil { err = msgp.WrapError(err, "Timestamp") return @@ -155,7 +155,7 @@ func (z *msgpRawEvent) UnmarshalMsg(bts []byte) (o []byte, err error) { // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message func (z *msgpRawEvent) Msgsize() (s int) { - s = 1 + 3 + msgp.Float64Size + 3 + msgp.Uint32Size + 5 + msgp.BytesPrefixSize + len(z.Data) + s = 1 + 3 + msgp.Uint32Size + 3 + msgp.Uint32Size + 5 + msgp.BytesPrefixSize + len(z.Data) return }