Using read to read from serial channel problem

Using read to read from serial channel problem

Post by Henrik Rav » Fri, 26 Jan 2001 00:47:03



Helle there.

In my target I have a serial port which I have on /tyCo/1.
I use "open( "/tyCo/0", O_RDWR, 0 )" to open the channel, later on I try to
read something from the port using the following: read( DeviceHandle,
SomeCharPointer, 1 ). If nothing has arrived on the channel, i would expect
the read-call to return immediately with return value 0. That doesn't seem
to be tha case - am I missing some initialisation with ioctl() or is
something else missing?

Henrik Ravn

 
 
 

Using read to read from serial channel problem

Post by Paul Whick » Fri, 26 Jan 2001 17:34:27


No sir, read is a blocking call, it won't return until it's got your
character. Look at using select(), I think there may also be an ioctl or some
other method for checking to see if there is a character there.

Surely the manual entry for read() mentions this?

Paul



Quote:>Helle there.

>In my target I have a serial port which I have on /tyCo/1.
>I use "open( "/tyCo/0", O_RDWR, 0 )" to open the channel, later on I try to
>read something from the port using the following: read( DeviceHandle,
>SomeCharPointer, 1 ). If nothing has arrived on the channel, i would expect
>the read-call to return immediately with return value 0. That doesn't seem
>to be tha case - am I missing some initialisation with ioctl() or is
>something else missing?

>Henrik Ravn


 
 
 

Using read to read from serial channel problem

Post by Andi Betsc » Fri, 26 Jan 2001 21:40:48


Hello,

there is an ioctl call. Use the following lines:

if (ioctl(fd, FIONREAD, (int)&iNum) != 0) /* Error ? */
    return(ERROR);                  

 if (iNum > 0)                       /* data available? */
 {
    if (read(fd, buf, 1) != 1)       /* read byte from device ok ?*/
      return(ERROR);                  /* no */
 }

Good bye.



Quote:>Helle there.

>In my target I have a serial port which I have on /tyCo/1.
>I use "open( "/tyCo/0", O_RDWR, 0 )" to open the channel, later on I try to
>read something from the port using the following: read( DeviceHandle,
>SomeCharPointer, 1 ). If nothing has arrived on the channel, i would expect
>the read-call to return immediately with return value 0. That doesn't seem
>to be tha case - am I missing some initialisation with ioctl() or is
>something else missing?

>Henrik Ravn

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----
 
 
 

Using read to read from serial channel problem

Post by Bob Irwi » Sat, 27 Jan 2001 00:35:19



> Helle there.

> In my target I have a serial port which I have on /tyCo/1.
> I use "open( "/tyCo/0", O_RDWR, 0 )" to open the channel, later on I try to
> read something from the port using the following: read( DeviceHandle,
> SomeCharPointer, 1 ). If nothing has arrived on the channel, i would expect
> the read-call to return immediately with return value 0. That doesn't seem
> to be tha case - am I missing some initialisation with ioctl() or is
> something else missing?

a read of tyCo is supposed to block until the requested number of bytes
have been read.  To check if bytes have been received without blocking
use the FIONREAD ioctl .  see man page for tyLib.

 - bob

--

 
 
 

1. PS2 online choas READ READ READ

I can not believe it!!!!!!!!
I decieded to check out how the compatition is doing a
online matters go, and it comes to my attention that more
than 75% of the PS2 online users are having trouble
playing any of the PS2 online games!!!! one said that
whan they started SOCOM up (a great [GAY] game that is
online) that his headset did not work and the PS2 turned
off by itself. Sony has charged him $120.00 dollars to
get the problem fixed (like you wouldn't spend $30.00
more to get an XBOX [kicks ASSSS]). Another writes that
sony did not install a USB port on his PS2 console, so he
can't plug in a headset to play online (like you would

There is a post on PS2.com, I believe it is titled,"WHAT
A RIPOFF!", where a PS2 owner has started a frenzy on how
SONY is not responding to any of the problems that people
are having with PS2 online! He and about 100 others that
have posted said they have had enough of SONYS $H1T (good
4 u). NOW!!!!!!!!!, is there anyone out there that can
prove to me in one aspect that PS2 online will be better
than !!XBOX LIVE!!? didn't think so. As 4 Gamecube,
Nintendo is going to be a software only company just like
SEGA (go Super Monkey Balls and Sonic Adventure 2 Battle
Rumble Fight Scuffle). And don't even take me into how
much better !!XBOX!! than PS2. I hope you sll will choose
wisely!

        P.S. !!XBOX!! rulz. Have fun with !!XBOX!! LIVE

2. ELM patches: IMAP, RELM

3. solved: Read Access Violation while using DDE to read Excel(Win NT/SAS8.2]

4. Curves

5. Read Access Violation while using DDE to read Excel(Win NT/SAS8.2]

6. Cheat devices ie, code breaker or gameshark is on available now?

7. Unable to Read read DICOM 3.0 Images Using Papyrus Toolkit

8. HELP! uncompress under Windows

9. How to open (to read) a database on a read-only partition using je1.5.0

10. How to read serial port using Excel VB

11. using serial port to read information

12. Problem of reading of the serial port

13. Problem reading comma-delimited text files using VBA