Small CLI monitoring tool to decode proprietary [...] protocol and display info in human readable representation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ycli-mon/yabl/protocol_test.go

45 lines
782 B

package yabl
import (
"cli-mon/can"
"log"
"testing"
"time"
)
type parameters struct {
fields []content
interval uint
}
type content struct {
length uint8
setter func(uint64 uint64)
last time.Time
}
func TestStartProtocolParsing(t *testing.T) {
var cis = ContactorInternalState{}
var cisMsg = parameters{fields: []content{
{length: 3, setter: cis.setContactorReady},
{length: 2, setter: cis.setContactorOn},
{length: 2, setter: cis.setUnexpectedState},
{length: 2, setter: cis.setIsolated},
{length: 2, setter: cis.setDebugEnabled},
}}
var messages = map[uint]parameters{
can.CAN_ID_071: cisMsg,
}
// try to use
var values = messages[can.CAN_ID_071]
for num, item := range values.fields {
item.setter(uint64(num))
log.Println(cis)
}
}