lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] hayes commands popping up in ppp stream


From: Sylvain Rochet
Subject: Re: [lwip-users] hayes commands popping up in ppp stream
Date: Fri, 14 Nov 2014 11:54:45 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi chrysn,


On Fri, Nov 14, 2014 at 10:09:18AM +0100, chrysn wrote:
> hello lwip users,
> 
> i'd like to keep track of my gsm device's position while a ppp data
> connection is active. unfortunately, that means that the non-ppp
> messages (/\r\n+CENG:[0-9,"a-f]+\r\n/ in my case) arrive in the same
> stream as ppp messages. (at least, it appears, they are not fully
> interleaved).

I feel dazed and confused, is this really a thing which is actually 
usual in the wild or is it specific to your modem ?

AFAIK modems usually use DTR level to switch from data mode to command 
mode, which is an OOB mechanism so it doesn't need dubious parsing. I 
know about the "pause +++ pause" mechanism but it is nowadays rarely 
used since it is prone to erroneous termination, and +STRING+ is not it.

Anyway, maybe you have a way out of that, modems in data mode are in 
strict binary mode of course so any ASCII parsing of the binary stream 
should result in a failure... but PPP use HDLC framing and your GSM 
modem is in charge of creating those HDLC frames as well as sending your 
ASCII string and I hope they are not overlapping.

HDLC frames always start with 0xff 0x03 in case of PPP over serial line, 
which goes to the following with the added HDLC flags:
  0x7e 0xff 0x03 ... 0x7e

While your "ASCII frame" will probably be:
  0x7e 0x0d(\r) 0x0a(\n) 0x2b(+) ... 0x7e

So you can probably split up those frames without much issue.


> does the lwip ppp stack provide a mechanism to feed back rejected
> strings somewhere else, or do i need to inspect the ppp stack's internal
> state from outside, determine whether it is currenlty inside or outside
> of a frame, and divert \r\n... sequences from it if no frame is
> currently being received?

Well, this looks like an ugly hack, I am not sure this belong to the 
lwIP stack, especially if this is specific to one modem. It actually 
breaks the HDLC framing protocol.

HDLC is pretty simple to parse and you don't need to do PPP packet 
formatting, then you can parse the HDLC stream and split up "HDLC valid 
frames" vs "ASCII frames" in the way your modem specific implementation 
does and before sending them to lwIP.

You don't even need to take care of HDLC byte-escaping because you 
should not find 0x7e inside a frame, well, 0x7e is also ASCII character 
~ and this is at least one reason why it actually breaks the HDLC 
framing.


> for reference, i'm working with lwip master branch, and the modem i'm
> using is a simcom sim900d. apart from the CENG messages, occasional
> "\r\nUNDER-VOLTAGE WARNNING\r\n" (sic) messages appear, and those can't
> be switched off.

[libel shield running, empty text here] ;-)


Sylvain

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]