format
All checks were successful
Go / build (1.21) (push) Successful in 1m18s
Go / build (1.22) (push) Successful in 1m16s

This commit is contained in:
saji 2024-03-07 06:18:49 -06:00
parent f380631b5e
commit 3c1a96c8e0
16 changed files with 571 additions and 859 deletions

View file

@ -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"
)

View file

@ -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
View file

@ -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 {

View file

@ -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 {

View file

@ -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)

View file

@ -6,23 +6,22 @@
// 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()
Id()
Data() []byte
Type() Kind
}
@ -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

View file

@ -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,13 +84,13 @@ 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
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)

View file

@ -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 {

View file

@ -1,4 +1,5 @@
//go:build openmct
package gotelem
import (

View file

@ -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)
}

File diff suppressed because one or more lines are too long

View file

@ -1,12 +1,10 @@
package skylab
import (
"testing"
"encoding/json"
"testing"
)
func TestMarshalUnmarshalBmsMeasurement(t *testing.T) {
v := &BmsMeasurement{}
bin, err := v.MarshalPacket()
@ -39,7 +37,6 @@ func TestJSONBmsMeasurement(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBatteryStatus(t *testing.T) {
@ -74,7 +71,6 @@ func TestJSONBatteryStatus(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsKillReason(t *testing.T) {
@ -109,7 +105,6 @@ func TestJSONBmsKillReason(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsModuleMinMax(t *testing.T) {
@ -144,7 +139,6 @@ func TestJSONBmsModuleMinMax(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsSoc(t *testing.T) {
@ -179,7 +173,6 @@ func TestJSONBmsSoc(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsCapacity(t *testing.T) {
@ -214,7 +207,6 @@ func TestJSONBmsCapacity(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsCurrentlimit(t *testing.T) {
@ -249,7 +241,6 @@ func TestJSONBmsCurrentlimit(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsFanInfo(t *testing.T) {
@ -284,7 +275,6 @@ func TestJSONBmsFanInfo(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsSetMinFanSpeed(t *testing.T) {
@ -319,7 +309,6 @@ func TestJSONBmsSetMinFanSpeed(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsModule(t *testing.T) {
@ -354,7 +343,6 @@ func TestJSONBmsModule(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsChargerResponse(t *testing.T) {
@ -389,7 +377,6 @@ func TestJSONBmsChargerResponse(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalChassisIsolationFault(t *testing.T) {
@ -424,7 +411,6 @@ func TestJSONChassisIsolationFault(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsImdInfo(t *testing.T) {
@ -459,7 +445,6 @@ func TestJSONBmsImdInfo(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalDashboardPedalPercentages(t *testing.T) {
@ -494,7 +479,6 @@ func TestJSONDashboardPedalPercentages(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalCarState(t *testing.T) {
@ -529,7 +513,6 @@ func TestJSONCarState(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalDashboardPedalFault(t *testing.T) {
@ -564,7 +547,6 @@ func TestJSONDashboardPedalFault(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalDashboardSystemTimeoutTest(t *testing.T) {
@ -599,7 +581,6 @@ func TestJSONDashboardSystemTimeoutTest(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalCarSpeed(t *testing.T) {
@ -634,7 +615,6 @@ func TestJSONCarSpeed(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalFlightComputerLvBoardDisconnectCounts(t *testing.T) {
@ -669,7 +649,6 @@ func TestJSONFlightComputerLvBoardDisconnectCounts(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalFlightComputerHvBoardDisconnectCounts(t *testing.T) {
@ -704,7 +683,6 @@ func TestJSONFlightComputerHvBoardDisconnectCounts(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalFlightComputerInternalState(t *testing.T) {
@ -739,7 +717,6 @@ func TestJSONFlightComputerInternalState(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalPowerToDrive(t *testing.T) {
@ -774,7 +751,6 @@ func TestJSONPowerToDrive(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalArrayPower(t *testing.T) {
@ -809,7 +785,6 @@ func TestJSONArrayPower(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalArrayEnergy(t *testing.T) {
@ -844,7 +819,6 @@ func TestJSONArrayEnergy(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalArrayEnergyReset(t *testing.T) {
@ -879,7 +853,6 @@ func TestJSONArrayEnergyReset(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalVisionTurnSignalsCommand(t *testing.T) {
@ -914,7 +887,6 @@ func TestJSONVisionTurnSignalsCommand(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalVisionBrakeLightsCommand(t *testing.T) {
@ -949,7 +921,6 @@ func TestJSONVisionBrakeLightsCommand(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalVisionHeadlightsCommand(t *testing.T) {
@ -984,7 +955,6 @@ func TestJSONVisionHeadlightsCommand(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalVisionHornCommand(t *testing.T) {
@ -1019,7 +989,6 @@ func TestJSONVisionHornCommand(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalVisionArrayLatchesCommand(t *testing.T) {
@ -1054,7 +1023,6 @@ func TestJSONVisionArrayLatchesCommand(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalVisionRearviewCommand(t *testing.T) {
@ -1089,7 +1057,6 @@ func TestJSONVisionRearviewCommand(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalTrackerEnable(t *testing.T) {
@ -1124,7 +1091,6 @@ func TestJSONTrackerEnable(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalDistanceTraveled(t *testing.T) {
@ -1159,7 +1125,6 @@ func TestJSONDistanceTraveled(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalChargerState(t *testing.T) {
@ -1194,7 +1159,6 @@ func TestJSONChargerState(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalChargerBmsRequest(t *testing.T) {
@ -1229,7 +1193,6 @@ func TestJSONChargerBmsRequest(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalChargerCurrentVoltage(t *testing.T) {
@ -1264,7 +1227,6 @@ func TestJSONChargerCurrentVoltage(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalChargerPower(t *testing.T) {
@ -1299,7 +1261,6 @@ func TestJSONChargerPower(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalThunderstruckControlMessage(t *testing.T) {
@ -1334,7 +1295,6 @@ func TestJSONThunderstruckControlMessage(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalVisionStatusFront(t *testing.T) {
@ -1369,7 +1329,6 @@ func TestJSONVisionStatusFront(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalVisionStatusRear(t *testing.T) {
@ -1404,7 +1363,6 @@ func TestJSONVisionStatusRear(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalLightsFrontId(t *testing.T) {
@ -1439,7 +1397,6 @@ func TestJSONLightsFrontId(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalLightsBackId(t *testing.T) {
@ -1474,7 +1431,6 @@ func TestJSONLightsBackId(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalVisionId(t *testing.T) {
@ -1509,7 +1465,6 @@ func TestJSONVisionId(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalSteeringPressCount1(t *testing.T) {
@ -1544,7 +1499,6 @@ func TestJSONSteeringPressCount1(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalSteeringPressCount2(t *testing.T) {
@ -1579,7 +1533,6 @@ func TestJSONSteeringPressCount2(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalSteeringButtonColors1(t *testing.T) {
@ -1614,7 +1567,6 @@ func TestJSONSteeringButtonColors1(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalSteeringButtonColors2(t *testing.T) {
@ -1649,7 +1601,6 @@ func TestJSONSteeringButtonColors2(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalSteeringHorn(t *testing.T) {
@ -1684,7 +1635,6 @@ func TestJSONSteeringHorn(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalThunderstruckStatusMessage(t *testing.T) {
@ -1719,7 +1669,6 @@ func TestJSONThunderstruckStatusMessage(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalTrackerData(t *testing.T) {
@ -1754,7 +1703,6 @@ func TestJSONTrackerData(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalTritiumMotorDriveL(t *testing.T) {
@ -1789,7 +1737,6 @@ func TestJSONTritiumMotorDriveL(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalTritiumMotorPowerL(t *testing.T) {
@ -1824,7 +1771,6 @@ func TestJSONTritiumMotorPowerL(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalTritiumResetL(t *testing.T) {
@ -1859,7 +1805,6 @@ func TestJSONTritiumResetL(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalTritiumMotorDriveR(t *testing.T) {
@ -1894,7 +1839,6 @@ func TestJSONTritiumMotorDriveR(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalTritiumMotorPowerR(t *testing.T) {
@ -1929,7 +1873,6 @@ func TestJSONTritiumMotorPowerR(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalTritiumResetR(t *testing.T) {
@ -1964,7 +1907,6 @@ func TestJSONTritiumResetR(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsAhSet(t *testing.T) {
@ -1999,7 +1941,6 @@ func TestJSONBmsAhSet(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsWhSet(t *testing.T) {
@ -2034,7 +1975,6 @@ func TestJSONBmsWhSet(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalBmsKill(t *testing.T) {
@ -2069,7 +2009,6 @@ func TestJSONBmsKill(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalTelemetryRtcReset(t *testing.T) {
@ -2104,7 +2043,6 @@ func TestJSONTelemetryRtcReset(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrIdentification(t *testing.T) {
@ -2139,7 +2077,6 @@ func TestJSONWsrIdentification(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrStatusInformation(t *testing.T) {
@ -2174,7 +2111,6 @@ func TestJSONWsrStatusInformation(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrBusMeasurement(t *testing.T) {
@ -2209,7 +2145,6 @@ func TestJSONWsrBusMeasurement(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrVelocity(t *testing.T) {
@ -2244,7 +2179,6 @@ func TestJSONWsrVelocity(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrPhaseCurrent(t *testing.T) {
@ -2279,7 +2213,6 @@ func TestJSONWsrPhaseCurrent(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrMotorVoltageVector(t *testing.T) {
@ -2314,7 +2247,6 @@ func TestJSONWsrMotorVoltageVector(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrMotorCurrentVector(t *testing.T) {
@ -2349,7 +2281,6 @@ func TestJSONWsrMotorCurrentVector(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrMotorBackemf(t *testing.T) {
@ -2384,7 +2315,6 @@ func TestJSONWsrMotorBackemf(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsr15165VoltageRail(t *testing.T) {
@ -2419,7 +2349,6 @@ func TestJSONWsr15165VoltageRail(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsr2512VoltageRail(t *testing.T) {
@ -2454,7 +2383,6 @@ func TestJSONWsr2512VoltageRail(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrHeatsinkMotorTemp(t *testing.T) {
@ -2489,7 +2417,6 @@ func TestJSONWsrHeatsinkMotorTemp(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrDspBoardTemp(t *testing.T) {
@ -2524,7 +2451,6 @@ func TestJSONWsrDspBoardTemp(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrReserved(t *testing.T) {
@ -2559,7 +2485,6 @@ func TestJSONWsrReserved(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrOdometerBusAmphoursMeasurement(t *testing.T) {
@ -2594,7 +2519,6 @@ func TestJSONWsrOdometerBusAmphoursMeasurement(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsrSlipSpeedMeasurement(t *testing.T) {
@ -2629,7 +2553,6 @@ func TestJSONWsrSlipSpeedMeasurement(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslIdentification(t *testing.T) {
@ -2664,7 +2587,6 @@ func TestJSONWslIdentification(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslStatusInformation(t *testing.T) {
@ -2699,7 +2621,6 @@ func TestJSONWslStatusInformation(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslBusMeasurement(t *testing.T) {
@ -2734,7 +2655,6 @@ func TestJSONWslBusMeasurement(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslVelocity(t *testing.T) {
@ -2769,7 +2689,6 @@ func TestJSONWslVelocity(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslPhaseCurrent(t *testing.T) {
@ -2804,7 +2723,6 @@ func TestJSONWslPhaseCurrent(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslMotorVoltageVector(t *testing.T) {
@ -2839,7 +2757,6 @@ func TestJSONWslMotorVoltageVector(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslMotorCurrentVector(t *testing.T) {
@ -2874,7 +2791,6 @@ func TestJSONWslMotorCurrentVector(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslMotorBackemf(t *testing.T) {
@ -2909,7 +2825,6 @@ func TestJSONWslMotorBackemf(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsl15165VoltageRail(t *testing.T) {
@ -2944,7 +2859,6 @@ func TestJSONWsl15165VoltageRail(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWsl2512VoltageRail(t *testing.T) {
@ -2979,7 +2893,6 @@ func TestJSONWsl2512VoltageRail(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslHeatsinkMotorTemp(t *testing.T) {
@ -3014,7 +2927,6 @@ func TestJSONWslHeatsinkMotorTemp(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslDspBoardTemp(t *testing.T) {
@ -3049,7 +2961,6 @@ func TestJSONWslDspBoardTemp(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslOdometerBusAmphoursMeasurement(t *testing.T) {
@ -3084,7 +2995,6 @@ func TestJSONWslOdometerBusAmphoursMeasurement(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslReserved(t *testing.T) {
@ -3119,7 +3029,6 @@ func TestJSONWslReserved(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}
func TestMarshalUnmarshalWslSlipSpeedMeasurement(t *testing.T) {
@ -3154,6 +3063,5 @@ func TestJSONWslSlipSpeedMeasurement(t *testing.T) {
default:
t.Fatalf("didn't match type: %T, %v", underlying, underlying)
}
}

View file

@ -12,5 +12,3 @@ import (
// this program demonstrates basic CAN stuff.
// i give up this shit is so hard

View file

@ -134,11 +134,10 @@ 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:
@ -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
@ -203,8 +202,8 @@ func (sck *CanSocket) Recv() (*can.Frame, error) {
// we got an error...
k = can.CanErrFrame
}
if raw_id & unix.CAN_RTR_FLAG != 0 {
if raw_id&unix.CAN_RTR_FLAG != 0 {
k = can.CanRTRFrame
}

View file

@ -5,7 +5,6 @@ import (
"encoding/binary"
"errors"
"io"
)
// Frameable is an object that can be sent in an XBee Frame. An XBee Frame
@ -104,7 +103,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.

View file

@ -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