Skip to content

Commit 0d0e8a8

Browse files
committed
Merge branch 'main' into lightning-stuff
2 parents 52635ee + 107a676 commit 0d0e8a8

9 files changed

Lines changed: 275 additions & 154 deletions

File tree

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ JSON files should be structured according to a strict hierarchy of:
5959

6060
At the root of any spec-compliant JSON file is a list of Message objects. Each Message object has the following members:
6161
- `id`, a hexadecimal string of the CAN ID (extended CAN supported and default)
62-
- `desc`, string representing a quick descroption of the CAN message
62+
- `desc`, string representing a quick descroption of the CAN message. Note that if it contains the word "overflow", it will be used as the overflow detection broadcast for said node. See the code-gen folder for details.
6363
- `points`, a list of CAN Points being sent from the Message
6464
- `fields`, a list of MQTT messages being sent from the Message
6565

@@ -77,7 +77,7 @@ You may want to publish the fields of a message to additional MQTT clients. Add
7777
#### NetField
7878

7979
Within the `fields` member of a Message object, there is a list of NetField objects. Think 1 MQTT Topic per NetField. Each NetField has the following members:
80-
- `name`, string of the message topic name, e.g. `The/Topic/Name`. Going 3 levels of slashes is usually preferred, don't put trailing slashes.
80+
- `name`, string of the message topic name, e.g. `The/Topic/Name`. Going 3 levels of slashes is usually preferred, don't put trailing slashes. The first level (in the above case `The`, is the name of the node sending the can message).
8181
- To embed live Point values in `name`, include point indices (from 1) in the name. Ex. `"Hello/{1}/World/{2}/Status"`
8282
- `unit`, string of the unit of the data, e.g. `mph`
8383
- `doc`, a short string with a human readable info about the topic
@@ -161,5 +161,12 @@ The script format.sh will format the files in place. It requires moreutils and
161161

162162
Work must be done in both Calypso and here.
163163

164-
1. In Calypso, edit the can_types.rs file to reflect your change
164+
1. In Calypso, edit the can_types.rs and nerdbc.rs file to reflect your change
165165
2. In here, migrate the JSON files to suite your needs.
166+
3. Optionally, migrate the code-gen files appropriately
167+
168+
## Code gen
169+
170+
This generates C code for CAN bus nodes.
171+
172+
To generate code, use the NER environment from Embedded-Base. The Jinja2 templates allow us to create .c and .h files by reading in the JSON specification files. In each compliant repository, there is a cangen.sh file which triggers this repository script under the submodule.

can-messages/bms.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@
281281
},
282282
{
283283
"size": 4,
284+
"name": "low_chip",
285+
"c_type": "uint8_t",
284286
"sim": {
285287
"min": 1,
286288
"max": 12,

can-messages/dti.json

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,6 @@
123123
"values": [
124124
2
125125
]
126-
},
127-
{
128-
"name": "DTI/Unused/Reserved",
129-
"unit": "",
130-
"doc": "Reserved",
131-
"values": [
132-
3
133-
]
134126
}
135127
],
136128
"sim_freq": 25
@@ -248,14 +240,6 @@
248240
"values": [
249241
3
250242
]
251-
},
252-
{
253-
"name": "DTI/Unused/Reserved",
254-
"unit": "",
255-
"doc": "Reserved",
256-
"values": [
257-
4
258-
]
259243
}
260244
],
261245
"sim_freq": 25
@@ -853,22 +837,6 @@
853837
22
854838
]
855839
},
856-
{
857-
"name": "DTI/Unused/Reserved",
858-
"unit": "",
859-
"doc": "Reserved",
860-
"values": [
861-
23
862-
]
863-
},
864-
{
865-
"name": "DTI/Unused/Reserved",
866-
"unit": "",
867-
"doc": "Reserved",
868-
"values": [
869-
24
870-
]
871-
},
872840
{
873841
"name": "DTI/General/CAN_Map_Version",
874842
"unit": "",
@@ -949,14 +917,6 @@
949917
"values": [
950918
1
951919
]
952-
},
953-
{
954-
"name": "DTI/Unused/Unused",
955-
"unit": "",
956-
"doc": "Reserved",
957-
"values": [
958-
2
959-
]
960920
}
961921
],
962922
"sim_freq": 25
@@ -989,14 +949,6 @@
989949
"values": [
990950
1
991951
]
992-
},
993-
{
994-
"name": "DTI/Unused/Unused",
995-
"unit": "",
996-
"doc": "Reserved",
997-
"values": [
998-
2
999-
]
1000952
}
1001953
],
1002954
"sim_freq": 25
@@ -1033,14 +985,6 @@
1033985
"values": [
1034986
1
1035987
]
1036-
},
1037-
{
1038-
"name": "DTI/Unused/Unused",
1039-
"unit": "",
1040-
"doc": "Reserved",
1041-
"values": [
1042-
2
1043-
]
1044988
}
1045989
],
1046990
"sim_freq": 25
@@ -1077,14 +1021,6 @@
10771021
"values": [
10781022
1
10791023
]
1080-
},
1081-
{
1082-
"name": "DTI/Unused/Unused",
1083-
"unit": "",
1084-
"doc": "Reserved",
1085-
"values": [
1086-
2
1087-
]
10881024
}
10891025
],
10901026
"sim_freq": 25
@@ -1121,14 +1057,6 @@
11211057
"values": [
11221058
1
11231059
]
1124-
},
1125-
{
1126-
"name": "DTI/Unused/Unused",
1127-
"unit": "",
1128-
"doc": "Reserved",
1129-
"values": [
1130-
2
1131-
]
11321060
}
11331061
],
11341062
"sim_freq": 25
@@ -1234,14 +1162,6 @@
12341162
"values": [
12351163
4
12361164
]
1237-
},
1238-
{
1239-
"name": "DTI/Unused/Unused",
1240-
"unit": "",
1241-
"doc": "Reserved",
1242-
"values": [
1243-
5
1244-
]
12451165
}
12461166
],
12471167
"sim_freq": 25
@@ -1280,14 +1200,6 @@
12801200
"values": [
12811201
1
12821202
]
1283-
},
1284-
{
1285-
"name": "DTI/Unused/Unused",
1286-
"unit": "",
1287-
"doc": "Reserved",
1288-
"values": [
1289-
2
1290-
]
12911203
}
12921204
],
12931205
"sim_freq": 25
@@ -1326,14 +1238,6 @@
13261238
"values": [
13271239
1
13281240
]
1329-
},
1330-
{
1331-
"name": "DTI/Unused/Unused",
1332-
"unit": "",
1333-
"doc": "Reserved",
1334-
"values": [
1335-
2
1336-
]
13371241
}
13381242
],
13391243
"sim_freq": 25

can-messages/tpu.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[
2+
{
3+
"desc": "TPU HaLow",
4+
"fields": [
5+
{
6+
"name": "TPU/HaLow/DataRate",
7+
"unit": "kb/s",
8+
"doc": "The data rate of HaLow"
9+
},
10+
{
11+
"name": "TPU/HaLow/ApMCS",
12+
"unit": "int",
13+
"doc": "The MCS of the AP station"
14+
},
15+
{
16+
"name": "TPU/HaLow/StaMCS",
17+
"unit": "int",
18+
"doc": "The MCS of the TPU"
19+
},
20+
{
21+
"name": "TPU/HaLow/RSSI",
22+
"unit": "int",
23+
"doc": "The signal strength of HaLow"
24+
}
25+
]
26+
},
27+
{
28+
"desc": "TPU CAN",
29+
"fields": [
30+
{
31+
"name": "TPU/CAN/BitsUsed",
32+
"unit": "bits",
33+
"doc": "The current bit utilization of the CAN bus"
34+
},
35+
{
36+
"name": "TPU/CAN/BusUtil",
37+
"unit": "%",
38+
"doc": "The current bus utilization"
39+
}
40+
]
41+
},
42+
{
43+
"desc": "TPU On Board",
44+
"fields": [
45+
{
46+
"name": "TPU/OnBoard/CpuTemp",
47+
"unit": "celsius",
48+
"doc": "The bus CPU temp of the TPU"
49+
},
50+
{
51+
"name": "TPU/OnBoard/CpuUsage",
52+
"unit": "percent",
53+
"doc": "The current total CPU usage (x cores)"
54+
},
55+
{
56+
"name": "TPU/OnBoard/BrokerCpuUsage",
57+
"unit": "percent",
58+
"doc": "The current total CPU usage (x cores) of the MQTT broker"
59+
},
60+
{
61+
"name": "TPU/OnBoard/MemAvailable",
62+
"unit": "MB",
63+
"doc": "The current total memory available for use"
64+
}
65+
]
66+
}
67+
]

code-gen/codegen

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)