2024-03-07 19:29:50 +00:00
// generated by gen_skylab.go at 2024-03-07 13:28:08.045194699 -0600 CST m=+0.003043646 DO NOT EDIT!
2023-05-19 22:04:03 +00:00
package skylab
import (
2024-03-07 12:18:49 +00:00
"errors"
2024-03-07 19:29:50 +00:00
"encoding/binary"
2024-03-07 12:18:49 +00:00
"github.com/kschamplin/gotelem/internal/can"
2024-03-07 19:29:50 +00:00
"encoding/json"
2023-05-19 22:04:03 +00:00
)
type SkylabId uint32
const (
2024-03-07 19:29:50 +00:00
BmsMeasurementId SkylabId = 0x10
BatteryStatusId SkylabId = 0x11
BmsKillReasonId SkylabId = 0x12
BmsModuleMinMaxId SkylabId = 0x13
BmsSocId SkylabId = 0x14
BmsCapacityId SkylabId = 0x15
BmsCurrentlimitId SkylabId = 0x18
BmsFanInfoId SkylabId = 0x19
BmsSetMinFanSpeedId SkylabId = 0x1B
BmsModuleId SkylabId = 0x40
BmsChargerResponseId SkylabId = 0x75
ChassisIsolationFaultId SkylabId = 0x38
BmsImdInfoId SkylabId = 0x37
DashboardPedalPercentagesId SkylabId = 0x290
CarStateId SkylabId = 0x291
DashboardPedalFaultId SkylabId = 0x292
DashboardSystemTimeoutTestId SkylabId = 0x299
CarSpeedId SkylabId = 0x29A
2023-05-19 22:04:03 +00:00
FlightComputerLvBoardDisconnectCountsId SkylabId = 0x29B
FlightComputerHvBoardDisconnectCountsId SkylabId = 0x29C
2024-03-07 19:29:50 +00:00
FlightComputerInternalStateId SkylabId = 0x29D
PowerToDriveId SkylabId = 0x19E
ArrayPowerId SkylabId = 0x19F
ArrayEnergyId SkylabId = 0x119
ArrayEnergyResetId SkylabId = 0x120
VisionTurnSignalsCommandId SkylabId = 0x2B0
VisionBrakeLightsCommandId SkylabId = 0x2B1
VisionHeadlightsCommandId SkylabId = 0x2B2
VisionHornCommandId SkylabId = 0x2B3
VisionArrayLatchesCommandId SkylabId = 0x2B4
VisionRearviewCommandId SkylabId = 0x2B5
TrackerEnableId SkylabId = 0x610
DistanceTraveledId SkylabId = 0x19D
ChargerStateId SkylabId = 0x573
ChargerBmsRequestId SkylabId = 0x74
ChargerCurrentVoltageId SkylabId = 0x576
ChargerPowerId SkylabId = 0x577
ThunderstruckControlMessageId SkylabId = 0x18E54024
VisionStatusFrontId SkylabId = 0x2B6
VisionStatusRearId SkylabId = 0x2B7
LightsFrontIdId SkylabId = 0x300
LightsBackIdId SkylabId = 0x301
VisionIdId SkylabId = 0x302
SteeringPressCount1Id SkylabId = 0x240
SteeringPressCount2Id SkylabId = 0x250
SteeringButtonColors1Id SkylabId = 0x241
SteeringButtonColors2Id SkylabId = 0x251
SteeringHornId SkylabId = 0x242
ThunderstruckStatusMessageId SkylabId = 0x18EB2440
TrackerDataId SkylabId = 0x600
TritiumMotorDriveLId SkylabId = 0x121
TritiumMotorPowerLId SkylabId = 0x122
TritiumResetLId SkylabId = 0x123
TritiumMotorDriveRId SkylabId = 0x161
TritiumMotorPowerRId SkylabId = 0x162
TritiumResetRId SkylabId = 0x163
BmsAhSetId SkylabId = 0x16
BmsWhSetId SkylabId = 0x17
BmsKillId SkylabId = 0x1A
TelemetryRtcResetId SkylabId = 0x700
WsrIdentificationId SkylabId = 0x140
WsrStatusInformationId SkylabId = 0x141
WsrBusMeasurementId SkylabId = 0x142
WsrVelocityId SkylabId = 0x143
WsrPhaseCurrentId SkylabId = 0x144
WsrMotorVoltageVectorId SkylabId = 0x145
WsrMotorCurrentVectorId SkylabId = 0x146
WsrMotorBackemfId SkylabId = 0x147
Wsr15165VoltageRailId SkylabId = 0x148
Wsr2512VoltageRailId SkylabId = 0x149
WsrHeatsinkMotorTempId SkylabId = 0x14B
WsrDspBoardTempId SkylabId = 0x14C
WsrReservedId SkylabId = 0x14D
WsrOdometerBusAmphoursMeasurementId SkylabId = 0x14E
WsrSlipSpeedMeasurementId SkylabId = 0x157
WslIdentificationId SkylabId = 0x100
WslStatusInformationId SkylabId = 0x101
WslBusMeasurementId SkylabId = 0x102
WslVelocityId SkylabId = 0x103
WslPhaseCurrentId SkylabId = 0x104
WslMotorVoltageVectorId SkylabId = 0x105
WslMotorCurrentVectorId SkylabId = 0x106
WslMotorBackemfId SkylabId = 0x107
Wsl15165VoltageRailId SkylabId = 0x108
Wsl2512VoltageRailId SkylabId = 0x109
WslHeatsinkMotorTempId SkylabId = 0x10B
WslDspBoardTempId SkylabId = 0x10C
WslOdometerBusAmphoursMeasurementId SkylabId = 0x10E
WslReservedId SkylabId = 0x10D
WslSlipSpeedMeasurementId SkylabId = 0x117
2023-05-19 22:04:03 +00:00
)
2024-02-28 20:10:40 +00:00
// list of every packet ID. Can be used for O(1) checks.
2024-02-12 15:45:23 +00:00
var idMap = map [ can . CanID ] bool {
2024-03-07 19:29:50 +00:00
{ Id : 0x10 , Extended : false } : true ,
{ Id : 0x11 , Extended : false } : true ,
{ Id : 0x12 , Extended : false } : true ,
{ Id : 0x13 , Extended : false } : true ,
{ Id : 0x14 , Extended : false } : true ,
{ Id : 0x15 , Extended : false } : true ,
{ Id : 0x18 , Extended : false } : true ,
{ Id : 0x19 , Extended : false } : true ,
{ Id : 0x1B , Extended : false } : true ,
{ Id : 0x40 , Extended : false } : true ,
{ Id : 0x41 , Extended : false } : true ,
{ Id : 0x42 , Extended : false } : true ,
{ Id : 0x43 , Extended : false } : true ,
{ Id : 0x44 , Extended : false } : true ,
{ Id : 0x45 , Extended : false } : true ,
{ Id : 0x46 , Extended : false } : true ,
{ Id : 0x47 , Extended : false } : true ,
{ Id : 0x48 , Extended : false } : true ,
{ Id : 0x49 , Extended : false } : true ,
{ Id : 0x4A , Extended : false } : true ,
{ Id : 0x4B , Extended : false } : true ,
{ Id : 0x4C , Extended : false } : true ,
{ Id : 0x4D , Extended : false } : true ,
{ Id : 0x4E , Extended : false } : true ,
{ Id : 0x4F , Extended : false } : true ,
{ Id : 0x50 , Extended : false } : true ,
{ Id : 0x51 , Extended : false } : true ,
{ Id : 0x52 , Extended : false } : true ,
{ Id : 0x53 , Extended : false } : true ,
{ Id : 0x54 , Extended : false } : true ,
{ Id : 0x55 , Extended : false } : true ,
{ Id : 0x56 , Extended : false } : true ,
{ Id : 0x57 , Extended : false } : true ,
{ Id : 0x58 , Extended : false } : true ,
{ Id : 0x59 , Extended : false } : true ,
{ Id : 0x5A , Extended : false } : true ,
{ Id : 0x5B , Extended : false } : true ,
{ Id : 0x5C , Extended : false } : true ,
{ Id : 0x5D , Extended : false } : true ,
{ Id : 0x5E , Extended : false } : true ,
{ Id : 0x5F , Extended : false } : true ,
{ Id : 0x60 , Extended : false } : true ,
{ Id : 0x61 , Extended : false } : true ,
{ Id : 0x62 , Extended : false } : true ,
{ Id : 0x63 , Extended : false } : true ,
{ Id : 0x75 , Extended : false } : true ,
{ Id : 0x38 , Extended : false } : true ,
{ Id : 0x37 , Extended : false } : true ,
{ Id : 0x290 , Extended : false } : true ,
{ Id : 0x291 , Extended : false } : true ,
{ Id : 0x292 , Extended : false } : true ,
{ Id : 0x299 , Extended : false } : true ,
{ Id : 0x29A , Extended : false } : true ,
{ Id : 0x29B , Extended : false } : true ,
{ Id : 0x29C , Extended : false } : true ,
{ Id : 0x29D , Extended : false } : true ,
{ Id : 0x19E , Extended : false } : true ,
{ Id : 0x19F , Extended : false } : true ,
{ Id : 0x119 , Extended : false } : true ,
{ Id : 0x120 , Extended : false } : true ,
{ Id : 0x2B0 , Extended : false } : true ,
{ Id : 0x2B1 , Extended : false } : true ,
{ Id : 0x2B2 , Extended : false } : true ,
{ Id : 0x2B3 , Extended : false } : true ,
{ Id : 0x2B4 , Extended : false } : true ,
{ Id : 0x2B5 , Extended : false } : true ,
{ Id : 0x610 , Extended : false } : true ,
{ Id : 0x611 , Extended : false } : true ,
{ Id : 0x612 , Extended : false } : true ,
{ Id : 0x613 , Extended : false } : true ,
{ Id : 0x614 , Extended : false } : true ,
{ Id : 0x615 , Extended : false } : true ,
{ Id : 0x19D , Extended : false } : true ,
{ Id : 0x573 , Extended : false } : true ,
{ Id : 0x74 , Extended : false } : true ,
{ Id : 0x576 , Extended : false } : true ,
{ Id : 0x577 , Extended : false } : true ,
{ Id : 0x18E54024 , Extended : true } : true ,
{ Id : 0x2B6 , Extended : false } : true ,
{ Id : 0x2B7 , Extended : false } : true ,
{ Id : 0x300 , Extended : false } : true ,
{ Id : 0x301 , Extended : false } : true ,
{ Id : 0x302 , Extended : false } : true ,
{ Id : 0x240 , Extended : false } : true ,
{ Id : 0x250 , Extended : false } : true ,
{ Id : 0x241 , Extended : false } : true ,
{ Id : 0x251 , Extended : false } : true ,
{ Id : 0x242 , Extended : false } : true ,
{ Id : 0x18EB2440 , Extended : false } : true ,
{ Id : 0x600 , Extended : false } : true ,
{ Id : 0x601 , Extended : false } : true ,
{ Id : 0x602 , Extended : false } : true ,
{ Id : 0x603 , Extended : false } : true ,
{ Id : 0x604 , Extended : false } : true ,
{ Id : 0x605 , Extended : false } : true ,
{ Id : 0x121 , Extended : false } : true ,
{ Id : 0x122 , Extended : false } : true ,
{ Id : 0x123 , Extended : false } : true ,
{ Id : 0x161 , Extended : false } : true ,
{ Id : 0x162 , Extended : false } : true ,
{ Id : 0x163 , Extended : false } : true ,
{ Id : 0x16 , Extended : false } : true ,
{ Id : 0x17 , Extended : false } : true ,
{ Id : 0x1A , Extended : false } : true ,
{ Id : 0x700 , Extended : false } : true ,
{ Id : 0x140 , Extended : false } : true ,
{ Id : 0x141 , Extended : false } : true ,
{ Id : 0x142 , Extended : false } : true ,
{ Id : 0x143 , Extended : false } : true ,
{ Id : 0x144 , Extended : false } : true ,
{ Id : 0x145 , Extended : false } : true ,
{ Id : 0x146 , Extended : false } : true ,
{ Id : 0x147 , Extended : false } : true ,
{ Id : 0x148 , Extended : false } : true ,
{ Id : 0x149 , Extended : false } : true ,
{ Id : 0x14B , Extended : false } : true ,
{ Id : 0x14C , Extended : false } : true ,
{ Id : 0x14D , Extended : false } : true ,
{ Id : 0x14E , Extended : false } : true ,
{ Id : 0x157 , Extended : false } : true ,
{ Id : 0x100 , Extended : false } : true ,
{ Id : 0x101 , Extended : false } : true ,
{ Id : 0x102 , Extended : false } : true ,
{ Id : 0x103 , Extended : false } : true ,
{ Id : 0x104 , Extended : false } : true ,
{ Id : 0x105 , Extended : false } : true ,
{ Id : 0x106 , Extended : false } : true ,
{ Id : 0x107 , Extended : false } : true ,
{ Id : 0x108 , Extended : false } : true ,
{ Id : 0x109 , Extended : false } : true ,
{ Id : 0x10B , Extended : false } : true ,
{ Id : 0x10C , Extended : false } : true ,
{ Id : 0x10E , Extended : false } : true ,
{ Id : 0x10D , Extended : false } : true ,
{ Id : 0x117 , Extended : false } : true ,
2023-05-19 22:04:03 +00:00
}
2023-05-22 13:41:37 +00:00
// FromCanFrame creates a Packet from a given CAN ID and data payload.
// If the CAN ID is unknown, it will return an error.
2024-02-12 15:45:23 +00:00
func FromCanFrame ( f can . Frame ) ( Packet , error ) {
id := f . Id
2023-05-19 22:04:03 +00:00
if ! idMap [ id ] {
2024-03-07 19:29:50 +00:00
return nil , & UnknownIdError { id . Id }
2023-05-19 22:04:03 +00:00
}
switch id {
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x10 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsMeasurement { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x11 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BatteryStatus { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x12 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsKillReason { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x13 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsModuleMinMax { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x14 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsSoc { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x15 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsCapacity { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x18 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsCurrentlimit { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x19 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsFanInfo { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x1B , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsSetMinFanSpeed { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x40 , Extended : false } , can . CanID { Id : 0x41 , Extended : false } , can . CanID { Id : 0x42 , Extended : false } , can . CanID { Id : 0x43 , Extended : false } , can . CanID { Id : 0x44 , Extended : false } , can . CanID { Id : 0x45 , Extended : false } , can . CanID { Id : 0x46 , Extended : false } , can . CanID { Id : 0x47 , Extended : false } , can . CanID { Id : 0x48 , Extended : false } , can . CanID { Id : 0x49 , Extended : false } , can . CanID { Id : 0x4A , Extended : false } , can . CanID { Id : 0x4B , Extended : false } , can . CanID { Id : 0x4C , Extended : false } , can . CanID { Id : 0x4D , Extended : false } , can . CanID { Id : 0x4E , Extended : false } , can . CanID { Id : 0x4F , Extended : false } , can . CanID { Id : 0x50 , Extended : false } , can . CanID { Id : 0x51 , Extended : false } , can . CanID { Id : 0x52 , Extended : false } , can . CanID { Id : 0x53 , Extended : false } , can . CanID { Id : 0x54 , Extended : false } , can . CanID { Id : 0x55 , Extended : false } , can . CanID { Id : 0x56 , Extended : false } , can . CanID { Id : 0x57 , Extended : false } , can . CanID { Id : 0x58 , Extended : false } , can . CanID { Id : 0x59 , Extended : false } , can . CanID { Id : 0x5A , Extended : false } , can . CanID { Id : 0x5B , Extended : false } , can . CanID { Id : 0x5C , Extended : false } , can . CanID { Id : 0x5D , Extended : false } , can . CanID { Id : 0x5E , Extended : false } , can . CanID { Id : 0x5F , Extended : false } , can . CanID { Id : 0x60 , Extended : false } , can . CanID { Id : 0x61 , Extended : false } , can . CanID { Id : 0x62 , Extended : false } , can . CanID { Id : 0x63 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsModule { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
res . Idx = id . Id - 0x40
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x75 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsChargerResponse { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x38 , Extended : false } :
2024-02-12 15:45:23 +00:00
var res = & ChassisIsolationFault { }
res . UnmarshalPacket ( f . Data )
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x37 , Extended : false } :
2024-02-12 15:45:23 +00:00
var res = & BmsImdInfo { }
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x290 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & DashboardPedalPercentages { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x291 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & CarState { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x292 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & DashboardPedalFault { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x299 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & DashboardSystemTimeoutTest { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x29A , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & CarSpeed { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x29B , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & FlightComputerLvBoardDisconnectCounts { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x29C , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & FlightComputerHvBoardDisconnectCounts { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x29D , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & FlightComputerInternalState { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x19E , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & PowerToDrive { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x19F , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & ArrayPower { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x119 , Extended : false } :
2024-02-12 15:45:23 +00:00
var res = & ArrayEnergy { }
res . UnmarshalPacket ( f . Data )
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x120 , Extended : false } :
2024-02-12 15:45:23 +00:00
var res = & ArrayEnergyReset { }
res . UnmarshalPacket ( f . Data )
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x2B0 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & VisionTurnSignalsCommand { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x2B1 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & VisionBrakeLightsCommand { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x2B2 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & VisionHeadlightsCommand { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x2B3 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & VisionHornCommand { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x2B4 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & VisionArrayLatchesCommand { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x2B5 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & VisionRearviewCommand { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x610 , Extended : false } , can . CanID { Id : 0x611 , Extended : false } , can . CanID { Id : 0x612 , Extended : false } , can . CanID { Id : 0x613 , Extended : false } , can . CanID { Id : 0x614 , Extended : false } , can . CanID { Id : 0x615 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & TrackerEnable { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
res . Idx = id . Id - 0x610
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x19D , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & DistanceTraveled { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x573 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & ChargerState { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x74 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & ChargerBmsRequest { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x576 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & ChargerCurrentVoltage { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x577 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & ChargerPower { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x18E54024 , Extended : true } :
2023-05-20 19:53:20 +00:00
var res = & ThunderstruckControlMessage { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x2B6 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & VisionStatusFront { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x2B7 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & VisionStatusRear { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x300 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & LightsFrontId { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x301 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & LightsBackId { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x302 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & VisionId { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x240 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & SteeringPressCount1 { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x250 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & SteeringPressCount2 { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x241 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & SteeringButtonColors1 { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x251 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & SteeringButtonColors2 { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x242 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & SteeringHorn { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x18EB2440 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & ThunderstruckStatusMessage { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x600 , Extended : false } , can . CanID { Id : 0x601 , Extended : false } , can . CanID { Id : 0x602 , Extended : false } , can . CanID { Id : 0x603 , Extended : false } , can . CanID { Id : 0x604 , Extended : false } , can . CanID { Id : 0x605 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & TrackerData { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
res . Idx = id . Id - 0x600
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x121 , Extended : false } :
2024-02-12 15:45:23 +00:00
var res = & TritiumMotorDriveL { }
res . UnmarshalPacket ( f . Data )
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x122 , Extended : false } :
2024-02-12 15:45:23 +00:00
var res = & TritiumMotorPowerL { }
res . UnmarshalPacket ( f . Data )
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x123 , Extended : false } :
2024-02-12 15:45:23 +00:00
var res = & TritiumResetL { }
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x161 , Extended : false } :
2024-02-12 15:45:23 +00:00
var res = & TritiumMotorDriveR { }
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x162 , Extended : false } :
2024-02-12 15:45:23 +00:00
var res = & TritiumMotorPowerR { }
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x163 , Extended : false } :
2024-02-12 15:45:23 +00:00
var res = & TritiumResetR { }
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x16 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsAhSet { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x17 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsWhSet { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x1A , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & BmsKill { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x700 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & TelemetryRtcReset { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x140 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrIdentification { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x141 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrStatusInformation { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x142 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrBusMeasurement { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x143 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrVelocity { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x144 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrPhaseCurrent { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x145 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrMotorVoltageVector { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x146 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrMotorCurrentVector { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x147 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrMotorBackemf { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x148 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & Wsr15165VoltageRail { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x149 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & Wsr2512VoltageRail { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x14B , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrHeatsinkMotorTemp { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x14C , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrDspBoardTemp { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x14D , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrReserved { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x14E , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrOdometerBusAmphoursMeasurement { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x157 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WsrSlipSpeedMeasurement { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x100 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslIdentification { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x101 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslStatusInformation { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x102 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslBusMeasurement { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x103 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslVelocity { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x104 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslPhaseCurrent { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x105 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslMotorVoltageVector { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x106 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslMotorCurrentVector { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x107 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslMotorBackemf { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x108 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & Wsl15165VoltageRail { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x109 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & Wsl2512VoltageRail { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x10B , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslHeatsinkMotorTemp { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x10C , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslDspBoardTemp { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x10E , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslOdometerBusAmphoursMeasurement { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x10D , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslReserved { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
2024-03-07 19:29:50 +00:00
case can . CanID { Id : 0x117 , Extended : false } :
2023-05-20 19:53:20 +00:00
var res = & WslSlipSpeedMeasurement { }
2024-02-12 15:45:23 +00:00
res . UnmarshalPacket ( f . Data )
2023-05-19 22:04:03 +00:00
return res , nil
}
2023-06-30 12:18:15 +00:00
panic ( "This should never happen. CAN ID didn't match but was in ID map" )
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
func FromJson ( name string , raw [ ] byte ) ( Packet , error ) {
2024-02-12 15:45:23 +00:00
switch name {
case "bms_measurement" :
2023-05-19 22:04:03 +00:00
var res = & BmsMeasurement { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "battery_status" :
2023-05-19 22:04:03 +00:00
var res = & BatteryStatus { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_kill_reason" :
2023-05-19 22:04:03 +00:00
var res = & BmsKillReason { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_module_min_max" :
2023-05-19 22:04:03 +00:00
var res = & BmsModuleMinMax { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_soc" :
2023-05-19 22:04:03 +00:00
var res = & BmsSoc { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_capacity" :
2023-05-19 22:04:03 +00:00
var res = & BmsCapacity { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_currentlimit" :
2023-05-19 22:04:03 +00:00
var res = & BmsCurrentlimit { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_fan_info" :
2023-05-19 22:04:03 +00:00
var res = & BmsFanInfo { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_set_min_fan_speed" :
2023-05-19 22:04:03 +00:00
var res = & BmsSetMinFanSpeed { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_module" :
2023-05-19 22:04:03 +00:00
var res = & BmsModule { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_charger_response" :
2023-05-19 22:04:03 +00:00
var res = & BmsChargerResponse { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "chassis_isolation_fault" :
var res = & ChassisIsolationFault { }
err := json . Unmarshal ( raw , res )
return res , err
case "bms_imd_info" :
var res = & BmsImdInfo { }
err := json . Unmarshal ( raw , res )
return res , err
case "dashboard_pedal_percentages" :
2023-05-19 22:04:03 +00:00
var res = & DashboardPedalPercentages { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "car_state" :
2023-05-19 22:04:03 +00:00
var res = & CarState { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "dashboard_pedal_fault" :
2023-05-19 22:04:03 +00:00
var res = & DashboardPedalFault { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "dashboard_system_timeout_test" :
2023-05-19 22:04:03 +00:00
var res = & DashboardSystemTimeoutTest { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "car_speed" :
2023-05-19 22:04:03 +00:00
var res = & CarSpeed { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "flight_computer_lv_board_disconnect_counts" :
2023-05-19 22:04:03 +00:00
var res = & FlightComputerLvBoardDisconnectCounts { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "flight_computer_hv_board_disconnect_counts" :
2023-05-19 22:04:03 +00:00
var res = & FlightComputerHvBoardDisconnectCounts { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "flight_computer_internal_state" :
2023-05-19 22:04:03 +00:00
var res = & FlightComputerInternalState { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "power_to_drive" :
2023-05-19 22:04:03 +00:00
var res = & PowerToDrive { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "array_power" :
2023-05-19 22:04:03 +00:00
var res = & ArrayPower { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "array_energy" :
var res = & ArrayEnergy { }
err := json . Unmarshal ( raw , res )
return res , err
case "array_energy_reset" :
var res = & ArrayEnergyReset { }
err := json . Unmarshal ( raw , res )
return res , err
case "vision_turn_signals_command" :
2023-05-19 22:04:03 +00:00
var res = & VisionTurnSignalsCommand { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "vision_brake_lights_command" :
2023-05-19 22:04:03 +00:00
var res = & VisionBrakeLightsCommand { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "vision_headlights_command" :
2023-05-19 22:04:03 +00:00
var res = & VisionHeadlightsCommand { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "vision_horn_command" :
2023-05-19 22:04:03 +00:00
var res = & VisionHornCommand { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "vision_array_latches_command" :
2023-05-19 22:04:03 +00:00
var res = & VisionArrayLatchesCommand { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "vision_rearview_command" :
2023-05-19 22:04:03 +00:00
var res = & VisionRearviewCommand { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "tracker_enable" :
2023-05-19 22:04:03 +00:00
var res = & TrackerEnable { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "distance_traveled" :
2023-05-19 22:04:03 +00:00
var res = & DistanceTraveled { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "charger_state" :
2023-05-19 22:04:03 +00:00
var res = & ChargerState { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "charger_bms_request" :
2023-05-19 22:04:03 +00:00
var res = & ChargerBmsRequest { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "charger_current_voltage" :
2023-05-19 22:04:03 +00:00
var res = & ChargerCurrentVoltage { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "charger_power" :
2023-05-19 22:04:03 +00:00
var res = & ChargerPower { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "thunderstruck_control_message" :
2023-05-19 22:04:03 +00:00
var res = & ThunderstruckControlMessage { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "vision_status_front" :
2023-05-19 22:04:03 +00:00
var res = & VisionStatusFront { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "vision_status_rear" :
2023-05-19 22:04:03 +00:00
var res = & VisionStatusRear { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "lights_front_id" :
2023-05-19 22:04:03 +00:00
var res = & LightsFrontId { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "lights_back_id" :
2023-05-19 22:04:03 +00:00
var res = & LightsBackId { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "vision_id" :
2023-05-19 22:04:03 +00:00
var res = & VisionId { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "steering_press_count_1" :
2023-05-19 22:04:03 +00:00
var res = & SteeringPressCount1 { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "steering_press_count_2" :
2023-05-19 22:04:03 +00:00
var res = & SteeringPressCount2 { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "steering_button_colors_1" :
2023-05-19 22:04:03 +00:00
var res = & SteeringButtonColors1 { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "steering_button_colors_2" :
2023-05-19 22:04:03 +00:00
var res = & SteeringButtonColors2 { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "steering_horn" :
2023-05-19 22:04:03 +00:00
var res = & SteeringHorn { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "thunderstruck_status_message" :
2023-05-19 22:04:03 +00:00
var res = & ThunderstruckStatusMessage { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "tracker_data" :
2023-05-19 22:04:03 +00:00
var res = & TrackerData { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "tritium_motor_drive_l" :
var res = & TritiumMotorDriveL { }
err := json . Unmarshal ( raw , res )
return res , err
case "tritium_motor_power_l" :
var res = & TritiumMotorPowerL { }
err := json . Unmarshal ( raw , res )
return res , err
case "tritium_reset_l" :
var res = & TritiumResetL { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "tritium_motor_drive_r" :
var res = & TritiumMotorDriveR { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "tritium_motor_power_r" :
var res = & TritiumMotorPowerR { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "tritium_reset_r" :
var res = & TritiumResetR { }
err := json . Unmarshal ( raw , res )
return res , err
case "bms_ah_set" :
2023-05-19 22:04:03 +00:00
var res = & BmsAhSet { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_wh_set" :
2023-05-19 22:04:03 +00:00
var res = & BmsWhSet { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "bms_kill" :
2023-05-19 22:04:03 +00:00
var res = & BmsKill { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "telemetry_rtc_reset" :
2023-05-19 22:04:03 +00:00
var res = & TelemetryRtcReset { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_identification" :
2023-05-19 22:04:03 +00:00
var res = & WsrIdentification { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_status_information" :
2023-05-19 22:04:03 +00:00
var res = & WsrStatusInformation { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_bus_measurement" :
2023-05-19 22:04:03 +00:00
var res = & WsrBusMeasurement { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_velocity" :
2023-05-19 22:04:03 +00:00
var res = & WsrVelocity { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_phase_current" :
2023-05-19 22:04:03 +00:00
var res = & WsrPhaseCurrent { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_motor_voltage_vector" :
2023-05-19 22:04:03 +00:00
var res = & WsrMotorVoltageVector { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_motor_current_vector" :
2023-05-19 22:04:03 +00:00
var res = & WsrMotorCurrentVector { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_motor_backemf" :
2023-05-19 22:04:03 +00:00
var res = & WsrMotorBackemf { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_15_165_voltage_rail" :
2023-05-19 22:04:03 +00:00
var res = & Wsr15165VoltageRail { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_25_12_voltage_rail" :
2023-05-19 22:04:03 +00:00
var res = & Wsr2512VoltageRail { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_heatsink_motor_temp" :
2023-05-19 22:04:03 +00:00
var res = & WsrHeatsinkMotorTemp { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_dsp_board_temp" :
2023-05-19 22:04:03 +00:00
var res = & WsrDspBoardTemp { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_reserved" :
2023-05-19 22:04:03 +00:00
var res = & WsrReserved { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_odometer_bus_amphours_measurement" :
2023-05-19 22:04:03 +00:00
var res = & WsrOdometerBusAmphoursMeasurement { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsr_slip_speed_measurement" :
2023-05-19 22:04:03 +00:00
var res = & WsrSlipSpeedMeasurement { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_identification" :
2023-05-19 22:04:03 +00:00
var res = & WslIdentification { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_status_information" :
2023-05-19 22:04:03 +00:00
var res = & WslStatusInformation { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_bus_measurement" :
2023-05-19 22:04:03 +00:00
var res = & WslBusMeasurement { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_velocity" :
2023-05-19 22:04:03 +00:00
var res = & WslVelocity { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_phase_current" :
2023-05-19 22:04:03 +00:00
var res = & WslPhaseCurrent { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_motor_voltage_vector" :
2023-05-19 22:04:03 +00:00
var res = & WslMotorVoltageVector { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_motor_current_vector" :
2023-05-19 22:04:03 +00:00
var res = & WslMotorCurrentVector { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_motor_backemf" :
2023-05-19 22:04:03 +00:00
var res = & WslMotorBackemf { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_15_165_voltage_rail" :
2023-05-19 22:04:03 +00:00
var res = & Wsl15165VoltageRail { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_25_12_voltage_rail" :
2023-05-19 22:04:03 +00:00
var res = & Wsl2512VoltageRail { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_heatsink_motor_temp" :
2023-05-19 22:04:03 +00:00
var res = & WslHeatsinkMotorTemp { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_dsp_board_temp" :
2023-05-19 22:04:03 +00:00
var res = & WslDspBoardTemp { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_odometer_bus_amphours_measurement" :
2023-05-19 22:04:03 +00:00
var res = & WslOdometerBusAmphoursMeasurement { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_reserved" :
2023-05-19 22:04:03 +00:00
var res = & WslReserved { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
2024-02-12 15:45:23 +00:00
case "wsl_slip_speed_measurement" :
2023-05-19 22:04:03 +00:00
var res = & WslSlipSpeedMeasurement { }
2023-05-29 00:39:03 +00:00
err := json . Unmarshal ( raw , res )
2023-05-19 22:04:03 +00:00
return res , err
}
2024-02-12 15:45:23 +00:00
return nil , errors . New ( "unknown packet name" )
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsMeasurement is Voltages for main battery and aux pack
type BmsMeasurement struct {
// 0.01 V
BatteryVoltage uint16 ` json:"battery_voltage" `
// 0.001 V
AuxVoltage uint16 ` json:"aux_voltage" `
// 1 A
Current float32 ` json:"current" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsMeasurement ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x10
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsMeasurement ) Size ( ) uint {
return 8
}
func ( p * BmsMeasurement ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , p . BatteryVoltage )
binary . LittleEndian . PutUint16 ( b [ 2 : ] , p . AuxVoltage )
float32ToBytes ( b [ 4 : ] , p . Current , false )
return b , nil
}
func ( p * BmsMeasurement ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . BatteryVoltage = binary . LittleEndian . Uint16 ( b [ 0 : ] )
p . AuxVoltage = binary . LittleEndian . Uint16 ( b [ 2 : ] )
p . Current = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * BmsMeasurement ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_measurement"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type BatteryStatusBatteryState struct {
2024-03-07 19:29:50 +00:00
Startup bool ` json:"startup" `
Precharge bool ` json:"precharge" `
Discharging bool ` json:"discharging" `
LvOnly bool ` json:"lv_only" `
Charging bool ` json:"charging" `
2023-05-19 22:04:03 +00:00
WallCharging bool ` json:"wall_charging" `
2024-03-07 19:29:50 +00:00
Killed bool ` json:"killed" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * BatteryStatusBatteryState ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . Startup {
b |= 1 << 0
}
if p . Precharge {
b |= 1 << 1
}
if p . Discharging {
b |= 1 << 2
}
if p . LvOnly {
b |= 1 << 3
}
if p . Charging {
b |= 1 << 4
}
if p . WallCharging {
b |= 1 << 5
}
if p . Killed {
b |= 1 << 6
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * BatteryStatusBatteryState ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . Startup = ( b & ( 1 << 0 ) ) != 0
p . Precharge = ( b & ( 1 << 1 ) ) != 0
p . Discharging = ( b & ( 1 << 2 ) ) != 0
p . LvOnly = ( b & ( 1 << 3 ) ) != 0
p . Charging = ( b & ( 1 << 4 ) ) != 0
p . WallCharging = ( b & ( 1 << 5 ) ) != 0
p . Killed = ( b & ( 1 << 6 ) ) != 0
}
type BatteryStatusContactorState struct {
2024-03-07 19:29:50 +00:00
BatteryHighContactor bool ` json:"battery_high_contactor" `
BatteryLowContactor bool ` json:"battery_low_contactor" `
2023-05-19 22:04:03 +00:00
BatteryVicorContactor bool ` json:"battery_vicor_contactor" `
2024-03-07 19:29:50 +00:00
BatteryPreContactor bool ` json:"battery_pre_contactor" `
2023-05-19 22:04:03 +00:00
BatteryHigh2Contactor bool ` json:"battery_high2_contactor" `
2024-03-07 19:29:50 +00:00
BatteryLow2Contactor bool ` json:"battery_low2_contactor" `
ChargerHighContactor bool ` json:"charger_high_contactor" `
ChargerPreContactor bool ` json:"charger_pre_contactor" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * BatteryStatusContactorState ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . BatteryHighContactor {
b |= 1 << 0
}
if p . BatteryLowContactor {
b |= 1 << 1
}
if p . BatteryVicorContactor {
b |= 1 << 2
}
if p . BatteryPreContactor {
b |= 1 << 3
}
if p . BatteryHigh2Contactor {
b |= 1 << 4
}
if p . BatteryLow2Contactor {
b |= 1 << 5
}
if p . ChargerHighContactor {
b |= 1 << 6
}
if p . ChargerPreContactor {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * BatteryStatusContactorState ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . BatteryHighContactor = ( b & ( 1 << 0 ) ) != 0
p . BatteryLowContactor = ( b & ( 1 << 1 ) ) != 0
p . BatteryVicorContactor = ( b & ( 1 << 2 ) ) != 0
p . BatteryPreContactor = ( b & ( 1 << 3 ) ) != 0
p . BatteryHigh2Contactor = ( b & ( 1 << 4 ) ) != 0
p . BatteryLow2Contactor = ( b & ( 1 << 5 ) ) != 0
p . ChargerHighContactor = ( b & ( 1 << 6 ) ) != 0
p . ChargerPreContactor = ( b & ( 1 << 7 ) ) != 0
}
type BatteryStatusLvChannelStatus struct {
2024-03-07 19:29:50 +00:00
AuxFault bool ` json:"aux_fault" `
MainFault bool ` json:"main_fault" `
AuxPowerValid bool ` json:"aux_power_valid" `
MainPowerValid bool ` json:"main_power_valid" `
AuxPowerActive bool ` json:"aux_power_active" `
2023-05-19 22:04:03 +00:00
MainPowerActive bool ` json:"main_power_active" `
}
2023-05-29 00:39:03 +00:00
func ( p * BatteryStatusLvChannelStatus ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . AuxFault {
b |= 1 << 0
}
if p . MainFault {
b |= 1 << 1
}
if p . AuxPowerValid {
b |= 1 << 2
}
if p . MainPowerValid {
b |= 1 << 3
}
if p . AuxPowerActive {
b |= 1 << 4
}
if p . MainPowerActive {
b |= 1 << 5
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * BatteryStatusLvChannelStatus ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . AuxFault = ( b & ( 1 << 0 ) ) != 0
p . MainFault = ( b & ( 1 << 1 ) ) != 0
p . AuxPowerValid = ( b & ( 1 << 2 ) ) != 0
p . MainPowerValid = ( b & ( 1 << 3 ) ) != 0
p . AuxPowerActive = ( b & ( 1 << 4 ) ) != 0
p . MainPowerActive = ( b & ( 1 << 5 ) ) != 0
}
type BatteryStatusLvControlStatus struct {
2024-03-07 19:29:50 +00:00
AuxVicorEnable bool ` json:"aux_vicor_enable" `
BatVicorEnable bool ` json:"bat_vicor_enable" `
AuxRelayHeld bool ` json:"aux_relay_held" `
AuxRefEnable bool ` json:"aux_ref_enable" `
2023-05-19 22:04:03 +00:00
AuxChargingEnable bool ` json:"aux_charging_enable" `
2024-03-07 19:29:50 +00:00
KillHv bool ` json:"kill_hv" `
KillLv bool ` json:"kill_lv" `
StartButton bool ` json:"start_button" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * BatteryStatusLvControlStatus ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . AuxVicorEnable {
b |= 1 << 0
}
if p . BatVicorEnable {
b |= 1 << 1
}
if p . AuxRelayHeld {
b |= 1 << 2
}
if p . AuxRefEnable {
b |= 1 << 3
}
if p . AuxChargingEnable {
b |= 1 << 4
}
if p . KillHv {
b |= 1 << 5
}
if p . KillLv {
b |= 1 << 6
}
if p . StartButton {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * BatteryStatusLvControlStatus ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . AuxVicorEnable = ( b & ( 1 << 0 ) ) != 0
p . BatVicorEnable = ( b & ( 1 << 1 ) ) != 0
p . AuxRelayHeld = ( b & ( 1 << 2 ) ) != 0
p . AuxRefEnable = ( b & ( 1 << 3 ) ) != 0
p . AuxChargingEnable = ( b & ( 1 << 4 ) ) != 0
p . KillHv = ( b & ( 1 << 5 ) ) != 0
p . KillLv = ( b & ( 1 << 6 ) ) != 0
p . StartButton = ( b & ( 1 << 7 ) ) != 0
}
2024-02-12 15:45:23 +00:00
type BatteryStatusPackChoice struct {
LargePack bool ` json:"large_pack" `
SmallPack bool ` json:"small_pack" `
}
func ( p * BatteryStatusPackChoice ) MarshalByte ( ) byte {
var b byte
if p . LargePack {
b |= 1 << 0
}
if p . SmallPack {
b |= 1 << 1
}
return b
}
func ( p * BatteryStatusPackChoice ) UnmarshalByte ( b byte ) {
p . LargePack = ( b & ( 1 << 0 ) ) != 0
p . SmallPack = ( b & ( 1 << 1 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BatteryStatus is Status bits for the battery
type BatteryStatus struct {
2024-03-07 19:29:50 +00:00
BatteryState BatteryStatusBatteryState ` json:"battery_state" `
ContactorState BatteryStatusContactorState ` json:"contactor_state" `
2023-05-19 22:04:03 +00:00
LvChannelStatus BatteryStatusLvChannelStatus ` json:"lv_channel_status" `
LvControlStatus BatteryStatusLvControlStatus ` json:"lv_control_status" `
2024-03-07 19:29:50 +00:00
PackChoice BatteryStatusPackChoice ` json:"pack_choice" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * BatteryStatus ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x11
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BatteryStatus ) Size ( ) uint {
2024-02-12 15:45:23 +00:00
return 5
2023-05-19 22:04:03 +00:00
}
func ( p * BatteryStatus ) MarshalPacket ( ) ( [ ] byte , error ) {
2024-02-12 15:45:23 +00:00
b := make ( [ ] byte , 5 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . BatteryState . MarshalByte ( )
b [ 1 ] = p . ContactorState . MarshalByte ( )
b [ 2 ] = p . LvChannelStatus . MarshalByte ( )
b [ 3 ] = p . LvControlStatus . MarshalByte ( )
2024-02-12 15:45:23 +00:00
b [ 4 ] = p . PackChoice . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * BatteryStatus ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 5 {
return & BadLengthError { expected : 5 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . BatteryState . UnmarshalByte ( b [ 0 ] )
p . ContactorState . UnmarshalByte ( b [ 1 ] )
p . LvChannelStatus . UnmarshalByte ( b [ 2 ] )
p . LvControlStatus . UnmarshalByte ( b [ 3 ] )
2024-02-12 15:45:23 +00:00
p . PackChoice . UnmarshalByte ( b [ 4 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * BatteryStatus ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "battery_status"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type BmsKillReasonReason1 struct {
2024-03-07 19:29:50 +00:00
OVERVOLT bool ` json:"OVERVOLT" `
UNDERVOLT bool ` json:"UNDERVOLT" `
OVERTEMP bool ` json:"OVERTEMP" `
2023-05-19 22:04:03 +00:00
TEMPDISCONNECT bool ` json:"TEMP_DISCONNECT" `
2024-03-07 19:29:50 +00:00
COMMFAIL bool ` json:"COMM_FAIL" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * BmsKillReasonReason1 ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . OVERVOLT {
b |= 1 << 0
}
if p . UNDERVOLT {
b |= 1 << 1
}
if p . OVERTEMP {
b |= 1 << 2
}
if p . TEMPDISCONNECT {
b |= 1 << 3
}
if p . COMMFAIL {
b |= 1 << 4
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * BmsKillReasonReason1 ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . OVERVOLT = ( b & ( 1 << 0 ) ) != 0
p . UNDERVOLT = ( b & ( 1 << 1 ) ) != 0
p . OVERTEMP = ( b & ( 1 << 2 ) ) != 0
p . TEMPDISCONNECT = ( b & ( 1 << 3 ) ) != 0
p . COMMFAIL = ( b & ( 1 << 4 ) ) != 0
}
type BmsKillReasonReason2 struct {
2024-03-07 19:29:50 +00:00
HARDWARE bool ` json:"HARDWARE" `
KILLPACKET bool ` json:"KILL_PACKET" `
UKNOWN bool ` json:"UKNOWN" `
OVERCURRENT bool ` json:"OVERCURRENT" `
2023-05-19 22:04:03 +00:00
PRECHARGEFAIL bool ` json:"PRECHARGE_FAIL" `
2024-03-07 19:29:50 +00:00
AUXOVERUNDER bool ` json:"AUX_OVER_UNDER" `
AUXOVERTEMP bool ` json:"AUX_OVERTEMP" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * BmsKillReasonReason2 ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . HARDWARE {
b |= 1 << 0
}
if p . KILLPACKET {
b |= 1 << 1
}
if p . UKNOWN {
b |= 1 << 2
}
if p . OVERCURRENT {
b |= 1 << 3
}
if p . PRECHARGEFAIL {
b |= 1 << 4
}
if p . AUXOVERUNDER {
b |= 1 << 5
}
2024-02-12 15:45:23 +00:00
if p . AUXOVERTEMP {
b |= 1 << 6
}
2023-05-19 22:04:03 +00:00
return b
}
2023-05-29 00:39:03 +00:00
func ( p * BmsKillReasonReason2 ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . HARDWARE = ( b & ( 1 << 0 ) ) != 0
p . KILLPACKET = ( b & ( 1 << 1 ) ) != 0
p . UKNOWN = ( b & ( 1 << 2 ) ) != 0
p . OVERCURRENT = ( b & ( 1 << 3 ) ) != 0
p . PRECHARGEFAIL = ( b & ( 1 << 4 ) ) != 0
p . AUXOVERUNDER = ( b & ( 1 << 5 ) ) != 0
2024-02-12 15:45:23 +00:00
p . AUXOVERTEMP = ( b & ( 1 << 6 ) ) != 0
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsKillReason is Information for when the car kills
type BmsKillReason struct {
Reason1 BmsKillReasonReason1 ` json:"reason1" `
Reason2 BmsKillReasonReason2 ` json:"reason2" `
2024-03-07 19:29:50 +00:00
Module uint16 ` json:"module" `
Value float32 ` json:"value" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * BmsKillReason ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x12
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsKillReason ) Size ( ) uint {
return 8
}
func ( p * BmsKillReason ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . Reason1 . MarshalByte ( )
b [ 1 ] = p . Reason2 . MarshalByte ( )
2023-05-19 22:04:03 +00:00
binary . LittleEndian . PutUint16 ( b [ 2 : ] , p . Module )
float32ToBytes ( b [ 4 : ] , p . Value , false )
return b , nil
}
func ( p * BmsKillReason ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . Reason1 . UnmarshalByte ( b [ 0 ] )
p . Reason2 . UnmarshalByte ( b [ 1 ] )
2023-05-19 22:04:03 +00:00
p . Module = binary . LittleEndian . Uint16 ( b [ 2 : ] )
p . Value = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * BmsKillReason ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_kill_reason"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsModuleMinMax is min and max cell voltages and temperatures
type BmsModuleMinMax struct {
// 0.01 C
ModuleMaxTemp int16 ` json:"module_max_temp" `
// 0.01 C
ModuleMinTemp int16 ` json:"module_min_temp" `
// 0.001 V
ModuleMaxVoltage uint16 ` json:"module_max_voltage" `
// 0.001 V
ModuleMinVoltage uint16 ` json:"module_min_voltage" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsModuleMinMax ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x13
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsModuleMinMax ) Size ( ) uint {
return 8
}
func ( p * BmsModuleMinMax ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , uint16 ( p . ModuleMaxTemp ) )
binary . LittleEndian . PutUint16 ( b [ 2 : ] , uint16 ( p . ModuleMinTemp ) )
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . ModuleMaxVoltage )
binary . LittleEndian . PutUint16 ( b [ 6 : ] , p . ModuleMinVoltage )
return b , nil
}
func ( p * BmsModuleMinMax ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . ModuleMaxTemp = int16 ( binary . LittleEndian . Uint16 ( b [ 0 : ] ) )
p . ModuleMinTemp = int16 ( binary . LittleEndian . Uint16 ( b [ 2 : ] ) )
p . ModuleMaxVoltage = binary . LittleEndian . Uint16 ( b [ 4 : ] )
p . ModuleMinVoltage = binary . LittleEndian . Uint16 ( b [ 6 : ] )
return nil
}
func ( p * BmsModuleMinMax ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_module_min_max"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsSoc is State of charge
type BmsSoc struct {
Soc float32 ` json:"soc" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsSoc ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x14
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsSoc ) Size ( ) uint {
return 4
}
func ( p * BmsSoc ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
float32ToBytes ( b [ 0 : ] , p . Soc , false )
return b , nil
}
func ( p * BmsSoc ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Soc = float32FromBytes ( b [ 0 : ] , false )
return nil
}
func ( p * BmsSoc ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_soc"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsCapacity is State of charge
type BmsCapacity struct {
Ah float32 ` json:"Ah" `
Wh float32 ` json:"Wh" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsCapacity ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x15
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsCapacity ) Size ( ) uint {
return 8
}
func ( p * BmsCapacity ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Ah , false )
float32ToBytes ( b [ 4 : ] , p . Wh , false )
return b , nil
}
func ( p * BmsCapacity ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Ah = float32FromBytes ( b [ 0 : ] , false )
p . Wh = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * BmsCapacity ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_capacity"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsCurrentlimit is reports BP params for current
type BmsCurrentlimit struct {
// 0.01 A
CurrentMax int16 ` json:"current_max" `
// 0.01 A
CurrentMin int16 ` json:"current_min" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsCurrentlimit ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x18
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsCurrentlimit ) Size ( ) uint {
return 4
}
func ( p * BmsCurrentlimit ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , uint16 ( p . CurrentMax ) )
binary . LittleEndian . PutUint16 ( b [ 2 : ] , uint16 ( p . CurrentMin ) )
return b , nil
}
func ( p * BmsCurrentlimit ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . CurrentMax = int16 ( binary . LittleEndian . Uint16 ( b [ 0 : ] ) )
p . CurrentMin = int16 ( binary . LittleEndian . Uint16 ( b [ 2 : ] ) )
return nil
}
func ( p * BmsCurrentlimit ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_currentlimit"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsFanInfo is BP Fans
type BmsFanInfo struct {
// 1 RPM
Fan1 uint16 ` json:"fan1" `
// 1 RPM
Fan2 uint16 ` json:"fan2" `
// 1 RPM
Fan3 uint16 ` json:"fan3" `
// 1 RPM
Fan4 uint16 ` json:"fan4" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsFanInfo ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x19
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsFanInfo ) Size ( ) uint {
return 8
}
func ( p * BmsFanInfo ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , p . Fan1 )
binary . LittleEndian . PutUint16 ( b [ 2 : ] , p . Fan2 )
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . Fan3 )
binary . LittleEndian . PutUint16 ( b [ 6 : ] , p . Fan4 )
return b , nil
}
func ( p * BmsFanInfo ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Fan1 = binary . LittleEndian . Uint16 ( b [ 0 : ] )
p . Fan2 = binary . LittleEndian . Uint16 ( b [ 2 : ] )
p . Fan3 = binary . LittleEndian . Uint16 ( b [ 4 : ] )
p . Fan4 = binary . LittleEndian . Uint16 ( b [ 6 : ] )
return nil
}
func ( p * BmsFanInfo ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_fan_info"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsSetMinFanSpeed is packet which sets a minimum fan speed of BMS for a specific time frame in seconds
type BmsSetMinFanSpeed struct {
// 0 percent
FanPercentage float32 ` json:"fan_percentage" `
// 0 s
Time uint16 ` json:"time" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsSetMinFanSpeed ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x1B
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsSetMinFanSpeed ) Size ( ) uint {
return 6
}
func ( p * BmsSetMinFanSpeed ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 6 )
float32ToBytes ( b [ 0 : ] , p . FanPercentage , false )
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . Time )
return b , nil
}
func ( p * BmsSetMinFanSpeed ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 6 {
return & BadLengthError { expected : 6 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . FanPercentage = float32FromBytes ( b [ 0 : ] , false )
p . Time = binary . LittleEndian . Uint16 ( b [ 4 : ] )
return nil
}
func ( p * BmsSetMinFanSpeed ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_set_min_fan_speed"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsModule is Voltage and temperature for a single module
type BmsModule struct {
// 1 V
Voltage float32 ` json:"voltage" `
// 1 C
Temperature float32 ` json:"temperature" `
// Idx is the packet index. The accepted range is 0-36
2023-05-22 13:41:37 +00:00
Idx uint32 ` json:"idx" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * BmsModule ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
2023-05-19 22:04:03 +00:00
if p . Idx >= 36 {
2024-03-07 19:29:50 +00:00
return c , & UnknownIdError { 0x40 }
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
c . Id = 0x40 + p . Idx
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsModule ) Size ( ) uint {
return 8
}
func ( p * BmsModule ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Voltage , false )
float32ToBytes ( b [ 4 : ] , p . Temperature , false )
return b , nil
}
func ( p * BmsModule ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Voltage = float32FromBytes ( b [ 0 : ] , false )
p . Temperature = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * BmsModule ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_module"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type BmsChargerResponseResponseFlags struct {
ChargingReady bool ` json:"charging_ready" `
}
2023-05-29 00:39:03 +00:00
func ( p * BmsChargerResponseResponseFlags ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . ChargingReady {
b |= 1 << 0
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * BmsChargerResponseResponseFlags ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . ChargingReady = ( b & ( 1 << 0 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsChargerResponse is Response packet from BMS for indicating whether BMS is ready for charging
type BmsChargerResponse struct {
ResponseFlags BmsChargerResponseResponseFlags ` json:"response_flags" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsChargerResponse ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x75
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsChargerResponse ) Size ( ) uint {
return 1
}
func ( p * BmsChargerResponse ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . ResponseFlags . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * BmsChargerResponse ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . ResponseFlags . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * BmsChargerResponse ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_charger_response"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
type ChassisIsolationFaultFaultDetected struct {
IsolationFault bool ` json:"isolation_fault" `
}
func ( p * ChassisIsolationFaultFaultDetected ) MarshalByte ( ) byte {
var b byte
if p . IsolationFault {
b |= 1 << 0
}
return b
}
func ( p * ChassisIsolationFaultFaultDetected ) UnmarshalByte ( b byte ) {
p . IsolationFault = ( b & ( 1 << 0 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
// ChassisIsolationFault is chassiss is not isolated from the battery
type ChassisIsolationFault struct {
FaultDetected ChassisIsolationFaultFaultDetected ` json:"fault_detected" `
}
2024-02-12 20:38:01 +00:00
func ( p * ChassisIsolationFault ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x38
return c , nil
2024-02-12 15:45:23 +00:00
}
func ( p * ChassisIsolationFault ) Size ( ) uint {
return 1
}
func ( p * ChassisIsolationFault ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
b [ 0 ] = p . FaultDetected . MarshalByte ( )
return b , nil
}
func ( p * ChassisIsolationFault ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2024-02-12 15:45:23 +00:00
p . FaultDetected . UnmarshalByte ( b [ 0 ] )
return nil
}
func ( p * ChassisIsolationFault ) String ( ) string {
return "chassis_isolation_fault"
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
type BmsImdInfoDImcStatus1 struct {
2024-03-07 19:29:50 +00:00
IsolationFault bool ` json:"isolation_fault" `
ChassisFault bool ` json:"chassis_fault" `
SystemFailure bool ` json:"system_failure" `
2024-02-12 15:45:23 +00:00
CalibrationRunning bool ` json:"calibration_running" `
2024-03-07 19:29:50 +00:00
SelfTestRunning bool ` json:"self_test_running" `
IsolationWarning bool ` json:"isolation_warning" `
Reserved bool ` json:"reserved" `
Reserved2 bool ` json:"reserved_2" `
2024-02-12 15:45:23 +00:00
}
func ( p * BmsImdInfoDImcStatus1 ) MarshalByte ( ) byte {
var b byte
if p . IsolationFault {
b |= 1 << 0
}
if p . ChassisFault {
b |= 1 << 1
}
if p . SystemFailure {
b |= 1 << 2
}
if p . CalibrationRunning {
b |= 1 << 3
}
if p . SelfTestRunning {
b |= 1 << 4
}
if p . IsolationWarning {
b |= 1 << 5
}
if p . Reserved {
b |= 1 << 6
}
if p . Reserved2 {
b |= 1 << 7
}
return b
}
func ( p * BmsImdInfoDImcStatus1 ) UnmarshalByte ( b byte ) {
p . IsolationFault = ( b & ( 1 << 0 ) ) != 0
p . ChassisFault = ( b & ( 1 << 1 ) ) != 0
p . SystemFailure = ( b & ( 1 << 2 ) ) != 0
p . CalibrationRunning = ( b & ( 1 << 3 ) ) != 0
p . SelfTestRunning = ( b & ( 1 << 4 ) ) != 0
p . IsolationWarning = ( b & ( 1 << 5 ) ) != 0
p . Reserved = ( b & ( 1 << 6 ) ) != 0
p . Reserved2 = ( b & ( 1 << 7 ) ) != 0
}
type BmsImdInfoDImcStatus2 struct {
2024-03-07 19:29:50 +00:00
Reserved bool ` json:"reserved" `
2024-02-12 15:45:23 +00:00
Reserved2 bool ` json:"reserved_2" `
Reserved3 bool ` json:"reserved_3" `
Reserved4 bool ` json:"reserved_4" `
Reserved5 bool ` json:"reserved_5" `
Reserved6 bool ` json:"reserved_6" `
Reserved7 bool ` json:"reserved_7" `
Reserved8 bool ` json:"reserved_8" `
}
func ( p * BmsImdInfoDImcStatus2 ) MarshalByte ( ) byte {
var b byte
if p . Reserved {
b |= 1 << 0
}
if p . Reserved2 {
b |= 1 << 1
}
if p . Reserved3 {
b |= 1 << 2
}
if p . Reserved4 {
b |= 1 << 3
}
if p . Reserved5 {
b |= 1 << 4
}
if p . Reserved6 {
b |= 1 << 5
}
if p . Reserved7 {
b |= 1 << 6
}
if p . Reserved8 {
b |= 1 << 7
}
return b
}
func ( p * BmsImdInfoDImcStatus2 ) UnmarshalByte ( b byte ) {
p . Reserved = ( b & ( 1 << 0 ) ) != 0
p . Reserved2 = ( b & ( 1 << 1 ) ) != 0
p . Reserved3 = ( b & ( 1 << 2 ) ) != 0
p . Reserved4 = ( b & ( 1 << 3 ) ) != 0
p . Reserved5 = ( b & ( 1 << 4 ) ) != 0
p . Reserved6 = ( b & ( 1 << 5 ) ) != 0
p . Reserved7 = ( b & ( 1 << 6 ) ) != 0
p . Reserved8 = ( b & ( 1 << 7 ) ) != 0
}
type BmsImdInfoDVifcStatus1 struct {
2024-03-07 19:29:50 +00:00
InsulationMeasurment bool ` json:"insulation_measurment" `
2024-02-12 15:45:23 +00:00
ImcConnectivityNotImplemented bool ` json:"imc_connectivity_not_implemented" `
2024-03-07 19:29:50 +00:00
ImcAliveSatusDetection bool ` json:"imc_alive_satus_detection" `
Reserved bool ` json:"reserved" `
VifcCommandNotImplemented bool ` json:"vifc_command_not_implemented" `
Reserved2 bool ` json:"reserved_2" `
Reserved3 bool ` json:"reserved_3" `
Reserved4 bool ` json:"reserved_4" `
2024-02-12 15:45:23 +00:00
}
func ( p * BmsImdInfoDVifcStatus1 ) MarshalByte ( ) byte {
var b byte
if p . InsulationMeasurment {
b |= 1 << 0
}
if p . ImcConnectivityNotImplemented {
b |= 1 << 1
}
if p . ImcAliveSatusDetection {
b |= 1 << 2
}
if p . Reserved {
b |= 1 << 3
}
if p . VifcCommandNotImplemented {
b |= 1 << 4
}
if p . Reserved2 {
b |= 1 << 5
}
if p . Reserved3 {
b |= 1 << 6
}
if p . Reserved4 {
b |= 1 << 7
}
return b
}
func ( p * BmsImdInfoDVifcStatus1 ) UnmarshalByte ( b byte ) {
p . InsulationMeasurment = ( b & ( 1 << 0 ) ) != 0
p . ImcConnectivityNotImplemented = ( b & ( 1 << 1 ) ) != 0
p . ImcAliveSatusDetection = ( b & ( 1 << 2 ) ) != 0
p . Reserved = ( b & ( 1 << 3 ) ) != 0
p . VifcCommandNotImplemented = ( b & ( 1 << 4 ) ) != 0
p . Reserved2 = ( b & ( 1 << 5 ) ) != 0
p . Reserved3 = ( b & ( 1 << 6 ) ) != 0
p . Reserved4 = ( b & ( 1 << 7 ) ) != 0
}
type BmsImdInfoDVifcStatus2 struct {
2024-03-07 19:29:50 +00:00
InsulationResistanceValue bool ` json:"insulation_resistance_value" `
Reserved bool ` json:"reserved" `
Reserved2 bool ` json:"reserved_2" `
Reserved3 bool ` json:"reserved_3" `
ImcSelfTestOverAll bool ` json:"imc_self_test_overAll" `
2024-02-12 15:45:23 +00:00
ImcSelfTestParameterConfig bool ` json:"imc_self_test_parameterConfig" `
2024-03-07 19:29:50 +00:00
Reserved4 bool ` json:"reserved_4" `
Reserved5 bool ` json:"reserved_5" `
2024-02-12 15:45:23 +00:00
}
func ( p * BmsImdInfoDVifcStatus2 ) MarshalByte ( ) byte {
var b byte
if p . InsulationResistanceValue {
b |= 1 << 0
}
if p . Reserved {
b |= 1 << 1
}
if p . Reserved2 {
b |= 1 << 2
}
if p . Reserved3 {
b |= 1 << 3
}
if p . ImcSelfTestOverAll {
b |= 1 << 4
}
if p . ImcSelfTestParameterConfig {
b |= 1 << 5
}
if p . Reserved4 {
b |= 1 << 6
}
if p . Reserved5 {
b |= 1 << 7
}
return b
}
func ( p * BmsImdInfoDVifcStatus2 ) UnmarshalByte ( b byte ) {
p . InsulationResistanceValue = ( b & ( 1 << 0 ) ) != 0
p . Reserved = ( b & ( 1 << 1 ) ) != 0
p . Reserved2 = ( b & ( 1 << 2 ) ) != 0
p . Reserved3 = ( b & ( 1 << 3 ) ) != 0
p . ImcSelfTestOverAll = ( b & ( 1 << 4 ) ) != 0
p . ImcSelfTestParameterConfig = ( b & ( 1 << 5 ) ) != 0
p . Reserved4 = ( b & ( 1 << 6 ) ) != 0
p . Reserved5 = ( b & ( 1 << 7 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
// BmsImdInfo is information from chassis isolation
type BmsImdInfo struct {
2024-03-07 19:29:50 +00:00
DImcRIso uint16 ` json:"d_imc_r_iso" `
DImcStatus1 BmsImdInfoDImcStatus1 ` json:"d_imc_status_1" `
DImcStatus2 BmsImdInfoDImcStatus2 ` json:"d_imc_status_2" `
2024-02-12 15:45:23 +00:00
DVifcStatus1 BmsImdInfoDVifcStatus1 ` json:"d_vifc_status_1" `
DVifcStatus2 BmsImdInfoDVifcStatus2 ` json:"d_vifc_status_2" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsImdInfo ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x37
return c , nil
2024-02-12 15:45:23 +00:00
}
func ( p * BmsImdInfo ) Size ( ) uint {
return 6
}
func ( p * BmsImdInfo ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 6 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , p . DImcRIso )
b [ 2 ] = p . DImcStatus1 . MarshalByte ( )
b [ 3 ] = p . DImcStatus2 . MarshalByte ( )
b [ 4 ] = p . DVifcStatus1 . MarshalByte ( )
b [ 5 ] = p . DVifcStatus2 . MarshalByte ( )
return b , nil
}
func ( p * BmsImdInfo ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 6 {
return & BadLengthError { expected : 6 , actual : uint32 ( len ( b ) ) }
}
2024-02-12 15:45:23 +00:00
p . DImcRIso = binary . LittleEndian . Uint16 ( b [ 0 : ] )
p . DImcStatus1 . UnmarshalByte ( b [ 2 ] )
p . DImcStatus2 . UnmarshalByte ( b [ 3 ] )
p . DVifcStatus1 . UnmarshalByte ( b [ 4 ] )
p . DVifcStatus2 . UnmarshalByte ( b [ 5 ] )
return nil
}
func ( p * BmsImdInfo ) String ( ) string {
return "bms_imd_info"
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// DashboardPedalPercentages is ADC values from the brake and accelerator pedals.
type DashboardPedalPercentages struct {
AccelPedalValue uint8 ` json:"accel_pedal_value" `
BrakePedalValue uint8 ` json:"brake_pedal_value" `
}
2024-02-12 20:38:01 +00:00
func ( p * DashboardPedalPercentages ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x290
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * DashboardPedalPercentages ) Size ( ) uint {
return 2
}
func ( p * DashboardPedalPercentages ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 2 )
b [ 0 ] = p . AccelPedalValue
b [ 1 ] = p . BrakePedalValue
return b , nil
}
func ( p * DashboardPedalPercentages ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 2 {
return & BadLengthError { expected : 2 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . AccelPedalValue = b [ 0 ]
p . BrakePedalValue = b [ 1 ]
return nil
}
func ( p * DashboardPedalPercentages ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "dashboard_pedal_percentages"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// CarState is Car gear. Forward, neutral, reverse, etc.
type CarState struct {
State uint8 ` json:"state" `
}
2024-02-12 20:38:01 +00:00
func ( p * CarState ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x291
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * CarState ) Size ( ) uint {
return 1
}
func ( p * CarState ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
b [ 0 ] = p . State
return b , nil
}
func ( p * CarState ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . State = b [ 0 ]
return nil
}
func ( p * CarState ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "car_state"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// DashboardPedalFault is Target speed that the driver should maintain.
type DashboardPedalFault struct {
BrakeFaultCount uint8 ` json:"brake_fault_count" `
AccelFaultCount uint8 ` json:"accel_fault_count" `
}
2024-02-12 20:38:01 +00:00
func ( p * DashboardPedalFault ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x292
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * DashboardPedalFault ) Size ( ) uint {
return 2
}
func ( p * DashboardPedalFault ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 2 )
b [ 0 ] = p . BrakeFaultCount
b [ 1 ] = p . AccelFaultCount
return b , nil
}
func ( p * DashboardPedalFault ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 2 {
return & BadLengthError { expected : 2 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . BrakeFaultCount = b [ 0 ]
p . AccelFaultCount = b [ 1 ]
return nil
}
func ( p * DashboardPedalFault ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "dashboard_pedal_fault"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type DashboardSystemTimeoutTestFlagSet0 struct {
2024-03-07 19:29:50 +00:00
SteeringDisconnected bool ` json:"steering_disconnected" `
2023-05-19 22:04:03 +00:00
VisionFrontDisconnected bool ` json:"vision_front_disconnected" `
2024-03-07 19:29:50 +00:00
VisionRearDisconnected bool ` json:"vision_rear_disconnected" `
TelemetryDisconnected bool ` json:"telemetry_disconnected" `
WslDisconnected bool ` json:"wsl_disconnected" `
WsrDisconnected bool ` json:"wsr_disconnected" `
FrontMpptDisconnected bool ` json:"front_mppt_disconnected" `
RearMpptDisconnected bool ` json:"rear_mppt_disconnected" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * DashboardSystemTimeoutTestFlagSet0 ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . SteeringDisconnected {
b |= 1 << 0
}
if p . VisionFrontDisconnected {
b |= 1 << 1
}
if p . VisionRearDisconnected {
b |= 1 << 2
}
if p . TelemetryDisconnected {
b |= 1 << 3
}
if p . WslDisconnected {
b |= 1 << 4
}
if p . WsrDisconnected {
b |= 1 << 5
}
if p . FrontMpptDisconnected {
b |= 1 << 6
}
if p . RearMpptDisconnected {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * DashboardSystemTimeoutTestFlagSet0 ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . SteeringDisconnected = ( b & ( 1 << 0 ) ) != 0
p . VisionFrontDisconnected = ( b & ( 1 << 1 ) ) != 0
p . VisionRearDisconnected = ( b & ( 1 << 2 ) ) != 0
p . TelemetryDisconnected = ( b & ( 1 << 3 ) ) != 0
p . WslDisconnected = ( b & ( 1 << 4 ) ) != 0
p . WsrDisconnected = ( b & ( 1 << 5 ) ) != 0
p . FrontMpptDisconnected = ( b & ( 1 << 6 ) ) != 0
p . RearMpptDisconnected = ( b & ( 1 << 7 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// DashboardSystemTimeoutTest is Exposes whether each system that dashboard is supposed to listen for packets from has sent a packet. Used for testing.
type DashboardSystemTimeoutTest struct {
FlagSet0 DashboardSystemTimeoutTestFlagSet0 ` json:"flag_set_0" `
}
2024-02-12 20:38:01 +00:00
func ( p * DashboardSystemTimeoutTest ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x299
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * DashboardSystemTimeoutTest ) Size ( ) uint {
return 1
}
func ( p * DashboardSystemTimeoutTest ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . FlagSet0 . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * DashboardSystemTimeoutTest ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . FlagSet0 . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * DashboardSystemTimeoutTest ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "dashboard_system_timeout_test"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// CarSpeed is speed of car in meters per second
type CarSpeed struct {
Speed float32 ` json:"speed" `
}
2024-02-12 20:38:01 +00:00
func ( p * CarSpeed ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x29A
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * CarSpeed ) Size ( ) uint {
return 4
}
func ( p * CarSpeed ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
float32ToBytes ( b [ 0 : ] , p . Speed , false )
return b , nil
}
func ( p * CarSpeed ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Speed = float32FromBytes ( b [ 0 : ] , false )
return nil
}
func ( p * CarSpeed ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "car_speed"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// FlightComputerLvBoardDisconnectCounts is Number of times a board hasn't been heard from within the allowed timeout.
type FlightComputerLvBoardDisconnectCounts struct {
2024-03-07 19:29:50 +00:00
FrontLights uint8 ` json:"front_lights" `
RearLights uint8 ` json:"rear_lights" `
Steering uint8 ` json:"steering" `
Vision uint8 ` json:"vision" `
2023-05-19 22:04:03 +00:00
DriverDisplay uint8 ` json:"driver_display" `
CenterConsole uint8 ` json:"center_console" `
}
2024-02-12 20:38:01 +00:00
func ( p * FlightComputerLvBoardDisconnectCounts ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x29B
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * FlightComputerLvBoardDisconnectCounts ) Size ( ) uint {
return 6
}
func ( p * FlightComputerLvBoardDisconnectCounts ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 6 )
b [ 0 ] = p . FrontLights
b [ 1 ] = p . RearLights
b [ 2 ] = p . Steering
b [ 3 ] = p . Vision
b [ 4 ] = p . DriverDisplay
b [ 5 ] = p . CenterConsole
return b , nil
}
func ( p * FlightComputerLvBoardDisconnectCounts ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 6 {
return & BadLengthError { expected : 6 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . FrontLights = b [ 0 ]
p . RearLights = b [ 1 ]
p . Steering = b [ 2 ]
p . Vision = b [ 3 ]
p . DriverDisplay = b [ 4 ]
p . CenterConsole = b [ 5 ]
return nil
}
func ( p * FlightComputerLvBoardDisconnectCounts ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "flight_computer_lv_board_disconnect_counts"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// FlightComputerHvBoardDisconnectCounts is Number of times a board hasn't been heard from within the allowed timeout.
type FlightComputerHvBoardDisconnectCounts struct {
2024-03-07 19:29:50 +00:00
Bms uint8 ` json:"bms" `
Charger uint8 ` json:"charger" `
Wsl uint8 ` json:"wsl" `
Wsr uint8 ` json:"wsr" `
2023-05-19 22:04:03 +00:00
MpptFront uint8 ` json:"mppt_front" `
2024-03-07 19:29:50 +00:00
MpptRear uint8 ` json:"mppt_rear" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * FlightComputerHvBoardDisconnectCounts ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x29C
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * FlightComputerHvBoardDisconnectCounts ) Size ( ) uint {
return 6
}
func ( p * FlightComputerHvBoardDisconnectCounts ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 6 )
b [ 0 ] = p . Bms
b [ 1 ] = p . Charger
b [ 2 ] = p . Wsl
b [ 3 ] = p . Wsr
b [ 4 ] = p . MpptFront
b [ 5 ] = p . MpptRear
return b , nil
}
func ( p * FlightComputerHvBoardDisconnectCounts ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 6 {
return & BadLengthError { expected : 6 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Bms = b [ 0 ]
p . Charger = b [ 1 ]
p . Wsl = b [ 2 ]
p . Wsr = b [ 3 ]
p . MpptFront = b [ 4 ]
p . MpptRear = b [ 5 ]
return nil
}
func ( p * FlightComputerHvBoardDisconnectCounts ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "flight_computer_hv_board_disconnect_counts"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type FlightComputerInternalStateBms struct {
2024-03-07 19:29:50 +00:00
BatteryKill bool ` json:"battery_kill" `
2023-05-19 22:04:03 +00:00
CellsInChargingThreshold bool ` json:"cells_in_charging_threshold" `
2024-03-07 19:29:50 +00:00
FirstPacketReceived bool ` json:"first_packet_received" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * FlightComputerInternalStateBms ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . BatteryKill {
b |= 1 << 0
}
if p . CellsInChargingThreshold {
b |= 1 << 1
}
if p . FirstPacketReceived {
b |= 1 << 2
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * FlightComputerInternalStateBms ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . BatteryKill = ( b & ( 1 << 0 ) ) != 0
p . CellsInChargingThreshold = ( b & ( 1 << 1 ) ) != 0
p . FirstPacketReceived = ( b & ( 1 << 2 ) ) != 0
}
type FlightComputerInternalStateCharger struct {
ProximityDetected bool ` json:"proximity_detected" `
}
2023-05-29 00:39:03 +00:00
func ( p * FlightComputerInternalStateCharger ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . ProximityDetected {
b |= 1 << 0
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * FlightComputerInternalStateCharger ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . ProximityDetected = ( b & ( 1 << 0 ) ) != 0
}
type FlightComputerInternalStatePhoton3 struct {
Enable bool ` json:"enable" `
}
2023-05-29 00:39:03 +00:00
func ( p * FlightComputerInternalStatePhoton3 ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . Enable {
b |= 1 << 0
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * FlightComputerInternalStatePhoton3 ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . Enable = ( b & ( 1 << 0 ) ) != 0
}
type FlightComputerInternalStateWavesculptor struct {
SendingReset bool ` json:"sending_reset" `
2024-03-07 19:29:50 +00:00
RegenEnable bool ` json:"regen_enable" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * FlightComputerInternalStateWavesculptor ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . SendingReset {
b |= 1 << 0
}
if p . RegenEnable {
b |= 1 << 1
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * FlightComputerInternalStateWavesculptor ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . SendingReset = ( b & ( 1 << 0 ) ) != 0
p . RegenEnable = ( b & ( 1 << 1 ) ) != 0
}
type FlightComputerInternalStateInternal struct {
AccelPedalDisconnect bool ` json:"accel_pedal_disconnect" `
BrakePedalDisconnect bool ` json:"brake_pedal_disconnect" `
}
2023-05-29 00:39:03 +00:00
func ( p * FlightComputerInternalStateInternal ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . AccelPedalDisconnect {
b |= 1 << 0
}
if p . BrakePedalDisconnect {
b |= 1 << 1
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * FlightComputerInternalStateInternal ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . AccelPedalDisconnect = ( b & ( 1 << 0 ) ) != 0
p . BrakePedalDisconnect = ( b & ( 1 << 1 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// FlightComputerInternalState is internal bools
type FlightComputerInternalState struct {
2024-03-07 19:29:50 +00:00
Bms FlightComputerInternalStateBms ` json:"bms" `
Charger FlightComputerInternalStateCharger ` json:"charger" `
Photon3 FlightComputerInternalStatePhoton3 ` json:"photon3" `
2023-05-19 22:04:03 +00:00
Wavesculptor FlightComputerInternalStateWavesculptor ` json:"wavesculptor" `
2024-03-07 19:29:50 +00:00
Internal FlightComputerInternalStateInternal ` json:"internal" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * FlightComputerInternalState ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x29D
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * FlightComputerInternalState ) Size ( ) uint {
return 5
}
func ( p * FlightComputerInternalState ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 5 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . Bms . MarshalByte ( )
b [ 1 ] = p . Charger . MarshalByte ( )
b [ 2 ] = p . Photon3 . MarshalByte ( )
b [ 3 ] = p . Wavesculptor . MarshalByte ( )
b [ 4 ] = p . Internal . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * FlightComputerInternalState ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 5 {
return & BadLengthError { expected : 5 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . Bms . UnmarshalByte ( b [ 0 ] )
p . Charger . UnmarshalByte ( b [ 1 ] )
p . Photon3 . UnmarshalByte ( b [ 2 ] )
p . Wavesculptor . UnmarshalByte ( b [ 3 ] )
p . Internal . UnmarshalByte ( b [ 4 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * FlightComputerInternalState ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "flight_computer_internal_state"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// PowerToDrive is calculated power required to drive the vehicle
type PowerToDrive struct {
MovingAverage100 int16 ` json:"moving_average_100" `
2024-03-07 19:29:50 +00:00
MovingAverage1K int16 ` json:"moving_average_1k" `
2023-05-19 22:04:03 +00:00
MovingAverage10K int16 ` json:"moving_average_10k" `
}
2024-02-12 20:38:01 +00:00
func ( p * PowerToDrive ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x19E
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * PowerToDrive ) Size ( ) uint {
return 6
}
func ( p * PowerToDrive ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 6 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , uint16 ( p . MovingAverage100 ) )
binary . LittleEndian . PutUint16 ( b [ 2 : ] , uint16 ( p . MovingAverage1K ) )
binary . LittleEndian . PutUint16 ( b [ 4 : ] , uint16 ( p . MovingAverage10K ) )
return b , nil
}
func ( p * PowerToDrive ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 6 {
return & BadLengthError { expected : 6 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . MovingAverage100 = int16 ( binary . LittleEndian . Uint16 ( b [ 0 : ] ) )
p . MovingAverage1K = int16 ( binary . LittleEndian . Uint16 ( b [ 2 : ] ) )
p . MovingAverage10K = int16 ( binary . LittleEndian . Uint16 ( b [ 4 : ] ) )
return nil
}
func ( p * PowerToDrive ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "power_to_drive"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// ArrayPower is array power calculated from current and voltage measurements
type ArrayPower struct {
FrontArrayChannel0 uint16 ` json:"front_array_channel_0" `
FrontArrayChannel1 uint16 ` json:"front_array_channel_1" `
2024-03-07 19:29:50 +00:00
RearArrayChannel0 uint16 ` json:"rear_array_channel_0" `
RearArrayChannel1 uint16 ` json:"rear_array_channel_1" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * ArrayPower ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x19F
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * ArrayPower ) Size ( ) uint {
return 8
}
func ( p * ArrayPower ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , p . FrontArrayChannel0 )
binary . LittleEndian . PutUint16 ( b [ 2 : ] , p . FrontArrayChannel1 )
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . RearArrayChannel0 )
binary . LittleEndian . PutUint16 ( b [ 6 : ] , p . RearArrayChannel1 )
return b , nil
}
func ( p * ArrayPower ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . FrontArrayChannel0 = binary . LittleEndian . Uint16 ( b [ 0 : ] )
p . FrontArrayChannel1 = binary . LittleEndian . Uint16 ( b [ 2 : ] )
p . RearArrayChannel0 = binary . LittleEndian . Uint16 ( b [ 4 : ] )
p . RearArrayChannel1 = binary . LittleEndian . Uint16 ( b [ 6 : ] )
return nil
}
func ( p * ArrayPower ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "array_power"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
// ArrayEnergy is cumulative energy received from the array
type ArrayEnergy struct {
// 0 Joule
Energy float32 ` json:"energy" `
}
2024-02-12 20:38:01 +00:00
func ( p * ArrayEnergy ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x119
return c , nil
2024-02-12 15:45:23 +00:00
}
func ( p * ArrayEnergy ) Size ( ) uint {
return 4
}
func ( p * ArrayEnergy ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
float32ToBytes ( b [ 0 : ] , p . Energy , false )
return b , nil
}
func ( p * ArrayEnergy ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2024-02-12 15:45:23 +00:00
p . Energy = float32FromBytes ( b [ 0 : ] , false )
return nil
}
func ( p * ArrayEnergy ) String ( ) string {
return "array_energy"
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
// ArrayEnergyReset is resets cumulative energy received from the array
type ArrayEnergyReset struct {
// 0 Joule
Energy float32 ` json:"energy" `
}
2024-02-12 20:38:01 +00:00
func ( p * ArrayEnergyReset ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x120
return c , nil
2024-02-12 15:45:23 +00:00
}
func ( p * ArrayEnergyReset ) Size ( ) uint {
return 4
}
func ( p * ArrayEnergyReset ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
float32ToBytes ( b [ 0 : ] , p . Energy , false )
return b , nil
}
func ( p * ArrayEnergyReset ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2024-02-12 15:45:23 +00:00
p . Energy = float32FromBytes ( b [ 0 : ] , false )
return nil
}
func ( p * ArrayEnergyReset ) String ( ) string {
return "array_energy_reset"
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type VisionTurnSignalsCommandLights struct {
2024-03-07 19:29:50 +00:00
LeftTurnSignal bool ` json:"left_turn_signal" `
2023-05-19 22:04:03 +00:00
RightTurnSignal bool ` json:"right_turn_signal" `
2024-03-07 19:29:50 +00:00
Spare1 bool ` json:"spare_1" `
Spare2 bool ` json:"spare_2" `
Spare3 bool ` json:"spare_3" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionTurnSignalsCommandLights ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . LeftTurnSignal {
b |= 1 << 0
}
if p . RightTurnSignal {
b |= 1 << 1
}
if p . Spare1 {
b |= 1 << 2
}
if p . Spare2 {
b |= 1 << 3
}
if p . Spare3 {
b |= 1 << 4
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionTurnSignalsCommandLights ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . LeftTurnSignal = ( b & ( 1 << 0 ) ) != 0
p . RightTurnSignal = ( b & ( 1 << 1 ) ) != 0
p . Spare1 = ( b & ( 1 << 2 ) ) != 0
p . Spare2 = ( b & ( 1 << 3 ) ) != 0
p . Spare3 = ( b & ( 1 << 4 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// VisionTurnSignalsCommand is Command to have the vision board illuminate or turn off left, right, or both turn signals
type VisionTurnSignalsCommand struct {
Lights VisionTurnSignalsCommandLights ` json:"lights" `
}
2024-02-12 20:38:01 +00:00
func ( p * VisionTurnSignalsCommand ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x2B0
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * VisionTurnSignalsCommand ) Size ( ) uint {
return 1
}
func ( p * VisionTurnSignalsCommand ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . Lights . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * VisionTurnSignalsCommand ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . Lights . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * VisionTurnSignalsCommand ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "vision_turn_signals_command"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type VisionBrakeLightsCommandLights struct {
BrakeLights bool ` json:"brake_lights" `
2024-03-07 19:29:50 +00:00
Spare1 bool ` json:"spare_1" `
Spare2 bool ` json:"spare_2" `
Spare3 bool ` json:"spare_3" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionBrakeLightsCommandLights ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . BrakeLights {
b |= 1 << 0
}
if p . Spare1 {
b |= 1 << 1
}
if p . Spare2 {
b |= 1 << 2
}
if p . Spare3 {
b |= 1 << 3
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionBrakeLightsCommandLights ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . BrakeLights = ( b & ( 1 << 0 ) ) != 0
p . Spare1 = ( b & ( 1 << 1 ) ) != 0
p . Spare2 = ( b & ( 1 << 2 ) ) != 0
p . Spare3 = ( b & ( 1 << 3 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// VisionBrakeLightsCommand is Command to have the vision board illuminate or turn off the brake lights
type VisionBrakeLightsCommand struct {
Lights VisionBrakeLightsCommandLights ` json:"lights" `
}
2024-02-12 20:38:01 +00:00
func ( p * VisionBrakeLightsCommand ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x2B1
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * VisionBrakeLightsCommand ) Size ( ) uint {
return 1
}
func ( p * VisionBrakeLightsCommand ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . Lights . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * VisionBrakeLightsCommand ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . Lights . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * VisionBrakeLightsCommand ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "vision_brake_lights_command"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type VisionHeadlightsCommandLights struct {
Headlights bool ` json:"headlights" `
2024-03-07 19:29:50 +00:00
HighBeams bool ` json:"high_beams" `
Spare1 bool ` json:"spare_1" `
Spare2 bool ` json:"spare_2" `
Spare3 bool ` json:"spare_3" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionHeadlightsCommandLights ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . Headlights {
b |= 1 << 0
}
if p . HighBeams {
b |= 1 << 1
}
if p . Spare1 {
b |= 1 << 2
}
if p . Spare2 {
b |= 1 << 3
}
if p . Spare3 {
b |= 1 << 4
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionHeadlightsCommandLights ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . Headlights = ( b & ( 1 << 0 ) ) != 0
p . HighBeams = ( b & ( 1 << 1 ) ) != 0
p . Spare1 = ( b & ( 1 << 2 ) ) != 0
p . Spare2 = ( b & ( 1 << 3 ) ) != 0
p . Spare3 = ( b & ( 1 << 4 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// VisionHeadlightsCommand is Command to have the vision board illuminate or turn off the headlights and high beams
type VisionHeadlightsCommand struct {
2024-03-07 19:29:50 +00:00
Lights VisionHeadlightsCommandLights ` json:"lights" `
Brightness float32 ` json:"brightness" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * VisionHeadlightsCommand ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x2B2
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * VisionHeadlightsCommand ) Size ( ) uint {
return 5
}
func ( p * VisionHeadlightsCommand ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 5 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . Lights . MarshalByte ( )
2023-05-19 22:04:03 +00:00
float32ToBytes ( b [ 1 : ] , p . Brightness , false )
return b , nil
}
func ( p * VisionHeadlightsCommand ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 5 {
return & BadLengthError { expected : 5 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . Lights . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
p . Brightness = float32FromBytes ( b [ 1 : ] , false )
return nil
}
func ( p * VisionHeadlightsCommand ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "vision_headlights_command"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type VisionHornCommandHorn struct {
2024-03-07 19:29:50 +00:00
Horn bool ` json:"horn" `
2023-05-19 22:04:03 +00:00
Spare bool ` json:"spare" `
}
2023-05-29 00:39:03 +00:00
func ( p * VisionHornCommandHorn ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . Horn {
b |= 1 << 0
}
if p . Spare {
b |= 1 << 1
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionHornCommandHorn ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . Horn = ( b & ( 1 << 0 ) ) != 0
p . Spare = ( b & ( 1 << 1 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// VisionHornCommand is Command the vision board honk the horn, must be repeatedly sent otherwise the vision board will stop honking after a bit. See high_power.h for details.
type VisionHornCommand struct {
Horn VisionHornCommandHorn ` json:"horn" `
}
2024-02-12 20:38:01 +00:00
func ( p * VisionHornCommand ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x2B3
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * VisionHornCommand ) Size ( ) uint {
return 1
}
func ( p * VisionHornCommand ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . Horn . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * VisionHornCommand ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . Horn . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * VisionHornCommand ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "vision_horn_command"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type VisionArrayLatchesCommandArrayLatches struct {
ArrayFront bool ` json:"array_front" `
2024-03-07 19:29:50 +00:00
ArrayRear bool ` json:"array_rear" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionArrayLatchesCommandArrayLatches ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . ArrayFront {
b |= 1 << 0
}
if p . ArrayRear {
b |= 1 << 1
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionArrayLatchesCommandArrayLatches ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . ArrayFront = ( b & ( 1 << 0 ) ) != 0
p . ArrayRear = ( b & ( 1 << 1 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// VisionArrayLatchesCommand is Command the vision board to open the array latches
type VisionArrayLatchesCommand struct {
ArrayLatches VisionArrayLatchesCommandArrayLatches ` json:"array_latches" `
}
2024-02-12 20:38:01 +00:00
func ( p * VisionArrayLatchesCommand ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x2B4
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * VisionArrayLatchesCommand ) Size ( ) uint {
return 1
}
func ( p * VisionArrayLatchesCommand ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . ArrayLatches . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * VisionArrayLatchesCommand ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . ArrayLatches . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * VisionArrayLatchesCommand ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "vision_array_latches_command"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type VisionRearviewCommandCameras struct {
2024-03-07 19:29:50 +00:00
Left bool ` json:"left" `
2023-05-19 22:04:03 +00:00
Right bool ` json:"right" `
2024-03-07 19:29:50 +00:00
Rear bool ` json:"rear" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionRearviewCommandCameras ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . Left {
b |= 1 << 0
}
if p . Right {
b |= 1 << 1
}
if p . Rear {
b |= 1 << 2
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionRearviewCommandCameras ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . Left = ( b & ( 1 << 0 ) ) != 0
p . Right = ( b & ( 1 << 1 ) ) != 0
p . Rear = ( b & ( 1 << 2 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// VisionRearviewCommand is Command the vision board turn on the rear view cameras
type VisionRearviewCommand struct {
Cameras VisionRearviewCommandCameras ` json:"cameras" `
}
2024-02-12 20:38:01 +00:00
func ( p * VisionRearviewCommand ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x2B5
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * VisionRearviewCommand ) Size ( ) uint {
return 1
}
func ( p * VisionRearviewCommand ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . Cameras . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * VisionRearviewCommand ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . Cameras . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * VisionRearviewCommand ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "vision_rearview_command"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// TrackerEnable is Enables/disables power trackers. Use 0x610 for the channel transmitting the data packet on 0x600, 0x611 for 0x601, et cetera. Sending 1 in the enable byte turns the tracker on; sending 0 turns it off.
type TrackerEnable struct {
Enable uint8 ` json:"enable" `
// Idx is the packet index. The accepted range is 0-6
2023-05-22 13:41:37 +00:00
Idx uint32 ` json:"idx" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * TrackerEnable ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
2023-05-19 22:04:03 +00:00
if p . Idx >= 6 {
2024-03-07 19:29:50 +00:00
return c , & UnknownIdError { 0x610 }
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
c . Id = 0x610 + p . Idx
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * TrackerEnable ) Size ( ) uint {
return 1
}
func ( p * TrackerEnable ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
b [ 0 ] = p . Enable
return b , nil
}
func ( p * TrackerEnable ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Enable = b [ 0 ]
return nil
}
func ( p * TrackerEnable ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "tracker_enable"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// DistanceTraveled is distance of wavesculptor odometer
type DistanceTraveled struct {
// 0 m
TripDistance float32 ` json:"trip_distance" `
}
2024-02-12 20:38:01 +00:00
func ( p * DistanceTraveled ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x19D
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * DistanceTraveled ) Size ( ) uint {
return 4
}
func ( p * DistanceTraveled ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
float32ToBytes ( b [ 0 : ] , p . TripDistance , false )
return b , nil
}
func ( p * DistanceTraveled ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . TripDistance = float32FromBytes ( b [ 0 : ] , false )
return nil
}
func ( p * DistanceTraveled ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "distance_traveled"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type ChargerStateStateFlags struct {
ChargerPlugged bool ` json:"charger_plugged" `
}
2023-05-29 00:39:03 +00:00
func ( p * ChargerStateStateFlags ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . ChargerPlugged {
b |= 1 << 0
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * ChargerStateStateFlags ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . ChargerPlugged = ( b & ( 1 << 0 ) ) != 0
}
type ChargerStateFault struct {
2024-03-07 19:29:50 +00:00
CHARGEROVERVOLT bool ` json:"CHARGER_OVERVOLT" `
CHARGEROVERTEMP bool ` json:"CHARGER_OVERTEMP" `
CHARGERCANTIMEOUT bool ` json:"CHARGER_CAN_TIMEOUT" `
BATTERYHVKILL bool ` json:"BATTERY_HV_KILL" `
BATTERYUNDERVOLT bool ` json:"BATTERY_UNDERVOLT" `
BATTERYOVERVOLT bool ` json:"BATTERY_OVERVOLT" `
2023-05-19 22:04:03 +00:00
BATTERYCELLOVERTEMP bool ` json:"BATTERY_CELL_OVERTEMP" `
2024-03-07 19:29:50 +00:00
BATTERYCANTIMEOUT bool ` json:"BATTERY_CAN_TIMEOUT" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * ChargerStateFault ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . CHARGEROVERVOLT {
b |= 1 << 0
}
if p . CHARGEROVERTEMP {
b |= 1 << 1
}
if p . CHARGERCANTIMEOUT {
b |= 1 << 2
}
if p . BATTERYHVKILL {
b |= 1 << 3
}
if p . BATTERYUNDERVOLT {
b |= 1 << 4
}
if p . BATTERYOVERVOLT {
b |= 1 << 5
}
if p . BATTERYCELLOVERTEMP {
b |= 1 << 6
}
if p . BATTERYCANTIMEOUT {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * ChargerStateFault ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . CHARGEROVERVOLT = ( b & ( 1 << 0 ) ) != 0
p . CHARGEROVERTEMP = ( b & ( 1 << 1 ) ) != 0
p . CHARGERCANTIMEOUT = ( b & ( 1 << 2 ) ) != 0
p . BATTERYHVKILL = ( b & ( 1 << 3 ) ) != 0
p . BATTERYUNDERVOLT = ( b & ( 1 << 4 ) ) != 0
p . BATTERYOVERVOLT = ( b & ( 1 << 5 ) ) != 0
p . BATTERYCELLOVERTEMP = ( b & ( 1 << 6 ) ) != 0
p . BATTERYCANTIMEOUT = ( b & ( 1 << 7 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// ChargerState is Notifies whether the J1772 cable is plugged.
type ChargerState struct {
StateFlags ChargerStateStateFlags ` json:"state_flags" `
// 0.001 C
2024-03-07 19:29:50 +00:00
ChargerMaxTemp uint16 ` json:"charger_max_temp" `
Fault ChargerStateFault ` json:"fault" `
2023-05-19 22:04:03 +00:00
// 0 A
ChargingCurrent float32 ` json:"charging_current" `
}
2024-02-12 20:38:01 +00:00
func ( p * ChargerState ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x573
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * ChargerState ) Size ( ) uint {
return 8
}
func ( p * ChargerState ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . StateFlags . MarshalByte ( )
2023-05-19 22:04:03 +00:00
binary . LittleEndian . PutUint16 ( b [ 1 : ] , p . ChargerMaxTemp )
2023-05-29 00:39:03 +00:00
b [ 3 ] = p . Fault . MarshalByte ( )
2023-05-19 22:04:03 +00:00
float32ToBytes ( b [ 4 : ] , p . ChargingCurrent , false )
return b , nil
}
func ( p * ChargerState ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . StateFlags . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
p . ChargerMaxTemp = binary . LittleEndian . Uint16 ( b [ 1 : ] )
2023-05-29 00:39:03 +00:00
p . Fault . UnmarshalByte ( b [ 3 ] )
2023-05-19 22:04:03 +00:00
p . ChargingCurrent = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * ChargerState ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "charger_state"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type ChargerBmsRequestRequestFlags struct {
ChargingRequested bool ` json:"charging_requested" `
}
2023-05-29 00:39:03 +00:00
func ( p * ChargerBmsRequestRequestFlags ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . ChargingRequested {
b |= 1 << 0
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * ChargerBmsRequestRequestFlags ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . ChargingRequested = ( b & ( 1 << 0 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// ChargerBmsRequest is Request packet for sending contactor commands from the charger to BP.
type ChargerBmsRequest struct {
RequestFlags ChargerBmsRequestRequestFlags ` json:"request_flags" `
}
2024-02-12 20:38:01 +00:00
func ( p * ChargerBmsRequest ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x74
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * ChargerBmsRequest ) Size ( ) uint {
return 1
}
func ( p * ChargerBmsRequest ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . RequestFlags . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * ChargerBmsRequest ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . RequestFlags . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * ChargerBmsRequest ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "charger_bms_request"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// ChargerCurrentVoltage is Packet to request charging current/voltage set
type ChargerCurrentVoltage struct {
// 0 A
MaxCurrent float32 ` json:"max_current" `
// 0 kWh
MaxCapacity float32 ` json:"max_capacity" `
}
2024-02-12 20:38:01 +00:00
func ( p * ChargerCurrentVoltage ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x576
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * ChargerCurrentVoltage ) Size ( ) uint {
return 8
}
func ( p * ChargerCurrentVoltage ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . MaxCurrent , false )
float32ToBytes ( b [ 4 : ] , p . MaxCapacity , false )
return b , nil
}
func ( p * ChargerCurrentVoltage ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . MaxCurrent = float32FromBytes ( b [ 0 : ] , false )
p . MaxCapacity = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * ChargerCurrentVoltage ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "charger_current_voltage"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// ChargerPower is Outputs the amount of power that the chargers are delivering.
type ChargerPower struct {
// 0 W
Power float32 ` json:"power" `
}
2024-02-12 20:38:01 +00:00
func ( p * ChargerPower ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x577
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * ChargerPower ) Size ( ) uint {
return 4
}
func ( p * ChargerPower ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
float32ToBytes ( b [ 0 : ] , p . Power , false )
return b , nil
}
func ( p * ChargerPower ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Power = float32FromBytes ( b [ 0 : ] , false )
return nil
}
func ( p * ChargerPower ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "charger_power"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// ThunderstruckControlMessage is Control packet for thunderstruck chargers
type ThunderstruckControlMessage struct {
// 1 V
Enable uint8 ` json:"Enable" `
// 1 V
CHARGEVOLTAGE uint16 ` json:"CHARGE_VOLTAGE" `
// 1 V
CHARGECURRENT uint16 ` json:"CHARGE_CURRENT" `
// 1 V
LEDBLINKPATTERN uint8 ` json:"LED_BLINK_PATTERN" `
// 1 V
RESERVED uint16 ` json:"RESERVED" `
}
2024-02-12 20:38:01 +00:00
func ( p * ThunderstruckControlMessage ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : true }
c . Id = 0x18E54024
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * ThunderstruckControlMessage ) Size ( ) uint {
return 8
}
func ( p * ThunderstruckControlMessage ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
b [ 0 ] = p . Enable
binary . LittleEndian . PutUint16 ( b [ 1 : ] , p . CHARGEVOLTAGE )
binary . LittleEndian . PutUint16 ( b [ 3 : ] , p . CHARGECURRENT )
b [ 5 ] = p . LEDBLINKPATTERN
binary . LittleEndian . PutUint16 ( b [ 6 : ] , p . RESERVED )
return b , nil
}
func ( p * ThunderstruckControlMessage ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Enable = b [ 0 ]
p . CHARGEVOLTAGE = binary . LittleEndian . Uint16 ( b [ 1 : ] )
p . CHARGECURRENT = binary . LittleEndian . Uint16 ( b [ 3 : ] )
p . LEDBLINKPATTERN = b [ 5 ]
p . RESERVED = binary . LittleEndian . Uint16 ( b [ 6 : ] )
return nil
}
func ( p * ThunderstruckControlMessage ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "thunderstruck_control_message"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type VisionStatusFrontLights struct {
2024-03-07 19:29:50 +00:00
LeftTurnSignal bool ` json:"left_turn_signal" `
2023-05-19 22:04:03 +00:00
RightTurnSignal bool ` json:"right_turn_signal" `
2024-03-07 19:29:50 +00:00
BrakeLights bool ` json:"brake_lights" `
Headlights bool ` json:"headlights" `
HighBeams bool ` json:"high_beams" `
Spare1 bool ` json:"spare_1" `
Spare2 bool ` json:"spare_2" `
Spare3 bool ` json:"spare_3" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusFrontLights ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . LeftTurnSignal {
b |= 1 << 0
}
if p . RightTurnSignal {
b |= 1 << 1
}
if p . BrakeLights {
b |= 1 << 2
}
if p . Headlights {
b |= 1 << 3
}
if p . HighBeams {
b |= 1 << 4
}
if p . Spare1 {
b |= 1 << 5
}
if p . Spare2 {
b |= 1 << 6
}
if p . Spare3 {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusFrontLights ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . LeftTurnSignal = ( b & ( 1 << 0 ) ) != 0
p . RightTurnSignal = ( b & ( 1 << 1 ) ) != 0
p . BrakeLights = ( b & ( 1 << 2 ) ) != 0
p . Headlights = ( b & ( 1 << 3 ) ) != 0
p . HighBeams = ( b & ( 1 << 4 ) ) != 0
p . Spare1 = ( b & ( 1 << 5 ) ) != 0
p . Spare2 = ( b & ( 1 << 6 ) ) != 0
p . Spare3 = ( b & ( 1 << 7 ) ) != 0
}
type VisionStatusFrontHorn struct {
2024-03-07 19:29:50 +00:00
Horn bool ` json:"horn" `
2023-05-19 22:04:03 +00:00
Spare bool ` json:"spare" `
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusFrontHorn ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . Horn {
b |= 1 << 0
}
if p . Spare {
b |= 1 << 1
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusFrontHorn ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . Horn = ( b & ( 1 << 0 ) ) != 0
p . Spare = ( b & ( 1 << 1 ) ) != 0
}
type VisionStatusFrontCameras struct {
2024-03-07 19:29:50 +00:00
Left bool ` json:"left" `
2023-05-19 22:04:03 +00:00
Right bool ` json:"right" `
2024-03-07 19:29:50 +00:00
Rear bool ` json:"rear" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusFrontCameras ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . Left {
b |= 1 << 0
}
if p . Right {
b |= 1 << 1
}
if p . Rear {
b |= 1 << 2
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusFrontCameras ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . Left = ( b & ( 1 << 0 ) ) != 0
p . Right = ( b & ( 1 << 1 ) ) != 0
p . Rear = ( b & ( 1 << 2 ) ) != 0
}
type VisionStatusFrontArrayLatches struct {
ArrayFront0 bool ` json:"array_front_0" `
ArrayFront1 bool ` json:"array_front_1" `
2024-03-07 19:29:50 +00:00
ArrayRear0 bool ` json:"array_rear_0" `
ArrayRear1 bool ` json:"array_rear_1" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusFrontArrayLatches ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . ArrayFront0 {
b |= 1 << 0
}
if p . ArrayFront1 {
b |= 1 << 1
}
if p . ArrayRear0 {
b |= 1 << 2
}
if p . ArrayRear1 {
b |= 1 << 3
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusFrontArrayLatches ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . ArrayFront0 = ( b & ( 1 << 0 ) ) != 0
p . ArrayFront1 = ( b & ( 1 << 1 ) ) != 0
p . ArrayRear0 = ( b & ( 1 << 2 ) ) != 0
p . ArrayRear1 = ( b & ( 1 << 3 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// VisionStatusFront is Status of the front vision board outputs
type VisionStatusFront struct {
2024-03-07 19:29:50 +00:00
Lights VisionStatusFrontLights ` json:"lights" `
Horn VisionStatusFrontHorn ` json:"horn" `
Cameras VisionStatusFrontCameras ` json:"cameras" `
2023-05-19 22:04:03 +00:00
ArrayLatches VisionStatusFrontArrayLatches ` json:"array_latches" `
}
2024-02-12 20:38:01 +00:00
func ( p * VisionStatusFront ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x2B6
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * VisionStatusFront ) Size ( ) uint {
return 4
}
func ( p * VisionStatusFront ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . Lights . MarshalByte ( )
b [ 1 ] = p . Horn . MarshalByte ( )
b [ 2 ] = p . Cameras . MarshalByte ( )
b [ 3 ] = p . ArrayLatches . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * VisionStatusFront ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . Lights . UnmarshalByte ( b [ 0 ] )
p . Horn . UnmarshalByte ( b [ 1 ] )
p . Cameras . UnmarshalByte ( b [ 2 ] )
p . ArrayLatches . UnmarshalByte ( b [ 3 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * VisionStatusFront ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "vision_status_front"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type VisionStatusRearLights struct {
2024-03-07 19:29:50 +00:00
LeftTurnSignal bool ` json:"left_turn_signal" `
2023-05-19 22:04:03 +00:00
RightTurnSignal bool ` json:"right_turn_signal" `
2024-03-07 19:29:50 +00:00
BrakeLights bool ` json:"brake_lights" `
Headlights bool ` json:"headlights" `
HighBeams bool ` json:"high_beams" `
Spare1 bool ` json:"spare_1" `
Spare2 bool ` json:"spare_2" `
Spare3 bool ` json:"spare_3" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusRearLights ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . LeftTurnSignal {
b |= 1 << 0
}
if p . RightTurnSignal {
b |= 1 << 1
}
if p . BrakeLights {
b |= 1 << 2
}
if p . Headlights {
b |= 1 << 3
}
if p . HighBeams {
b |= 1 << 4
}
if p . Spare1 {
b |= 1 << 5
}
if p . Spare2 {
b |= 1 << 6
}
if p . Spare3 {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusRearLights ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . LeftTurnSignal = ( b & ( 1 << 0 ) ) != 0
p . RightTurnSignal = ( b & ( 1 << 1 ) ) != 0
p . BrakeLights = ( b & ( 1 << 2 ) ) != 0
p . Headlights = ( b & ( 1 << 3 ) ) != 0
p . HighBeams = ( b & ( 1 << 4 ) ) != 0
p . Spare1 = ( b & ( 1 << 5 ) ) != 0
p . Spare2 = ( b & ( 1 << 6 ) ) != 0
p . Spare3 = ( b & ( 1 << 7 ) ) != 0
}
type VisionStatusRearHorn struct {
2024-03-07 19:29:50 +00:00
Horn bool ` json:"horn" `
2023-05-19 22:04:03 +00:00
Spare bool ` json:"spare" `
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusRearHorn ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . Horn {
b |= 1 << 0
}
if p . Spare {
b |= 1 << 1
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusRearHorn ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . Horn = ( b & ( 1 << 0 ) ) != 0
p . Spare = ( b & ( 1 << 1 ) ) != 0
}
type VisionStatusRearCameras struct {
2024-03-07 19:29:50 +00:00
Left bool ` json:"left" `
2023-05-19 22:04:03 +00:00
Right bool ` json:"right" `
2024-03-07 19:29:50 +00:00
Rear bool ` json:"rear" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusRearCameras ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . Left {
b |= 1 << 0
}
if p . Right {
b |= 1 << 1
}
if p . Rear {
b |= 1 << 2
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusRearCameras ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . Left = ( b & ( 1 << 0 ) ) != 0
p . Right = ( b & ( 1 << 1 ) ) != 0
p . Rear = ( b & ( 1 << 2 ) ) != 0
}
type VisionStatusRearArrayLatches struct {
ArrayFront0 bool ` json:"array_front_0" `
ArrayFront1 bool ` json:"array_front_1" `
2024-03-07 19:29:50 +00:00
ArrayRear0 bool ` json:"array_rear_0" `
ArrayRear1 bool ` json:"array_rear_1" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusRearArrayLatches ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . ArrayFront0 {
b |= 1 << 0
}
if p . ArrayFront1 {
b |= 1 << 1
}
if p . ArrayRear0 {
b |= 1 << 2
}
if p . ArrayRear1 {
b |= 1 << 3
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * VisionStatusRearArrayLatches ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . ArrayFront0 = ( b & ( 1 << 0 ) ) != 0
p . ArrayFront1 = ( b & ( 1 << 1 ) ) != 0
p . ArrayRear0 = ( b & ( 1 << 2 ) ) != 0
p . ArrayRear1 = ( b & ( 1 << 3 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// VisionStatusRear is Status of the rear vision board outputs
type VisionStatusRear struct {
2024-03-07 19:29:50 +00:00
Lights VisionStatusRearLights ` json:"lights" `
Horn VisionStatusRearHorn ` json:"horn" `
Cameras VisionStatusRearCameras ` json:"cameras" `
2023-05-19 22:04:03 +00:00
ArrayLatches VisionStatusRearArrayLatches ` json:"array_latches" `
}
2024-02-12 20:38:01 +00:00
func ( p * VisionStatusRear ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x2B7
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * VisionStatusRear ) Size ( ) uint {
return 4
}
func ( p * VisionStatusRear ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . Lights . MarshalByte ( )
b [ 1 ] = p . Horn . MarshalByte ( )
b [ 2 ] = p . Cameras . MarshalByte ( )
b [ 3 ] = p . ArrayLatches . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * VisionStatusRear ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . Lights . UnmarshalByte ( b [ 0 ] )
p . Horn . UnmarshalByte ( b [ 1 ] )
p . Cameras . UnmarshalByte ( b [ 2 ] )
p . ArrayLatches . UnmarshalByte ( b [ 3 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * VisionStatusRear ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "vision_status_rear"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// LightsFrontId is Unique identification packet for front lights board
type LightsFrontId struct {
BoardId uint16 ` json:"board_id" `
// 0.01 C
McuTemp int16 ` json:"mcu_temp" `
// 0.001 V
BusVoltage uint16 ` json:"bus_voltage" `
2024-03-07 19:29:50 +00:00
FaultCode uint16 ` json:"fault_code" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * LightsFrontId ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x300
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * LightsFrontId ) Size ( ) uint {
return 8
}
func ( p * LightsFrontId ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , p . BoardId )
binary . LittleEndian . PutUint16 ( b [ 2 : ] , uint16 ( p . McuTemp ) )
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . BusVoltage )
binary . LittleEndian . PutUint16 ( b [ 6 : ] , p . FaultCode )
return b , nil
}
func ( p * LightsFrontId ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . BoardId = binary . LittleEndian . Uint16 ( b [ 0 : ] )
p . McuTemp = int16 ( binary . LittleEndian . Uint16 ( b [ 2 : ] ) )
p . BusVoltage = binary . LittleEndian . Uint16 ( b [ 4 : ] )
p . FaultCode = binary . LittleEndian . Uint16 ( b [ 6 : ] )
return nil
}
func ( p * LightsFrontId ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "lights_front_id"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// LightsBackId is Unique identification packet for back lights board
type LightsBackId struct {
BoardId uint16 ` json:"board_id" `
// 0.01 C
McuTemp int16 ` json:"mcu_temp" `
// 0.001 V
BusVoltage uint16 ` json:"bus_voltage" `
2024-03-07 19:29:50 +00:00
FaultCode uint16 ` json:"fault_code" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * LightsBackId ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x301
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * LightsBackId ) Size ( ) uint {
return 8
}
func ( p * LightsBackId ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , p . BoardId )
binary . LittleEndian . PutUint16 ( b [ 2 : ] , uint16 ( p . McuTemp ) )
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . BusVoltage )
binary . LittleEndian . PutUint16 ( b [ 6 : ] , p . FaultCode )
return b , nil
}
func ( p * LightsBackId ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . BoardId = binary . LittleEndian . Uint16 ( b [ 0 : ] )
p . McuTemp = int16 ( binary . LittleEndian . Uint16 ( b [ 2 : ] ) )
p . BusVoltage = binary . LittleEndian . Uint16 ( b [ 4 : ] )
p . FaultCode = binary . LittleEndian . Uint16 ( b [ 6 : ] )
return nil
}
func ( p * LightsBackId ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "lights_back_id"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// VisionId is Unique identification packet for vision
type VisionId struct {
BoardId uint16 ` json:"board_id" `
// 0.01 C
McuTemp int16 ` json:"mcu_temp" `
// 0.001 V
BusVoltage uint16 ` json:"bus_voltage" `
2024-03-07 19:29:50 +00:00
FaultCode uint16 ` json:"fault_code" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * VisionId ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x302
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * VisionId ) Size ( ) uint {
return 8
}
func ( p * VisionId ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , p . BoardId )
binary . LittleEndian . PutUint16 ( b [ 2 : ] , uint16 ( p . McuTemp ) )
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . BusVoltage )
binary . LittleEndian . PutUint16 ( b [ 6 : ] , p . FaultCode )
return b , nil
}
func ( p * VisionId ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . BoardId = binary . LittleEndian . Uint16 ( b [ 0 : ] )
p . McuTemp = int16 ( binary . LittleEndian . Uint16 ( b [ 2 : ] ) )
p . BusVoltage = binary . LittleEndian . Uint16 ( b [ 4 : ] )
p . FaultCode = binary . LittleEndian . Uint16 ( b [ 6 : ] )
return nil
}
func ( p * VisionId ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "vision_id"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// SteeringPressCount1 is Shows whether each button has been toggled an even ("on") or odd ("off") number of times.
type SteeringPressCount1 struct {
Button0 uint8 ` json:"button0" `
Button1 uint8 ` json:"button1" `
Button2 uint8 ` json:"button2" `
Button3 uint8 ` json:"button3" `
Button4 uint8 ` json:"button4" `
Button5 uint8 ` json:"button5" `
Button6 uint8 ` json:"button6" `
}
2024-02-12 20:38:01 +00:00
func ( p * SteeringPressCount1 ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x240
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * SteeringPressCount1 ) Size ( ) uint {
return 7
}
func ( p * SteeringPressCount1 ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 7 )
b [ 0 ] = p . Button0
b [ 1 ] = p . Button1
b [ 2 ] = p . Button2
b [ 3 ] = p . Button3
b [ 4 ] = p . Button4
b [ 5 ] = p . Button5
b [ 6 ] = p . Button6
return b , nil
}
func ( p * SteeringPressCount1 ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 7 {
return & BadLengthError { expected : 7 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Button0 = b [ 0 ]
p . Button1 = b [ 1 ]
p . Button2 = b [ 2 ]
p . Button3 = b [ 3 ]
p . Button4 = b [ 4 ]
p . Button5 = b [ 5 ]
p . Button6 = b [ 6 ]
return nil
}
func ( p * SteeringPressCount1 ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "steering_press_count_1"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// SteeringPressCount2 is Shows whether each button has been toggled an even ("on") or odd ("off") number of times.
type SteeringPressCount2 struct {
2024-03-07 19:29:50 +00:00
Button7 uint8 ` json:"button7" `
Button8 uint8 ` json:"button8" `
Button9 uint8 ` json:"button9" `
2023-05-19 22:04:03 +00:00
Button10 uint8 ` json:"button10" `
}
2024-02-12 20:38:01 +00:00
func ( p * SteeringPressCount2 ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x250
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * SteeringPressCount2 ) Size ( ) uint {
return 4
}
func ( p * SteeringPressCount2 ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
b [ 0 ] = p . Button7
b [ 1 ] = p . Button8
b [ 2 ] = p . Button9
b [ 3 ] = p . Button10
return b , nil
}
func ( p * SteeringPressCount2 ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Button7 = b [ 0 ]
p . Button8 = b [ 1 ]
p . Button9 = b [ 2 ]
p . Button10 = b [ 3 ]
return nil
}
func ( p * SteeringPressCount2 ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "steering_press_count_2"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// SteeringButtonColors1 is This packet controls each button's color. Each byte is a hex color code.
type SteeringButtonColors1 struct {
Button0 uint8 ` json:"button0" `
Button1 uint8 ` json:"button1" `
Button2 uint8 ` json:"button2" `
Button3 uint8 ` json:"button3" `
Button4 uint8 ` json:"button4" `
Button5 uint8 ` json:"button5" `
Button6 uint8 ` json:"button6" `
}
2024-02-12 20:38:01 +00:00
func ( p * SteeringButtonColors1 ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x241
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * SteeringButtonColors1 ) Size ( ) uint {
return 7
}
func ( p * SteeringButtonColors1 ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 7 )
b [ 0 ] = p . Button0
b [ 1 ] = p . Button1
b [ 2 ] = p . Button2
b [ 3 ] = p . Button3
b [ 4 ] = p . Button4
b [ 5 ] = p . Button5
b [ 6 ] = p . Button6
return b , nil
}
func ( p * SteeringButtonColors1 ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 7 {
return & BadLengthError { expected : 7 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Button0 = b [ 0 ]
p . Button1 = b [ 1 ]
p . Button2 = b [ 2 ]
p . Button3 = b [ 3 ]
p . Button4 = b [ 4 ]
p . Button5 = b [ 5 ]
p . Button6 = b [ 6 ]
return nil
}
func ( p * SteeringButtonColors1 ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "steering_button_colors_1"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// SteeringButtonColors2 is This packet controls each button's color. Each byte is a hex color code.
type SteeringButtonColors2 struct {
2024-03-07 19:29:50 +00:00
Button7 uint8 ` json:"button7" `
Button8 uint8 ` json:"button8" `
Button9 uint8 ` json:"button9" `
2023-05-19 22:04:03 +00:00
Button10 uint8 ` json:"button10" `
}
2024-02-12 20:38:01 +00:00
func ( p * SteeringButtonColors2 ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x251
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * SteeringButtonColors2 ) Size ( ) uint {
return 4
}
func ( p * SteeringButtonColors2 ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
b [ 0 ] = p . Button7
b [ 1 ] = p . Button8
b [ 2 ] = p . Button9
b [ 3 ] = p . Button10
return b , nil
}
func ( p * SteeringButtonColors2 ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Button7 = b [ 0 ]
p . Button8 = b [ 1 ]
p . Button9 = b [ 2 ]
p . Button10 = b [ 3 ]
return nil
}
func ( p * SteeringButtonColors2 ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "steering_button_colors_2"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// SteeringHorn is This packet controls the state of the horn.
type SteeringHorn struct {
Horn uint8 ` json:"horn" `
}
2024-02-12 20:38:01 +00:00
func ( p * SteeringHorn ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x242
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * SteeringHorn ) Size ( ) uint {
return 1
}
func ( p * SteeringHorn ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
b [ 0 ] = p . Horn
return b , nil
}
func ( p * SteeringHorn ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Horn = b [ 0 ]
return nil
}
func ( p * SteeringHorn ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "steering_horn"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// ThunderstruckStatusMessage is Status packet for thunderstruck chargers
type ThunderstruckStatusMessage struct {
// 1 V
STATUSFLAGS uint8 ` json:"STATUS_FLAGS" `
// 1 V
CHARGEFLAGS uint8 ` json:"CHARGE_FLAGS" `
// 1 V
OUTPUTVOLTAGE uint16 ` json:"OUTPUT_VOLTAGE" `
// 1 V
OUTPUTCURRENT uint16 ` json:"OUTPUT_CURRENT" `
// 1 V
CHARGERTEMP uint8 ` json:"CHARGER_TEMP" `
// 1 V
RESERVED uint8 ` json:"RESERVED" `
}
2024-02-12 20:38:01 +00:00
func ( p * ThunderstruckStatusMessage ) CanId ( ) ( can . CanID , error ) {
2024-03-07 19:29:50 +00:00
c := can . CanID { Extended : false }
2024-02-12 20:38:01 +00:00
c . Id = 0x18EB2440
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * ThunderstruckStatusMessage ) Size ( ) uint {
return 8
}
func ( p * ThunderstruckStatusMessage ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
b [ 0 ] = p . STATUSFLAGS
b [ 1 ] = p . CHARGEFLAGS
binary . LittleEndian . PutUint16 ( b [ 2 : ] , p . OUTPUTVOLTAGE )
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . OUTPUTCURRENT )
b [ 6 ] = p . CHARGERTEMP
b [ 7 ] = p . RESERVED
return b , nil
}
func ( p * ThunderstruckStatusMessage ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . STATUSFLAGS = b [ 0 ]
p . CHARGEFLAGS = b [ 1 ]
p . OUTPUTVOLTAGE = binary . LittleEndian . Uint16 ( b [ 2 : ] )
p . OUTPUTCURRENT = binary . LittleEndian . Uint16 ( b [ 4 : ] )
p . CHARGERTEMP = b [ 6 ]
p . RESERVED = b [ 7 ]
return nil
}
func ( p * ThunderstruckStatusMessage ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "thunderstruck_status_message"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// TrackerData is Tracker data. Each channel transmits on a specific ID, which should be specified along with the tracker, most likely 0x600-0x603.
type TrackerData struct {
// 0.01 V
ArrayVoltage uint16 ` json:"array_voltage" `
// 0.001 A
ArrayCurrent uint16 ` json:"array_current" `
// 0.01 V
BatteryVoltage uint16 ` json:"battery_voltage" `
// 0.01 C
Temperature uint16 ` json:"temperature" `
// Idx is the packet index. The accepted range is 0-6
2023-05-22 13:41:37 +00:00
Idx uint32 ` json:"idx" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * TrackerData ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
2023-05-19 22:04:03 +00:00
if p . Idx >= 6 {
2024-03-07 19:29:50 +00:00
return c , & UnknownIdError { 0x600 }
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
c . Id = 0x600 + p . Idx
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * TrackerData ) Size ( ) uint {
return 8
}
func ( p * TrackerData ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
binary . LittleEndian . PutUint16 ( b [ 0 : ] , p . ArrayVoltage )
binary . LittleEndian . PutUint16 ( b [ 2 : ] , p . ArrayCurrent )
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . BatteryVoltage )
binary . LittleEndian . PutUint16 ( b [ 6 : ] , p . Temperature )
return b , nil
}
func ( p * TrackerData ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . ArrayVoltage = binary . LittleEndian . Uint16 ( b [ 0 : ] )
p . ArrayCurrent = binary . LittleEndian . Uint16 ( b [ 2 : ] )
p . BatteryVoltage = binary . LittleEndian . Uint16 ( b [ 4 : ] )
p . Temperature = binary . LittleEndian . Uint16 ( b [ 6 : ] )
return nil
}
func ( p * TrackerData ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "tracker_data"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
// TritiumMotorDriveL is Tritium Motor Drive Command
type TritiumMotorDriveL struct {
2023-05-19 22:04:03 +00:00
MotorVelocity float32 ` json:"motor_velocity" `
2024-03-07 19:29:50 +00:00
MotorCurrent float32 ` json:"motor_current" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * TritiumMotorDriveL ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x121
return c , nil
2023-05-19 22:04:03 +00:00
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumMotorDriveL ) Size ( ) uint {
2023-05-19 22:04:03 +00:00
return 8
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumMotorDriveL ) MarshalPacket ( ) ( [ ] byte , error ) {
2023-05-19 22:04:03 +00:00
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . MotorVelocity , false )
float32ToBytes ( b [ 4 : ] , p . MotorCurrent , false )
return b , nil
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumMotorDriveL ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . MotorVelocity = float32FromBytes ( b [ 0 : ] , false )
p . MotorCurrent = float32FromBytes ( b [ 4 : ] , false )
return nil
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumMotorDriveL ) String ( ) string {
return "tritium_motor_drive_l"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
// TritiumMotorPowerL is Tritium Motor Power Command
type TritiumMotorPowerL struct {
2024-03-07 19:29:50 +00:00
Reserved float32 ` json:"reserved" `
2023-05-19 22:04:03 +00:00
BusCurrent float32 ` json:"bus_current" `
}
2024-02-12 20:38:01 +00:00
func ( p * TritiumMotorPowerL ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x122
return c , nil
2023-05-19 22:04:03 +00:00
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumMotorPowerL ) Size ( ) uint {
2023-05-19 22:04:03 +00:00
return 8
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumMotorPowerL ) MarshalPacket ( ) ( [ ] byte , error ) {
2023-05-19 22:04:03 +00:00
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Reserved , false )
float32ToBytes ( b [ 4 : ] , p . BusCurrent , false )
return b , nil
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumMotorPowerL ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Reserved = float32FromBytes ( b [ 0 : ] , false )
p . BusCurrent = float32FromBytes ( b [ 4 : ] , false )
return nil
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumMotorPowerL ) String ( ) string {
return "tritium_motor_power_l"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
// TritiumResetL is Tritium Reset Command
type TritiumResetL struct {
2023-05-19 22:04:03 +00:00
Unused1 float32 ` json:"unused1" `
Unused2 float32 ` json:"unused2" `
}
2024-02-12 20:38:01 +00:00
func ( p * TritiumResetL ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x123
return c , nil
2023-05-19 22:04:03 +00:00
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumResetL ) Size ( ) uint {
return 8
}
func ( p * TritiumResetL ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Unused1 , false )
float32ToBytes ( b [ 4 : ] , p . Unused2 , false )
return b , nil
}
func ( p * TritiumResetL ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2024-02-12 15:45:23 +00:00
p . Unused1 = float32FromBytes ( b [ 0 : ] , false )
p . Unused2 = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * TritiumResetL ) String ( ) string {
return "tritium_reset_l"
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
// TritiumMotorDriveR is Tritium Motor Drive Command
type TritiumMotorDriveR struct {
MotorVelocity float32 ` json:"motor_velocity" `
2024-03-07 19:29:50 +00:00
MotorCurrent float32 ` json:"motor_current" `
2024-02-12 15:45:23 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * TritiumMotorDriveR ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x161
return c , nil
2024-02-12 15:45:23 +00:00
}
func ( p * TritiumMotorDriveR ) Size ( ) uint {
return 8
}
func ( p * TritiumMotorDriveR ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . MotorVelocity , false )
float32ToBytes ( b [ 4 : ] , p . MotorCurrent , false )
return b , nil
}
func ( p * TritiumMotorDriveR ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2024-02-12 15:45:23 +00:00
p . MotorVelocity = float32FromBytes ( b [ 0 : ] , false )
p . MotorCurrent = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * TritiumMotorDriveR ) String ( ) string {
return "tritium_motor_drive_r"
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
// TritiumMotorPowerR is Tritium Motor Power Command
type TritiumMotorPowerR struct {
2024-03-07 19:29:50 +00:00
Reserved float32 ` json:"reserved" `
2024-02-12 15:45:23 +00:00
BusCurrent float32 ` json:"bus_current" `
}
2024-02-12 20:38:01 +00:00
func ( p * TritiumMotorPowerR ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x162
return c , nil
2024-02-12 15:45:23 +00:00
}
func ( p * TritiumMotorPowerR ) Size ( ) uint {
return 8
}
func ( p * TritiumMotorPowerR ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Reserved , false )
float32ToBytes ( b [ 4 : ] , p . BusCurrent , false )
return b , nil
}
func ( p * TritiumMotorPowerR ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2024-02-12 15:45:23 +00:00
p . Reserved = float32FromBytes ( b [ 0 : ] , false )
p . BusCurrent = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * TritiumMotorPowerR ) String ( ) string {
return "tritium_motor_power_r"
}
2024-03-07 19:29:50 +00:00
2024-02-12 15:45:23 +00:00
// TritiumResetR is Tritium Reset Command
type TritiumResetR struct {
Unused1 float32 ` json:"unused1" `
Unused2 float32 ` json:"unused2" `
}
2024-02-12 20:38:01 +00:00
func ( p * TritiumResetR ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x163
return c , nil
2024-02-12 15:45:23 +00:00
}
func ( p * TritiumResetR ) Size ( ) uint {
2023-05-19 22:04:03 +00:00
return 8
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumResetR ) MarshalPacket ( ) ( [ ] byte , error ) {
2023-05-19 22:04:03 +00:00
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Unused1 , false )
float32ToBytes ( b [ 4 : ] , p . Unused2 , false )
return b , nil
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumResetR ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Unused1 = float32FromBytes ( b [ 0 : ] , false )
p . Unused2 = float32FromBytes ( b [ 4 : ] , false )
return nil
}
2024-02-12 15:45:23 +00:00
func ( p * TritiumResetR ) String ( ) string {
return "tritium_reset_r"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsAhSet is write state of charge, use with caution
type BmsAhSet struct {
Ah uint32 ` json:"ah" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsAhSet ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x16
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsAhSet ) Size ( ) uint {
return 4
}
func ( p * BmsAhSet ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
binary . LittleEndian . PutUint32 ( b [ 0 : ] , p . Ah )
return b , nil
}
func ( p * BmsAhSet ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Ah = binary . LittleEndian . Uint32 ( b [ 0 : ] )
return nil
}
func ( p * BmsAhSet ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_ah_set"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsWhSet is write state of charge, use with caution
type BmsWhSet struct {
Wh uint32 ` json:"wh" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsWhSet ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x17
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsWhSet ) Size ( ) uint {
return 4
}
func ( p * BmsWhSet ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 4 )
binary . LittleEndian . PutUint32 ( b [ 0 : ] , p . Wh )
return b , nil
}
func ( p * BmsWhSet ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 4 {
return & BadLengthError { expected : 4 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Wh = binary . LittleEndian . Uint32 ( b [ 0 : ] )
return nil
}
func ( p * BmsWhSet ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_wh_set"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type BmsKillKillType struct {
KILLHARD bool ` json:"KILL_HARD" `
}
2023-05-29 00:39:03 +00:00
func ( p * BmsKillKillType ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . KILLHARD {
b |= 1 << 0
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * BmsKillKillType ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . KILLHARD = ( b & ( 1 << 0 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// BmsKill is packet to cause BMS kill
type BmsKill struct {
KillType BmsKillKillType ` json:"kill_type" `
}
2024-02-12 20:38:01 +00:00
func ( p * BmsKill ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x1A
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * BmsKill ) Size ( ) uint {
return 1
}
func ( p * BmsKill ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 1 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . KillType . MarshalByte ( )
2023-05-19 22:04:03 +00:00
return b , nil
}
func ( p * BmsKill ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 1 {
return & BadLengthError { expected : 1 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . KillType . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
return nil
}
func ( p * BmsKill ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "bms_kill"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// TelemetryRtcReset is Reset telemetry's real-time clock (RTC).
type TelemetryRtcReset struct {
2024-03-07 19:29:50 +00:00
Year uint8 ` json:"year" `
Month uint8 ` json:"month" `
Day uint8 ` json:"day" `
Hour uint8 ` json:"hour" `
2023-05-19 22:04:03 +00:00
Minute uint8 ` json:"minute" `
Second uint8 ` json:"second" `
}
2024-02-12 20:38:01 +00:00
func ( p * TelemetryRtcReset ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x700
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * TelemetryRtcReset ) Size ( ) uint {
return 6
}
func ( p * TelemetryRtcReset ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 6 )
b [ 0 ] = p . Year
b [ 1 ] = p . Month
b [ 2 ] = p . Day
b [ 3 ] = p . Hour
b [ 4 ] = p . Minute
b [ 5 ] = p . Second
return b , nil
}
func ( p * TelemetryRtcReset ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 6 {
return & BadLengthError { expected : 6 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Year = b [ 0 ]
p . Month = b [ 1 ]
p . Day = b [ 2 ]
p . Hour = b [ 3 ]
p . Minute = b [ 4 ]
p . Second = b [ 5 ]
return nil
}
func ( p * TelemetryRtcReset ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "telemetry_rtc_reset"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrIdentification is WS RIGHT Identification Information
type WsrIdentification struct {
2024-03-07 19:29:50 +00:00
TritiumId uint32 ` json:"tritium_id" `
2023-05-19 22:04:03 +00:00
SerialNumber uint32 ` json:"serial_number" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrIdentification ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x140
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrIdentification ) Size ( ) uint {
return 8
}
func ( p * WsrIdentification ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
binary . LittleEndian . PutUint32 ( b [ 0 : ] , p . TritiumId )
binary . LittleEndian . PutUint32 ( b [ 4 : ] , p . SerialNumber )
return b , nil
}
func ( p * WsrIdentification ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . TritiumId = binary . LittleEndian . Uint32 ( b [ 0 : ] )
p . SerialNumber = binary . LittleEndian . Uint32 ( b [ 4 : ] )
return nil
}
func ( p * WsrIdentification ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_identification"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type WsrStatusInformationLimitFlags struct {
2024-03-07 19:29:50 +00:00
OutputVoltagePwm bool ` json:"output_voltage_pwm" `
MotorCurrent bool ` json:"motor_current" `
Velocity bool ` json:"velocity" `
BusCurrent bool ` json:"bus_current" `
BusVoltageUpperLimit bool ` json:"bus_voltage_upper_limit" `
BusVoltageLowerLimit bool ` json:"bus_voltage_lower_limit" `
2023-05-19 22:04:03 +00:00
IpmTemperatureOrMotorTemperature bool ` json:"ipm_temperature_or_motor_temperature" `
2024-03-07 19:29:50 +00:00
Reserved bool ` json:"reserved" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * WsrStatusInformationLimitFlags ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . OutputVoltagePwm {
b |= 1 << 0
}
if p . MotorCurrent {
b |= 1 << 1
}
if p . Velocity {
b |= 1 << 2
}
if p . BusCurrent {
b |= 1 << 3
}
if p . BusVoltageUpperLimit {
b |= 1 << 4
}
if p . BusVoltageLowerLimit {
b |= 1 << 5
}
if p . IpmTemperatureOrMotorTemperature {
b |= 1 << 6
}
if p . Reserved {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * WsrStatusInformationLimitFlags ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . OutputVoltagePwm = ( b & ( 1 << 0 ) ) != 0
p . MotorCurrent = ( b & ( 1 << 1 ) ) != 0
p . Velocity = ( b & ( 1 << 2 ) ) != 0
p . BusCurrent = ( b & ( 1 << 3 ) ) != 0
p . BusVoltageUpperLimit = ( b & ( 1 << 4 ) ) != 0
p . BusVoltageLowerLimit = ( b & ( 1 << 5 ) ) != 0
p . IpmTemperatureOrMotorTemperature = ( b & ( 1 << 6 ) ) != 0
p . Reserved = ( b & ( 1 << 7 ) ) != 0
}
type WsrStatusInformationErrorFlags0 struct {
2024-03-07 19:29:50 +00:00
HardwareOverCurrent bool ` json:"hardware_over_current" `
SoftwareOverCurrent bool ` json:"software_over_current" `
DcBusOverVoltage bool ` json:"dc_bus_over_voltage" `
2023-05-19 22:04:03 +00:00
BadMotorPositionHallSequence bool ` json:"bad_motor_position_hall_sequence" `
2024-03-07 19:29:50 +00:00
WatchdogCausedLastReset bool ` json:"watchdog_caused_last_reset" `
ConfigReadError bool ` json:"config_read_error" `
LvRailUnderVoltageLockOut bool ` json:"lv_rail_under_voltage_lock_out" `
DesaturationFault bool ` json:"desaturation_fault" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * WsrStatusInformationErrorFlags0 ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . HardwareOverCurrent {
b |= 1 << 0
}
if p . SoftwareOverCurrent {
b |= 1 << 1
}
if p . DcBusOverVoltage {
b |= 1 << 2
}
if p . BadMotorPositionHallSequence {
b |= 1 << 3
}
if p . WatchdogCausedLastReset {
b |= 1 << 4
}
if p . ConfigReadError {
b |= 1 << 5
}
if p . LvRailUnderVoltageLockOut {
b |= 1 << 6
}
if p . DesaturationFault {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * WsrStatusInformationErrorFlags0 ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . HardwareOverCurrent = ( b & ( 1 << 0 ) ) != 0
p . SoftwareOverCurrent = ( b & ( 1 << 1 ) ) != 0
p . DcBusOverVoltage = ( b & ( 1 << 2 ) ) != 0
p . BadMotorPositionHallSequence = ( b & ( 1 << 3 ) ) != 0
p . WatchdogCausedLastReset = ( b & ( 1 << 4 ) ) != 0
p . ConfigReadError = ( b & ( 1 << 5 ) ) != 0
p . LvRailUnderVoltageLockOut = ( b & ( 1 << 6 ) ) != 0
p . DesaturationFault = ( b & ( 1 << 7 ) ) != 0
}
type WsrStatusInformationErrorFlags1 struct {
MotorOverSpeed bool ` json:"motor_over_speed" `
2024-03-07 19:29:50 +00:00
Reserved9 bool ` json:"reserved_9" `
Reserved10 bool ` json:"reserved_10" `
Reserved11 bool ` json:"reserved_11" `
Reserved12 bool ` json:"reserved_12" `
Reserved13 bool ` json:"reserved_13" `
Reserved14 bool ` json:"reserved_14" `
Reserved15 bool ` json:"reserved_15" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * WsrStatusInformationErrorFlags1 ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . MotorOverSpeed {
b |= 1 << 0
}
if p . Reserved9 {
b |= 1 << 1
}
if p . Reserved10 {
b |= 1 << 2
}
if p . Reserved11 {
b |= 1 << 3
}
if p . Reserved12 {
b |= 1 << 4
}
if p . Reserved13 {
b |= 1 << 5
}
if p . Reserved14 {
b |= 1 << 6
}
if p . Reserved15 {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * WsrStatusInformationErrorFlags1 ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . MotorOverSpeed = ( b & ( 1 << 0 ) ) != 0
p . Reserved9 = ( b & ( 1 << 1 ) ) != 0
p . Reserved10 = ( b & ( 1 << 2 ) ) != 0
p . Reserved11 = ( b & ( 1 << 3 ) ) != 0
p . Reserved12 = ( b & ( 1 << 4 ) ) != 0
p . Reserved13 = ( b & ( 1 << 5 ) ) != 0
p . Reserved14 = ( b & ( 1 << 6 ) ) != 0
p . Reserved15 = ( b & ( 1 << 7 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrStatusInformation is WS RIGHT Status Information
type WsrStatusInformation struct {
2024-03-07 19:29:50 +00:00
LimitFlags WsrStatusInformationLimitFlags ` json:"limit_flags" `
LimitFlagsReserved uint8 ` json:"limit_flags_reserved" `
ErrorFlags0 WsrStatusInformationErrorFlags0 ` json:"error_flags_0" `
ErrorFlags1 WsrStatusInformationErrorFlags1 ` json:"error_flags_1" `
ActiveMotor uint16 ` json:"active_motor" `
Reserved uint16 ` json:"reserved" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * WsrStatusInformation ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x141
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrStatusInformation ) Size ( ) uint {
return 8
}
func ( p * WsrStatusInformation ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . LimitFlags . MarshalByte ( )
2023-05-19 22:04:03 +00:00
b [ 1 ] = p . LimitFlagsReserved
2023-05-29 00:39:03 +00:00
b [ 2 ] = p . ErrorFlags0 . MarshalByte ( )
b [ 3 ] = p . ErrorFlags1 . MarshalByte ( )
2023-05-19 22:04:03 +00:00
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . ActiveMotor )
binary . LittleEndian . PutUint16 ( b [ 6 : ] , p . Reserved )
return b , nil
}
func ( p * WsrStatusInformation ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . LimitFlags . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
p . LimitFlagsReserved = b [ 1 ]
2023-05-29 00:39:03 +00:00
p . ErrorFlags0 . UnmarshalByte ( b [ 2 ] )
p . ErrorFlags1 . UnmarshalByte ( b [ 3 ] )
2023-05-19 22:04:03 +00:00
p . ActiveMotor = binary . LittleEndian . Uint16 ( b [ 4 : ] )
p . Reserved = binary . LittleEndian . Uint16 ( b [ 6 : ] )
return nil
}
func ( p * WsrStatusInformation ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_status_information"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrBusMeasurement is WS RIGHT Bus Measurement
type WsrBusMeasurement struct {
// 0 V
BusVoltage float32 ` json:"bus_voltage" `
// 0 A
BusCurrent float32 ` json:"bus_current" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrBusMeasurement ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x142
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrBusMeasurement ) Size ( ) uint {
return 8
}
func ( p * WsrBusMeasurement ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . BusVoltage , false )
float32ToBytes ( b [ 4 : ] , p . BusCurrent , false )
return b , nil
}
func ( p * WsrBusMeasurement ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . BusVoltage = float32FromBytes ( b [ 0 : ] , false )
p . BusCurrent = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrBusMeasurement ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_bus_measurement"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrVelocity is WS RIGHT Velocity Measurement
type WsrVelocity struct {
// 0 rpm
MotorVelocity float32 ` json:"motor_velocity" `
// 0 m/s
VehicleVelocity float32 ` json:"vehicle_velocity" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrVelocity ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x143
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrVelocity ) Size ( ) uint {
return 8
}
func ( p * WsrVelocity ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . MotorVelocity , false )
float32ToBytes ( b [ 4 : ] , p . VehicleVelocity , false )
return b , nil
}
func ( p * WsrVelocity ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . MotorVelocity = float32FromBytes ( b [ 0 : ] , false )
p . VehicleVelocity = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrVelocity ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_velocity"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrPhaseCurrent is WS RIGHT Phase Current Measurement
type WsrPhaseCurrent struct {
// 0 A rms
PhaseBCurrent float32 ` json:"phase_b_current" `
// 0 A rms
PhaseCCurrent float32 ` json:"phase_c_current" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrPhaseCurrent ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x144
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrPhaseCurrent ) Size ( ) uint {
return 8
}
func ( p * WsrPhaseCurrent ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . PhaseBCurrent , false )
float32ToBytes ( b [ 4 : ] , p . PhaseCCurrent , false )
return b , nil
}
func ( p * WsrPhaseCurrent ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . PhaseBCurrent = float32FromBytes ( b [ 0 : ] , false )
p . PhaseCCurrent = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrPhaseCurrent ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_phase_current"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrMotorVoltageVector is WS RIGHT Motor Voltage Vector Measurement
type WsrMotorVoltageVector struct {
// 0 V
Vq float32 ` json:"vq" `
// 0 V
Vd float32 ` json:"vd" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrMotorVoltageVector ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x145
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrMotorVoltageVector ) Size ( ) uint {
return 8
}
func ( p * WsrMotorVoltageVector ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Vq , false )
float32ToBytes ( b [ 4 : ] , p . Vd , false )
return b , nil
}
func ( p * WsrMotorVoltageVector ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Vq = float32FromBytes ( b [ 0 : ] , false )
p . Vd = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrMotorVoltageVector ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_motor_voltage_vector"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrMotorCurrentVector is WS RIGHT Motor Current Vector Measurement
type WsrMotorCurrentVector struct {
// 0 A
Iq float32 ` json:"iq" `
// 0 A
Id float32 ` json:"id" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrMotorCurrentVector ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x146
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrMotorCurrentVector ) Size ( ) uint {
return 8
}
func ( p * WsrMotorCurrentVector ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Iq , false )
float32ToBytes ( b [ 4 : ] , p . Id , false )
return b , nil
}
func ( p * WsrMotorCurrentVector ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Iq = float32FromBytes ( b [ 0 : ] , false )
p . Id = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrMotorCurrentVector ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_motor_current_vector"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrMotorBackemf is WS RIGHT Motor BackEMF Measurement / Prediction
type WsrMotorBackemf struct {
// 0 V
Bemfq float32 ` json:"bemfq" `
// 0 V
Bemfd float32 ` json:"bemfd" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrMotorBackemf ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x147
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrMotorBackemf ) Size ( ) uint {
return 8
}
func ( p * WsrMotorBackemf ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Bemfq , false )
float32ToBytes ( b [ 4 : ] , p . Bemfd , false )
return b , nil
}
func ( p * WsrMotorBackemf ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Bemfq = float32FromBytes ( b [ 0 : ] , false )
p . Bemfd = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrMotorBackemf ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_motor_backemf"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// Wsr15165VoltageRail is WS RIGHT 15 and 1.65 Voltage Rail Measurement
type Wsr15165VoltageRail struct {
// 0 V
Reference165V float32 ` json:"reference_165v" `
// 0 V
Supply15V float32 ` json:"supply_15v" `
}
2024-02-12 20:38:01 +00:00
func ( p * Wsr15165VoltageRail ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x148
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * Wsr15165VoltageRail ) Size ( ) uint {
return 8
}
func ( p * Wsr15165VoltageRail ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Reference165V , false )
float32ToBytes ( b [ 4 : ] , p . Supply15V , false )
return b , nil
}
func ( p * Wsr15165VoltageRail ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Reference165V = float32FromBytes ( b [ 0 : ] , false )
p . Supply15V = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * Wsr15165VoltageRail ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_15_165_voltage_rail"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// Wsr2512VoltageRail is WS RIGHT 2.5V and 1.2V Voltage Rail Measurement
type Wsr2512VoltageRail struct {
// 0 V
Supply12V float32 ` json:"supply_12v" `
// 0 V
Supply25V float32 ` json:"supply_25v" `
}
2024-02-12 20:38:01 +00:00
func ( p * Wsr2512VoltageRail ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x149
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * Wsr2512VoltageRail ) Size ( ) uint {
return 8
}
func ( p * Wsr2512VoltageRail ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Supply12V , false )
float32ToBytes ( b [ 4 : ] , p . Supply25V , false )
return b , nil
}
func ( p * Wsr2512VoltageRail ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Supply12V = float32FromBytes ( b [ 0 : ] , false )
p . Supply25V = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * Wsr2512VoltageRail ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_25_12_voltage_rail"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrHeatsinkMotorTemp is WS RIGHT Heat-sink & Motor Temperature Measurement
type WsrHeatsinkMotorTemp struct {
// 0 C
MotorTemp float32 ` json:"motor_temp" `
// 0 C
HeatsinkTemp float32 ` json:"heatsink_temp" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrHeatsinkMotorTemp ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x14B
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrHeatsinkMotorTemp ) Size ( ) uint {
return 8
}
func ( p * WsrHeatsinkMotorTemp ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . MotorTemp , false )
float32ToBytes ( b [ 4 : ] , p . HeatsinkTemp , false )
return b , nil
}
func ( p * WsrHeatsinkMotorTemp ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . MotorTemp = float32FromBytes ( b [ 0 : ] , false )
p . HeatsinkTemp = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrHeatsinkMotorTemp ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_heatsink_motor_temp"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrDspBoardTemp is WS RIGHT DPS Board Temperature Measurement
type WsrDspBoardTemp struct {
// 0 C
DspBoardTemp float32 ` json:"dsp_board_temp" `
// 0 C
Reserved float32 ` json:"reserved" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrDspBoardTemp ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x14C
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrDspBoardTemp ) Size ( ) uint {
return 8
}
func ( p * WsrDspBoardTemp ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . DspBoardTemp , false )
float32ToBytes ( b [ 4 : ] , p . Reserved , false )
return b , nil
}
func ( p * WsrDspBoardTemp ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . DspBoardTemp = float32FromBytes ( b [ 0 : ] , false )
p . Reserved = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrDspBoardTemp ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_dsp_board_temp"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrReserved is WS RIGHT Reserved
type WsrReserved struct {
Reserved0 float32 ` json:"reserved0" `
Reserved1 float32 ` json:"reserved1" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrReserved ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x14D
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrReserved ) Size ( ) uint {
return 8
}
func ( p * WsrReserved ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Reserved0 , false )
float32ToBytes ( b [ 4 : ] , p . Reserved1 , false )
return b , nil
}
func ( p * WsrReserved ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Reserved0 = float32FromBytes ( b [ 0 : ] , false )
p . Reserved1 = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrReserved ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_reserved"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrOdometerBusAmphoursMeasurement is WS RIGHT Odometer and Bus AmpHours Measurement
type WsrOdometerBusAmphoursMeasurement struct {
// 0 m
Odometer float32 ` json:"odometer" `
// 0 Ah
DcBusAmphours float32 ` json:"dc_bus_amphours" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrOdometerBusAmphoursMeasurement ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x14E
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrOdometerBusAmphoursMeasurement ) Size ( ) uint {
return 8
}
func ( p * WsrOdometerBusAmphoursMeasurement ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Odometer , false )
float32ToBytes ( b [ 4 : ] , p . DcBusAmphours , false )
return b , nil
}
func ( p * WsrOdometerBusAmphoursMeasurement ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Odometer = float32FromBytes ( b [ 0 : ] , false )
p . DcBusAmphours = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrOdometerBusAmphoursMeasurement ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_odometer_bus_amphours_measurement"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WsrSlipSpeedMeasurement is WS RIGHT Slip Speed Measurement
type WsrSlipSpeedMeasurement struct {
// 0 C
Reserved float32 ` json:"reserved" `
// 0 Hz
SlipSpeed float32 ` json:"slip_speed" `
}
2024-02-12 20:38:01 +00:00
func ( p * WsrSlipSpeedMeasurement ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x157
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WsrSlipSpeedMeasurement ) Size ( ) uint {
return 8
}
func ( p * WsrSlipSpeedMeasurement ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Reserved , false )
float32ToBytes ( b [ 4 : ] , p . SlipSpeed , false )
return b , nil
}
func ( p * WsrSlipSpeedMeasurement ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Reserved = float32FromBytes ( b [ 0 : ] , false )
p . SlipSpeed = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WsrSlipSpeedMeasurement ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsr_slip_speed_measurement"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslIdentification is WS LEFT Identification Information
type WslIdentification struct {
2024-03-07 19:29:50 +00:00
TritiumId uint32 ` json:"tritium_id" `
2023-05-19 22:04:03 +00:00
SerialNumber uint32 ` json:"serial_number" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslIdentification ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x100
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslIdentification ) Size ( ) uint {
return 8
}
func ( p * WslIdentification ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
binary . LittleEndian . PutUint32 ( b [ 0 : ] , p . TritiumId )
binary . LittleEndian . PutUint32 ( b [ 4 : ] , p . SerialNumber )
return b , nil
}
func ( p * WslIdentification ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . TritiumId = binary . LittleEndian . Uint32 ( b [ 0 : ] )
p . SerialNumber = binary . LittleEndian . Uint32 ( b [ 4 : ] )
return nil
}
func ( p * WslIdentification ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_identification"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
type WslStatusInformationLimitFlags struct {
2024-03-07 19:29:50 +00:00
OutputVoltagePwm bool ` json:"output_voltage_pwm" `
MotorCurrent bool ` json:"motor_current" `
Velocity bool ` json:"velocity" `
BusCurrent bool ` json:"bus_current" `
BusVoltageUpperLimit bool ` json:"bus_voltage_upper_limit" `
BusVoltageLowerLimit bool ` json:"bus_voltage_lower_limit" `
2023-05-19 22:04:03 +00:00
IpmTemperatureOrMotorTemperature bool ` json:"ipm_temperature_or_motor_temperature" `
2024-03-07 19:29:50 +00:00
Reserved bool ` json:"reserved" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * WslStatusInformationLimitFlags ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . OutputVoltagePwm {
b |= 1 << 0
}
if p . MotorCurrent {
b |= 1 << 1
}
if p . Velocity {
b |= 1 << 2
}
if p . BusCurrent {
b |= 1 << 3
}
if p . BusVoltageUpperLimit {
b |= 1 << 4
}
if p . BusVoltageLowerLimit {
b |= 1 << 5
}
if p . IpmTemperatureOrMotorTemperature {
b |= 1 << 6
}
if p . Reserved {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * WslStatusInformationLimitFlags ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . OutputVoltagePwm = ( b & ( 1 << 0 ) ) != 0
p . MotorCurrent = ( b & ( 1 << 1 ) ) != 0
p . Velocity = ( b & ( 1 << 2 ) ) != 0
p . BusCurrent = ( b & ( 1 << 3 ) ) != 0
p . BusVoltageUpperLimit = ( b & ( 1 << 4 ) ) != 0
p . BusVoltageLowerLimit = ( b & ( 1 << 5 ) ) != 0
p . IpmTemperatureOrMotorTemperature = ( b & ( 1 << 6 ) ) != 0
p . Reserved = ( b & ( 1 << 7 ) ) != 0
}
type WslStatusInformationErrorFlags0 struct {
2024-03-07 19:29:50 +00:00
HardwareOverCurrent bool ` json:"hardware_over_current" `
SoftwareOverCurrent bool ` json:"software_over_current" `
DcBusOverVoltage bool ` json:"dc_bus_over_voltage" `
2023-05-19 22:04:03 +00:00
BadMotorPositionHallSequence bool ` json:"bad_motor_position_hall_sequence" `
2024-03-07 19:29:50 +00:00
WatchdogCausedLastReset bool ` json:"watchdog_caused_last_reset" `
ConfigReadError bool ` json:"config_read_error" `
LvRailUnderVoltageLockOut bool ` json:"lv_rail_under_voltage_lock_out" `
DesaturationFault bool ` json:"desaturation_fault" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * WslStatusInformationErrorFlags0 ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . HardwareOverCurrent {
b |= 1 << 0
}
if p . SoftwareOverCurrent {
b |= 1 << 1
}
if p . DcBusOverVoltage {
b |= 1 << 2
}
if p . BadMotorPositionHallSequence {
b |= 1 << 3
}
if p . WatchdogCausedLastReset {
b |= 1 << 4
}
if p . ConfigReadError {
b |= 1 << 5
}
if p . LvRailUnderVoltageLockOut {
b |= 1 << 6
}
if p . DesaturationFault {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * WslStatusInformationErrorFlags0 ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . HardwareOverCurrent = ( b & ( 1 << 0 ) ) != 0
p . SoftwareOverCurrent = ( b & ( 1 << 1 ) ) != 0
p . DcBusOverVoltage = ( b & ( 1 << 2 ) ) != 0
p . BadMotorPositionHallSequence = ( b & ( 1 << 3 ) ) != 0
p . WatchdogCausedLastReset = ( b & ( 1 << 4 ) ) != 0
p . ConfigReadError = ( b & ( 1 << 5 ) ) != 0
p . LvRailUnderVoltageLockOut = ( b & ( 1 << 6 ) ) != 0
p . DesaturationFault = ( b & ( 1 << 7 ) ) != 0
}
type WslStatusInformationErrorFlags1 struct {
MotorOverSpeed bool ` json:"motor_over_speed" `
2024-03-07 19:29:50 +00:00
Reserved9 bool ` json:"reserved_9" `
Reserved10 bool ` json:"reserved_10" `
Reserved11 bool ` json:"reserved_11" `
Reserved12 bool ` json:"reserved_12" `
Reserved13 bool ` json:"reserved_13" `
Reserved14 bool ` json:"reserved_14" `
Reserved15 bool ` json:"reserved_15" `
2023-05-19 22:04:03 +00:00
}
2023-05-29 00:39:03 +00:00
func ( p * WslStatusInformationErrorFlags1 ) MarshalByte ( ) byte {
2023-05-19 22:04:03 +00:00
var b byte
if p . MotorOverSpeed {
b |= 1 << 0
}
if p . Reserved9 {
b |= 1 << 1
}
if p . Reserved10 {
b |= 1 << 2
}
if p . Reserved11 {
b |= 1 << 3
}
if p . Reserved12 {
b |= 1 << 4
}
if p . Reserved13 {
b |= 1 << 5
}
if p . Reserved14 {
b |= 1 << 6
}
if p . Reserved15 {
b |= 1 << 7
}
return b
}
2023-05-29 00:39:03 +00:00
func ( p * WslStatusInformationErrorFlags1 ) UnmarshalByte ( b byte ) {
2023-05-19 22:04:03 +00:00
p . MotorOverSpeed = ( b & ( 1 << 0 ) ) != 0
p . Reserved9 = ( b & ( 1 << 1 ) ) != 0
p . Reserved10 = ( b & ( 1 << 2 ) ) != 0
p . Reserved11 = ( b & ( 1 << 3 ) ) != 0
p . Reserved12 = ( b & ( 1 << 4 ) ) != 0
p . Reserved13 = ( b & ( 1 << 5 ) ) != 0
p . Reserved14 = ( b & ( 1 << 6 ) ) != 0
p . Reserved15 = ( b & ( 1 << 7 ) ) != 0
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslStatusInformation is WS LEFT Status Information
type WslStatusInformation struct {
2024-03-07 19:29:50 +00:00
LimitFlags WslStatusInformationLimitFlags ` json:"limit_flags" `
LimitFlagsReserved uint8 ` json:"limit_flags_reserved" `
ErrorFlags0 WslStatusInformationErrorFlags0 ` json:"error_flags_0" `
ErrorFlags1 WslStatusInformationErrorFlags1 ` json:"error_flags_1" `
ActiveMotor uint16 ` json:"active_motor" `
Reserved uint16 ` json:"reserved" `
2023-05-19 22:04:03 +00:00
}
2024-02-12 20:38:01 +00:00
func ( p * WslStatusInformation ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x101
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslStatusInformation ) Size ( ) uint {
return 8
}
func ( p * WslStatusInformation ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
2023-05-29 00:39:03 +00:00
b [ 0 ] = p . LimitFlags . MarshalByte ( )
2023-05-19 22:04:03 +00:00
b [ 1 ] = p . LimitFlagsReserved
2023-05-29 00:39:03 +00:00
b [ 2 ] = p . ErrorFlags0 . MarshalByte ( )
b [ 3 ] = p . ErrorFlags1 . MarshalByte ( )
2023-05-19 22:04:03 +00:00
binary . LittleEndian . PutUint16 ( b [ 4 : ] , p . ActiveMotor )
binary . LittleEndian . PutUint16 ( b [ 6 : ] , p . Reserved )
return b , nil
}
func ( p * WslStatusInformation ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-29 00:39:03 +00:00
p . LimitFlags . UnmarshalByte ( b [ 0 ] )
2023-05-19 22:04:03 +00:00
p . LimitFlagsReserved = b [ 1 ]
2023-05-29 00:39:03 +00:00
p . ErrorFlags0 . UnmarshalByte ( b [ 2 ] )
p . ErrorFlags1 . UnmarshalByte ( b [ 3 ] )
2023-05-19 22:04:03 +00:00
p . ActiveMotor = binary . LittleEndian . Uint16 ( b [ 4 : ] )
p . Reserved = binary . LittleEndian . Uint16 ( b [ 6 : ] )
return nil
}
func ( p * WslStatusInformation ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_status_information"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslBusMeasurement is WS LEFT Bus Measurement
type WslBusMeasurement struct {
// 0 V
BusVoltage float32 ` json:"bus_voltage" `
// 0 A
BusCurrent float32 ` json:"bus_current" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslBusMeasurement ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x102
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslBusMeasurement ) Size ( ) uint {
return 8
}
func ( p * WslBusMeasurement ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . BusVoltage , false )
float32ToBytes ( b [ 4 : ] , p . BusCurrent , false )
return b , nil
}
func ( p * WslBusMeasurement ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . BusVoltage = float32FromBytes ( b [ 0 : ] , false )
p . BusCurrent = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslBusMeasurement ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_bus_measurement"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslVelocity is WS LEFT Velocity Measurement
type WslVelocity struct {
// 0 rpm
MotorVelocity float32 ` json:"motor_velocity" `
// 0 m/s
VehicleVelocity float32 ` json:"vehicle_velocity" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslVelocity ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x103
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslVelocity ) Size ( ) uint {
return 8
}
func ( p * WslVelocity ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . MotorVelocity , false )
float32ToBytes ( b [ 4 : ] , p . VehicleVelocity , false )
return b , nil
}
func ( p * WslVelocity ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . MotorVelocity = float32FromBytes ( b [ 0 : ] , false )
p . VehicleVelocity = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslVelocity ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_velocity"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslPhaseCurrent is WS LEFT Phase Current Measurement
type WslPhaseCurrent struct {
// 0 A rms
PhaseBCurrent float32 ` json:"phase_b_current" `
// 0 A rms
PhaseCCurrent float32 ` json:"phase_c_current" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslPhaseCurrent ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x104
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslPhaseCurrent ) Size ( ) uint {
return 8
}
func ( p * WslPhaseCurrent ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . PhaseBCurrent , false )
float32ToBytes ( b [ 4 : ] , p . PhaseCCurrent , false )
return b , nil
}
func ( p * WslPhaseCurrent ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . PhaseBCurrent = float32FromBytes ( b [ 0 : ] , false )
p . PhaseCCurrent = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslPhaseCurrent ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_phase_current"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslMotorVoltageVector is WS LEFT Motor Voltage Vector Measurement
type WslMotorVoltageVector struct {
// 0 V
Vq float32 ` json:"vq" `
// 0 V
Vd float32 ` json:"vd" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslMotorVoltageVector ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x105
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslMotorVoltageVector ) Size ( ) uint {
return 8
}
func ( p * WslMotorVoltageVector ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Vq , false )
float32ToBytes ( b [ 4 : ] , p . Vd , false )
return b , nil
}
func ( p * WslMotorVoltageVector ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Vq = float32FromBytes ( b [ 0 : ] , false )
p . Vd = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslMotorVoltageVector ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_motor_voltage_vector"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslMotorCurrentVector is WS LEFT Motor Current Vector Measurement
type WslMotorCurrentVector struct {
// 0 A
Iq float32 ` json:"iq" `
// 0 A
Id float32 ` json:"id" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslMotorCurrentVector ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x106
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslMotorCurrentVector ) Size ( ) uint {
return 8
}
func ( p * WslMotorCurrentVector ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Iq , false )
float32ToBytes ( b [ 4 : ] , p . Id , false )
return b , nil
}
func ( p * WslMotorCurrentVector ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Iq = float32FromBytes ( b [ 0 : ] , false )
p . Id = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslMotorCurrentVector ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_motor_current_vector"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslMotorBackemf is WS LEFT Motor BackEMF Measurement / Prediction
type WslMotorBackemf struct {
// 0 V
Bemfq float32 ` json:"bemfq" `
// 0 V
Bemfd float32 ` json:"bemfd" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslMotorBackemf ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x107
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslMotorBackemf ) Size ( ) uint {
return 8
}
func ( p * WslMotorBackemf ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Bemfq , false )
float32ToBytes ( b [ 4 : ] , p . Bemfd , false )
return b , nil
}
func ( p * WslMotorBackemf ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Bemfq = float32FromBytes ( b [ 0 : ] , false )
p . Bemfd = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslMotorBackemf ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_motor_backemf"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// Wsl15165VoltageRail is WS LEFT 15 and 1.65 Voltage Rail Measurement
type Wsl15165VoltageRail struct {
// 0 V
Reference165V float32 ` json:"reference_165v" `
// 0 V
Supply15V float32 ` json:"supply_15v" `
}
2024-02-12 20:38:01 +00:00
func ( p * Wsl15165VoltageRail ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x108
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * Wsl15165VoltageRail ) Size ( ) uint {
return 8
}
func ( p * Wsl15165VoltageRail ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Reference165V , false )
float32ToBytes ( b [ 4 : ] , p . Supply15V , false )
return b , nil
}
func ( p * Wsl15165VoltageRail ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Reference165V = float32FromBytes ( b [ 0 : ] , false )
p . Supply15V = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * Wsl15165VoltageRail ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_15_165_voltage_rail"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// Wsl2512VoltageRail is WS LEFT 2.5V and 1.2V Voltage Rail Measurement
type Wsl2512VoltageRail struct {
// 0 V
Supply12V float32 ` json:"supply_12v" `
// 0 V
Supply25V float32 ` json:"supply_25v" `
}
2024-02-12 20:38:01 +00:00
func ( p * Wsl2512VoltageRail ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x109
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * Wsl2512VoltageRail ) Size ( ) uint {
return 8
}
func ( p * Wsl2512VoltageRail ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Supply12V , false )
float32ToBytes ( b [ 4 : ] , p . Supply25V , false )
return b , nil
}
func ( p * Wsl2512VoltageRail ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Supply12V = float32FromBytes ( b [ 0 : ] , false )
p . Supply25V = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * Wsl2512VoltageRail ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_25_12_voltage_rail"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslHeatsinkMotorTemp is WS LEFT Heat-sink & Motor Temperature Measurement
type WslHeatsinkMotorTemp struct {
// 0 C
MotorTemp float32 ` json:"motor_temp" `
// 0 C
HeatsinkTemp float32 ` json:"heatsink_temp" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslHeatsinkMotorTemp ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x10B
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslHeatsinkMotorTemp ) Size ( ) uint {
return 8
}
func ( p * WslHeatsinkMotorTemp ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . MotorTemp , false )
float32ToBytes ( b [ 4 : ] , p . HeatsinkTemp , false )
return b , nil
}
func ( p * WslHeatsinkMotorTemp ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . MotorTemp = float32FromBytes ( b [ 0 : ] , false )
p . HeatsinkTemp = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslHeatsinkMotorTemp ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_heatsink_motor_temp"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslDspBoardTemp is WS LEFT DPS Board Temperature Measurement
type WslDspBoardTemp struct {
// 0 C
DspBoardTemp float32 ` json:"dsp_board_temp" `
// 0 C
Reserved float32 ` json:"reserved" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslDspBoardTemp ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x10C
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslDspBoardTemp ) Size ( ) uint {
return 8
}
func ( p * WslDspBoardTemp ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . DspBoardTemp , false )
float32ToBytes ( b [ 4 : ] , p . Reserved , false )
return b , nil
}
func ( p * WslDspBoardTemp ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . DspBoardTemp = float32FromBytes ( b [ 0 : ] , false )
p . Reserved = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslDspBoardTemp ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_dsp_board_temp"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslOdometerBusAmphoursMeasurement is WS LEFT Odometer and Bus AmpHours Measurement
type WslOdometerBusAmphoursMeasurement struct {
// 0 m
Odometer float32 ` json:"odometer" `
// 0 Ah
DcBusAmphours float32 ` json:"dc_bus_amphours" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslOdometerBusAmphoursMeasurement ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x10E
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslOdometerBusAmphoursMeasurement ) Size ( ) uint {
return 8
}
func ( p * WslOdometerBusAmphoursMeasurement ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Odometer , false )
float32ToBytes ( b [ 4 : ] , p . DcBusAmphours , false )
return b , nil
}
func ( p * WslOdometerBusAmphoursMeasurement ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Odometer = float32FromBytes ( b [ 0 : ] , false )
p . DcBusAmphours = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslOdometerBusAmphoursMeasurement ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_odometer_bus_amphours_measurement"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslReserved is WS LEFT Reserved
type WslReserved struct {
Reserved0 float32 ` json:"reserved0" `
Reserved1 float32 ` json:"reserved1" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslReserved ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x10D
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslReserved ) Size ( ) uint {
return 8
}
func ( p * WslReserved ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Reserved0 , false )
float32ToBytes ( b [ 4 : ] , p . Reserved1 , false )
return b , nil
}
func ( p * WslReserved ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Reserved0 = float32FromBytes ( b [ 0 : ] , false )
p . Reserved1 = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslReserved ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_reserved"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-05-19 22:04:03 +00:00
// WslSlipSpeedMeasurement is WS LEFT Slip Speed Measurement
type WslSlipSpeedMeasurement struct {
// 0 C
Reserved float32 ` json:"reserved" `
// 0 Hz
SlipSpeed float32 ` json:"slip_speed" `
}
2024-02-12 20:38:01 +00:00
func ( p * WslSlipSpeedMeasurement ) CanId ( ) ( can . CanID , error ) {
c := can . CanID { Extended : false }
c . Id = 0x117
return c , nil
2023-05-19 22:04:03 +00:00
}
func ( p * WslSlipSpeedMeasurement ) Size ( ) uint {
return 8
}
func ( p * WslSlipSpeedMeasurement ) MarshalPacket ( ) ( [ ] byte , error ) {
b := make ( [ ] byte , 8 )
float32ToBytes ( b [ 0 : ] , p . Reserved , false )
float32ToBytes ( b [ 4 : ] , p . SlipSpeed , false )
return b , nil
}
func ( p * WslSlipSpeedMeasurement ) UnmarshalPacket ( b [ ] byte ) error {
2024-02-29 00:41:01 +00:00
if len ( b ) != 8 {
return & BadLengthError { expected : 8 , actual : uint32 ( len ( b ) ) }
}
2023-05-19 22:04:03 +00:00
p . Reserved = float32FromBytes ( b [ 0 : ] , false )
p . SlipSpeed = float32FromBytes ( b [ 4 : ] , false )
return nil
}
func ( p * WslSlipSpeedMeasurement ) String ( ) string {
2023-05-22 17:16:48 +00:00
return "wsl_slip_speed_measurement"
2023-05-19 22:04:03 +00:00
}
2024-03-07 19:29:50 +00:00
2023-06-23 21:20:28 +00:00
// The json representation that was used to generate this data.
// can be used to share the parsing data for i.e dynamic python gui.
2024-03-07 19:29:50 +00:00
const SkylabDefinitions = ` { "packets" : [ { "name" : "bms_measurement" , "description" : "Voltages for main battery and aux pack" , "id" : 16 , "endian" : "little" , "data" : [ { "name" : "battery_voltage" , "type" : "uint16_t" , "units" : "V" , "conversion" : 0.01 } , { "name" : "aux_voltage" , "type" : "uint16_t" , "units" : "V" , "conversion" : 0.001 } , { "name" : "current" , "type" : "float" , "units" : "A" , "conversion" : 1 } ] } , { "name" : "battery_status" , "description" : "Status bits for the battery" , "id" : 17 , "endian" : "little" , "data" : [ { "name" : "battery_state" , "type" : "bitfield" , "bits" : [ { "name" : "startup" } , { "name" : "precharge" } , { "name" : "discharging" } , { "name" : "lv_only" } , { "name" : "charging" } , { "name" : "wall_charging" } , { "name" : "killed" } ] } , { "name" : "contactor_state" , "type" : "bitfield" , "bits" : [ { "name" : "battery_high_contactor" } , { "name" : "battery_low_contactor" } , { "name" : "battery_vicor_contactor" } , { "name" : "battery_pre_contactor" } , { "name" : "battery_high2_contactor" } , { "name" : "battery_low2_contactor" } , { "name" : "charger_high_contactor" } , { "name" : "charger_pre_contactor" } ] } , { "name" : "lv_channel_status" , "type" : "bitfield" , "bits" : [ { "name" : "aux_fault" } , { "name" : "main_fault" } , { "name" : "aux_power_valid" } , { "name" : "main_power_valid" } , { "name" : "aux_power_active" } , { "name" : "main_power_active" } ] } , { "name" : "lv_control_status" , "type" : "bitfield" , "bits" : [ { "name" : "aux_vicor_enable" } , { "name" : "bat_vicor_enable" } , { "name" : "aux_relay_held" } , { "name" : "aux_ref_enable" } , { "name" : "aux_charging_enable" } , { "name" : "kill_hv" } , { "name" : "kill_lv" } , { "name" : "start_button" } ] } , { "name" : "pack_choice" , "type" : "bitfield" , "bits" : [ { "name" : "large_pack" } , { "name" : "small_pack" } ] } ] } , { "name" : "bms_kill_reason" , "description" : "Information for when the car kills" , "id" : 18 , "endian" : "little" , "data" : [ { "name" : "reason1" , "type" : "bitfield" , "bits" : [ { "name" : "OVERVOLT" } , { "name" : "UNDERVOLT" } , { "name" : "OVERTEMP" } , { "name" : "TEMP_DISCONNECT" } , { "name" : "COMM_FAIL" } ] } , { "name" : "reason2" , "type" : "bitfield" , "bits" : [ { "name" : "HARDWARE" } , { "name" : "KILL_PACKET" } , { "name" : "UKNOWN" } , { "name" : "OVERCURRENT" } , { "name" : "PRECHARGE_FAIL" } , { "name" : "AUX_OVER_UNDER" } , { "name" : "AUX_OVERTEMP" } ] } , { "name" : "module" , "type" : "uint16_t" } , { "name" : "value" , "type" : "float" } ] } , { "name" : "bms_module_min_max" , "description" : "min and max cell voltages and temperatures" , "id" : 19 , "endian" : "little" , "data" : [ { "name" : "module_max_temp" , "type" : "int16_t" , "units" : "C" , "conversion" : 0.01 } , { "name" : "module_min_temp" , "type" : "int16_t" , "units" : "C" , "conversion" : 0.01 } , { "name" : "module_max_voltage" , "type" : "uint16_t" , "units" : "V" , "conversion" : 0.001 } , { "name" : "module_min_voltage" , "type" : "uint16_t" , "units" : "V" , "conversion" : 0.001 } ] } , { "name" : "bms_soc" , "description" : "State of charge" , "id" : 20 , "endian" : "little" , "data" : [ { "name" : "soc" , "type" : "float" , "conversion" : 1 } ] } , { "name" : "bms_capacity" , "description" : "State of charge" , "id" : 21 , "endian" : "little" , "data" : [ { "name" : "Ah" , "type" : "float" , "conversion" : 1 } , { "name" : "Wh" , "type" : "float" , "conversion" : 1 } ] } , { "name" : "bms_currentlimit" , "description" : "reports BP params for current" , "id" : 24 , "endian" : "little" , "data" : [ { "name" : "current_max" , "type" : "int16_t" , "units" : "A" , "conversion" : 0.01 } , { "name" : "current_min" , "type" : "int16_t" , "units" : "A" , "conversion" : 0.01 } ] } , { "name" : "bms_fan_info" , "description" : "BP Fans" , "id" : 25 , "endian" : "little" , "data" : [ { "name" : "fan1" , "type" : "uint16_t" , "units" : "RPM" , "conversion" : 1 } , { "name" : "fan2" , "type" : "uint16_t" , "units" : "RPM" , "conversion" : 1 } , { "name" : "fan3" , "type" : "uint16_t" , "units" : "RPM" , "conversion" : 1 } , { "name" : "fan4" , "type" : "uint16_t" , "units" : "RPM" , "conversion" : 1 } ] } , { "name" : "bms_set_min_fan_speed" , "description" : "packet which sets a minimum fan speed of BMS for a specific time frame in seconds" , "id" : 27 , "endian" : "little" , "data" : [ { "name" : "fan_percentage" , "type" : "float" , "units" : "percent" } , { "name" : "time" , "type" : "uint16_t" , "units" : "s" } ] } , { "name" : "bms_module" , "description" : "Voltage and temperature for a single module" , "id" : 64 , "endian" : "little" , "repeat" : 36 , "offset" : 1 , "data" : [ { "name" : "voltage" , "type" : "float" , "units" : "V" , "conversion" : 1 } , { "name" : "temperature" , "type" : "float" , "units" : "C" , "conversion" : 1 } ] } , { "name" : "bms_charger_response" , "description" : "Response packet from BMS for indicating whether BMS is ready for charging" , "id" : 117 , "endian" :