这些方框代表什么?
从设备文件读取时获得此输出。
我用cutecom和putty检查过。它工作正常。
这是我的代码片段。
def button_on_pressed(self):
## try connecting to serial port
try:
## create an instance of serial port with user specified parameters
self.port_connected = serial.Serial(port=self.ids.txtinp_1.text,baudrate=int(self.ids.txtinp_2.text),timeout=0)
self.ids.text_3.text='[color=3333ff][b]successful connected to ' + self.ids.txtinp_1.text + ' ' + self.ids.txtinp_2.text+ '[/color][/b]'
self.port_connected.write('\n\n\n\n\n\n\n')
self.ids.Main_txtinp_1.text = self.readlineCR()
except serial.SerialException:
self.ids.text_3.text= '[color=ff3333][size=18][b]Error: device not available[/b][/size][/color]'
finally:
pass
def on_enter_txt_input(self,value):
try:
self.ids.text_3.text = value
print value
self.txt_input_user = value + '\r'
self.port_connected.write(self.txt_input_user)
self.ids.Main_txtinp_1.text = ''.join(self.ids.Main_txtinp_1.text + '\r\n' + self.readlineCR())
self.ids.sub_txtinp.focus = False
self.ids.sub_txtinp.focus = True
except :
self.ids.text_3.text= '[color=ff3333][size=18][b]Error: open device 1st[/b][/size][/color]'
finally:
pass
def readlineCR(self):
rv = ""
while True:
ch = self.port_connected.read(1)
rv += ch
if ch=='\r' or ch=='':
return rv