myGPIO Protocol#

myGPIOd can be controlled and queried through a simple line-based text protocol.

The myGPIOd protocol exchanges line-based text messages between client and server over a local Unix socket.

You can test the protocol with:

socat unix-client:/run/mygpiod/socket stdio

When the client connects, the server responds with:

OK
version:{major}.{minor}.{patch}
END

Default socket: /run/mygpiod/socket

Requests#

COMMAND [ARG...]

Responses#

  • The first line of the response is OK on completion or ERROR:<message> on failure.

  • After an OK:

    • Any number of key:value pairs can follow.

    • A final END denotes the end of the server response.

General commands#

close#

Closes the connection.

idle#

Enables the idle mode for the connection. In this mode the client waits for gpio events. This command disables the connection timeout.

The command returns as soon as an event occurs. It returns immediately if there are events occurred while the client was not in idle mode. myGPIOd stores only the last 10 events while not in idle mode.

Only the noidle command is allowed while the client is in idle mode.

Response

gpio:{gpio number}
event:{falling|rising|long_press}
timestamp_ms:{milliseconds}
gpio:{gpio number}
event:{falling|rising|long_press}
timestamp_ms:{milliseconds}
END

noidle#

Exits the idle mode and allows the client to send commands. It responds with the accumulated events.

Response

OK
gpio:{gpio number}
event:{falling|rising|long_press}
timestamp_ms:{milliseconds}
gpio:{gpio number}
event:{falling|rising|long_press}
timestamp_ms:{milliseconds}
END

Events#

Events are triggered by monitored gpios. Valid events are:

  • falling

  • rising

  • long_press

GPIO commands#

gpiolist#

Lists all configured gpios.

Response

OK
gpio:{gpio number}
direction:{in|out}
value:{active|inactive}
END

gpioinfo {gpio number}#

Gets the current settings of a configured input or output gpio.

Response for an input gpio

OK
direction:in
value:{active|inactive}
active_low:{true|false}
bias:{as-is|disable|pull-down|pull-up}
event_request:{both|falling|rising}
is_debounced:{true|false}
debounce_period_us:{microseconds}
event_clock:{monotonic|realtime|hte}
END

Response for an output gpio

OK
direction:out
value:{active|inactive}
drive:{push-pull|open-drain|open-source}
END

gpioget {gpio number}#

Gets the current value of a configured input or output gpio.

Response

OK
value:{active|inactive}
END

gpioset {gpio number} {active|inactive}#

Sets the value of a configured output gpio.

gpiotoggle {gpio number}#

Toggles the value of a configured output gpio.

VCIO commands#

vciotemp#

Gets the temperature from /dev/vcio.

Response

OK
Value: 36.7'C
END

vciovolts#

Gets the core voltage from /dev/vcio.

Response

OK
Value: 0.7500V
END

vcioclock#

Gets the clock speed from /dev/vcio.

Response

OK
Value: 1600017024
END

vciothrottled#

Gets the throttled mask from /dev/vcio.

Response

OK
Value: 0x0
END