10. API - COM Port

10.1. Regular Classes

The following classes are intended for general use with the devices they represent. All classes in this section are concrete (not abstract).

10.1.1. COMPort

class lannerpsp.COMPort(num: int)[source]

Communication Port.

Parameters:

num (int) – COM port number

Raises:
get_info() COMPortInfoModel[source]

Get COM port information.

Example:

>>> com1 = COMPort(1)
>>> com1_info = com1.get_info()
>>> com1_info.num
1
>>> com1_info.mode
485
>>> com1_info.mode_str
'RS-485'
>>> com1_info.termination
True
>>> com1_info.termination_str
'Enabled'
>>> com1_info.to_dict()
{'num': 1, 'mode': 485, 'mode_str': 'RS-485', 'termination': True, 'termination_str': 'Enabled'}
Returns:

COM port information

Return type:

COMPortInfoModel

Raises:

PSPError – General PSP functional error.

set_mode(mode: int) None[source]

Set COM port mode to RS-232, RS-422 or RS-485.

Example:

>>> com1 = COMPort(1)
>>> com1.set_mode(232)
Parameters:

mode (int) – 232/422/485

Raises:
set_termination(enable: bool) None[source]

Set RS-422/RS-485 termination.

Example:

>>> com1 = COMPort(1)
>>> com1.set_termination(False)
Parameters:

enable (bool) – set True to enable, otherwise False

Raises:

10.2. Models

The following models are used to store data for data modeling.

10.2.1. COMPortInfoModel

class lannerpsp.COMPortInfoModel(num: int, mode: int, mode_str: str, termination: bool, termination_str: str)[source]

To store COM port information.

to_dict() Dict[str, Any][source]

Convert to dict.

10.3. Supported Platforms

Note

The LEC-7242 requires some additional dependencies to be installed via pip install lannerpsp[portio] to use the COM port.

The following platforms have been verified and confirmed to be supported: