{"id":26317997,"url":"https://github.com/jakka351/can0swc","last_synced_at":"2025-03-15T14:16:26.225Z","repository":{"id":54391149,"uuid":"319690831","full_name":"jakka351/can0swc","owner":"jakka351","description":" FG Steering Wheel Controls Adapter","archived":false,"fork":false,"pushed_at":"2024-12-11T07:21:54.000Z","size":18142,"stargazers_count":14,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-12-11T08:27:32.717Z","etag":null,"topics":["can","can0","falcon","fg","fg-falcon","ford","frames","libsocketcan","mcp2515","pi","pican2","python","python3","raspberry","rpi","socketcan","swc","throw-keypresses","uinput","vehicle"],"latest_commit_sha":null,"homepage":"https://testerpresent.com.au","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jakka351.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}},"created_at":"2020-12-08T16:06:35.000Z","updated_at":"2024-12-11T07:21:59.000Z","dependencies_parsed_at":"2024-12-11T08:32:31.084Z","dependency_job_id":null,"html_url":"https://github.com/jakka351/can0swc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakka351%2Fcan0swc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakka351%2Fcan0swc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakka351%2Fcan0swc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakka351%2Fcan0swc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakka351","download_url":"https://codeload.github.com/jakka351/can0swc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243738910,"owners_count":20340003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["can","can0","falcon","fg","fg-falcon","ford","frames","libsocketcan","mcp2515","pi","pican2","python","python3","raspberry","rpi","socketcan","swc","throw-keypresses","uinput","vehicle"],"created_at":"2025-03-15T14:16:25.785Z","updated_at":"2025-03-15T14:16:26.220Z","avatar_url":"https://github.com/jakka351.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003ca href=\"https://testerpresent.com.au/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Tester Present Specialist Automotive Solutions -Open Source Projects- blue\" /\u003e\u003c/a\u003e\n\n![image](https://user-images.githubusercontent.com/57064943/163714778-8598c24a-6ae2-49f6-ba4c-42de94dfa025.png)\n# [`can0swc`](https://github.com/jakka351/can0swc)    \n\n\n\u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/jakka351/FG-Falcon/master/resources/can0swc.gif\" /\u003e\n\n![image](https://user-images.githubusercontent.com/57064943/163714778-8598c24a-6ae2-49f6-ba4c-42de94dfa025.png)\n  ### `Steering Wheel Controls adaptor for mk1 FG`\n  Uses the python-can library to listen for pushes of steering wheel buttons, which are visible on the Falcon's mid-speed controller area network with CAN ID 0x2F2. Also listens for ICC button pushes on CAN ID 0x2FC and BEM functions on 0x307.\n    When a button is pushed, the script emulates a keypress on the Raspberry Pi. This is used here with [OpenDash's](https://github.com/opendsh/dash) implementation of Android Auto emulator [Openauto]() to control basic media functions. The Car used is an Ford FG mk1 Falcon. The factory display from the vehicle has been replaced with a Raspberry Pi 7 Inch Touchscreen.    \n  \n  ### [Basic Breakdown of Steering Wheel Controls for FG Falcon](https://github.com/jakka351/FG-Falcon/wiki/Steering-Wheel-Media-Controls)    \n                                   \nSWC are resistance based, all switches run on a single wire, pushing a button causes a specific resistance in the circuit. The Module sees a change in resistance, and accordingly sends data on to CAN-bus where it is recieved by the ACM/FDIM/ICC and acted upon. \n\n --  [Relevant ICC Diagrams + Pinouts](https://github.com/jakka351/FG-Falcon/wiki/Interior-Command-Centre)  \n    \n![image](https://user-images.githubusercontent.com/57064943/163714778-8598c24a-6ae2-49f6-ba4c-42de94dfa025.png)\n### Hardware\n\n **Vehicle:** FG Falcon mk1   \n **Interface:** SocketCAN can0 interface, MCP2515 chipset, Midspeed-CAN@125kbps  \n **Software:**  Can-Utils, Python-Can, Openauto, Opendash, Raspbian   \n **SBC:** Raspberry Pi 4B - 8gb, PiCan2 Hat, i2s audio hat  \n **Other:** Modified OBD-DB9 Cable, 7\" Official Touchscreen, 2 Metre DSI Ribbon Cable, heatsink case, fans, enclosure, 12vdc-5vdc converter   \n  \n  #### Unit Diagram\n \u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/jakka351/can0swc/main/falcon.png\" width=\"500\" height=\"500\" /\u003e  \n \u003c/p\u003e  \u003cbr/\u003e\n \n#### Actual Unit \n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/jakka351/can0swc/main/canpii.jpg\" width=\"300\" height=\"425\"\u003e \n  \u003cbr/\u003e\u003cimg src=\"https://raw.githubusercontent.com/jakka351/can0swc/main/test%20(1).jpg\" width=\"325\" height=\"425\" /\u003e \n\u003c/p\u003e\u003cbr/\u003e  \n  \n![image](https://user-images.githubusercontent.com/57064943/163714778-8598c24a-6ae2-49f6-ba4c-42de94dfa025.png)\n### Installation, Dependencies \u0026 Config\n       \n   #### Edit  \n   - edit \"/etc/modules\" to include   \n        `uinput`         \n        `can`  \n        `can_dev`  \n        `can_raw`  \n        `vcan`  \n          \n   #### Set Up CAN interface    \n   - Add the following to the 'config.txt' file in the /boot partition of the Raspberry Pi sd card.   \n       ```shell\n       dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25\n       ```   \n   - If using a PiCan Board set oscillator to 16000000  \n       `oscillator=16000000`  \n\n - Add the following to '/etc/network/interfaces'   \n         `auto can0    `  \n         `iface can0 inet manual    `\n         `    pre-up /sbin/ip link set can0 type can bitrate 125000 triple-sampling on restart-ms 100 `    \n         `    up /sbin/ifconfig can0 up txqueuelen 65535   `   \n         `    down /sbin/ifconfig can0 down `    \n - Bring the can0 interface up  \n         `sudo ip link set can0 type can bitrate 125000 triple-sampling on restart-ms 100 `   \n         `sudo ifconfig can0 up txqueuelen 65535 ` \n          \n   #### Install  \n       sudo apt update -y \u0026\u0026 sudo apt upgrade -y \u0026\u0026\n       sudo apt install -y can-utils libsocketcan2 libsocketcan-dev python-can python3-can \u0026\u0026   \n       sudo apt install -y python3-uinput python3-evdev \u0026\u0026  \n       sudo git clone https://github.com/jakka351/can0swc ./can0swc \u0026\u0026  \n       cd ./can0swc \u0026\u0026  \n       pip3 install -r requirements.txt \u0026\u0026    \n       sudo modprobe uinput \u0026\u0026\n       sudo cp ./can0swc.service /lib/systemd/system/can0swc.service \u0026\u0026  \n       sudo systemctl enable can0swc.service \u0026\u0026  \n       sudo systemctl start can0swc.service \u0026\u0026  \n       sudo systemctl status can0swc.service \u0026\u0026  \n       sudo reboot\n               \n   #### Testing with can-utils  \n   - Test the script with socketcan virtual can interface, vcan0 and candump log files      \n        `sudo modprobe vcan0`  \n        `sudo ip link add dev vcan0 type vcan`  \n        `sudo ifconfig vcan0 up txqueuelen 1000`  \n   - Use canplayer to run the candump log    \n        `canplayer -I ./candump.log -v vcan0=can0`  \n   - If running cangen use '-L 8' to keep frames at 11bits or an error will occur  \n        `cangen vcan0 -c -L 8 \u0026`  \n   - Candump logs available [here](https://github.com/jakka351/fg-falcon)  \n       \n   #### Run Script Manually\n        `cd ~/can0swc`  \n        `sudo python3 ./can0swc.py`  \n        \n       \n![image](https://user-images.githubusercontent.com/57064943/163714778-8598c24a-6ae2-49f6-ba4c-42de94dfa025.png)\n  ### Wiring Diagrams\n  \n  \u003cimg src=\"https://github.com/jakka351/FG-Falcon/blob/master/resources/images/36042a635002807104849f240acc63e5.jpg\" width=\"600\" height=\"600\" /\u003e    \n  \u003cimg src=\"https://raw.githubusercontent.com/jakka351/FG-Falcon/master/resources/images/plug_dlc.png\" width=\"600\" height=\"600\" /\u003e \n\n![image](https://user-images.githubusercontent.com/57064943/163714778-8598c24a-6ae2-49f6-ba4c-42de94dfa025.png)\n  ### CAN Data  \n\n   | Address | Data    | Function | Byte1      | Byte2      | Byte3 | Byte4 | Byte5 | Byte6 | Byte7   | Byte8   |\n| ------- | ----    | -------- | -----      | -----      | ----- | ----- | ----- | ----- | -----   | -----   |\n| `754`   | 8 bytes | Volume Data  | 0x00| x | x | x | x | x | x | x |  \n| `754`   | 8 bytes | Seek  | x | x | x | x | x | x | x | 0x08* |  \n| `754`   | 8 bytes | Volume Up  | x | x | x | x | x | x | x | 0x10* |  \n| `754`   | 8 bytes | Volume Down  | x| x | x | x | x | x | x | 0x18* |  \n| `754`   | 8 bytes | Phone  | x| x | x | x | x | x | 0x61** | x |  \n| `748`   | 8 bytes | Mode  | x| x | x | x | x | x | 0x10 | x |  \n\n\n*+1 depending on audio mode  \n**65 or 68 depending on audio mode  \n![image](https://user-images.githubusercontent.com/57064943/163714778-8598c24a-6ae2-49f6-ba4c-42de94dfa025.png)\n  \n  ### Use in Different Vehicles  \n  There is a templated version of the script that can be used to make your own version of can0swc, named as 'template.py'. \n\n![image](https://user-images.githubusercontent.com/57064943/163714778-8598c24a-6ae2-49f6-ba4c-42de94dfa025.png)\n    \n  ###  Based upon:  \n   -- [Python-CAN PiCAN2 Examples](https://github.com/jakka351/FG-Falcon/tree/master/resources/software/pythoncan)   \n   -- [Webjocke canbus to keypress](https://github.com/webjocke/Python-CAN-bus-to-Keypresses) \n   \n![](https://www.raspberrypi.org/app/uploads/2017/06/Powered-by-Raspberry-Pi-Logo_Outline-Colour-Screen-500x153.png)  \n\n![image](https://user-images.githubusercontent.com/57064943/163714778-8598c24a-6ae2-49f6-ba4c-42de94dfa025.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakka351%2Fcan0swc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakka351%2Fcan0swc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakka351%2Fcan0swc/lists"}