Re: Reading from serial devices...

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

 



On 3/9/06, Matthew Percival <matthew@xxxxxxxxx> wrote:
> G'Day,
>
>         I am writing a script (in Lua) to transmit to/read from a serial device
> (in this case, a GSM modem).  Whilst I have no difficulty with most
> normal aspects (eg transmit AT, read back OK), I seem unable to use the
> SMS properly.  As a brief description of what should happen, I transmit
> `AT+CMGS=(phone number)' and receive back a `> ' prompt to let me know
> it is ready for the message.  If I send that line and the message in
> interactive mode (waiting to see the `> ' appear in minicom before
> sending the message), then it works fine (so the basic concept seems to
> be right), but I cannot seem to script this.
>
>         If I try to read back from the device one character at a time (after
> sending the AT+CMGS line), I get two blanks then it blocks.  If I look
> on a terminal program, I can see that after I sent the command, there
> was a carriage return and a line feed, then on the next line was the >
> and (space) for the prompt.  This suggests to me that I am reading the
> CR and the LF, but it blocks when it tries to read the next line, which
> has no control characters terminating it (after all, it is a prompts).
>
>         My question, to anyone who knows the way the serial driver works, is:
> can I read back from the device a single character, or does the driver
> only buffer a complete line, defined as being 0 or more characters
> ending in a control character (or something like that)?  My observation
> seems to be that I can read anything that ends in a control character,
> but nothing that does not.
>

Hi Matthew-

The problem is an issue of the serial port being in "cooked" mode -
the driver doesn't deliver the characters in the buttern until either
a carriage return or a line feed (I forget which one) is received.
There is a way to put the driver into "raw" mode, which delivers every
single character immediately. However, I don't have any example code
in front of me, and the only example code that I have is in C. I can
forward you the example code a little later today, if you are
intereseted. I'm surry there's a way to do it via command-line/script,
I just don't know it off the top of my head.

-James



>         Thanks for your time,
>
>         Matthew
>
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
>
>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux