Communication Protocols
I/O Protocol Overview
The BB-400 supports multiple protocols for communicating with the digital I/O subsystem. Each protocol has different characteristics suitable for various applications.
| Protocol | Port |
|---|---|
| ASCII TCP | 9500 |
| REST | 9000 |
| WebSocket | 8989 |
ASCII TCP Protocol
The ASCII protocol provides a simple query-response interface compatible with Brainboxes ED range remote I/O modules. Connect to port 9500 using Telnet or any TCP client.
Common ASCII Commands
| Command | Response | Description |
|---|---|---|
| @01 | >(Data) | Read digital I/O status |
| @01(Data) | > | Set all digital outputs |
| #01N | !01(Data) | Read counter value for channel N (0-7) |
REST API
The REST API enables HTTP-based access to I/O state. The server runs on port 9000 and returns JSON responses.
REST Endpoints
| Endpoint | Method | Description |
|---|---|---|
| /io | GET | Get complete I/O state (inputs, outputs, counts) |
| /io/inputs | GET | Get all input states |
| /io/inputs/N | GET | Get state of input N |
| /io/outputs | GET | Get all output states |
| /io/outputs | POST | Set all output states (JSON array) |
| /io/outputs/N | POST | Set state of output N |
Example REST Request
GET http://bb400-xxxx:9000/io returns:
{
"inputs": [1, 0, 1, 0, 0, 0, 1, 1],
"outputs": [0, 1, 0, 0, 0, 0, 0, 0],
"counts": [0, 0, 0, 0, 0, 0, 0, 0]
}
WebSocket Protocol
The WebSocket server on port 8989 provides real-time bidirectional communication. The server pushes I/O state changes to connected clients and accepts JSON commands to modify outputs.
Connect using: ws://bb400-xxxx:8989
To set outputs, send a JSON array: [1,0,0,0,0,0,0,1] sets DIO 0 and DIO 7 high.
Unix Domain Socket
For applications running locally on the BB-400, the Unix Domain Socket provides the fastest access to I/O state. The socket file is located at /var/run/bb-io.sock.
curl -GET --unix-socket /var/run/bb-io.sock http://localhost/io