keypad-firmware icon indicating copy to clipboard operation
keypad-firmware copied to clipboard

Overlapping messages

Open ghost opened this issue 6 years ago • 3 comments

On occasion the Serial.read() on my network arduino would get overlapping messages from the Alarm Panel arduino on the Serial.println() when the display message and the status message were really close together on an event change like arming system. The Serial.read() would start getting the Display message and then the Status message would cut in and would get a mixed string of display and status. A quick fix to that was to add Serial.flush(); to the end of each Display and Status message. So far that seems to be working great with no issues. Just thought I would pass that along.

ghost avatar Jun 02 '18 22:06 ghost

Stand corrected, the serial.flush() reduced the problem but still getting a random few overlapping messages on the network arduino. Serial console on the first alarm panel aruino is showing just fine so the problem is with the timing on the serial connection to the second arduino when the incoming alarm panel message come in too close together. Seems to only happen on the display message but the overlapping message that cuts in could be a status message or a display message which I think is due to the display message being significantly longer. Still researching this problem.

ghost avatar Jun 04 '18 01:06 ghost

Is the message that cuts in complete and then the original message finishes or do they intertwine?

{F7...}{F2}{...F7}

or

{F7...}{F2...}{...F7}{...F2}{...F7}

markkimsal avatar Jun 04 '18 11:06 markkimsal

I changed the Json into a much smaller packet so it fits in the 64bit serial limit and to keep it small as possible. Your core structure is the same, just different message format in your Json section. Here is what proper messages look like. Display message: LEN: 42 MSG: DFFFFTFTF: DISARMED CHIME Hit * for faults Status message: LEN: 6 MSG: SFTTTF

Here are some sample collisions. LEN: 61 MSG: DTFFFTFTT:ARMED ***DTFFFTFTT:ARMED AWAYMay Exit Now 44 LEN: 25 MSG: DTFFFTFTT:ARMED ***SFTTTF LEN: 61 MSG: DTFFFTFTT:ARMED ***DFFFFTFTF: DISARMED CHIME Hit * for faults LEN: 61 MSG: DTFFFTFTT:ARMED ***DTFFFTFTT:ARMED AWAYMay Exit Now 42 LEN: 61 MSG: DTFFFTFTT:ARMED ***DTFFFTFTT:ARMED AWAYMay Exit Now 29 LEN: 25 MSG: DTFFFTFTT:ARMED ***SFTTTF

In all cases, the second message cuts into the first message and the first message never completes and the second message takes over and prints in full. Also interesting to note that it seems to cut in at the same 20th char and we get the first 19 chars of the first message. On the alarm panel arduino, the serial console never ever shows these collisions and the Serial.print is clean and never see any problems. It only happens on the second arduino that is doing the serial1.read() where the collisions happen.

ghost avatar Jun 04 '18 16:06 ghost