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

Feature/usb terminal #54

Merged
merged 17 commits into from
Sep 9, 2020
Merged

Feature/usb terminal #54

merged 17 commits into from
Sep 9, 2020

Conversation

ryan-summers
Copy link
Member

@ryan-summers ryan-summers commented Sep 8, 2020

This PR adds a basic USB serial terminal for configuring the broker and booster IP addresses as well as resetting the device. It also adds a placeholder BoosterSettings structure for containing device-wide configuration parameters.

This closes #9

Currently, the USB functionality relies on the changes in rust-embedded-community/usb-device#41 to implement a stable usb serial port, so forks have been set up for usb-device, usbd-serial, synopsys-otg-usb, and stm32f4xx-hal to use the forked usb-device crate. Once changes are merged, we should integrate them into our dependencies and update as necessary.

Settings are not yet persisted to flash, so configuration is not maintained upon reset.

TODO:

  • Add netmask and gateway as configurable properties
  • Allow configuration of booster MQTT ID
  • Get a real USB VID:PID
  • Use MAC or chip UID as USB serial number

src/serial_terminal.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
}
}

#[task(priority = 2, schedule = [channel_monitor], resources=[channels, leds])]
#[task(priority = 3, schedule = [channel_monitor], resources=[channels, leds])]
Copy link
Member

Choose a reason for hiding this comment

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

Correct. This should stay the highest priority task. If its duration causes problems with latency spikes on the other tasks, then we need to tweak it.

Copy link
Member Author

Choose a reason for hiding this comment

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

The only reason I'm changing the priorities here is because the mqtt_client will block when attempting to connect the TCP port - when we're using that resource, the interrupt priority threshold is raised to that of the task with the highest priority that also uses the mqtt_client. Right now, that task is only telemtry. USB has been put at a slightly higher priority than telemetry just to ensure that MQTT client locking does not unintentionally block the USB interface, which would make it pretty unresponsive.

@ryan-summers
Copy link
Member Author

Here's a capture of what the terminal console looks like:
image

match self.usb_serial.read(&mut buffer) {
Ok(count) => {
// Echo the data back.
self.write(&buffer[..count]);
Copy link
Member Author

Choose a reason for hiding this comment

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

We should probably have a CommandLine proxy to manage arrow keys, backspace, and other characters to make the terminal nicer to work with. Something like an embedded-readline

Copy link
Member

Choose a reason for hiding this comment

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

Yes if it reduces the amount of code. But the command line doesn't need to be extensive.

Copy link
Member Author

Choose a reason for hiding this comment

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

Any sort of support for arrow keys, backspacing, or other character detection would only really increase complexity at this point, so if we're going for MVP, I would recommend we leave it as-is.

Copy link

Choose a reason for hiding this comment

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

Any sort of support for arrow keys, backspacing, or other character detection would only really increase complexity at this point, so if we're going for MVP, I would recommend we leave it as-is.

Works for me. I plan to have very minimal interactions with this interface so simple is good (in contrast to the old firmware which had lots of bells and whistles that didn't help me, but also lots of bugs)

@ryan-summers ryan-summers requested a review from jordens September 9, 2020 10:29
@ryan-summers ryan-summers merged commit 486d5ca into develop Sep 9, 2020
@ryan-summers ryan-summers deleted the feature/usb-terminal branch September 9, 2020 16:14
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.

Develop a basic user terminal over USB
3 participants