├── basic_gui_sc.png
├── LICENSE
├── README.md
├── data
└── index.html
└── ESP32_CANViewer.ino
/basic_gui_sc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cellgalvano/ESP32_CANViewer/HEAD/basic_gui_sc.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Felix
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ESP32 CANViewer
2 | A ESP32 based CAN interface for your webbrowser
3 |
4 | ### Super basic webclient
5 | 
6 |
7 | ## Requirements
8 | ### Libraries
9 | - [Arduino CAN (Adafruit fork)](https://github.com/adafruit/arduino-CAN) or [Arduino CAN](https://github.com/sandeepmistry/arduino-CAN)
10 | - [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer)
11 | - [arduinoWebSockets](https://github.com/Links2004/arduinoWebSockets)
12 | - [ArduinoJson](https://arduinojson.org/)
13 |
14 | ### Hardware
15 | - ESP32
16 | - 3.3V CAN Transceiver e.g. SN65HVD230
17 |
18 | ## Setup
19 | 1. Download the required libraries
20 | 2. Compile sketch and upload
21 | 3. Use the [ESP32 Sketch Data Upload Plugin](https://github.com/me-no-dev/arduino-esp32fs-plugin) to upload the data folder
22 |
23 | ## What should work?
24 | ### Server
25 | The ESP32 tries to connect to your specified WIFI network. If no connection is possible it will start an access point.
26 | On port 80 a simple webserver is available that serves the index.html.
27 | The communication works via websockets on port 1337.
28 |
29 | The websockets accepts JSON strings.
30 | Currently the following commands are implemented on the server side:
31 | - SEND: `{"cmd":"SEND", "id":1, "dlc":4, "data":[4,5,6,7]}`
32 | creates a CAN packet with ID 0x1 and the four data bytes
33 | - SETFILTER: `{"cmd":"SETFILTER", "id":8, "mask":2047}`
34 | sets the CAN acceptance filter to ID 0x8 and the MASK to 0x7FF (I don't know how to reset the filter so you need to reset the ESP in order to clear it)
35 | - SETSPEED: `{"cmd":"SETSPEED", "speed":125000}`
36 | resets the CAN library and configures the desired speed (there are no plausibilty checks included from my side, use a valid speed)
37 |
38 | The server broadcasts a STATUS message every second:
39 | `{"ts":1234,"type":"STATUS","baudrate":500000,"filterId":-1,"filterMask":-1}`
40 | ts: timestamp (Arduino millis)
41 | type: message type = STATUS
42 | baudrate: current baudrate
43 | filterId: currently set filter id (-1 means no filter set)
44 | filterMask: currently set filter mask (-1 means no filter set)
45 |
46 | Whenever a CAN packet gets received a message gets broadcasted:
47 | `{"ts":1234,"type":PACKETTYPE,"dlc":LENGTH,"data":[1,2,3,4,5,6,7,8]}`
48 | ts: timestamp (Arduino millis)
49 | type: message type
50 | - STD: Standard CAN Frame
51 | - EXT: Extended CAN Frame
52 | - RTR: Remote Transmission Request
53 | - ERTR: Extended Remote Transmission Request
54 |
55 | dlc: Data Length Code = 1-8 Bytes
56 | data: 0-8 Bytes of payload data, only in STD and EXT Frames
57 |
58 | ### Client
59 | The client is currently just a super simple first try. It just creates a HTML table with all received packets and is pretty ugly.
60 | In javascript there are more functions available than what the GUI represents:
61 | - `setSpeed(speed)`
62 | e.g. setSpeed(125000); sets a baudrate of 125KBit/s
63 | - `setFilter(id, mask)`
64 | e.g. setFilter(0x8, 0x7FF); sets the filter to only receive packets with id 0x8
65 | - `sendPacket(id, dataArray)`
66 | e.g. sendPacket(0x8, [1,2,3,4,5]); sends a five byte CAN packet with id 0x8 and the content 1,2,3,4,5
67 |
--------------------------------------------------------------------------------
/data/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |