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:
TypeError – The input parameters type error.
PSPInvalid – The input parameter is out of range.
PSPNotSupport – This function is not supported.
NotImplementedError – It has not been verified to run on this platform.
- 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:
- 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:
PermissionError – if not running as root user
TypeError – The input parameters type error.
PSPInvalid – The input parameter is out of range.
PSPError – General PSP functional error.
10.2. Models
The following models are used to store data for data modeling.
10.2.1. COMPortInfoModel
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: