Decode Ready-To-Drive Message
Confluence for https://uwmidsun.atlassian.net/browse/SOFT-498
We defined a new CAN message, specifying when power main sequence is finished.
In “can_transmit.h”
#define CAN_TRANSMIT_DRIVE_STATE(drive_state_u16) \
({ \
CanMessage msg = { 0 }; \
CAN_PACK_DRIVE_STATE(&msg, (drive_state_u16)); \
StatusCode status = can_transmit(&msg, NULL); \
status; \
})
In “power_main_sequence.c”
static void prv_state_power_main_complete(Fsm *fsm, const Event *e, void *context) {
event_raise(POWER_MAIN_SEQUENCE_EVENT_COMPLETE, 0);
CAN_TRANSMIT_READY_TO_DRIVER(true);
}
This message is for driver display to know when to display ready to drive.
Using the telemetry scripts,
https://github.com/uw-midsun/telemetry_xiv/blob/master/telemetry_scripts/web_aggregate_can_data.py and https://github.com/uw-midsun/telemetry_xiv/blob/master/MSXIV_Driver_Display/lib/main.dart
You can just look for if the message is sent.
void filterMessage(String data) {
var msg = data.split('-');
var msgName = msg[0];
var parsedInternalData = json.decode(msg[2].replaceAll("'", "\""));
if (msgName == 'MOTOR_VELOCITY') {
_speedChange((parsedInternalData['vehicle_velocity_left']).toDouble());
} else if (msgName == 'LIGHTS') {
selectLights(EELightType.values[(parsedInternalData['lights_id'])],
EELightState.values[(parsedInternalData['state'])]);
} else if (msgName == 'BATTERY_CHANGE') {
// TODO: Figure out voltage levels versus battery charge
} else if (msgName == 'CRUISE_CONTROL_COMMAND') {
toggleCruise();
} else if (msgName == 'DRIVE_STATE') {
selectDriveState(EEDriveOutput.values[parsedInternalData['drive_state']]);
} else if (msgName == 'BPS_HEARTBEAT') {
addBatteryHeartbeatWarnings(parsedInternalData['status']);
} else if (msgName == "CHARGER_FAULT") {
addChargerWarnings(EEChargerFault.values[parsedInternalData['fault']]);
} else if (msgName == "SOLAR_FAULT") {
addSolarWarnings(EESolarFault.values[parsedInternalData['fault']]);
} else if (msgName.contains(new RegExp(r'FAULT'))) {
addWarnings(msgName);
} else if (msgName == "READY_TO_DRIVE") {
# display ready to drive
}
}
Of course, you’ll also need the latest DBC file, to decode this.