Skip to content

Commit

Permalink
chore: add tpms messages
Browse files Browse the repository at this point in the history
  • Loading branch information
FerroO2000 committed Jul 1, 2024
1 parent f7b7a43 commit f7c209a
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 39 deletions.
6 changes: 3 additions & 3 deletions examples/markdown/MCB.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ BO_ 1301 DASH_rotarySwitchState: 1 DASH
SG_ ROT_SWITCH_0_position : 0|4@1+ (1,0) [0|10] "" DSPACE, SCANNER
SG_ ROT_SWITCH_1_position : 4|4@1+ (1,0) [0|10] "" DSPACE, SCANNER

BO_ 37 DSPACE_rtdACK: 1 DSPACE
SG_ RTD_FSM_STATE : 0|8@1- (1,0) [-1|6] "" DASH, SCANNER
BO_ 37 DSPACE_status: 1 DSPACE
SG_ DSPACE_FSM_state : 0|8@1- (1,0) [-1|6] "" DASH, SCANNER

BO_ 512 DSPACE_peripheralsCTRL: 2 DSPACE
SG_ BRAKE_LIGHT_activeCMD : 0|1@1+ (1,0) [0|1] "" SB_REAR, SCANNER
Expand Down Expand Up @@ -425,7 +425,7 @@ CM_ SG_ 19 PRECHARGE_RLY_IMP_isPresent "States whether an implausibility from th
CM_ SG_ 19 DC_BUS_IMP_isPresent "States whether an implausibility from the DC bus is present.";
CM_ SG_ 19 ANY_IMP_isLatched "States whether any implausibility is latched.";


CM_ SG_ 37 DSPACE_FSM_state "The state of the dspace RTD state machine\n0 = Idle (waiting for push)\n1 = Precharge (1st push)\n2 = TS ON\n3 = RTD requested (2nd push)\n4 = RTD\n5 = Turn OFF\n-1 = Reboot/discharge";


BA_DEF_ BO_ "GenMsgCycleTime" INT 0 1000;
Expand Down
127 changes: 95 additions & 32 deletions examples/markdown/SC24.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The CAN network of the squadracorse 2024 formula SAE car.
- [DSPACE](#dspace)
- [DSPACE_xcpRX](#dspace_xcprx)
- [DSPACE_hello](#dspace_hello)
- [DSPACE_rtdACK](#dspace_rtdack)
- [DSPACE_status](#dspace_status)
- [DSPACE_datetime](#dspace_datetime)
- [DSPACE_peripheralsCTRL](#dspace_peripheralsctrl)
- [DSPACE_motorStatus](#dspace_motorstatus)
Expand Down Expand Up @@ -62,6 +62,9 @@ The CAN network of the squadracorse 2024 formula SAE car.
- [SCANNER_xcpRX](#scanner_xcprx)
- [EXTRA_NODE](#extra_node)
- [unknown_ir](#unknown_ir)
- [TPMS](#tpms)
- [TPMS_front](#tpms_front)
- [TPMS_rear](#tpms_rear)
- [Signal Types](#signal-types)
- [Signal Units](#signal-units)
- [Signal Enums](#signal-enums)
Expand Down Expand Up @@ -535,7 +538,7 @@ Receivers: [DSPACE](#dspace), [SCANNER](#scanner)
| FW_patchVersion | 16 | 8 | [`uint8_t`](#signal-types) | 0 | 255 | - | The firmware patch version of the dSpace. |

---
#### DSPACE_rtdACK
#### DSPACE_status
CAN-ID (static): **37** (dec), **0x25** (hex)

Size: **1** bytes
Expand All @@ -546,9 +549,9 @@ Cycle Time: -

Receivers: [DASH](#dash), [SCANNER](#scanner)

| Name | Start Bit | Size | Type | Min | Max | Unit | Description |
|---------------|-----------|------|------------------------------|-----|-----|------|-------------|
| RTD_FSM_STATE | 0 | 8 | [`rtd_fsm_t`](#signal-types) | -1 | 6 | - | - |
| Name | Start Bit | Size | Type | Min | Max | Unit | Description |
|------------------|-----------|------|------------------------------|-----|-----|------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| DSPACE_FSM_state | 0 | 8 | [`rtd_fsm_t`](#signal-types) | -1 | 6 | - | The state of the dspace RTD state machine\n0 = Idle (waiting for push)\n1 = Precharge (1st push)\n2 = TS ON\n3 = RTD requested (2nd push)\n4 = RTD\n5 = Turn OFF\n-1 = Reboot/discharge |

---
#### DSPACE_datetime
Expand Down Expand Up @@ -990,40 +993,100 @@ Cycle Time: -

Receivers:

---
### TPMS
The tire pressure monitoring system.

---
Node ID: **9**

---
#### TPMS_front
CAN-ID (static): **1816** (dec), **0x718** (hex)

Size: **8** bytes

Byte Order: **little-endian**

Cycle Time: -

Receivers: [DSPACE](#dspace), [SCANNER](#scanner)

| Name | Start Bit | Size | Type | Min | Max | Unit | Description |
|---------------------|-----------|------|---------------------------------------|-----|------|-------------------------|------------------------------------------|
| TIRE_FL_sensID | 0 | 8 | [`tire_sens_id_t`](#signal-types) | 254 | -255 | - | The sensor id of the front left tire. |
| TIRE_FL_status | 8 | 8 | [`tire_sens_status_t`](#signal-types) | 254 | -255 | - | The status the front left tire. |
| TIRE_FL_temperature | 16 | 8 | [`tire_temp_t`](#signal-types) | 10 | 170 | [`degC`](#signal-units) | The temperature of the front left tire. |
| TIRE_FL_pressure | 24 | 8 | [`tire_press_t`](#signal-types) | 1 | 254 | [`mB`](#signal-units) | The pressure of the front left tire. |
| TIRE_FR_sensID | 32 | 8 | [`tire_sens_id_t`](#signal-types) | 254 | -255 | - | The sensor id of the front right tire. |
| TIRE_FR_status | 40 | 8 | [`tire_sens_status_t`](#signal-types) | 254 | -255 | - | The status the front right tire. |
| TIRE_FR_temperature | 48 | 8 | [`tire_temp_t`](#signal-types) | 10 | 170 | [`degC`](#signal-units) | The temperature of the front right tire. |
| TIRE_FR_pressure | 56 | 8 | [`tire_press_t`](#signal-types) | 1 | 254 | [`mB`](#signal-units) | The pressure of the front right tire. |

---
#### TPMS_rear
CAN-ID (static): **1832** (dec), **0x728** (hex)

Size: **8** bytes

Byte Order: **little-endian**

Cycle Time: -

Receivers: [DSPACE](#dspace), [SCANNER](#scanner)

| Name | Start Bit | Size | Type | Min | Max | Unit | Description |
|---------------------|-----------|------|---------------------------------------|-----|------|-------------------------|-----------------------------------------|
| TIRE_RL_sensID | 0 | 8 | [`tire_sens_id_t`](#signal-types) | 254 | -255 | - | The sensor id of the rear left tire. |
| TIRE_RL_status | 8 | 8 | [`tire_sens_status_t`](#signal-types) | 254 | -255 | - | The status the rear left tire. |
| TIRE_RL_temperature | 16 | 8 | [`tire_temp_t`](#signal-types) | 10 | 170 | [`degC`](#signal-units) | The temperature of the rear left tire. |
| TIRE_RL_pressure | 24 | 8 | [`tire_press_t`](#signal-types) | 1 | 254 | [`mB`](#signal-units) | The pressure of the rear left tire. |
| TIRE_RR_sensID | 32 | 8 | [`tire_sens_id_t`](#signal-types) | 254 | -255 | - | The sensor id of the rear right tire. |
| TIRE_RR_status | 40 | 8 | [`tire_sens_status_t`](#signal-types) | 254 | -255 | - | The status the rear right tire. |
| TIRE_RR_temperature | 48 | 8 | [`tire_temp_t`](#signal-types) | 10 | 170 | [`degC`](#signal-units) | The temperature of the rear right tire. |
| TIRE_RR_pressure | 56 | 8 | [`tire_press_t`](#signal-types) | 1 | 254 | [`mB`](#signal-units) | The pressure of the rear right tire. |

## Signal Types
The list of all the signal types used in the network.

| Name | Size | Kind | Signed | Min | Max | Scale | Offset | Description |
|-----------------------|------|-----------|---------|-----|-----------|-------|--------|-------------|
| flag_t | 1 | `flag` | `false` | 0 | 1 | 1 | 0 | - |
| month_t | 4 | `integer` | `false` | 0 | 11 | 1 | 0 | - |
| fan_pwm_t | 4 | `integer` | `false` | 0 | 10 | 1 | 0 | - |
| rotary_switch_pos_t | 4 | `integer` | `false` | 0 | 10 | 1 | 0 | - |
| hours_t | 5 | `integer` | `false` | 0 | 23 | 1 | 0 | - |
| day_t | 5 | `integer` | `false` | 1 | 31 | 1 | 0 | - |
| minutes_t | 6 | `integer` | `false` | 0 | 59 | 1 | 0 | - |
| seconds_t | 6 | `integer` | `false` | 0 | 59 | 1 | 0 | - |
| uint8_t | 8 | `integer` | `false` | 0 | 255 | 1 | 0 | - |
| rtd_fsm_t | 8 | `integer` | `true` | -1 | 6 | 1 | 0 | - |
| ntc_resistance_t | 10 | `decimal` | `false` | 0 | 31968.75 | 31.25 | 1000 | - |
| bms_lv_password_t | 15 | `integer` | `false` | 0 | 32768 | 1 | 0 | - |
| uint16_t | 16 | `integer` | `false` | 0 | 65535 | 1 | 0 | - |
| lv_bat_current_sens_t | 16 | `decimal` | `false` | 0 | 4980.66 | 0.076 | 0 | - |
| lv_bat_voltage_t | 16 | `decimal` | `false` | 0 | 17497.845 | 0.267 | 14000 | - |
| lv_cell_voltage_t | 16 | `decimal` | `false` | 0 | 2490.33 | 0.038 | 2000 | - |
| Name | Size | Kind | Signed | Min | Max | Scale | Offset | Description |
|-----------------------|------|-----------|---------|-----|-----------|-------|--------|--------------------------------------------------|
| flag_t | 1 | `flag` | `false` | 0 | 1 | 1 | 0 | - |
| rotary_switch_pos_t | 4 | `integer` | `false` | 0 | 10 | 1 | 0 | - |
| month_t | 4 | `integer` | `false` | 0 | 11 | 1 | 0 | - |
| fan_pwm_t | 4 | `integer` | `false` | 0 | 10 | 1 | 0 | - |
| day_t | 5 | `integer` | `false` | 1 | 31 | 1 | 0 | - |
| hours_t | 5 | `integer` | `false` | 0 | 23 | 1 | 0 | - |
| seconds_t | 6 | `integer` | `false` | 0 | 59 | 1 | 0 | - |
| minutes_t | 6 | `integer` | `false` | 0 | 59 | 1 | 0 | - |
| tire_sens_id_t | 8 | `decimal` | `false` | 254 | -255 | 1 | 0 | - |
| tire_press_t | 8 | `decimal` | `false` | 1 | 254 | 1 | 0 | - |
| tire_sens_status_t | 8 | `decimal` | `false` | 254 | -255 | 1 | 0 | Bit #2: 0 if battery voltage > 2.2V, otherwise 1 |
| | | | | | | | | Bit #3: 0 if wheel spinning, 1 otherwise |
| tire_temp_t | 8 | `integer` | `false` | 10 | 170 | 1 | 0 | - |
| rtd_fsm_t | 8 | `integer` | `true` | -1 | 6 | 1 | 0 | - |
| uint8_t | 8 | `integer` | `false` | 0 | 255 | 1 | 0 | - |
| ntc_resistance_t | 10 | `decimal` | `false` | 0 | 31968.75 | 31.25 | 1000 | - |
| bms_lv_password_t | 15 | `integer` | `false` | 0 | 32768 | 1 | 0 | - |
| lv_cell_voltage_t | 16 | `decimal` | `false` | 0 | 2490.33 | 0.038 | 2000 | - |
| lv_bat_current_sens_t | 16 | `decimal` | `false` | 0 | 4980.66 | 0.076 | 0 | - |
| lv_bat_voltage_t | 16 | `decimal` | `false` | 0 | 17497.845 | 0.267 | 14000 | - |
| uint16_t | 16 | `integer` | `false` | 0 | 65535 | 1 | 0 | - |

## Signal Units
The list of all the signal units used in the network.

| Name | Kind | Symbol | Description |
|--------|--------|--------|-------------|
| % | custom | % | - |
| Ohm | custom | Ohm | - |
| closed | custom | closed | - |
| h | custom | h | - |
| mV | custom | mV | - |
| min | custom | min | - |
| sec | custom | sec | - |
| Name | Kind | Symbol | Description |
|-----------------|-------------|--------|-------------|
| % | custom | % | - |
| Ohm | custom | Ohm | - |
| closed | custom | closed | - |
| h | custom | h | - |
| mV | custom | mV | - |
| min | custom | min | - |
| press_milli_bar | custom | mB | - |
| sec | custom | sec | - |
| temp_celsius | temperature | degC | - |

## Signal Enums
The list of all the signal enums used in the network.
Expand Down
125 changes: 124 additions & 1 deletion examples/markdown/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,20 @@ func main() {
modifySignalTypeName(dspaceInt, "DSPACE_datetime", "DATETIME_day", "day_t")
modifySignalTypeName(dspaceInt, "DSPACE_datetime", "DATETIME_hours", "hours_t")
modifySignalTypeName(dspaceInt, "DSPACE_datetime", "DATETIME_minutes", "minutes_t")
modifySignalTypeName(dspaceInt, "DSPACE_rtdACK", "RTD_FSM_STATE", "rtd_fsm_t")
modifySignalTypeName(dspaceInt, "DSPACE_status", "DSPACE_FSM_state", "rtd_fsm_t")

extraNode := acmelib.NewNode("EXTRA_NODE", 8, 1)
unknownIRMsg := acmelib.NewMessage("unknown_ir", 0x70, 8)
extraNodeInt := extraNode.Interfaces()[0]
checkErr(mcb.AddNodeInterface(extraNodeInt))
checkErr(extraNodeInt.AddMessage(unknownIRMsg))

scannerInt, err := mcb.GetNodeInterfaceByNodeName("SCANNER")
checkErr(err)

// adding tpms
tpms(mcb, scannerInt, dspaceInt)

dbcFile, err := os.Create("mcb_parsed.dbc")
checkErr(err)
defer dbcFile.Close()
Expand Down Expand Up @@ -161,3 +167,120 @@ func modifySignalType(nodeInt *acmelib.NodeInterface, msgName, sigName string, n
checkErr(err)
tmpStdSig.SetType(newType)
}

func tpms(mcb *acmelib.Bus, scanner, dspace *acmelib.NodeInterface) *acmelib.Node {
tpms := acmelib.NewNode("TPMS", 9, 1)
tpms.SetDesc("The tire pressure monitoring system.")
tpmsInt := tpms.Interfaces()[0]
checkErr(mcb.AddNodeInterface(tpmsInt))

idSigType, err := acmelib.NewDecimalSignalType("tire_sens_id_t", 8, false)
checkErr(err)

statusSigType, err := acmelib.NewDecimalSignalType("tire_sens_status_t", 8, false)
checkErr(err)
statusSigType.SetDesc("Bit #2: 0 if battery voltage > 2.2V, otherwise 1\nBit #3: 0 if wheel spinning, 1 otherwise")

tempSigType, err := acmelib.NewIntegerSignalType("tire_temp_t", 8, false)
checkErr(err)
tempSigType.SetMin(0x0a)
tempSigType.SetMax(0xaa)

tempUnit := acmelib.NewSignalUnit("temp_celsius", acmelib.SignalUnitKindTemperature, "degC")

pressSigType, err := acmelib.NewDecimalSignalType("tire_press_t", 8, false)
checkErr(err)
pressSigType.SetMin(0x01)
pressSigType.SetMax(0xfe)

pressUnit := acmelib.NewSignalUnit("press_milli_bar", acmelib.SignalUnitKindCustom, "mB")

frontMsg := acmelib.NewMessage("TPMS_front", 0x718, 8)
frontMsg.SetStaticCANID(0x718)
tmpSig, err := acmelib.NewStandardSignal("TIRE_FL_sensID", idSigType)
checkErr(err)
tmpSig.SetDesc("The sensor id of the front left tire.")
checkErr(frontMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_FL_status", statusSigType)
checkErr(err)
tmpSig.SetDesc("The status the front left tire.")
checkErr(frontMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_FL_temperature", tempSigType)
checkErr(err)
tmpSig.SetUnit(tempUnit)
tmpSig.SetDesc("The temperature of the front left tire.")
checkErr(frontMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_FL_pressure", pressSigType)
checkErr(err)
tmpSig.SetUnit(pressUnit)
tmpSig.SetDesc("The pressure of the front left tire.")
checkErr(frontMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_FR_sensID", idSigType)
checkErr(err)
tmpSig.SetDesc("The sensor id of the front right tire.")
checkErr(frontMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_FR_status", statusSigType)
checkErr(err)
tmpSig.SetDesc("The status the front right tire.")
checkErr(frontMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_FR_temperature", tempSigType)
checkErr(err)
tmpSig.SetUnit(tempUnit)
tmpSig.SetDesc("The temperature of the front right tire.")
checkErr(frontMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_FR_pressure", pressSigType)
checkErr(err)
tmpSig.SetUnit(pressUnit)
tmpSig.SetDesc("The pressure of the front right tire.")
checkErr(frontMsg.AppendSignal(tmpSig))

rearMsg := acmelib.NewMessage("TPMS_rear", 0x728, 8)
rearMsg.SetStaticCANID(0x728)
tmpSig, err = acmelib.NewStandardSignal("TIRE_RL_sensID", idSigType)
checkErr(err)
tmpSig.SetDesc("The sensor id of the rear left tire.")
checkErr(rearMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_RL_status", statusSigType)
checkErr(err)
tmpSig.SetDesc("The status the rear left tire.")
checkErr(rearMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_RL_temperature", tempSigType)
checkErr(err)
tmpSig.SetUnit(tempUnit)
tmpSig.SetDesc("The temperature of the rear left tire.")
checkErr(rearMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_RL_pressure", pressSigType)
checkErr(err)
tmpSig.SetUnit(pressUnit)
tmpSig.SetDesc("The pressure of the rear left tire.")
checkErr(rearMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_RR_sensID", idSigType)
checkErr(err)
tmpSig.SetDesc("The sensor id of the rear right tire.")
checkErr(rearMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_RR_status", statusSigType)
checkErr(err)
tmpSig.SetDesc("The status the rear right tire.")
checkErr(rearMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_RR_temperature", tempSigType)
checkErr(err)
tmpSig.SetUnit(tempUnit)
tmpSig.SetDesc("The temperature of the rear right tire.")
checkErr(rearMsg.AppendSignal(tmpSig))
tmpSig, err = acmelib.NewStandardSignal("TIRE_RR_pressure", pressSigType)
checkErr(err)
tmpSig.SetUnit(pressUnit)
tmpSig.SetDesc("The pressure of the rear right tire.")
checkErr(rearMsg.AppendSignal(tmpSig))

checkErr(tpmsInt.AddMessage(frontMsg))
checkErr(tpmsInt.AddMessage(rearMsg))

frontMsg.AddReceiver(dspace)
frontMsg.AddReceiver(scanner)

rearMsg.AddReceiver(dspace)
rearMsg.AddReceiver(scanner)

return tpms
}
Loading

0 comments on commit f7c209a

Please sign in to comment.