Skip to main content

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.

ProtocolPort
ASCII TCP9500
REST9000
WebSocket8989

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

CommandResponseDescription
@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

EndpointMethodDescription
/ioGETGet complete I/O state (inputs, outputs, counts)
/io/inputsGETGet all input states
/io/inputs/NGETGet state of input N
/io/outputsGETGet all output states
/io/outputsPOSTSet all output states (JSON array)
/io/outputs/NPOSTSet 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.

Example using cURL
curl -GET --unix-socket /var/run/bb-io.sock http://localhost/io