Serial data source stops receiving data after a period of time.
-
Hi Terry,
It seems like occasionally the '\r' character is not being extracted from the buffer.
Here is an example from the logs:DEBUG 2014-08-11 13:24:58,217 (com.infiniteautomation.serial.rt.SerialDataSourceRT.matchPointValues:316) - Message matched regex: (([A-Z][A-Z][0-9]+.[0-9]+[a-zA-Z0-9]+=).\r)|(.\r)
DEBUG 2014-08-11 13:24:58,218 (com.infiniteautomation.serial.rt.SerialDataSourceRT.matchPointValues:320) - Point Identified: null
DEBUG 2014-08-11 13:24:58,222 (com.infiniteautomation.io.serial.SerialPortProxyEventTask.run:29) - Running event created at: 1407720298215
DEBUG 2014-08-11 13:24:58,223 (com.infiniteautomation.serial.rt.SerialDataSourceRT.serialEvent:252) - Buffer after read: 534f3234312e
DEBUG 2014-08-11 13:24:58,223 (com.infiniteautomation.io.serial.JsscSerialPortInputStream.serialEvent:119) - Serial Receive Event fired.
DEBUG 2014-08-11 13:24:58,224 (com.infiniteautomation.io.serial.JsscSerialPortInputStream.serialEvent:128) - Recieved: 31373546524f4d3d3234312e3137350d534f3234312e313735484f50533d320d534f3234312e
DEBUG 2014-08-11 13:24:58,225 (com.infiniteautomation.serial.rt.SerialDataSourceRT.serialEvent:281) - Terminator not found in message yet.
DEBUG 2014-08-11 13:24:58,225 (com.infiniteautomation.io.serial.SerialPortProxyEventTask.run:29) - Running event created at: 1407720298224
DEBUG 2014-08-11 13:24:58,226 (com.infiniteautomation.io.serial.JsscSerialPortInputStream.serialEvent:119) - Serial Receive Event fired.
DEBUG 2014-08-11 13:24:58,226 (com.infiniteautomation.serial.rt.SerialDataSourceRT.serialEvent:252) - Buffer after read: 534f3234312e31373546524f4d3d3234312e3137350d
DEBUG 2014-08-11 13:24:58,227 (com.infiniteautomation.io.serial.JsscSerialPortInputStream.serialEvent:128) - Recieved: 313735525353493d2d3531
DEBUG 2014-08-11 13:24:58,227 (com.infiniteautomation.serial.rt.SerialDataSourceRT.serialEvent:274) - Matching will use UTF8: SO241.175FROM=241.175Here the buffer starts with 534f3234312e - "SO241."
Data is then read from the serial port 31373546524f4d3d3234312e3137350d534f3234312e313735484f50533d320d534f3234312e
"175FROM=241.175
SO241.175HOPS=2
SO241."The buffer is now
"SO241.175FROM=241.175
SO241.175HOPS=2
SO241."Then the debug message "Terminator not found in message yet." however there are 2 '\r' strings sitting in the buffer.
The two strings "SO241.175FROM=241.175\r" and "SO241.175HOPS=2\r" then get extracted from the buffer which should leave "SO241." in the buffer. The rest should follow in the next serial port read.
It would seem like the buffer is filling up faster than the data is being extracted from it.
Matt.
-
Matt,
I've changed the logging to show the buffer as UTF8 instead of as Hex, this should make life a little easier. I also changed the way the terminators are matched and processed, allowing the processing of multiple messages at once. You were correct in assuming that we were "missing" some of the terminators because of the amount of data coming in on the port so quickly.
Give this version a try and let me know how it goes.
Thanks,
TerryAttachment: download link
-
CheersTerry,
The last module ran for a day without crashing so that's an improvement. Hopefully your last change should fix the issue of terminators being missed.Thank you for your help,
Matt. -
Hi Terry,
That last Data Source seems to have fixed the crashing.
How do I remove the added debug messages from the logs?
I have removed the line from the log4j configuration file and restarted Mango but the messages keep coming.
I am getting daily logs over 650MB in size.Cheers,
Matt.