Dear Sir/Ms
I encountered an issue when using system.serial.writeBytes and system.serial.write.
When i write to the hyperterminal, i notice that the first few characters are missing , the maximum characters that it would output to the hyper terminal is only “03-19 16:22:56”, whatever is in front would be chopped off.
Whereas the two statements { print "today = " , today} before and after the write statement , printed on to the console perfectly.
It seems that there is some kind of limitation or buffer? Is there any way to increase it?
I need to send/write a data packet in one write command across the serial port.
I have no problem reading the similar data packet, it looks something like this in ASCII format:
“2018-03-19 16:25:13<\r><\n>Number=30<\r><\n>1,60.0<\r><\n>2,0.0<\r><\n>”
Would appreciate any advise or help in this .
Thank you very much
The following is my code tested using date and time only instead of the full data packet:
def serialwrite(today):
port=“COM1”
system.serial.configureSerialPort(
port=“COM1”,
bitRate=system.serial.BIT_RATE_19200,
dataBits=system.serial.DATA_BITS_8,
handshake=system.serial.HANDSHAKE_NONE,
hardwareFlowControl=False,
parity=system.serial.PARITY_NONE,
stopBits=system.serial.STOP_BITS_1)
print " "
print "START *********************************************************START "
system.serial.openSerialPort(port)
today=today+’\r\n’
print "today = " , today
system.serial.writeBytes(port, today)
print "today = " , today
system.serial.write(port, today)
system.serial.closeSerialPort(port)
LCcurrentlist=[]
today1 = system.date.now()
today= system.date.format(today1, “yyyy-MM-dd HH:mm:ss”)
print serialwrite(today)