前面获开机获取了基本参数,今天继续完善,这次是手工设定阻值:
Python的代码:
def QrChange(self):
myRvalue = self.ui.lineEdit.text()
try:
if myRvalue != "":
myRvalue = int(myRvalue)
atcmd = "AT+USER.SP=%s" % myRvalue
self.test_at.send_at(atcmd)
mystr = self.test_at.check_at_resp('OK')
if mystr is not None:
pattern = r".=(\d+.\d+)"
m_list = re.findall(pattern, mystr)
if len(m_list) == 4:
self.ui.label_R.setText("当前设定阻值(SP):%s R" % m_list[0])
self.ui.label_PV.setText("当前电阻输出值(PV):%s" % m_list[1])
except Exception as e:
print("err: %s" % e)
实验现象:
QQ录屏20220821102927
|