Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review PR: Add "Offline" SDLogger Mode #676

Open
wants to merge 205 commits into
base: main
Choose a base branch
from
Open

Conversation

brentru
Copy link
Member

@brentru brentru commented Dec 27, 2024

This pull request is not meant to be merged in. It is a review-only pull request for specific regions of code.

Codebase regions for review

  • Added a new class, ws_sdcard - for interfacing with a micro SD Card breakout.
    • Request: please take a careful look at how parseConfigFile functions and looks
    • Request: please take a careful look at how we switch between production and debug-mode in this class
    • BuildJSONDoc and LogJSONDoc API interfaces are present for each type of component
    • This class also supports a Real-Time-Clock breakout.
  • API calls for interacting with ws_sdcard and mode-switching (determining whether the device is online or offline) within WipperSnapper_V2 class in two functions -provision() and connect()
  • Added API calls for parsing the SD CS pins from the JSON file on the WIPPER drive within classes - FS_V2 and LittleFS_V2
  • Refactored network_interfaces/ to adapters/ to allow for a WipperSnapper device without a network interface (offline/).
    • Added new class, adapters/offline/ws_offline_pico to support a Raspberry Pi in offline mode.

Workflow enhancements for review:

  • Added a new GitHub Actions workflow file, run-tests.yml, to automate testing using Wokwi.

brentru added 30 commits August 13, 2024 14:34
Use latest build artifacts
New checkin model class added along with functions within .cpp to exec. it
@brentru brentru requested a review from tyeth December 27, 2024 16:38
"top": 9.2,
"left": 74,
"rotate": 270,
"attrs": { "color": "green" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be using bounce:0 here too? (Like ../diagram.json)

@@ -24,12 +24,12 @@ void setup() {
wipper.provision();

Serial.begin(115200);
//while (!Serial) delay(10);
while (!Serial) delay(10);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this should be commented out again


wipper.connect();

}

void loop() {
wipper.run();
//wipper.run();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this should be re-enabled

import json

# load json file from provided path
with open(sys.argv[1], 'r') as f:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to trap errors here (like no args and missing file), but looks like it's only for our usage anyway

C:\dev\arduino\Adafruit_Wippersnapper_Arduino [review-mode-sdlogger ≡ +1 ~1 -0 !]> python .\generate_json_checksum.py 
Traceback (most recent call last):
  File "C:\dev\arduino\Adafruit_Wippersnapper_Arduino\generate_json_checksum.py", line 6, in <module>
    with open(sys.argv[1], 'r') as f:
              ~~~~~~~~^^^
IndexError: list index out of range
C:\dev\arduino\Adafruit_Wippersnapper_Arduino [review-mode-sdlogger ≡ +1 ~1 -0 !]> python .\generate_json_checksum.py a.json
Traceback (most recent call last):
  File "C:\dev\arduino\Adafruit_Wippersnapper_Arduino\generate_json_checksum.py", line 6, in <module>
    with open(sys.argv[1], 'r') as f:
         ^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'a.json'

@@ -14,12 +14,13 @@ default_envs = adafruit_feather_esp32s3_tft, adafruit_magtag29_esp32s2, adafruit
[env]
framework = arduino
monitor_speed = 115200
extra_scripts = upload_no_build.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not intended to be here I believe

Comment on lines +1 to +8
Import("env")
env.AddCustomTarget(
"uploadnobuild",
None,
'pio run -e %s -t nobuild -t upload' %
env["PIOENV"],
title="Uploads without building"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem useful, but probably not in this PR / needs fixing up (doesn't appear to function)

},
{
"componentAPI": "ds18x20",
"name": "DS18B20: Temperature Sensor (°F)",
Copy link
Contributor

@tyeth tyeth Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This degree symbol is \u encoded in another config (src/config.json), not sure it matters, but was curious how the two ended up differing/ Looks like export includes the degree symbol, so probably the checksum calculation script is doing it.

Also the sensor component appears to be including two metrics, so should be named differently, and presumably major rework for the front end / rails to accommodate (but totally in line with our talk of one poll period per sensor instead of subcomponent).

WS_DEBUG_PRINTLN("Published AnalogIOEvent message to broker!")
} else {

// TODO: Log out this data by calling a logging function in sdcard class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming we're not doing general logging and only datapoints are logged to SD, is that correct?

uint8_t workbuf_v2[4096];

// make filesystem
FRESULT r = f_mkfs("", FM_FAT | FM_SFD, 0, workbuf_v2, sizeof(workbuf_v2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This result could be checked too

}

// Write contents to the formatted filesystem
if (!writeFSContents()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be called unless !is_fs_formatted so we avoid writing to the file system unnecessarily. Alternatively the comments throughout the method mention it being a fresh file system which won't be the case most of the time with the current code.
Alternatively the brownout PR can resolve that issue of unnecessarily replacing bootout.txt each boot and we can fix this up later.

#define UNKNOWN_VALUE "unknown" ///< Default unknown JSON field value
#define MAX_SZ_LOG_FILE (512 * 1024 * 1024) ///< Maximum log file size, in Bytes
#define MAX_LEN_CFG_JSON \
4096 ///< Maximum length of the configuration JSON file, in Bytes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably need to be bigger / doubled, the current offline-config is 1.5k with 4 components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants