Reading from serial devices...

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

 



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.

	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/


[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