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

Add protocol.md #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# CDBA protocol description

## General stuff:

### cdba operates over ssh

### Client:
* `~/.ssh/config` is effectively the 'real' config on the client side
* The connection is established by executing:
```sh
# serverbinaryname defaults to 'cdba-server'
/usr/bin/ssh user@server serverbinaryname
```
* ssh `stdout` receives `messages` and the client is expected to handle them instantly after receiving, until `EOF`
* ssh `stderr` receives `status updates` (blue text) and the client is expected to handle them instantly after receiving, until `EOF`

### Server:
* The server enumerates all of the connected devices, based on a configuration file
* Client messages are received over `stdin`
* Messages are sent to the clients over `stdout`, until the connection is closed (or drops)
* The server opens a tty to the serial port on the device and forwards the output via `MSG_CONSOLE`

## Supported messages
`C - client | S - server`


### 1 - MSG_SELECT_BOARD [C -> S]
> ```data = string board name | len = sizeof(data) ```
>
> Select the board to operate on.
>
> Return [**S**]: Echo the command back with `len = 0`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is isually called "Respond". Also you have been using term 'message' instead of 'command.


### 2 - MSG_CONSOLE [C <-> S]
> ```data = string_buffer | len = sizeof(data) ```
> Send TTY I/O.
>
> Return [**C**/**S**]: Echo the command back with `len = sizeof(buf), data = buf`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The way you describe hte protocol looks almost like a request/response. But at least MSG_CONSOLE isn't a request/response thing, is it?


### 3 - MSG_HARDRESET
`<unused>`

### 4 - MSG_POWER_ON [C -> S]
> ```len = 0```
>
> Power on the board.
>
> Return [**S**]: Echo the command back with `len = 0`.

### 5 - MSG_POWER_OFF [C -> S]
> ```len = 0```
>
> Power off the board.
>
> Return [**S**]: Echo the command back with `len = 0`.

### 6 - MSG_FASTBOOT_PRESENT [S -> C]
> ```data = 0 / 1 | len = 1 ```
>
> Signal that the device is available over fastboot and ready to receive further commands.
> Return [**C**]: MSG_FASTBOOT_DOWNLOAD or MSG_FASTBOOT_CONTINUE with `len = 0`.

### 7 - MSG_FASTBOOT_DOWNLOAD [C -> S]
> ```data = binary_chunk | len = sizeof(data)```
>
> Send binary data for fastboot.
>
> Return [**S**]: Echo the command back with `len = 0`.

### 8 - MSG_FASTBOOT_BOOT
`<unused>`

### 9 - MSG_STATUS_UPDATE [C -> S]
> TODO: json
>
>Return:

### 10 - MSG_VBUS_ON [C -> S]
> Enable USB VBUS going to the board.
>
> Return [**S**]: None

### 11 - MSG_VBUS_OFF [C -> S]
> Disable USB VBUS going to the board.
>
> Return [**S**]: None

### 12 - MSG_FASTBOOT_REBOOT
`<unused>`

### 13 - MSG_SEND_BREAK [C -> S]
> ```len = 0```
>
> Send a tcsendbreak to the board.
>
> Return [**S**]: None

### 14 - MSG_LIST_DEVICES [C - > S]
> ```len = 0```
>
> List the available boards.
>
> Return [**S**]: Echo the command back NUM_DEVICES times with `len = sizeof(buf), data = buf`. Once done, echo the command back with `len = 0`.

### 15 - MSG_BOARD_INFO [C -> S]
> ```data = string board name | len = sizeof(data) ```
>
> Get the board description.
>
> Return [**S**]: Echo the command back with `len = sizeof(buf), data = buf`.

### 16 - MSG_FASTBOOT_CONTINUE [C -> S]
> ```len = 0```
>
> Send `fastboot continue` to the board.
>
> Return [**S**]: Echo the command back with `len = 0`.
Loading