-
-
Notifications
You must be signed in to change notification settings - Fork 398
gRPC interface to monitors #286
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
Conversation
Tests are failing because of a missing dep on the Docker image we use in the CI, fixing in a separate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super clean implementation, I like it a lot.
Tested successfully with the provided gist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Serial monitor test checked: LGTM
What
This PR adds a bidirectional stream implementing a serial monitor through gRPC
How
The concept of
Monitor
is introduced in thearduino
package. AMonitor
is an interface capable of reading a writing to a certain "target":A
Monitor
is used by a new gRPC service, different from the one exposing the cli commands, to let users pass astream
object that can be used to read/write from/to the monitor at the same time (bidirectional stream):In order to initialize a Monitor target (think about opening a serial port, or connecting to a socket) the first message of the stream must contain a special message containing the type of the target (for now only SERIAL), a string containing the target name, and a special field called
additionalConfig
that implements a JSON-like generic object, to be used to pass configuration options that are peculiar for specific targets:Subsequent message will just contain data in the form of an array of bytes. Messages sent back from the Monitor will be similar, just containing data:
Serial monitor
This PR also includes a concrete implementation of the
Monitor
interface, specific to talk with a serial port:Upon receiving the first message, a serial port will be opened according to the configuration parameters, and 2 goroutines will be started to interact with the gRPC stream and the serial port respectively. The serial port will be gracefully closed in case the stream is closed from the client side.
Example
To test a server started out of this branch you can use a sketch and client programs from https://gist.github.com/masci/804ba2679c8598630ca05919713ab106
TODO