{"id":36027545,"url":"https://github.com/c3re/can2mqtt","last_synced_at":"2026-01-11T20:00:41.721Z","repository":{"id":13936410,"uuid":"75400208","full_name":"c3re/can2mqtt","owner":"c3re","description":"CAN-Bus -- MQTT bridge: bidirectional, configurable and extendable ","archived":false,"fork":false,"pushed_at":"2025-09-13T10:07:42.000Z","size":304,"stargazers_count":95,"open_issues_count":12,"forks_count":24,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-09-13T12:35:35.732Z","etag":null,"topics":["bridge","bus","can","can-bus","can2mqtt","canbus","canbus-messages","converter","iot","linux","mosquitto","mqtt","mqtt-client","mqtt-message","mqtt-mirror","mqtt-topics","raspberry-pi","rust","socketcan"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c3re.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-12-02T13:58:12.000Z","updated_at":"2025-09-13T10:07:39.000Z","dependencies_parsed_at":"2023-12-20T11:58:30.954Z","dependency_job_id":"fd947887-dd20-4fdc-8eab-b25b3d8c0fe8","html_url":"https://github.com/c3re/can2mqtt","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/c3re/can2mqtt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c3re%2Fcan2mqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c3re%2Fcan2mqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c3re%2Fcan2mqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c3re%2Fcan2mqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c3re","download_url":"https://codeload.github.com/c3re/can2mqtt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c3re%2Fcan2mqtt/sbom","scorecard":{"id":261020,"data":{"date":"2025-08-11","repo":{"name":"github.com/c3re/can2mqtt","commit":"69993bfe4ebbecc71a37fff8f4ee7bf01cfb6f73"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/25 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":2,"reason":"3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":4,"reason":"dependency not pinned by hash detected -- score normalized to 4","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/c3re/can2mqtt/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/c3re/can2mqtt/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/c3re/can2mqtt/release.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yaml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/c3re/can2mqtt/release.yaml/main?enable=pin","Info:   0 out of   3 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":10,"reason":"project is fuzzed","details":["Info: GoBuiltInFuzzer integration found: src/convertmode/none_test.go:79","Info: GoBuiltInFuzzer integration found: src/convertmode/none_test.go:134"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v2.3.2 not signed: https://api.github.com/repos/c3re/can2mqtt/releases/221383736","Warn: release artifact v2.3.1 not signed: https://api.github.com/repos/c3re/can2mqtt/releases/183072792","Warn: release artifact v2.3.0 not signed: https://api.github.com/repos/c3re/can2mqtt/releases/167706732","Warn: release artifact v2.2.1 not signed: https://api.github.com/repos/c3re/can2mqtt/releases/164267951","Warn: release artifact v2.2.0 not signed: https://api.github.com/repos/c3re/can2mqtt/releases/155312498","Warn: release artifact v2.3.2 does not have provenance: https://api.github.com/repos/c3re/can2mqtt/releases/221383736","Warn: release artifact v2.3.1 does not have provenance: https://api.github.com/repos/c3re/can2mqtt/releases/183072792","Warn: release artifact v2.3.0 does not have provenance: https://api.github.com/repos/c3re/can2mqtt/releases/167706732","Warn: release artifact v2.2.1 does not have provenance: https://api.github.com/repos/c3re/can2mqtt/releases/164267951","Warn: release artifact v2.2.0 does not have provenance: https://api.github.com/repos/c3re/can2mqtt/releases/155312498"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T10:50:29.604Z","repository_id":13936410,"created_at":"2025-08-17T10:50:29.604Z","updated_at":"2025-08-17T10:50:29.604Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28321263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T18:42:50.174Z","status":"ssl_error","status_checked_at":"2026-01-11T18:39:13.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bridge","bus","can","can-bus","can2mqtt","canbus","canbus-messages","converter","iot","linux","mosquitto","mqtt","mqtt-client","mqtt-message","mqtt-mirror","mqtt-topics","raspberry-pi","rust","socketcan"],"created_at":"2026-01-10T15:00:40.726Z","updated_at":"2026-01-11T20:00:41.698Z","avatar_url":"https://github.com/c3re.png","language":"Rust","funding_links":[],"categories":["Interfaces"],"sub_categories":["Smart Home Hardware Interfaces"],"readme":"# can2mqtt\ncan2mqtt connects a CAN-Bus to an MQTT broker and vice versa. You create pairs of CAN-Bus IDs and MQTT topics and choose a conversion mode between them. \n\nHere you can see can2mqtt in action:\n[![can2mqtt demo](screenshot.png)](https://asciinema.org/a/542608?autoplay=1)\n\n## Installation\nYou can download prebuilt binaries or compile can2mqtt yourself.\n### Binary download\nThe latest compiled binary is available in the [releases](https://github.com/c3re/can2mqtt/releases/latest).\nThe binaries are statically linked (against [musl](https://www.musl-libc.org/)) and have no further dependencies. On a Raspberry you can install via:\n```\nwget https://github.com/c3re/can2mqtt/releases/download/v3.0.1/can2mqtt-v3.0.1-armv7-unknown-linux-musleabihf -O can2mqtt\nchmod +x can2mqtt\n./can2mqtt\n```\n### Compile\nYou need a Rust toolchain. [Here](https://rust-lang.org/learn/get-started/) is the standard guide how to obtain one. Apart from that, nothing special to take care of: clone, `cargo build`, and you are good to go. can2mqtt is also pushed to [crates.io](https://crates.io/crates/can2mqtt) so you can run `cargo install can2mqtt`.\n\n## Usage\nThe commandline parameters are the following:\n ```\n ./can2mqtt -f \u003ccan2mqtt.csv\u003e  -m \u003cmqtt-connectstring\u003e [-v] -c \u003ccan-interface\u003e\n ```\n \n`\u003ccan2mqtt.csv\u003e` is the configurations where your can2mqtt pairs are set.\n\n`\u003cmqtt-connectstring\u003e` is a URL that is used to connect to your MQTT-Broker. username and password can be supplied like this: `tcp://user:pass@host:port`.\n\n`\u003ccan-interface\u003e` refers to the name of a [socket-can](https://www.kernel.org/doc/html/next/networking/can.html) interface on your computer that you want to bridge with can2mqtt. In case you have no idea what a socket-can interface is or how to configure it, read [how do i get a socket-can interface?](#how-do-i-get-a-socket-can-interface).\n\nAn additional `-v` flag can be passed to get verbose debug output.\n\nHere is a full, working example:\n```\n./can2mqtt -f /etc/can2mqtt.csv -c can0 -m tcp://127.0.0.1:1883\n```\n## can2mqtt.csv\nThe file can2mqtt.csv has three columns. In the first column you need to specify the CAN-ID as a decimal number. In the second column you have to specify the convert-mode. You can find a list of available convert-modes below. In the last column you have to specify the MQTT-Topic. Each CAN-ID and each MQTT-Topic is allowed to appear only once in the whole file.\n\nExample:\n```\n112,none,huette/all/a03/door/sensors/opened\n113,2uint322ascii,huette/all/000/ccu/sensors/time\n115,uint322ascii,huette/serverraum/000/filebitch/sensors/ftp_diskusage_percent\n116,uint322ascii,huette/all/000/router/sensors/rx_bytes_s\n117,uint322ascii,huette/all/000/router/sensors/tx_bytes_s\n118,uint322ascii,huette/clubraum/000/ds18b20/sensors/temperatur\n119,uint322ascii,huette/all/000/airmonitor/sensors/temp\n120,uint322ascii,huette/all/000/airmonitor/sensors/hum\n121,uint322ascii,huette/all/000/airmonitor/sensors/airq\n122,uint322ascii,huette/all/000/airmonitor/sensors/pm2_5\n123,uint322ascii,huette/all/000/airmonitor/sensors/pm10\n```\n\nExplanation for the 1st Line: For example our Doorstatus is published on the CAN-Bus every second with the CAN-ID 112 (decimal). can2mqtt will take everything that is published there and will push it through to mqtt-topic huette/all/a03/door/sensors/opened.\n\n## convert-modes\nHere they are:\n\n| convertmode           | description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `none`                | does not convert anything. It just takes a bunch of bytes and hands it over to the other side. If you want to send strings, this will be your choice. If you have a mqtt payload that is longer than eight bytes, only the first eight bytes will be send via CAN.                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| `bytecolor2colorcode` | Converts an bytearray of 3 bytes to hexadecimal colorcode                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |\n| `pixelbin2ascii`      | This mode was designed to address colorized pixels. MQTT-wise you can insert a string like \"\u003c0-255\u003e #RRGGBB\" which will be converted to 4 byte on the CAN-BUS the first byte will be the number of the LED 0-255 and bytes 1, 2, 3 are the color of red, green and blue.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |\n| `16bool2ascii`        | Interprets two bytes can-wise and publishes them as 16 boolean values to mqtt                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| `{i}[u]int{b}2ascii`  | `i` is the amount of instances of numbers in the CAN-Frame/the MQTT-message. Valid instance amounts are currently 1,2,4 and 8. Although other combinations are possible. Might be added in the future, if the need arises. `b` is the size of each number in bits. Supported values are 8,16,32 and 64. You can use either one unsigned or signed integers. This are all possible combinations:  `int82ascii`, `2int82ascii`, `4int82ascii`, `8int82ascii`, `int162ascii`, `2int162ascii`, `4int162ascii`, `int322ascii`, `2int322ascii`, `int642ascii`, `uint82ascii`, `2uint82ascii`, `4uint82ascii`, `8uint82ascii`, `uint162ascii`, `2uint162ascii`, `4uint162ascii`, `uint322ascii`, `2uint322ascii`, `uint642ascii` |\n\n\n## Unidirectional Mode\nNormally can2mqtt works in bidirectional mode, that means all messages from the CAN-bus are send to mqtt and vice versa. If you wish you can run can2mqtt in a unidirectional mode to only send messages from can to mqtt or only mqtt to can. To do so you have to use the flag `-d` with one fo the following settings:\n\n| dirMode | effect                                                                          |\n|---------|---------------------------------------------------------------------------------|\n| 0       | bidirectional mode, messages will be send from can to mqtt and vice versa       |\n| 1       | unidirectional mode, messages will only be send from CAN-Bus to mqtt broker     |\n| 2       | unidirectional mode, messages will only be send from mqtt broker to the CAN-Bus |\n## How do I get a socket-can interface?\nYou can either use a hardware interface or setup a virtual socket-can interface.\n### Hardware interface\nThere are many articles on the internet on how to get a can interface in Linux. The important part here is that you get a socket-can interface in the end. But in most cases this is possible. For example the MCP2515 chip can be used with the SPI interface of a raspberry to create a socket-can interface. There is a driver for the ELM327 chip too. Serial-to-CAN converters can be used too via `slcand`.\n### Virtual interface\nFor testing purposes or to just get you going you can use `vcan` a virtual can interface that comes with Linux itself. You can configure it for example like this:\n```bash\nsudo ip link add dev vcan0 type vcan\nsudo ip link set vcan0 up\n```\nNow you can use your new interface `vcan0` as socket-can interface with can2mqtt.\n\n## Debugging\nTo debug the behaviour of can2mqtt you need to be able to send and receive CAN frames and MQTT messages. For MQTT I recommend [mosquitto](https://mosquitto.org/) with its `mosquitto_pub` and `mosquitto_sub` commands. For CAN i recommend [can-utils]() with its tools `cansend` and `candump`.\n\n## Add a convert-Mode\nIf you want to add a convert-Mode think about a name. This is the name that you can later refer to when you want to\nuse your convert-Mode in the `can2mqtt.csv` config-file. Now, use the file `src/converter/mymode.rs` as a template for your own convertmode. Copy that file to `src/converter/\u003cyournewmode\u003e.rs`. Now change all occurrences of \"MyMode\" with your preferred Name (Lets say `YourNewMode` in this example). Next you have to write three functions (implement the `Converter` and `std::fmt::Display` trait):\n1. A conversion method from CAN -\u003e MQTT: `towards_mqtt(self: \u0026MyModeConverter, cf: CANFrame) -\u003e Result\u003cMQTTPayload, String\u003e`\n2. A conversion method from MQTT -\u003e CAN: `towards_can(self: \u0026MyModeConverter, mut msg: MQTTPayload) -\u003e Result\u003cCANFrame, String\u003e`\n3. A `fmt(\u0026self, f: \u0026mut fmt::Formatter\u003c'_\u003e) -\u003e fmt::Result` method that reports the name of that convertmode. This method is used in some log-messages\n\nYour almost done, the last step is to \"register\" your new convertmode. To do so add the following to [`src/converter/all.rs#L29`](./src/converter/all.rs#L29)\n```Rust\n    let yournewmodecv = Arc::new(YourNewMode::default());\n    convertmodes.insert(yournewmodecv.to_string(), yournewmodecv);\n```\n\nNow you can use your new convertmode in your `can2mqtt.csv` config File. Use the string that your return in the `fmt()` function as the name of the convertmode. In the `mymode.rs` code this is `\"mymode\"`.\n\nGood luck \u0026 happy hacking ✌\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc3re%2Fcan2mqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc3re%2Fcan2mqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc3re%2Fcan2mqtt/lists"}