Global functions

c104.set_debug_mode(mode: c104.Debug) None

set the debug mode

Parameters:

mode (Debug) – debug mode bitset

Example

>>> c104.set_debug_mode(mode=c104.Debug.Client|c104.Debug.Connection)
c104.get_debug_mode() c104.Debug

get current debug mode

Returns:

debug mode bitset

Return type:

Debug

Example

>>> mode = c104.get_debug_mode()
c104.enable_debug(mode: c104.Debug) None

enable additional debugging modes

Parameters:

mode (Debug) – debug mode bitset

Example

>>> c104.set_debug_mode(mode=c104.Debug.Client|c104.Debug.Connection)
>>> c104.enable_debug(mode=c104.Debug.Callback|c104.Debug.Gil)
>>> c104.get_debug_mode() == c104.Debug.Client|c104.Debug.Connection|c104.Debug.Callback|c104.Debug.Gil
c104.disable_debug(mode: c104.Debug) None

disable debugging modes

Parameters:

mode (Debug) – debug mode bitset

Example

>>> c104.set_debug_mode(mode=c104.Debug.Client|c104.Debug.Connection|c104.Debug.Callback|c104.Debug.Gil)
>>> c104.disable_debug(mode=c104.Debug.Callback|c104.Debug.Gil)
>>> c104.get_debug_mode() == c104.Debug.Client|c104.Debug.Connection
c104.explain_bytes()

explain bytes in a string

c104.explain_bytes_dict()

explain_bytes(apdu: bytes) -> str

Interpret 104er APDU bytes and extract information into a dictionary

Parameters:

apdu (bytes) – APDU protocol bytes

Returns:

information about APDU in dictionary {"format":str, "type":str, "cot":str, "rx": Optional[int], "tx": Optional[int], "numberOfObjects": Optional[int], "sequence": Optional[bool], "negative": Optional[bool], "test": Optional[bool], "commonAddress": Optional[int], "originatorAddress": Optional[int], "firstInformationObjectAddress": Optional[int], "elements": Optional[str]}

Return type:

dict

Example

>>> def sv_on_receive_raw(server: c104.Server, data: bytes) -> None:
>>>    pprint("SV] -->| {1} [{0}] | SERVER {2}:{3}".format(data.hex(), c104.explain_bytes_dict(apdu=data), server.ip, server.port))
c104.add_client(tick_rate_ms: int = 1000, command_timeout_ms: int = 1000, transport_security: c104.TransportSecurity | None = None) None

create a new 104er client

Parameters:
  • tick_rate_ms (int) – client thread update interval

  • command_timeout_ms (int) – time to wait for a command response

  • transport_security (TransportSecurity) – TLS configuration object

Warning

Deprecated: Use the default constructor c104.Client(…) instead. Will be removed in 2.x

c104.remove_client(instance: c104.Client) None

destroy and free a 104er client

Parameters:

instance (Client) – client instance

Warning

Deprecated: Simple remove all references to the instance instead. Will be removed in 2.x

c104.add_server(self: c104.Server, ip: str = '0.0.0.0', port: int = 2404, tick_rate_ms: int = 1000, max_connections: int = 0, transport_security: c104.TransportSecurity | None = None) None

create a new 104er server

Parameters:
  • ip (str) – listening server ip address

  • port (int) – listening server port

  • tick_rate_ms (int) – server thread update interval

  • max_connections (int) – maximum number of clients allowed to connect

  • transport_security (TransportSecurity) – TLS configuration object

Warning

Deprecated: Use the default constructor c104.Server(…) instead. Will be removed in 2.x

c104.remove_server(instance: c104.Server) None

destroy and free a 104er server

Parameters:

instance (Server) – server instance

Warning

Deprecated: Simple remove all references to the instance instead. Will be removed in 2.x