Hi there
Good day
i run system.serial.readBytesAsString() and find that the return value is sometimes incomplete
for example:
The string Scaned: test123456789
sometime the string returned in value:
test12345 or test or test123456
There are no rules
def readData(rootContainer=event.source.parent):
Port=rootContainer.ScanCom1
print 'present COM',Port
recv=''
errMsg=''
try:
system.serial.configureSerialPort(\
port=Port,\
bitRate=system.serial.BIT_RATE_115200,\
dataBits=system.serial.DATA_BITS_8,\
handshake=system.serial.HANDSHAKE_NONE,\
hardwareFlowControl=False,\
parity=system.serial.PARITY_NONE,\
stopBits=system.serial.STOP_BITS_1)
system.serial.openSerialPort(Port)
# www=system.serial.readBytes(Port,10)
# print 'byte',www
recv=system.serial.readBytesAsString(Port,50,10000)
# recv=system.serial.readLine(Port,10000)
print recv+'wwwwww'
if recv:
print recv,len(recv)
else:
errMsg=u'接收空数据'
system.serial.closeSerialPort(Port)
except :
errMsg=u'打开串口失败或通讯超时'
system.serial.closeSerialPort(Port)
def sendBack(recv=recv,errMsg=errMsg,rootContainer=rootContainer):
import system
if recv:
rootContainer.getComponent('txtscan 1').ScanData=recv
print 'newerr--------------->',errMsg
rootContainer.getComponent('lberr 1').text=errMsg
if errMsg=='':
event.source.doClick()
system.util.invokeLater(sendBack)
system.util.invokeAsynchronous(readData)
* List item