diff --git a/CMakeLists.txt b/CMakeLists.txt index cff2121..1f3304d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # The following lines of boilerplate have to be in your project's # CMakeLists in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(esp32_socketcand_adapter) diff --git a/README.md b/README.md index ed20514..7886a85 100644 --- a/README.md +++ b/README.md @@ -20,22 +20,33 @@ Here's an image of an example setup: ![Example ESP32 Socketcand Translate Setup](socketcand_adapter_labeled.jpg) ## Installation -The *Releases* page contains pre-built `esp32_socketcand_adapter.bin` files. -To flash them onto your ESP32 using -[Esptool](https://docs.espressif.com/projects/esptool/en/latest/esp32/), run this command: -```bash -esptool.py write_flash 0 esp32_socketcand_adapter.bin -``` +1. Install [Esptool](https://docs.espressif.com/projects/esptool/en/latest/esp32/) +by running: + ``` + python -m pip install esptool + ``` -To monitor log output from the ESP32 on Linux, run: \ -(replace "/dev/ttyUSB0" with the port you're using) +2. Download the latest `esp32_socketcand_adapter.bin` file from the +[Releases](https://github.com/wibotic/socketcand_translate/releases) page. -```bash -tail -f /dev/ttyUSB0 -``` +3. Connect an [Olimex ESP32-EVB](https://www.olimex.com/Products/IoT/ESP32/ESP32-EVB/open-source-hardware) +to your computer with a micro USB cable. + +4. Flash your ESP32 by running + ``` + python -m esptool write_flash 0 esp32_socketcand_adapter.bin + ``` + +5. Optionally, monitor log output on Linux by running: -Note: Flashing will fail if the port is being monitored. + ```bash + tail -f /dev/ttyUSB0 + ``` + Replace */dev/ttyUSB0* with the port you're using. + Run `lsusb` to get a list of USB ports. + + Note: Flashing will fail if the port is being monitored. ## Build from source Alternatively, you can build the project yourself. diff --git a/main/persistent_settings.c b/main/persistent_settings.c index dd12aa1..5abcbe9 100644 --- a/main/persistent_settings.c +++ b/main/persistent_settings.c @@ -80,11 +80,11 @@ esp_err_t persistent_settings_load() { err = nvs_get_blob(nvs_handle, "config", &persistent_settings_data, &config_size); - if (err == ESP_ERR_NVS_NOT_FOUND) { - ESP_LOGW(TAG, "No saved settings detected, so using defaults."); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Couldn't load persistent settings: %s", + esp_err_to_name(err)); + ESP_LOGW(TAG, "Using default settings instead."); persistent_settings_data = persistent_settings_default; - } else { - ESP_RETURN_ON_ERROR(err, TAG, "Couldn't read value from NVS."); } nvs_close(nvs_handle); diff --git a/main/status_report.c b/main/status_report.c index 05d89ee..a404629 100644 --- a/main/status_report.c +++ b/main/status_report.c @@ -308,22 +308,22 @@ static esp_err_t print_socketcand_status(char *buf_out, size_t buflen, "{\n" "\"Total socketcand frames received over TCP\": " - "\"%lld\",\n" + "%lld,\n" "\"Total invalid socketcand frames received over TCP\": " - "\"%lld\",\n" + "%lld,\n" "\"Total frames transmitted to CAN bus\": " - "\"%lld\",\n" + "%lld,\n" "\"Total CAN transmit fails\": " - "\"%lld\",\n" + "%lld,\n" "\"Total frames received from CAN bus\": " - "\"%lld\",\n" + "%lld,\n" "\"Total socketcand frames sent over TCP\": " - "\"%lld\"\n" + "%lld\n" "}", status.socketcand_frames_received,