format
This commit is contained in:
parent
f380631b5e
commit
3c1a96c8e0
|
@ -9,9 +9,9 @@ import (
|
|||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/kschamplin/gotelem"
|
||||
"github.com/kschamplin/gotelem/internal/logparsers"
|
||||
"github.com/kschamplin/gotelem/skylab"
|
||||
"github.com/kschamplin/gotelem"
|
||||
"github.com/urfave/cli/v2"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
|
|
@ -96,7 +96,6 @@ func (s *socketCANService) Start(cCtx *cli.Context, deps svcDeps) (err error) {
|
|||
|
||||
frame, err = skylab.ToCanFrame(msg.Data)
|
||||
|
||||
|
||||
s.sock.Send(&frame)
|
||||
|
||||
case msg := <-rxCan:
|
||||
|
@ -107,7 +106,7 @@ func (s *socketCANService) Start(cCtx *cli.Context, deps svcDeps) (err error) {
|
|||
}
|
||||
cde := skylab.BusEvent{
|
||||
Timestamp: time.Now(),
|
||||
Name: p.String(),
|
||||
Name: p.String(),
|
||||
Data: p,
|
||||
}
|
||||
broker.Publish("socketCAN", cde)
|
||||
|
|
4
db.go
4
db.go
|
@ -321,7 +321,6 @@ func (e DocumentNotFoundError) Error() string {
|
|||
return fmt.Sprintf("document could not find key: %s", string(e))
|
||||
}
|
||||
|
||||
|
||||
// UpdateDocument replaces the entire contents of a document matching
|
||||
// the given key. Note that the key is derived from the document,
|
||||
// and no checks are done to ensure that the new key is the same.
|
||||
|
@ -343,7 +342,6 @@ func (tdb *TelemDb) UpdateDocument(ctx context.Context, key string,
|
|||
return err
|
||||
}
|
||||
|
||||
|
||||
// GetDocument gets the document matching the corresponding key.
|
||||
func (tdb *TelemDb) GetDocument(ctx context.Context, key string) (json.RawMessage, error) {
|
||||
const get = `SELECT data FROM openmct_objects WHERE key IS ?`
|
||||
|
@ -363,7 +361,7 @@ func (tdb *TelemDb) GetDocument(ctx context.Context, key string) (json.RawMessag
|
|||
|
||||
// GetAllDocuments returns all documents in the database.
|
||||
func (tdb *TelemDb) GetAllDocuments(ctx context.Context) ([]json.RawMessage, error) {
|
||||
const getall = `SELECT data FROM openmct_objects`;
|
||||
const getall = `SELECT data FROM openmct_objects`
|
||||
|
||||
rows, err := tdb.db.QueryxContext(ctx, getall)
|
||||
if err != nil {
|
||||
|
|
|
@ -201,7 +201,7 @@ func TestDbDocuments(t *testing.T) {
|
|||
tdb := MakeMockDatabase(t.Name())
|
||||
tdb.db.Ping()
|
||||
ctx := context.Background()
|
||||
var badDoc = map[string]string{"bad":"duh"}
|
||||
var badDoc = map[string]string{"bad": "duh"}
|
||||
msg, err := json.Marshal(badDoc)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -241,7 +241,7 @@ func TestDbDocuments(t *testing.T) {
|
|||
|
||||
res, err := tdb.GetDocument(ctx, "hi")
|
||||
|
||||
if err == nil || !errors.Is(err, DocumentNotFoundError("hi")){
|
||||
if err == nil || !errors.Is(err, DocumentNotFoundError("hi")) {
|
||||
t.Fatalf("GetDocument expected DocumentNotFoundError, got %v", err)
|
||||
}
|
||||
if res != nil {
|
||||
|
|
1
http.go
1
http.go
|
@ -274,7 +274,6 @@ func apiV1GetValues(db *TelemDb) http.HandlerFunc {
|
|||
// override the bus event filter name option
|
||||
bef.Names = []string{name}
|
||||
|
||||
|
||||
var res []Datum
|
||||
// make the call, skip the limit modifier if it's nil.
|
||||
res, err = db.GetValues(r.Context(), *bef, field, lim)
|
||||
|
|
|
@ -6,20 +6,19 @@
|
|||
// by writing "adapters" to various devices/formats (xbee, socketcan)
|
||||
package can
|
||||
|
||||
|
||||
type CanID struct {
|
||||
Id uint32
|
||||
Id uint32
|
||||
Extended bool // since the id itself is not enough.
|
||||
}
|
||||
|
||||
// Frame represents a protocol-agnostic CAN frame. The Id can be standard or extended,
|
||||
// but if it is extended, the Kind should be EFF.
|
||||
type Frame struct {
|
||||
Id CanID
|
||||
Id CanID
|
||||
Data []byte
|
||||
Kind Kind
|
||||
}
|
||||
|
||||
|
||||
// TODO: should this be replaced
|
||||
type CANFrame interface {
|
||||
Id()
|
||||
|
@ -34,8 +33,8 @@ type Kind uint8
|
|||
|
||||
const (
|
||||
CanDataFrame Kind = iota // Standard ID Frame
|
||||
CanRTRFrame // Remote Transmission Request Frame
|
||||
CanErrFrame // Error Frame
|
||||
CanRTRFrame // Remote Transmission Request Frame
|
||||
CanErrFrame // Error Frame
|
||||
)
|
||||
|
||||
// CanFilter is a basic filter for masking out data. It has an Inverted flag
|
||||
|
|
|
@ -44,7 +44,7 @@ var candumpRegex = regexp.MustCompile(`^\((\d+)\.(\d{6})\) \w+ (\w+)#(\w+)$`)
|
|||
|
||||
func parseCanDumpLine(dumpLine string) (frame can.Frame, ts time.Time, err error) {
|
||||
frame = can.Frame{}
|
||||
ts = time.Unix(0,0)
|
||||
ts = time.Unix(0, 0)
|
||||
// dumpline looks like this:
|
||||
// (1684538768.521889) can0 200#8D643546
|
||||
// remove trailing newline/whitespaces
|
||||
|
@ -84,11 +84,11 @@ func parseCanDumpLine(dumpLine string) (frame can.Frame, ts time.Time, err error
|
|||
}
|
||||
|
||||
// TODO: add extended id support, need an example log and a test.
|
||||
frame.Id = can.CanID{Id: uint32(id), Extended: false}
|
||||
frame.Id = can.CanID{Id: uint32(id), Extended: false}
|
||||
frame.Data = rawData
|
||||
frame.Kind = can.CanDataFrame
|
||||
|
||||
ts = time.Unix(unixSeconds, unixMicros * int64(time.Microsecond))
|
||||
ts = time.Unix(unixSeconds, unixMicros*int64(time.Microsecond))
|
||||
|
||||
return
|
||||
|
||||
|
@ -103,7 +103,7 @@ var telemRegex = regexp.MustCompile(`^(\d+)\.(\d{3}) (\w{3})(\w+)$`)
|
|||
|
||||
func parseTelemLogLine(line string) (frame can.Frame, ts time.Time, err error) {
|
||||
frame = can.Frame{}
|
||||
ts = time.Unix(0,0)
|
||||
ts = time.Unix(0, 0)
|
||||
// strip trailng newline since we rely on it being gone
|
||||
line = strings.TrimSpace(line)
|
||||
|
||||
|
|
|
@ -159,7 +159,6 @@ func Test_parseTelemLogLine_errors(t *testing.T) {
|
|||
name: "utf8 corruption",
|
||||
input: "1698180835.318 0619\xed\xa0\x80fsadfD805640X0EBE24",
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//go:build openmct
|
||||
|
||||
package gotelem
|
||||
|
||||
import (
|
||||
|
|
|
@ -74,7 +74,6 @@ type Sizer interface {
|
|||
// CanSend takes a packet and makes CAN framing data.
|
||||
func ToCanFrame(p Packet) (f can.Frame, err error) {
|
||||
|
||||
|
||||
f.Id, err = p.CanId()
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -146,8 +145,9 @@ func (e *UnknownIdError) Error() string {
|
|||
|
||||
type BadLengthError struct {
|
||||
expected uint32
|
||||
actual uint32
|
||||
actual uint32
|
||||
}
|
||||
|
||||
func (e *BadLengthError) Error() string {
|
||||
return fmt.Sprintf("bad data length, expected %d, got %d", e.expected, e.actual)
|
||||
}
|
||||
|
|
1261
skylab/skylab_gen.go
1261
skylab/skylab_gen.go
File diff suppressed because one or more lines are too long
|
@ -1,12 +1,10 @@
|
|||
|
||||
package skylab
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
||||
func TestMarshalUnmarshalBmsMeasurement(t *testing.T) {
|
||||
v := &BmsMeasurement{}
|
||||
bin, err := v.MarshalPacket()
|
||||
|
@ -40,7 +38,6 @@ func TestJSONBmsMeasurement(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBatteryStatus(t *testing.T) {
|
||||
v := &BatteryStatus{}
|
||||
|
@ -75,7 +72,6 @@ func TestJSONBatteryStatus(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsKillReason(t *testing.T) {
|
||||
v := &BmsKillReason{}
|
||||
|
@ -110,7 +106,6 @@ func TestJSONBmsKillReason(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsModuleMinMax(t *testing.T) {
|
||||
v := &BmsModuleMinMax{}
|
||||
|
@ -145,7 +140,6 @@ func TestJSONBmsModuleMinMax(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsSoc(t *testing.T) {
|
||||
v := &BmsSoc{}
|
||||
|
@ -180,7 +174,6 @@ func TestJSONBmsSoc(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsCapacity(t *testing.T) {
|
||||
v := &BmsCapacity{}
|
||||
|
@ -215,7 +208,6 @@ func TestJSONBmsCapacity(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsCurrentlimit(t *testing.T) {
|
||||
v := &BmsCurrentlimit{}
|
||||
|
@ -250,7 +242,6 @@ func TestJSONBmsCurrentlimit(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsFanInfo(t *testing.T) {
|
||||
v := &BmsFanInfo{}
|
||||
|
@ -285,7 +276,6 @@ func TestJSONBmsFanInfo(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsSetMinFanSpeed(t *testing.T) {
|
||||
v := &BmsSetMinFanSpeed{}
|
||||
|
@ -320,7 +310,6 @@ func TestJSONBmsSetMinFanSpeed(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsModule(t *testing.T) {
|
||||
v := &BmsModule{}
|
||||
|
@ -355,7 +344,6 @@ func TestJSONBmsModule(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsChargerResponse(t *testing.T) {
|
||||
v := &BmsChargerResponse{}
|
||||
|
@ -390,7 +378,6 @@ func TestJSONBmsChargerResponse(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalChassisIsolationFault(t *testing.T) {
|
||||
v := &ChassisIsolationFault{}
|
||||
|
@ -425,7 +412,6 @@ func TestJSONChassisIsolationFault(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsImdInfo(t *testing.T) {
|
||||
v := &BmsImdInfo{}
|
||||
|
@ -460,7 +446,6 @@ func TestJSONBmsImdInfo(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalDashboardPedalPercentages(t *testing.T) {
|
||||
v := &DashboardPedalPercentages{}
|
||||
|
@ -495,7 +480,6 @@ func TestJSONDashboardPedalPercentages(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalCarState(t *testing.T) {
|
||||
v := &CarState{}
|
||||
|
@ -530,7 +514,6 @@ func TestJSONCarState(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalDashboardPedalFault(t *testing.T) {
|
||||
v := &DashboardPedalFault{}
|
||||
|
@ -565,7 +548,6 @@ func TestJSONDashboardPedalFault(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalDashboardSystemTimeoutTest(t *testing.T) {
|
||||
v := &DashboardSystemTimeoutTest{}
|
||||
|
@ -600,7 +582,6 @@ func TestJSONDashboardSystemTimeoutTest(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalCarSpeed(t *testing.T) {
|
||||
v := &CarSpeed{}
|
||||
|
@ -635,7 +616,6 @@ func TestJSONCarSpeed(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalFlightComputerLvBoardDisconnectCounts(t *testing.T) {
|
||||
v := &FlightComputerLvBoardDisconnectCounts{}
|
||||
|
@ -670,7 +650,6 @@ func TestJSONFlightComputerLvBoardDisconnectCounts(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalFlightComputerHvBoardDisconnectCounts(t *testing.T) {
|
||||
v := &FlightComputerHvBoardDisconnectCounts{}
|
||||
|
@ -705,7 +684,6 @@ func TestJSONFlightComputerHvBoardDisconnectCounts(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalFlightComputerInternalState(t *testing.T) {
|
||||
v := &FlightComputerInternalState{}
|
||||
|
@ -740,7 +718,6 @@ func TestJSONFlightComputerInternalState(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalPowerToDrive(t *testing.T) {
|
||||
v := &PowerToDrive{}
|
||||
|
@ -775,7 +752,6 @@ func TestJSONPowerToDrive(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalArrayPower(t *testing.T) {
|
||||
v := &ArrayPower{}
|
||||
|
@ -810,7 +786,6 @@ func TestJSONArrayPower(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalArrayEnergy(t *testing.T) {
|
||||
v := &ArrayEnergy{}
|
||||
|
@ -845,7 +820,6 @@ func TestJSONArrayEnergy(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalArrayEnergyReset(t *testing.T) {
|
||||
v := &ArrayEnergyReset{}
|
||||
|
@ -880,7 +854,6 @@ func TestJSONArrayEnergyReset(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalVisionTurnSignalsCommand(t *testing.T) {
|
||||
v := &VisionTurnSignalsCommand{}
|
||||
|
@ -915,7 +888,6 @@ func TestJSONVisionTurnSignalsCommand(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalVisionBrakeLightsCommand(t *testing.T) {
|
||||
v := &VisionBrakeLightsCommand{}
|
||||
|
@ -950,7 +922,6 @@ func TestJSONVisionBrakeLightsCommand(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalVisionHeadlightsCommand(t *testing.T) {
|
||||
v := &VisionHeadlightsCommand{}
|
||||
|
@ -985,7 +956,6 @@ func TestJSONVisionHeadlightsCommand(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalVisionHornCommand(t *testing.T) {
|
||||
v := &VisionHornCommand{}
|
||||
|
@ -1020,7 +990,6 @@ func TestJSONVisionHornCommand(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalVisionArrayLatchesCommand(t *testing.T) {
|
||||
v := &VisionArrayLatchesCommand{}
|
||||
|
@ -1055,7 +1024,6 @@ func TestJSONVisionArrayLatchesCommand(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalVisionRearviewCommand(t *testing.T) {
|
||||
v := &VisionRearviewCommand{}
|
||||
|
@ -1090,7 +1058,6 @@ func TestJSONVisionRearviewCommand(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalTrackerEnable(t *testing.T) {
|
||||
v := &TrackerEnable{}
|
||||
|
@ -1125,7 +1092,6 @@ func TestJSONTrackerEnable(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalDistanceTraveled(t *testing.T) {
|
||||
v := &DistanceTraveled{}
|
||||
|
@ -1160,7 +1126,6 @@ func TestJSONDistanceTraveled(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalChargerState(t *testing.T) {
|
||||
v := &ChargerState{}
|
||||
|
@ -1195,7 +1160,6 @@ func TestJSONChargerState(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalChargerBmsRequest(t *testing.T) {
|
||||
v := &ChargerBmsRequest{}
|
||||
|
@ -1230,7 +1194,6 @@ func TestJSONChargerBmsRequest(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalChargerCurrentVoltage(t *testing.T) {
|
||||
v := &ChargerCurrentVoltage{}
|
||||
|
@ -1265,7 +1228,6 @@ func TestJSONChargerCurrentVoltage(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalChargerPower(t *testing.T) {
|
||||
v := &ChargerPower{}
|
||||
|
@ -1300,7 +1262,6 @@ func TestJSONChargerPower(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalThunderstruckControlMessage(t *testing.T) {
|
||||
v := &ThunderstruckControlMessage{}
|
||||
|
@ -1335,7 +1296,6 @@ func TestJSONThunderstruckControlMessage(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalVisionStatusFront(t *testing.T) {
|
||||
v := &VisionStatusFront{}
|
||||
|
@ -1370,7 +1330,6 @@ func TestJSONVisionStatusFront(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalVisionStatusRear(t *testing.T) {
|
||||
v := &VisionStatusRear{}
|
||||
|
@ -1405,7 +1364,6 @@ func TestJSONVisionStatusRear(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalLightsFrontId(t *testing.T) {
|
||||
v := &LightsFrontId{}
|
||||
|
@ -1440,7 +1398,6 @@ func TestJSONLightsFrontId(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalLightsBackId(t *testing.T) {
|
||||
v := &LightsBackId{}
|
||||
|
@ -1475,7 +1432,6 @@ func TestJSONLightsBackId(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalVisionId(t *testing.T) {
|
||||
v := &VisionId{}
|
||||
|
@ -1510,7 +1466,6 @@ func TestJSONVisionId(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalSteeringPressCount1(t *testing.T) {
|
||||
v := &SteeringPressCount1{}
|
||||
|
@ -1545,7 +1500,6 @@ func TestJSONSteeringPressCount1(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalSteeringPressCount2(t *testing.T) {
|
||||
v := &SteeringPressCount2{}
|
||||
|
@ -1580,7 +1534,6 @@ func TestJSONSteeringPressCount2(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalSteeringButtonColors1(t *testing.T) {
|
||||
v := &SteeringButtonColors1{}
|
||||
|
@ -1615,7 +1568,6 @@ func TestJSONSteeringButtonColors1(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalSteeringButtonColors2(t *testing.T) {
|
||||
v := &SteeringButtonColors2{}
|
||||
|
@ -1650,7 +1602,6 @@ func TestJSONSteeringButtonColors2(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalSteeringHorn(t *testing.T) {
|
||||
v := &SteeringHorn{}
|
||||
|
@ -1685,7 +1636,6 @@ func TestJSONSteeringHorn(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalThunderstruckStatusMessage(t *testing.T) {
|
||||
v := &ThunderstruckStatusMessage{}
|
||||
|
@ -1720,7 +1670,6 @@ func TestJSONThunderstruckStatusMessage(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalTrackerData(t *testing.T) {
|
||||
v := &TrackerData{}
|
||||
|
@ -1755,7 +1704,6 @@ func TestJSONTrackerData(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalTritiumMotorDriveL(t *testing.T) {
|
||||
v := &TritiumMotorDriveL{}
|
||||
|
@ -1790,7 +1738,6 @@ func TestJSONTritiumMotorDriveL(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalTritiumMotorPowerL(t *testing.T) {
|
||||
v := &TritiumMotorPowerL{}
|
||||
|
@ -1825,7 +1772,6 @@ func TestJSONTritiumMotorPowerL(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalTritiumResetL(t *testing.T) {
|
||||
v := &TritiumResetL{}
|
||||
|
@ -1860,7 +1806,6 @@ func TestJSONTritiumResetL(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalTritiumMotorDriveR(t *testing.T) {
|
||||
v := &TritiumMotorDriveR{}
|
||||
|
@ -1895,7 +1840,6 @@ func TestJSONTritiumMotorDriveR(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalTritiumMotorPowerR(t *testing.T) {
|
||||
v := &TritiumMotorPowerR{}
|
||||
|
@ -1930,7 +1874,6 @@ func TestJSONTritiumMotorPowerR(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalTritiumResetR(t *testing.T) {
|
||||
v := &TritiumResetR{}
|
||||
|
@ -1965,7 +1908,6 @@ func TestJSONTritiumResetR(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsAhSet(t *testing.T) {
|
||||
v := &BmsAhSet{}
|
||||
|
@ -2000,7 +1942,6 @@ func TestJSONBmsAhSet(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsWhSet(t *testing.T) {
|
||||
v := &BmsWhSet{}
|
||||
|
@ -2035,7 +1976,6 @@ func TestJSONBmsWhSet(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalBmsKill(t *testing.T) {
|
||||
v := &BmsKill{}
|
||||
|
@ -2070,7 +2010,6 @@ func TestJSONBmsKill(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalTelemetryRtcReset(t *testing.T) {
|
||||
v := &TelemetryRtcReset{}
|
||||
|
@ -2105,7 +2044,6 @@ func TestJSONTelemetryRtcReset(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrIdentification(t *testing.T) {
|
||||
v := &WsrIdentification{}
|
||||
|
@ -2140,7 +2078,6 @@ func TestJSONWsrIdentification(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrStatusInformation(t *testing.T) {
|
||||
v := &WsrStatusInformation{}
|
||||
|
@ -2175,7 +2112,6 @@ func TestJSONWsrStatusInformation(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrBusMeasurement(t *testing.T) {
|
||||
v := &WsrBusMeasurement{}
|
||||
|
@ -2210,7 +2146,6 @@ func TestJSONWsrBusMeasurement(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrVelocity(t *testing.T) {
|
||||
v := &WsrVelocity{}
|
||||
|
@ -2245,7 +2180,6 @@ func TestJSONWsrVelocity(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrPhaseCurrent(t *testing.T) {
|
||||
v := &WsrPhaseCurrent{}
|
||||
|
@ -2280,7 +2214,6 @@ func TestJSONWsrPhaseCurrent(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrMotorVoltageVector(t *testing.T) {
|
||||
v := &WsrMotorVoltageVector{}
|
||||
|
@ -2315,7 +2248,6 @@ func TestJSONWsrMotorVoltageVector(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrMotorCurrentVector(t *testing.T) {
|
||||
v := &WsrMotorCurrentVector{}
|
||||
|
@ -2350,7 +2282,6 @@ func TestJSONWsrMotorCurrentVector(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrMotorBackemf(t *testing.T) {
|
||||
v := &WsrMotorBackemf{}
|
||||
|
@ -2385,7 +2316,6 @@ func TestJSONWsrMotorBackemf(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsr15165VoltageRail(t *testing.T) {
|
||||
v := &Wsr15165VoltageRail{}
|
||||
|
@ -2420,7 +2350,6 @@ func TestJSONWsr15165VoltageRail(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsr2512VoltageRail(t *testing.T) {
|
||||
v := &Wsr2512VoltageRail{}
|
||||
|
@ -2455,7 +2384,6 @@ func TestJSONWsr2512VoltageRail(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrHeatsinkMotorTemp(t *testing.T) {
|
||||
v := &WsrHeatsinkMotorTemp{}
|
||||
|
@ -2490,7 +2418,6 @@ func TestJSONWsrHeatsinkMotorTemp(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrDspBoardTemp(t *testing.T) {
|
||||
v := &WsrDspBoardTemp{}
|
||||
|
@ -2525,7 +2452,6 @@ func TestJSONWsrDspBoardTemp(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrReserved(t *testing.T) {
|
||||
v := &WsrReserved{}
|
||||
|
@ -2560,7 +2486,6 @@ func TestJSONWsrReserved(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrOdometerBusAmphoursMeasurement(t *testing.T) {
|
||||
v := &WsrOdometerBusAmphoursMeasurement{}
|
||||
|
@ -2595,7 +2520,6 @@ func TestJSONWsrOdometerBusAmphoursMeasurement(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsrSlipSpeedMeasurement(t *testing.T) {
|
||||
v := &WsrSlipSpeedMeasurement{}
|
||||
|
@ -2630,7 +2554,6 @@ func TestJSONWsrSlipSpeedMeasurement(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslIdentification(t *testing.T) {
|
||||
v := &WslIdentification{}
|
||||
|
@ -2665,7 +2588,6 @@ func TestJSONWslIdentification(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslStatusInformation(t *testing.T) {
|
||||
v := &WslStatusInformation{}
|
||||
|
@ -2700,7 +2622,6 @@ func TestJSONWslStatusInformation(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslBusMeasurement(t *testing.T) {
|
||||
v := &WslBusMeasurement{}
|
||||
|
@ -2735,7 +2656,6 @@ func TestJSONWslBusMeasurement(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslVelocity(t *testing.T) {
|
||||
v := &WslVelocity{}
|
||||
|
@ -2770,7 +2690,6 @@ func TestJSONWslVelocity(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslPhaseCurrent(t *testing.T) {
|
||||
v := &WslPhaseCurrent{}
|
||||
|
@ -2805,7 +2724,6 @@ func TestJSONWslPhaseCurrent(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslMotorVoltageVector(t *testing.T) {
|
||||
v := &WslMotorVoltageVector{}
|
||||
|
@ -2840,7 +2758,6 @@ func TestJSONWslMotorVoltageVector(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslMotorCurrentVector(t *testing.T) {
|
||||
v := &WslMotorCurrentVector{}
|
||||
|
@ -2875,7 +2792,6 @@ func TestJSONWslMotorCurrentVector(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslMotorBackemf(t *testing.T) {
|
||||
v := &WslMotorBackemf{}
|
||||
|
@ -2910,7 +2826,6 @@ func TestJSONWslMotorBackemf(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsl15165VoltageRail(t *testing.T) {
|
||||
v := &Wsl15165VoltageRail{}
|
||||
|
@ -2945,7 +2860,6 @@ func TestJSONWsl15165VoltageRail(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWsl2512VoltageRail(t *testing.T) {
|
||||
v := &Wsl2512VoltageRail{}
|
||||
|
@ -2980,7 +2894,6 @@ func TestJSONWsl2512VoltageRail(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslHeatsinkMotorTemp(t *testing.T) {
|
||||
v := &WslHeatsinkMotorTemp{}
|
||||
|
@ -3015,7 +2928,6 @@ func TestJSONWslHeatsinkMotorTemp(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslDspBoardTemp(t *testing.T) {
|
||||
v := &WslDspBoardTemp{}
|
||||
|
@ -3050,7 +2962,6 @@ func TestJSONWslDspBoardTemp(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslOdometerBusAmphoursMeasurement(t *testing.T) {
|
||||
v := &WslOdometerBusAmphoursMeasurement{}
|
||||
|
@ -3085,7 +2996,6 @@ func TestJSONWslOdometerBusAmphoursMeasurement(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslReserved(t *testing.T) {
|
||||
v := &WslReserved{}
|
||||
|
@ -3120,7 +3030,6 @@ func TestJSONWslReserved(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
func TestMarshalUnmarshalWslSlipSpeedMeasurement(t *testing.T) {
|
||||
v := &WslSlipSpeedMeasurement{}
|
||||
|
@ -3155,5 +3064,4 @@ func TestJSONWslSlipSpeedMeasurement(t *testing.T) {
|
|||
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,5 +12,3 @@ import (
|
|||
|
||||
// this program demonstrates basic CAN stuff.
|
||||
// i give up this shit is so hard
|
||||
|
||||
|
||||
|
|
|
@ -134,12 +134,11 @@ func (sck *CanSocket) Send(msg *can.Frame) error {
|
|||
|
||||
idToWrite := msg.Id.Id
|
||||
|
||||
if (msg.Id.Extended) {
|
||||
if msg.Id.Extended {
|
||||
idToWrite &= unix.CAN_EFF_MASK
|
||||
idToWrite |= unix.CAN_EFF_FLAG
|
||||
}
|
||||
|
||||
|
||||
switch msg.Kind {
|
||||
case can.CanRTRFrame:
|
||||
idToWrite |= unix.CAN_RTR_FLAG
|
||||
|
@ -191,10 +190,10 @@ func (sck *CanSocket) Recv() (*can.Frame, error) {
|
|||
id.Id = raw_id
|
||||
if raw_id&unix.CAN_EFF_FLAG != 0 {
|
||||
// extended id frame
|
||||
id.Extended = true;
|
||||
id.Extended = true
|
||||
} else {
|
||||
// it's a normal can frame
|
||||
id.Extended = false;
|
||||
id.Extended = false
|
||||
}
|
||||
|
||||
var k can.Kind = can.CanDataFrame
|
||||
|
@ -204,7 +203,7 @@ func (sck *CanSocket) Recv() (*can.Frame, error) {
|
|||
k = can.CanErrFrame
|
||||
}
|
||||
|
||||
if raw_id & unix.CAN_RTR_FLAG != 0 {
|
||||
if raw_id&unix.CAN_RTR_FLAG != 0 {
|
||||
k = can.CanRTRFrame
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"encoding/binary"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
)
|
||||
|
||||
// Frameable is an object that can be sent in an XBee Frame. An XBee Frame
|
||||
|
@ -105,7 +104,6 @@ func xbeeFrameSplit(data []byte, atEOF bool) (advance int, token []byte, err err
|
|||
// FIXME: add bounds checking! this can panic.
|
||||
var frameLen = int(binary.BigEndian.Uint16(data[startIdx+1:startIdx+3])) + 4
|
||||
|
||||
|
||||
// if the value of frameLen is > 0x100, we know that it's screwed up.
|
||||
// this helps keep error duration lowered.
|
||||
if frameLen > 0x100 {
|
||||
|
|
|
@ -103,14 +103,13 @@ func Test_xbeeFrameSplit(t *testing.T) {
|
|||
{
|
||||
name: "start delimiter inside partial packet",
|
||||
args: args{
|
||||
data: advTest,
|
||||
data: advTest,
|
||||
atEOF: false,
|
||||
},
|
||||
wantAdvance: 2,
|
||||
wantToken: nil,
|
||||
wantErr: false,
|
||||
wantToken: nil,
|
||||
wantErr: false,
|
||||
},
|
||||
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
@ -129,8 +128,6 @@ func Test_xbeeFrameSplit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
func Test_parseFrame(t *testing.T) {
|
||||
type args struct {
|
||||
frame []byte
|
||||
|
|
Loading…
Reference in a new issue