Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^3: Wierd File pipe problem...

by steves (Curate)
on Dec 20, 2004 at 23:22 UTC ( #416351=note: print w/replies, xml ) Need Help??

in reply to Re^2: Wierd File pipe problem...
in thread Wierd File pipe problem...

It would help to see the exact code and output from a failure. I still don't understand 100% but it sounds like your failure is on the read side -- that you try reading from the device and get an empty "line". In the first read examples, you're opening the device with O_NDELAY. If I remember correctly, on most *nix systems, the way that behaves with a terminal device is that it returns nothing if nothing is available on the terminal at the time of the read. It seems like that behavior may be matching exactly what you're seeing. I also believe that an open using O_NDELAY may itself return immediately, before the terminal device is ready, which could cause problems that only show up when timing changes.

In general, reading directly from terminal devices like this is tricky and error prone. So you may want to revisit exactly what it is you're trying to achieve -- something else I can't really gather from the example so far. The last open is cat'ing the terminal device and reading from that output. That should do almost the same thing the opens before it are attempting, but it should avoid the O_NDELAY issues ... I think. It would help to know the context the terminal device is bneing read in -- what's being typed there, how that device relates to the one the program is running on, etc.

Replies are listed 'Best First'.
Re^4: Wierd File pipe problem...
by bferlin (Acolyte) on Dec 21, 2004 at 16:57 UTC
    Here's the skinny. What I REALLY want to do is just cat the file /dev/ttyS0 and read the resulting ascii characters one line at a time. I have already thought about just capturing a buffered stream of characters, which is what I'm going to do next (Just use sysopen and sysread, then capture characters between /ns and pass them on to the next part.) If anybody has a suggestion on just reading the damn file and calling a command based on the data off that line, let me know. And thanks for everybody for looking... I'll let you know if it works!
Re^4: Wierd File pipe problem...
by bferlin (Acolyte) on Dec 21, 2004 at 15:32 UTC
    I tried missing the O_NDELAY by using sysopen with that option. I also tried a basic cat pipe to avoid that as well. It's driving me crazy because, (And here's the kicker) IT STILL PRINTS. $line prints just fine, no matter how many times it goes through. But if I run ANY function on it, no matter what, the return is always empty. Why would it print okay, but not return from functions okay?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://416351]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2023-03-24 16:51 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (61 votes). Check out past polls.