added raw messages and a simple python "mqtt decoder"

This commit is contained in:
Christian Lind Vie Madsen
2026-06-15 10:54:20 +02:00
parent 75c15c71ec
commit 9519b64a52
3 changed files with 125 additions and 10 deletions

View File

@@ -0,0 +1,86 @@
I (70462) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (70472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (70472) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x3, [2]: 0xff,[3]: 0xa, [4]: 0xff, [5]: 0xa,
I (81462) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (81472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (81472) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x4, [2]: 0xff,[3]: 0xff, [4]: 0xff, [5]: 0x0,
I (92462) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (92472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (92472) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x6, [2]: 0x2b,[3]: 0x2b, [4]: 0x2b, [5]: 0x2b,
I (103472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (103472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (103472) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x7, [2]: 0x2b,[3]: 0x2b, [4]: 0x0, [5]: 0x0,
I (114472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (114472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (125472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (125472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (125482) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x0, [2]: 0x1,[3]: 0x1, [4]: 0x1, [5]: 0x1,
I (136472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (136472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (136482) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x1, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (147472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (147472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (147482) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x2, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x8,
I (158472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (158472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (158482) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x3, [2]: 0xff,[3]: 0xa, [4]: 0xff, [5]: 0xa,
I (169472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (169482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (169482) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x4, [2]: 0xff,[3]: 0xff, [4]: 0xff, [5]: 0x0,
I (180472) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (180482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (180482) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x6, [2]: 0x2b,[3]: 0x2b, [4]: 0x2b, [5]: 0x2b,
I (191482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (191482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (191482) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x7, [2]: 0x2b,[3]: 0x2b, [4]: 0x0, [5]: 0x0,
I (202482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (202482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (213482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (213482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (213492) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x0, [2]: 0x1,[3]: 0x1, [4]: 0x1, [5]: 0x1,
I (224482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (224482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (224492) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x1, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (235482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (235482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (235492) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x2, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x8,
I (246482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (246492) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (246492) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x3, [2]: 0xff,[3]: 0xa, [4]: 0xff, [5]: 0xa,
I (257482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (257492) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (257492) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x4, [2]: 0xff,[3]: 0xff, [4]: 0xff, [5]: 0x0,
I (268482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (268492) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (268492) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x6, [2]: 0x2b,[3]: 0x2b, [4]: 0x2b, [5]: 0x2b,
I (279482) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (279492) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (279492) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x7, [2]: 0x2b,[3]: 0x2b, [4]: 0x0, [5]: 0x0,
I (290492) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (290492) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (301502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (301502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (301502) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x0, [2]: 0x1,[3]: 0x1, [4]: 0x1, [5]: 0x1,
I (312502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (312502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (312512) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x1, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (323502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (323502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (323512) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x2, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x8,
I (324592) canbus_service.c: ID: 0x18d; [0]: 0x0, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (331592) canbus_service.c: ID: 0x20d; [0]: 0x10, [1]: 0x1, [2]: 0xd8,[3]: 0x1, [4]: 0xf, [5]: 0x2,
I (331602) canbus_service.c: ID: 0x28d; [0]: 0xff, [1]: 0x3f, [2]: 0xff,[3]: 0x3f, [4]: 0x0, [5]: 0x0,
I (331602) canbus_service.c: ID: 0x30d; [0]: 0x0, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (331612) canbus_service.c: ID: 0x38d; [0]: 0x0, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (331622) canbus_service.c: ID: 0x24d; [0]: 0x0, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (331632) canbus_service.c: ID: 0x2cd; [0]: 0x0, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (331642) canbus_service.c: ID: 0x34d; [0]: 0x0, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (334502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (334502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (334512) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x3, [2]: 0xff,[3]: 0xa, [4]: 0xff, [5]: 0xa,
I (345502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (345502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (345512) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x4, [2]: 0xff,[3]: 0xff, [4]: 0xff, [5]: 0x0,
I (356502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x0, [2]: 0x0,[3]: 0x0, [4]: 0x0, [5]: 0x0,
I (356502) canbus_service.c: ID: 0x70d; [0]: 0x5, [1]: 0x92, [2]: 0x1,[3]: 0x0, [4]: 0xbc, [5]: 0x70,
I (356512) canbus_service.c: ID: 0x1cd; [0]: 0x1, [1]: 0x6, [2]: 0x2b,[3]: 0x2b, [4]: 0x2b, [5]: 0x2b,

View File

@@ -15,7 +15,7 @@ import matplotlib.pyplot as plt
MQTT_BROKER = "s960411f.ala.eu-central-1.emqxsl.com"
MQTT_PORT = 8883
MQTT_USER = "cma"
MQTT_PASS = "cmatest"
MQTT_PASS = "testcma"
TOPIC = "can/raw"
@@ -29,6 +29,7 @@ candidates = defaultdict(list)
# MQTT callback
# ----------------------------
def on_message(client, userdata, msg):
try:
data = json.loads(msg.payload.decode())
@@ -39,9 +40,14 @@ def on_message(client, userdata, msg):
timestamp = data.get("ts", time.time())
history[can_id].append((timestamp, payload))
if can_id != 0x70D and can_id != 0x1CD:
print("ID:", hex(can_id), "Data:", payload)
except Exception as e:
print("Parse error:", e)
# ----------------------------
@@ -116,9 +122,10 @@ def plot_sensor(can_id, byte_index):
client = mqtt.Client()
client.username_pw_set(MQTT_USER, MQTT_PASS)
client.on_message = on_message
client.tls_set(ca_certs='./server-ca.crt')
client.connect(MQTT_BROKER, MQTT_PORT, 60)
client.subscribe(TOPIC)
client.subscribe(TOPIC,qos=1)
client.loop_start()
@@ -132,13 +139,13 @@ plt.ion()
while True:
time.sleep(5)
print_candidates()
# print_candidates()
# try plotting strongest candidate (if any)
sensors = detect_sensor_like_signals()
# sensors = detect_sensor_like_signals()
for can_id, signals in sensors.items():
if signals:
byte_index = signals[0][0]
plot_sensor(can_id, byte_index)
break
# for can_id, signals in sensors.items():
# if signals:
# byte_index = signals[0][0]
# plot_sensor(can_id, byte_index)
# break

View File

@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH
MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI
2/Ou8jqJkTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx
1x7e/dfgy5SDN67sH0NO3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQ
q2EGnI/yuum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5Wz
tCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQ
vIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAP
BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV
5uNu5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY
1Yl9PMWLSn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4
NeF22d+mQrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NG
Fdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91
8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe
pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
MrY=
-----END CERTIFICATE-----