[LCP]read - serial port programming
Bill Rausch
BRausch at owt.com
Wed May 14 23:28:02 UTC 2003
At 5:50 -0700 5/14/03, michael bosu wrote:
>Hi,
>
>Please to read from the serial port, what does the
>function read return. For instance if the code below
>return 8 for count. Does that mean the number of bytes
>is 8 or what?
>
>Also if I want to get the actual bytes received how do
>I go about it.
>
>
>if ((count = read(fd, &vbuf[vlen], BUFFERSIZE - vlen))
>== -1) {
>
> perror("read");
> exit(1);
>
> }
>
>Thank you,
>Michael mfbosu at yahoo.com
Read the man pages. "man read" If that isn't understandable, get a
good book. ;)
Yes, read() returns the number of bytes read. They are stored in the
buffer you supply. In the example above, the first byte read would
be at vbuf[vlen], the next at vbuf[vlen+1], etc.
--
"Try to learn something about everything and everything about
something." (Thomas H. Huxley)
More information about the linuxCprogramming
mailing list