nopnop2002 / esp-idf-can2mqtt

CANbus to mqtt bridge using esp32
MIT License
38 stars 8 forks source link

Modifications needed for Windows developers #7

Open lbartik opened 1 week ago

lbartik commented 1 week ago

I'm new to ESP and MQTT. I struggled getting this to run on an ESP32-EVB from a windows PC (VS Code + esp-idf). Test broker is mosquitto running insecure (port 1883) on the same windows PC.

Eventually traced it down to EOL characters in the csv\can2mqtt.csv and csv\mqtt2can.csv files. This project's .gitattributes must clone these with windows-compatible CR+LF chars on windows GIT. The 0x0D CR characters are literally interpreted by the ESP code and appended to every published/subscribed topic. Apparently, those CRs are illegal in MQTT topic names, at least for my mosquitto 2.0.18 broker.

Quick fix in notepad++ or VS code with command - change end of line sequence - LF. There's probably all kinds of other ways to do it at the GIT level or parse and discard/flag invalid characters in ESP code too.

mosquitto -v (verbose) output: Client pub-c8f09e54d97c disconnected due to malformed packet.

ESP-LOG output: mqtt_client: esp_mqtt_handle_transport_read_error: transport_read(): EOF E (133398) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read() error: errno=128 I (133408) PUB: MQTT_EVENT_ERROR E (133408) mqtt_client: mqtt_process_receive: mqtt_message_receive() returned -2 W (133418) PUB: MQTT_EVENT_DISCONNECTED

Thankful for this project. Glad I stuck it out and got it running. Looking forward to putting it to use.

nopnop2002 commented 1 week ago

Thank you for your report.

ESP-IDF on Linux is very easy and doesn't cause these problems, so please give it a try.