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

Code structure suggestions #2

Open
6 of 9 tasks
Eirenliel opened this issue Dec 27, 2022 · 0 comments
Open
6 of 9 tasks

Code structure suggestions #2

Eirenliel opened this issue Dec 27, 2022 · 0 comments
Assignees

Comments

@Eirenliel
Copy link
Member

Eirenliel commented Dec 27, 2022

Can't write, but I can criticize! So, here are my suggestions on what to do change with code examples!

  1. Move ESP-specific functions to a separate file

fn reset_esp_no_delay(pin: &mut OutputPin) -> rppal::gpio::Result<()> {

fn reset_esp(pin: &mut OutputPin) -> rppal::gpio::Result<()> {

fn enable_flashing(flash_pin: &mut OutputPin, rst_pin: &mut OutputPin) -> rppal::gpio::Result<()> {

  1. Move serial-specific functions to a separate file

fn read_serial(serial: &mut Box<dyn SerialPort>) -> Result<([u8; 128], usize), String> {

  1. Split main function into multiple stages, like init, runTests, generateReport, finish, etc...

  1. Instead of repeating this part of code on error or on success it should be a separate function that would be easy to edit everywhere

reporter.fill(tui::Color::Red);
sleep(Duration::from_secs(1));
wait_for_next_board(&mut reporter, board);

reporter.fill(tui::Color::Green);
sleep(Duration::from_secs(1));
wait_for_next_board(&mut reporter, board);

  1. We should first connect to serial, then reset the board, since USB is not reset.

reset_esp_no_delay(&mut rst_pin).unwrap();
reporter.in_progress("Connecting to serial port...");

  1. All [ERR], [FATAL], [SEVERE] etc errors in logs should be reported as test failure, not just a few specific ones

if l.contains("[ERR] I2C: Can't find I2C device on provided addresses, scanning for all I2C devices and returning") ||

  1. Should check that BNO is on the correct address and reports correct firmware values, not just part of the log (ask for the full log)

if l.contains("[INFO ] [BNO080Sensor:0] Connected to") {

  1. Actually serial should probably have a function to "wait for text and throw an error if it gets [ERR], [FATAL], [SEVERE]", so we could reuse it. We should be able to send it a list of strings to watch for - all of them should be present to succeed and no errors should be present during this time.

  2. Figure out why serial writing doesn't work, and GET TEST is not parsed by the board at all...

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

No branches or pull requests

3 participants