这个matlab函数用来设置串口参数
function [sphandle] = configureCliPort(comportPnum)
comportnum_str = ['COM' num2str(comportPnum)]
sphandle = serial(comportnum_str, 'BaudRate', 115200);
set(sphandle, 'Parity', 'none')
set(sphandle, 'Terminator', 'LF')
fopen(sphandle);
return
现需要将它转为python,我是这么改的:
def configureCliPort(comportPnum):
comportnum_str = ['COM'+str(comportPnum)]
sphandle = serial.Serial(comportnum_str, 115200)
sphandle.parity = serial.PARITY_NONE
sphandle.stopbits = 1
open(sphandle)
return sphandle
调用了serial函数库
问题在于,在python串口通信模块里没有找到终止符的设置属性
也就是说, set(sphandle, 'Terminator', 'LF') 这行代码的对应不确定
依据网上的指南,我 用sphandle.stopbits = 1 替代它
但感觉意思已经不一样了
这行代码的python对应是什么?求解答