skylab fixes and rework

This commit is contained in:
saji 2023-05-20 14:53:20 -05:00
parent a9a11c5456
commit 992c0cac13
3 changed files with 89 additions and 90 deletions

View file

@ -25,9 +25,9 @@ func float32ToBytes(b []byte, f float32, bigEndian bool) {
func float32FromBytes(b []byte, bigEndian bool) (f float32) {
var bits uint32
if bigEndian {
binary.BigEndian.Uint32(b)
bits = binary.BigEndian.Uint32(b)
} else {
binary.LittleEndian.Uint32(b)
bits = binary.LittleEndian.Uint32(b)
}
return math.Float32frombits(bits)
}
@ -74,7 +74,7 @@ func CanSend(p Packet) (id uint32, data []byte, err error) {
// ---- JSON encoding business ----
type JSONPacket struct {
Id uint32
Id uint32
Data json.RawMessage
}
@ -96,6 +96,5 @@ func ToJson(p Packet) (*JSONPacket, error) {
return jp, nil
}
// 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
// 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

View file

@ -1,4 +1,4 @@
// generated by gen_skylab.go at 2023-05-19 08:33:18.49782257 -0500 CDT m=+0.002787240 DO NOT EDIT!
// generated by gen_skylab.go at 2023-05-20 12:46:09.664376329 -0500 CDT m=+0.002839937 DO NOT EDIT!
package skylab
@ -238,338 +238,338 @@ func FromCanFrame(id uint32, data []byte) (Packet, error) {
}
switch id {
case 0x10:
var res *BmsMeasurement
var res = &BmsMeasurement{}
res.UnmarshalPacket(data)
return res, nil
case 0x11:
var res *BatteryStatus
var res = &BatteryStatus{}
res.UnmarshalPacket(data)
return res, nil
case 0x12:
var res *BmsKillReason
var res = &BmsKillReason{}
res.UnmarshalPacket(data)
return res, nil
case 0x13:
var res *BmsModuleMinMax
var res = &BmsModuleMinMax{}
res.UnmarshalPacket(data)
return res, nil
case 0x14:
var res *BmsSoc
var res = &BmsSoc{}
res.UnmarshalPacket(data)
return res, nil
case 0x15:
var res *BmsCapacity
var res = &BmsCapacity{}
res.UnmarshalPacket(data)
return res, nil
case 0x18:
var res *BmsCurrentlimit
var res = &BmsCurrentlimit{}
res.UnmarshalPacket(data)
return res, nil
case 0x19:
var res *BmsFanInfo
var res = &BmsFanInfo{}
res.UnmarshalPacket(data)
return res, nil
case 0x1B:
var res *BmsSetMinFanSpeed
var res = &BmsSetMinFanSpeed{}
res.UnmarshalPacket(data)
return res, nil
case 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F:
var res *BmsModule
var res = &BmsModule{}
res.UnmarshalPacket(data)
res.Idx = id - 0x1C
return res, nil
case 0x75:
var res *BmsChargerResponse
var res = &BmsChargerResponse{}
res.UnmarshalPacket(data)
return res, nil
case 0x290:
var res *DashboardPedalPercentages
var res = &DashboardPedalPercentages{}
res.UnmarshalPacket(data)
return res, nil
case 0x291:
var res *CarState
var res = &CarState{}
res.UnmarshalPacket(data)
return res, nil
case 0x292:
var res *DashboardPedalFault
var res = &DashboardPedalFault{}
res.UnmarshalPacket(data)
return res, nil
case 0x299:
var res *DashboardSystemTimeoutTest
var res = &DashboardSystemTimeoutTest{}
res.UnmarshalPacket(data)
return res, nil
case 0x29A:
var res *CarSpeed
var res = &CarSpeed{}
res.UnmarshalPacket(data)
return res, nil
case 0x29B:
var res *FlightComputerLvBoardDisconnectCounts
var res = &FlightComputerLvBoardDisconnectCounts{}
res.UnmarshalPacket(data)
return res, nil
case 0x29C:
var res *FlightComputerHvBoardDisconnectCounts
var res = &FlightComputerHvBoardDisconnectCounts{}
res.UnmarshalPacket(data)
return res, nil
case 0x29D:
var res *FlightComputerInternalState
var res = &FlightComputerInternalState{}
res.UnmarshalPacket(data)
return res, nil
case 0x19E:
var res *PowerToDrive
var res = &PowerToDrive{}
res.UnmarshalPacket(data)
return res, nil
case 0x19F:
var res *ArrayPower
var res = &ArrayPower{}
res.UnmarshalPacket(data)
return res, nil
case 0x2B0:
var res *VisionTurnSignalsCommand
var res = &VisionTurnSignalsCommand{}
res.UnmarshalPacket(data)
return res, nil
case 0x2B1:
var res *VisionBrakeLightsCommand
var res = &VisionBrakeLightsCommand{}
res.UnmarshalPacket(data)
return res, nil
case 0x2B2:
var res *VisionHeadlightsCommand
var res = &VisionHeadlightsCommand{}
res.UnmarshalPacket(data)
return res, nil
case 0x2B3:
var res *VisionHornCommand
var res = &VisionHornCommand{}
res.UnmarshalPacket(data)
return res, nil
case 0x2B4:
var res *VisionArrayLatchesCommand
var res = &VisionArrayLatchesCommand{}
res.UnmarshalPacket(data)
return res, nil
case 0x2B5:
var res *VisionRearviewCommand
var res = &VisionRearviewCommand{}
res.UnmarshalPacket(data)
return res, nil
case 0x610, 0x611, 0x612, 0x613, 0x614, 0x615:
var res *TrackerEnable
var res = &TrackerEnable{}
res.UnmarshalPacket(data)
res.Idx = id - 0x610
return res, nil
case 0x200:
var res *DistanceTraveled
var res = &DistanceTraveled{}
res.UnmarshalPacket(data)
return res, nil
case 0x573:
var res *ChargerState
var res = &ChargerState{}
res.UnmarshalPacket(data)
return res, nil
case 0x74:
var res *ChargerBmsRequest
var res = &ChargerBmsRequest{}
res.UnmarshalPacket(data)
return res, nil
case 0x576:
var res *ChargerCurrentVoltage
var res = &ChargerCurrentVoltage{}
res.UnmarshalPacket(data)
return res, nil
case 0x577:
var res *ChargerPower
var res = &ChargerPower{}
res.UnmarshalPacket(data)
return res, nil
case 0x18E54024:
var res *ThunderstruckControlMessage
var res = &ThunderstruckControlMessage{}
res.UnmarshalPacket(data)
return res, nil
case 0x2B6:
var res *VisionStatusFront
var res = &VisionStatusFront{}
res.UnmarshalPacket(data)
return res, nil
case 0x2B7:
var res *VisionStatusRear
var res = &VisionStatusRear{}
res.UnmarshalPacket(data)
return res, nil
case 0x300:
var res *LightsFrontId
var res = &LightsFrontId{}
res.UnmarshalPacket(data)
return res, nil
case 0x301:
var res *LightsBackId
var res = &LightsBackId{}
res.UnmarshalPacket(data)
return res, nil
case 0x302:
var res *VisionId
var res = &VisionId{}
res.UnmarshalPacket(data)
return res, nil
case 0x240:
var res *SteeringPressCount1
var res = &SteeringPressCount1{}
res.UnmarshalPacket(data)
return res, nil
case 0x250:
var res *SteeringPressCount2
var res = &SteeringPressCount2{}
res.UnmarshalPacket(data)
return res, nil
case 0x241:
var res *SteeringButtonColors1
var res = &SteeringButtonColors1{}
res.UnmarshalPacket(data)
return res, nil
case 0x251:
var res *SteeringButtonColors2
var res = &SteeringButtonColors2{}
res.UnmarshalPacket(data)
return res, nil
case 0x242:
var res *SteeringHorn
var res = &SteeringHorn{}
res.UnmarshalPacket(data)
return res, nil
case 0x18EB2440:
var res *ThunderstruckStatusMessage
var res = &ThunderstruckStatusMessage{}
res.UnmarshalPacket(data)
return res, nil
case 0x600, 0x601, 0x602, 0x603, 0x604, 0x605:
var res *TrackerData
var res = &TrackerData{}
res.UnmarshalPacket(data)
res.Idx = id - 0x600
return res, nil
case 0x121:
var res *TritiumMotorDrive
var res = &TritiumMotorDrive{}
res.UnmarshalPacket(data)
return res, nil
case 0x122:
var res *TritiumMotorPower
var res = &TritiumMotorPower{}
res.UnmarshalPacket(data)
return res, nil
case 0x123:
var res *TritiumReset
var res = &TritiumReset{}
res.UnmarshalPacket(data)
return res, nil
case 0x16:
var res *BmsAhSet
var res = &BmsAhSet{}
res.UnmarshalPacket(data)
return res, nil
case 0x17:
var res *BmsWhSet
var res = &BmsWhSet{}
res.UnmarshalPacket(data)
return res, nil
case 0x1A:
var res *BmsKill
var res = &BmsKill{}
res.UnmarshalPacket(data)
return res, nil
case 0x700:
var res *TelemetryRtcReset
var res = &TelemetryRtcReset{}
res.UnmarshalPacket(data)
return res, nil
case 0x140:
var res *WsrIdentification
var res = &WsrIdentification{}
res.UnmarshalPacket(data)
return res, nil
case 0x141:
var res *WsrStatusInformation
var res = &WsrStatusInformation{}
res.UnmarshalPacket(data)
return res, nil
case 0x142:
var res *WsrBusMeasurement
var res = &WsrBusMeasurement{}
res.UnmarshalPacket(data)
return res, nil
case 0x143:
var res *WsrVelocity
var res = &WsrVelocity{}
res.UnmarshalPacket(data)
return res, nil
case 0x144:
var res *WsrPhaseCurrent
var res = &WsrPhaseCurrent{}
res.UnmarshalPacket(data)
return res, nil
case 0x145:
var res *WsrMotorVoltageVector
var res = &WsrMotorVoltageVector{}
res.UnmarshalPacket(data)
return res, nil
case 0x146:
var res *WsrMotorCurrentVector
var res = &WsrMotorCurrentVector{}
res.UnmarshalPacket(data)
return res, nil
case 0x147:
var res *WsrMotorBackemf
var res = &WsrMotorBackemf{}
res.UnmarshalPacket(data)
return res, nil
case 0x148:
var res *Wsr15165VoltageRail
var res = &Wsr15165VoltageRail{}
res.UnmarshalPacket(data)
return res, nil
case 0x149:
var res *Wsr2512VoltageRail
var res = &Wsr2512VoltageRail{}
res.UnmarshalPacket(data)
return res, nil
case 0x14B:
var res *WsrHeatsinkMotorTemp
var res = &WsrHeatsinkMotorTemp{}
res.UnmarshalPacket(data)
return res, nil
case 0x14C:
var res *WsrDspBoardTemp
var res = &WsrDspBoardTemp{}
res.UnmarshalPacket(data)
return res, nil
case 0x14D:
var res *WsrReserved
var res = &WsrReserved{}
res.UnmarshalPacket(data)
return res, nil
case 0x14E:
var res *WsrOdometerBusAmphoursMeasurement
var res = &WsrOdometerBusAmphoursMeasurement{}
res.UnmarshalPacket(data)
return res, nil
case 0x157:
var res *WsrSlipSpeedMeasurement
var res = &WsrSlipSpeedMeasurement{}
res.UnmarshalPacket(data)
return res, nil
case 0x100:
var res *WslIdentification
var res = &WslIdentification{}
res.UnmarshalPacket(data)
return res, nil
case 0x101:
var res *WslStatusInformation
var res = &WslStatusInformation{}
res.UnmarshalPacket(data)
return res, nil
case 0x102:
var res *WslBusMeasurement
var res = &WslBusMeasurement{}
res.UnmarshalPacket(data)
return res, nil
case 0x103:
var res *WslVelocity
var res = &WslVelocity{}
res.UnmarshalPacket(data)
return res, nil
case 0x104:
var res *WslPhaseCurrent
var res = &WslPhaseCurrent{}
res.UnmarshalPacket(data)
return res, nil
case 0x105:
var res *WslMotorVoltageVector
var res = &WslMotorVoltageVector{}
res.UnmarshalPacket(data)
return res, nil
case 0x106:
var res *WslMotorCurrentVector
var res = &WslMotorCurrentVector{}
res.UnmarshalPacket(data)
return res, nil
case 0x107:
var res *WslMotorBackemf
var res = &WslMotorBackemf{}
res.UnmarshalPacket(data)
return res, nil
case 0x108:
var res *Wsl15165VoltageRail
var res = &Wsl15165VoltageRail{}
res.UnmarshalPacket(data)
return res, nil
case 0x109:
var res *Wsl2512VoltageRail
var res = &Wsl2512VoltageRail{}
res.UnmarshalPacket(data)
return res, nil
case 0x10B:
var res *WslHeatsinkMotorTemp
var res = &WslHeatsinkMotorTemp{}
res.UnmarshalPacket(data)
return res, nil
case 0x10C:
var res *WslDspBoardTemp
var res = &WslDspBoardTemp{}
res.UnmarshalPacket(data)
return res, nil
case 0x10E:
var res *WslOdometerBusAmphoursMeasurement
var res = &WslOdometerBusAmphoursMeasurement{}
res.UnmarshalPacket(data)
return res, nil
case 0x10D:
var res *WslReserved
var res = &WslReserved{}
res.UnmarshalPacket(data)
return res, nil
case 0x117:
var res *WslSlipSpeedMeasurement
var res = &WslSlipSpeedMeasurement{}
res.UnmarshalPacket(data)
return res, nil
}