From 1faec65785eb58c80f0bbb4c6a6fea3e3e05a473 Mon Sep 17 00:00:00 2001 From: djfiander Date: Fri, 17 Oct 2008 23:48:02 +0000 Subject: [PATCH] Untested fix for dealing with the incorrect record terminators transmitted by Cen-Tec self-check hardware. --- Sip.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sip.pm b/Sip.pm index 03b0815..a1e586c 100644 --- a/Sip.pm +++ b/Sip.pm @@ -164,6 +164,19 @@ sub read_SIP_packet { local $/ = "\r"; $record = readline($file); + + # + # Cen-Tec self-check terminals transmit '\r\n' line terminators. + # This is actually very hard to deal with in perl in a reasonable + # since every OTHER piece of hardware out there gets the protocol + # right. + # + # The incorrect line terminator presents as a \r at the end of the + # first record, and then a \n at the BEGINNING of the next record. + # So, the simplest thing to do is just throw away a leading newline + # on the input. + # + $record =~ s/^\012//; syslog("LOG_INFO", "INPUT MSG: '$record'") if $record; return $record; } -- 2.11.0