LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-09-2008, 02:28 AM   #1
evilfish
LQ Newbie
 
Registered: Oct 2008
Posts: 6

Rep: Reputation: 0
Information about open()/read()


Hi guys

I have a problem with the function read() or open(), that some of you might be able to help me with.

I have a Huawei E220 3G modem, which works perfectly. I'm designing a system, that have to access the huawei modem, and read the flowreports it sends back. This also work perfectly (sometimes ).

But heres the kicker:

I currently open the modem like this:

fd = open(UIDEVICE, O_RDWR | O_NDELAY);

And read like this:

read(fd,buf,255);

As far as i know, this means that it is opened as read and write, and it has/is no_delay/non_blocking.

When i use read, it does not call the read as blocking call, so it return null, when ever no data is present. I would like it to be a blocking call. This means that I have to remove the non_blocking option on the open function. But this does not make it blocking call. It still returns null values constantly.

I have also tried to make the mode to read only: O_RDONLY. But no results.

Do any of you have some idea that i could try to make it a blocking call, or perhaps an explanation to why it is not a blocking call?

Thanks in advance.

- the fish
 
Old 10-10-2008, 12:46 PM   #2
ranton
LQ Newbie
 
Registered: May 2008
Posts: 2

Rep: Reputation: 0
For read() a return of 0 indicates an EOF/end of file condition, not a would block condition. Would block on a nonblocking fd is indicated by a return of < 0 with errno set to EAGAIN. I am not sure why you are getting an EOF condition, depends on what you're reading from, but setting to to blocking/non-blocking is not going to change it.
 
  


Reply

Tags
e220, huawei, nonblocking, open, read


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to read group information from repositories jnreddy Linux - Networking 3 10-02-2008 10:23 PM
How to read machine information? ArthurHuang Suse/Novell 3 03-05-2007 12:06 PM
LXer: Libraries facilitate open access to information with open source software LXer Syndicated Linux News 0 01-23-2007 03:54 AM
time taken to read the information present in pipe ujnam Programming 0 10-27-2004 04:19 AM
How do I read disc and space used information on a DVD? opera_sys Linux - Hardware 2 07-19-2004 05:17 PM


All times are GMT -5. The time now is 01:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration