Extending the protocol#

The server and the device communicate through a binary protocol, designed exclusively for Scrutiny. This protocol is a half-duplex and oeprates in a command-based fashion. Each request has a command ID (7bits) and a subcommand ID (8bits).

In order to allow a user to share that communication channel with Scrutiny without interfering, it is possible to encapsulate data into a dedicated Scrutiny command called UserCommand. This command ID solely activates a user-defined callback in the firmware, passing the subfunction and data to this callback.

It is possible to send a UserCommand through the python SDK. The device’s response will then be relayed directly back to the client.


ScrutinyClient.user_command(subfunction, data=b'')[source]#

Sends a UserCommand request to the device with the given subfunction and data. UserCommand is a request that calls a user defined callback in the device firmware. It allows a developer to take advantage of the scrutiny protocol to communicate non-scrutiny data with its device.

Parameters:
  • subfunction (int) – Subfunction of the request. From 0x0 to 0x7F

  • data (bytes) – The payload to send to the device

Raises:
  • ValueError – Bad parameter value

  • TypeError – Given parameter not of the expected type

  • OperationFailure – If the command completion fails

Return type:

UserCommandResponse


class scrutiny.sdk.UserCommandResponse[source]#

(Immutable struct) Response returned by the device after performing a ScrutinyClient.user_command

subfunction: int#

The subfunction echoed by the device when sending a response

data: bytes#

The data returned by the device