-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Since the serial port of the microcontroller is occupied by the Msgpack RPC, the usual Serial.println(...)
cannot be used.
We need a way to send debugging messages. The proposed solution is to create an API on the router to send and receive a debugging stream, thereby mimicking the behavior of a classic serial port.
Here is a possible API that I've already implemented in the router: https://github.com/bcmi-labs/orchestrator/pull/358
New methods implemented in the router:
mon/read MAXLEN
: returns the bytes written from the orchestrator in the data stream. It returns at most MAXLEN bytes, or the empty array if no data is present.
mon/write DATA
: writes DATA to the data stream to the orchestrator. DATA is a string or a binary array.
mon/connected
: returns true if the orchestrator is connected to the data stream, false otherwise. If the orchestrator is not connected, every read and write results in a null operation, and the data is discarded.
mon/reset
: disconnects the orchestrator from the data stream, it should be used when the board is reset.
Ideally, we want to create a Monitor
object that extends Stream
and could be used in the sketch instead of Serial
.
Every message sent or received from the Monitor
object will be forwarded through the mon/read
and mon/write
RPC methods.