SFM2 Python Lib

To begin working with the library, first create a Sfm2 instance using connect_first_found() (or see Sfm2Factory for other options). Once you have the Sfm2, see Sfm2 for reference on how to use it.

Note

The simplest way to navigate this docs is to use hyperlinks. Start with connect_first_found(). Click on its return type to navigate to Sfm2 page. Then explore the properties of Sfm2 class, again using return values to see details.

You may also want to check out utils in utils

sfm2.sfm2_factory

class sfm2.sfm2_factory.Sfm2Factory

Bases: object

Static class used to create Sfm2 objects.

See the static methods of this class for different connection options.

static create_on_serial_port(port_name: str, options: sfm2.interface.sfm2_init_options.Sfm2InitOptions = Sfm2InitOptions(skip_version_check=False, cache_name=True, terminate_serial_on_error=False, response_timeout_s=2, log_all_cmds=False, verify_all_cmd_response_values=True, reset_retries_after_timeout=3, delay_after_reset_s=0.5, serial_port_sync_enabled=True, serial_port_sync_timeout_s=10, serial_rx_timeout_s=1, self_test_timeout_s=20, enable_acc_for_env_sensors=True))sfm2.interface.sfm2.Sfm2

Connects to a SFM2 device on selected serial port

Parameters
  • port_name (str) – Serial port name

  • options (Sfm2InitOptions) – Additional options. Can be omitted.

Returns

A connected SFM2

Return type

Sfm2

static find_all_on_serial_ports(options: sfm2.interface.sfm2_init_options.Sfm2InitOptions = Sfm2InitOptions(skip_version_check=False, cache_name=True, terminate_serial_on_error=False, response_timeout_s=2, log_all_cmds=False, verify_all_cmd_response_values=True, reset_retries_after_timeout=3, delay_after_reset_s=0.5, serial_port_sync_enabled=True, serial_port_sync_timeout_s=10, serial_rx_timeout_s=1, self_test_timeout_s=20, enable_acc_for_env_sensors=True)) → Iterator[sfm2.interface.found_sfm2.FoundSfm2]

Discovers all SFM2s connected to the computer.

Calling this function does not yet connect to any device. Instead you get an iterable collection of found SFM2s, represented as FoundSfm2 objects, which you can then use to connect.

Parameters

options (Sfm2InitOptions) – Additional options. Can be omitted.

Return type

Iterator[FoundSfm2]

static connect_first_found(options: sfm2.interface.sfm2_init_options.Sfm2InitOptions = Sfm2InitOptions(skip_version_check=False, cache_name=True, terminate_serial_on_error=False, response_timeout_s=2, log_all_cmds=False, verify_all_cmd_response_values=True, reset_retries_after_timeout=3, delay_after_reset_s=0.5, serial_port_sync_enabled=True, serial_port_sync_timeout_s=10, serial_rx_timeout_s=1, self_test_timeout_s=20, enable_acc_for_env_sensors=True))sfm2.interface.sfm2.Sfm2

Connects to first found SFM2

Raises

NoSfm2FoundException – When no SFM2s were found.

Parameters

options (Sfm2InitOptions) – Additional options. Can be omitted.

Return type

Sfm2

static connect_all_found(device_options: sfm2.interface.sfm2_init_options.Sfm2InitOptions = Sfm2InitOptions(skip_version_check=False, cache_name=True, terminate_serial_on_error=False, response_timeout_s=2, log_all_cmds=False, verify_all_cmd_response_values=True, reset_retries_after_timeout=3, delay_after_reset_s=0.5, serial_port_sync_enabled=True, serial_port_sync_timeout_s=10, serial_rx_timeout_s=1, self_test_timeout_s=20, enable_acc_for_env_sensors=True), collection_options: sfm2.interface.sfm2_init_options.Sfm2CollectionInitOptions = Sfm2CollectionInitOptions(ignore_connection_errors=False, key_by_id_not_name=False, allow_duplicate_keys=False)) → sfm2.utils.sfm2_collection.Sfm2Collection

Connects to all found SFM2

Raises

NoSfm2FoundException – When no SFM2s were found.

Parameters

options (Sfm2InitOptions) – Additional options. Can be omitted.

Return type

Sfm2