SECS I

module imports.

class secsgem.secsi.SecsISettings(**kwargs)[source]

Settings for SECS-I connection.

These attributes can be initialized in the constructor and accessed as property.

Example

>>> import secsgem.secsi
>>>
>>> settings = secsgem.secsi.SecsISettings(port="COM1")
>>> settings.port
'COM1'
>>> settings.speed
9600
property port: str

Serial port.

Default: “”

property speed: int

Serial port baud rate.

Default: 9600

create_protocol()[source]

Protocol class for this configuration.

Return type:

Protocol

create_connection()[source]

Connection class for this configuration.

Return type:

Connection

property name: str

Name of this configuration.

generate_thread_name(functionality)[source]

Generate a unique thread name for this configuration and a provided functionality.

Parameters:

functionality (str) – name of the functionality to generate thread name for

Return type:

str

Returns:

generated thread name

class secsgem.secsi.SecsIProtocol(settings)[source]

Implementation for SECS-I protocol.

message_type

alias of SecsIMessage

serialize_data()[source]

Return data for serialization.

Returns:

data to serialize for this object

Return type:

dict

class secsgem.secsi.SecsIHeader(system, session_id, stream=0, function=0, block=0, from_equipment=False, require_response=False, last_block=True)[source]

Generic SECS I header.

Base for different specific headers

property block: int

Get block number.

property from_equipment: bool

Get if the message is from equipment (True) or host (False).

This is the reverse bit (r-bit).

property last_block: bool

Get if the message is the last of a multi-block message.

This is the end bit (e-bit).

encode()[source]

Encode header to SECS I message.

Return type:

bytes

Returns:

encoded header

Example

>>> import secsgem.secsi
>>> import secsgem.common
>>>
>>> header = secsgem.secsi.SecsIHeader(2, 100)
>>> secsgem.common.format_hex(header.encode())
'00:64:00:00:80:00:00:00:00:02'
classmethod decode(data)[source]

Decode data to SecsIHeader object.

Parameters:

data (bytes) – data to decode

Return type:

SecsIHeader

Returns:

new header object