Server Control#
Establishing a connection#
The communication with the server is done through a TCP socket. One can call connect()
and disconnect(). It is also possible to use connect()
in a with block
- ScrutinyClient.connect(hostname, port, wait_status=True)[source]#
Connect to a Scrutiny server through a TCP socket.
- Parameters:
hostname (str) – The hostname or IP address of the server
port (int) – The listening port of the server
wait_status (bool) – Wait for a server status update after the socket connection is established. Ensure that a value is available when calling
get_latest_server_status()
- Raises:
ConnectionError – In case of failure
- Return type:
Example#
with client.connect('localhost', 1234):
pass # Do something
# disconnect automatically called
Getting the server status#
Upon establishing a connection with a client, and at regular intervals thereafter, the server broadcasts a status. This status is a data structure that encapsulates all the pertinent information about what is happening at the other end of the TCP socket. It includes:
The type of connection used by the device
A unique session ID with the device (if connected).
The state of the datalogger within the device
The loaded SFD.
etc.
- ScrutinyClient.get_latest_server_status()[source]#
Returns an immutable structure of data containing the latest server status that has been broadcast. This makes no request to the server, it simply returns the latest value. See
request_server_status_updateto fetch a new status update from the server- Raises:
ConnectionError – If the connection to the server is lost
InvalidValueError – If the server status is not available (never received it).
- Return type:
- ScrutinyClient.wait_server_status_update(timeout=2.5)[source]#
Wait for the server to broadcast a status update. Happens periodically
- Parameters:
timeout (float) – Amount of time to wait for the update
- Raises:
TypeError – Given parameter not of the expected type
ValueError – Given parameter has an invalid value
TimeoutException – Server status update did not occurred within the timeout time
- Return type:
None
- ScrutinyClient.request_server_status_update(wait=False, timeout=None)[source]#
Request the server with an immediate status update. Avoid waiting for the periodic request to be sent.
- Parameters:
wait (bool) – Wait for the response if
Truetimeout (float | None) – Amount of time to wait for the update. Have no effect if
wait=False. Use the SDK default timeout ifNone
- Raises:
OperationFailure – Failed to get the server status
TimeoutException – Server status update did not occurred within the timeout time
- Returns:
The server status if
wait=True,Noneotherwise- Return type:
ServerInfo | None
- ScrutinyClient.wait_device_ready(timeout)[source]#
Wait for a device to be connected to the server and have finished its handshake.
- Parameters:
timeout (float) – Amount of time to wait for the device
- Raises:
TypeError – Given parameter not of the expected type
ValueError – Given parameter has an invalid value
InvalidValueError – If the watchable becomes invalid while waiting
TimeoutException – If the device does not become ready within the required timeout
- Return type:
None
- ScrutinyClient.get_device_info()[source]#
Gets all the available details about the device. This information includes device id, name, communication parameters, special memory regions, datalogging details, available sampling rates, etc.
- Raises:
OperationFailure – If the request to the server fails
- Returns:
The device informations or
Noneif not device is connected- Return type:
DeviceInfo | None
- class scrutiny.sdk.ServerInfo[source]#
(Immutable struct) A summary of everything going on on the server side. Status broadcast by the server to every client.
- device_comm_state: DeviceCommState#
Status of the communication between the server and the device
- device_session_id: str | None#
A unique ID created each time a communication with the device is established.
Nonewhen no communication with a device.
- datalogging: DataloggingInfo#
Datalogging state
- sfd_firmware_id: str | None#
The firmware ID of the Scrutiny Firmware Description file actually loaded on the server.
Noneif none is loaded
- device_link: DeviceLinkInfo#
Communication channel presently used to communicate with the device
- class scrutiny.sdk.DeviceCommState[source]#
(Enum) The state of the connection with the device
- Disconnected = 1#
No device connected
- Connecting = 2#
Handshake in progress between the server and the device
- ConnectedReady = 3#
A device is connected and ready to respond to queries.
- class scrutiny.sdk.DeviceInfo[source]#
(Immutable struct) Information about the device connected to the server
- session_id: str#
The unique ID assigned to the communication session between the server abd the device when this data was gathered
- device_id: str#
A unique ID identifying the device and its software (Firmware ID).
- display_name: str#
The display name broadcast by the device
- max_tx_data_size: int#
Maximum payload size that the device can send
- max_rx_data_size: int#
Maximum payload size that the device can receive
- max_bitrate_bps: int | None#
Maximum bitrate between the device and the server. Requested by the device.
Noneif no throttling is requested
- rx_timeout_us: int#
Amount of time without data being received that the device will wait to restart its reception state machine (new frame)
- heartbeat_timeout: float#
Timeout value without heartbeat message response to consider that the communication is broken, in seconds
- address_size_bits: Literal[8, 16, 32, 64, 128]#
Address size in the device
- protocol_major: int#
Device communication protocol version (major number)
- protocol_minor: int#
Device communication protocol version (minor number)
- supported_features: SupportedFeatureMap#
Features supported by the device
- forbidden_memory_regions: List[MemoryRegion]#
List of memory region that cannot be access
- readonly_memory_regions: List[MemoryRegion]#
List of memory region that are read-only
- datalogging_capabilities: DataloggingCapabilities | None#
Contains the device datalogging capabilities.
Noneif datalogging is not supported
- class scrutiny.sdk.DeviceLinkInfo[source]#
(Immutable struct) Represent a communication link between the server and a device
- type: DeviceLinkType#
Type of communication channel between the server and the device
- config: UDPLinkConfig | TCPLinkConfig | SerialLinkConfig | RTTLinkConfig | NoneLinkConfig | CANLinkConfig | None#
A channel type specific configuration
- operational: bool#
Tells if the link is opened and working correctly
- demo_mode: bool#
Trueif the server is running an emulated device for demo purpose.Falseotherwise
- class scrutiny.sdk.SupportedFeatureMap[source]#
(Immutable struct) Represent the list of features that the connected device supports
- memory_write: bool#
Indicates if the device allows write to memory
- datalogging: bool#
Indicates if the device is able of doing datalogging
- user_command: bool#
Indicates if the device has a callback set for the user command
- sixtyfour_bits: bool#
Indicates if the device supports 64bits element. 64bits RPV and datalogging of 64bits elements (variable or RPV) are not possible if
False. Watching 64 bits variables does not depends on the device and is therefore always possible
- class scrutiny.sdk.MemoryRegion[source]#
(Immutable struct) Represent a memory region spanning from
starttostart+size-1inclusively- start: int#
Start address of the region
- size: int#
Size in bytes of the region
- class scrutiny.sdk.DataloggingInfo[source]#
(Immutable struct) Information about the datalogger that are volatile (change during the normal operation)
- state: DataloggingState#
The state of the datalogger in the device
- completion_ratio: float | None#
The completion ratio of the actually running acquisition.
Noneif no acquisition being captured
- class scrutiny.sdk.DataloggingState[source]#
(Enum) The state in which the server datalogging manager currently is
- NA = 0#
The state is not available
- Standby = 1#
The datalogger is doing nothing
- WaitForTrigger = 2#
The datalogger is logging and actively monitor for the trigger condition to end the acquisition
- Acquiring = 3#
The datalogger is actively logging and the acquisition is ending since the trigger event has been fired
- Downloading = 4#
The datalogger has finished logging and data is being transferred to the server
- Error = 5#
The datalogger has encountered a problem and is not operational
Diagnostic metrics#
The client can also provide some diagnostic metrics to monitor the well being of the system.
Local metrics (measured by the client) are available through get_local_stats().
Server metrics (measured by the server) are available through get_server_stats().
- class scrutiny.sdk.client.ScrutinyClient.Statistics#
Performance metrics given by the client useful for diagnostic and debugging
- rx_data_rate: float#
Returns the approximated data input rate coming from the server in Bytes/sec
- rx_message_rate: float#
Returns the approximated message input rate coming from the server in msg/sec
- tx_data_rate: float#
Returns the approximated data output rate sent to the server in Bytes/sec
- tx_message_rate: float#
Returns the approximated message output rate sent to the server in msg/sec
- ScrutinyClient.get_server_stats(timeout=None)[source]#
- Parameters:
timeout (float | None) –
- Return type:
- class scrutiny.sdk.ServerStatistics[source]#
Some statistics giving an insight of what’s happening on the server side
- uptime: float#
Time in seconds elapsed since the server has been started
- invalid_request_count: int#
Number of invalid request the server received
- unexpected_error_count: int#
Number of unexpected error the server encountered while processing a request
- client_count: int#
Number of clients actually connected to the server
- to_all_clients_datarate_byte_per_sec: float#
Datarate (byte/sec) going out of the API, all clients summed together
- from_any_client_datarate_byte_per_sec: float#
Datarate (byte/sec) going in the API, all clients summed together
- msg_received: int#
Number of message received, all clients summed together
- msg_sent: int#
Number of message sent, all clients summed together
- device_session_count: int#
Counter indicating how many new working connections has been established with a device
- to_device_datarate_byte_per_sec: float#
Datarate (byte/sec) traveling from the server to the device
- from_device_datarate_byte_per_sec: float#
Datarate (byte/sec) traveling from the device to the server
- device_request_per_sec: float#
Number of request/response per seconds exchanged between the server and the device
Configuring the device link#
The device link is the communication channel between the server and the device.
This link can be configured by the client. If a device is present, the server will automatically connect to it. If no device is found, the server will simply report that no device is connected
- ScrutinyClient.configure_device_link(link_type, link_config)[source]#
Configure the communication link between the Scrutiny server and the device remote device. If the link is configured in a way that a Scrutiny device is accessible, the server will automatically connect to it and inform the client about it. The client.server.server_state.device_comm_state will reflect this.
- Parameters:
link_type (DeviceLinkType) – Type of communication link to use. Serial, UDP, TCP, etc.
link_config (BaseLinkConfig | None) – A configuration object that matches the link type.
UDP:UDPLinkConfig/TCP:TCPLinkConfig/Serial:SerialLinkConfig
- Raises:
ValueError – Bad parameter value
TypeError – Given parameter not of the expected type
OperationFailure – If the request to the server fails
- Return type:
None
- class scrutiny.sdk.DeviceLinkType[source]#
(Enum) The type of communication link used between the server and the device
- NONE = 0#
No link. No device communication will happen
- UDP = 1#
UDP/IP socket
- TCP = 2#
TCP/IP Socket
- Serial = 3#
Serial port
- RTT = 4#
Segger JLink Real-Time Transfer port
- CAN = 5#
CAN Bus
TCP#
UDP#
Serial#
- class scrutiny.sdk.SerialLinkConfig[source]#
(Immutable struct) The configuration structure for a device link of type
Serial- baudrate: int#
Communication speed in baud/sec
- port: str#
Port name on the machine. COMX on Windows. /dev/xxx on posix platforms
- start_delay: float#
A delay of communication silence after opening the port. Accommodate devices that triggers a bootloader upon port open (like Arduino).
- class scrutiny.sdk.SerialLinkConfig.StopBits#
Number of stop bits as defined by RS-232
- ONE = 1#
- ONE_POINT_FIVE = 1.5#
- TWO = 2#
- classmethod from_float(v, default=None)#
- Parameters:
v (float) –
default (Self | None) –
- Return type:
Self
- get_numerical()#
Return the number of stop bits as
float- Return type:
float
- to_float()#
- Return type:
float
- class scrutiny.sdk.SerialLinkConfig.DataBits#
Number of data bits as defined by RS-232
- EIGHT = 8#
- FIVE = 5#
- SEVEN = 7#
- SIX = 6#
- classmethod from_int(v, default=None)#
- Parameters:
v (int) –
default (Self | None) –
- Return type:
Self
- get_numerical()#
Return the number of data bits as
int- Return type:
int
- to_int()#
- Return type:
int
- class scrutiny.sdk.SerialLinkConfig.Parity#
A serial port parity configuration
- EVEN = 'even'#
- MARK = 'mark'#
- NONE = 'none'#
- ODD = 'odd'#
- SPACE = 'space'#
- classmethod from_str(v, default=None)#
- Parameters:
v (str) –
default (Self | None) –
- Return type:
Self
- get_displayable_name()#
Return the value as
str- Return type:
str
- to_str()#
- Return type:
str
Seger RTT#
- class scrutiny.sdk.RTTLinkConfig[source]#
(Immutable struct) The configuration structure for a device link of type
RTT- jlink_interface: JLinkInterface#
The type of JLink interface
- target_device: str#
Chip name passed to pylink
JLink.connect()method
- class scrutiny.sdk.RTTLinkConfig.JLinkInterface#
Type of JLink interface used when calling
JLink.set_tif(). Refer to Segger documentation for more details. The values of this enum are not meant to be in sync with the Segger API. The server will convert the SDK value to a JLink enum- JTAG = 'jtag'#
ARM Multi-ICE compatible JTAG adapter
- SWD = 'swd'#
ARM Serial Wire Debug
- FINE = 'fine'#
Segger Rx Fine adapter
- ICSP = 'icsp'#
Microchip In-Circuit Serial Programming
- SPI = 'spi'#
Motorola Serial Peripheral Interface
- C2 = 'c2'#
SiLabs C2 Adapter
CAN Bus#
- class scrutiny.sdk.CANLinkConfig[source]#
(Immutable struct) The configuration structure for a device link of type
CAN- bitrate_switch: bool#
A flag telling if the server should do bitrate switch when transmitting. Only possible with CAN FD
- extended_id: bool#
A flag indicating if we use extended IDs (29 bits). Standard IDs (11 bits) are used when
False
- fd: bool#
A flag indicating if we use CAN FD. Use of CAN 2.0 when
False
- interface: CANInterface#
The type of CAN interface used to access the CAN bus
- interface_config: SocketCANConfig | VectorConfig | KVaserConfig | PCANConfig | ETASConfig#
A configuration specific to the interface
- rxid: int#
The CAN ID used to transmit data from the device to the server
- txid: int#
The CAN ID used to transmit data from the server to the device
- class scrutiny.sdk.CANLinkConfig.CANInterface#
Type of CAN interface instantiated with
python-can.- SocketCAN = 0#
Connect to a SocketCAN network interface.
- Vector = 1#
Use Vector hardware through the Vector XL API. The XL Driver library must be installed on the server
- KVaser = 2#
Use KVaser hardware
- PCAN = 3#
Use PCAN hardware through the PCAN API
- ETAS = 4#
Use ETAS hardware through the ETAS DLL.
- class scrutiny.sdk.CANLinkConfig.ETASConfig#
(Immutable struct) A ETAS specific configuration used when
CANLinkConfig.interface=ETAS.Refer to
python-candocumentation for more details.- channel: str#
The channel number
- bitrate: int#
The bitrate in bit/sec
- data_bitrate: int#
The data bitrate in bit/sec for CAN FD (requires a bitrate switch)
- class scrutiny.sdk.CANLinkConfig.KVaserConfig#
(Immutable struct) A KVaser specific configuration used when
CANLinkConfig.interface=KVaser.Refer to
python-candocumentation for more details.- channel: int#
The channel number
- bitrate: int#
The bitrate in bit/sec
- data_bitrate: int#
The data bitrate in bit/sec for CAN FD (requires a bitrate switch)
- fd_non_iso: bool#
Enable non-ISO CAN FD mode (Bosch). ISO CAN FD if
False
- class scrutiny.sdk.CANLinkConfig.PCANConfig#
(Immutable struct) A PCAN specific configuration used when
CANLinkConfig.interface=PCAN.Refer to
python-candocumentation for more details.- channel: str#
The channel number
- bitrate: int#
The bitrate in bit/sec
- class scrutiny.sdk.CANLinkConfig.SocketCANConfig#
(Immutable struct) A SocketCAN specific configuration used when
CANLinkConfig.interface=SocketCAN.Refer to
python-candocumentation for more details.- channel: str#
The name of the network interface
- class scrutiny.sdk.CANLinkConfig.VectorConfig#
(Immutable struct) A Vector specific configuration used when
CANLinkConfig.interface=Vector.Refer to
python-candocumentation for more details.- channel: str | int#
The name of the channel or channel number
- bitrate: int#
The bitrate in bit/sec
- data_bitrate: int#
The data bitrate in bit/sec for CAN FD (requires a bitrate switch)
None#
- class scrutiny.sdk.NoneLinkConfig[source]#
(Immutable struct) An Empty object acting as configuration structure for a device link of type
NONEExists only to differentiateNone(data not available) fromNoneLinkConfig(data available - no link configured)
Demo Mode#
One can enable the server demo mode with request_demo_mode().
When the demo mode is enabled, the server connects to an emulated device that runs in a python thread and simulate the scrutiny-embedded library. This mode is meant to try Scrutiny without having to go through the process of instrumenting a firmware.
The demo mode is deactivated by the server when the device connection parameters are updated with configure_device_link()
- ScrutinyClient.request_demo_mode(enable)[source]#
Enable or disable the server demo mode
- Parameters:
enable (bool) – Enable the demo mode when
True. Disable it whenFalse- Raises:
TypeError – Given parameter not of the expected type
OperationFailure – If the request to the server fails
- Return type:
None