*/
do {
c = getModemChar(0);
+ if (c == DLE) {
+ c = getModemChar(0);
+ if (c == ETX) {
+ protoTrace("--> ...+DLE+ETX");
+ break;
+ }
+ }
+ if (c == '\n') {
+ protoTrace("--> ...+LF");
+ break;
+ }
+
} while (c != EOF && c != 0xff);
if (c == 0xff) { // address field received
do {
} while ((c = getModemChar(0)) != EOF);
}
stopTimeout("receiving HDLC frame data");
+ if (frame.getLength() > 0)
+ traceHDLCFrame("-->", frame);
if (wasTimeout()) {
abortReceive();
return (false);
}
- traceHDLCFrame("-->", frame);
/*
* Now collect the "OK", "ERROR", or "FCERROR"
* response telling whether or not the FCS was
gotData = true;
break;
}
+ if (c == EOF) {
+ break;
+ }
}
buf.put(bitrev[c]);
+ if (buf.getLength() > 10000) {
+ setTimeout(true);
+ break;
+ }
+
} while ((c = getModemChar(0)) != EOF);
}
}
(void) setXONXOFF(FLOW_NONE, FLOW_NONE, ACT_DRAIN);
setInputBuffering(false);
if (!messageReceived && rmResponse != AT_FCERROR) {
- /*
- * One of many things may have happened:
- * o if we lost carrier, then some modems will return
- * AT_NOCARRIER or AT_EMPTYLINE in response to the
- * AT+FRM request.
- * o otherwise, there may have been a timeout receiving
- * the message data, or there was a timeout waiting
- * for the carrier to drop. Anything unexpected causes
- * us abort the receive to avoid looping.
- * The only case that we don't abort on is that we found
- * the wrong carrier, which means that there is an HDLC
- * frame waiting for us--in which case it should get
- * picked up below.
- */
- break;
+ if (rmResponse != AT_ERROR) {
+ /*
+ * One of many things may have happened:
+ * o if we lost carrier, then some modems will return
+ * AT_NOCARRIER or AT_EMPTYLINE in response to the
+ * AT+FRM request.
+ * o otherwise, there may have been a timeout receiving
+ * the message data, or there was a timeout waiting
+ * for the carrier to drop. Anything unexpected causes
+ * us abort the receive to avoid looping.
+ * The only case that we don't abort on is that we found
+ * the wrong carrier, which means that there is an HDLC
+ * frame waiting for us--in which case it should get
+ * picked up below.
+ */
+ if (wasTimeout()) {
+ abortReceive(); // return to command state
+ }
+ break;
+ } else {
+ /*
+ * Some modems respond ERROR instead +FCERROR on wrong carrier
+ * and not return to command state.
+ */
+ abortReceive(); // return to command state
+ }
}
}
/*