Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6603973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:05:21+00:00 2026-05-25T19:05:21+00:00

i m using Select() sys cal on XBee rf module which is on /dev/ttyUSB0.but

  • 0

i m using Select() sys cal on XBee rf module which is on /dev/ttyUSB0.but this syscal just doesnt return(returns only on timeout),but if i use read() in a WHILE loop on this port i can see the data comming

 /*code to open the port*/
 system("stty -F /dev/ttyUSB0 5:0:8bd:0:3:1c:7f:15:1:64:0:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0");
fd = open("/dev/ttyUSB0", O_RDWR  );
printf("fd is %d",fd);
if(fd == -1)
    return ERR_PORT;

select returns only when TIMEOUT not when port is ready for reading

FD_ZERO (&set);
FD_SET (fd, &set);//fd is an opened file des. for /dev/ttyUSB0
struct timeval timeout;
timeout.tv_sec = 50;
timeout.tv_usec = 0;

if(select(FD_SETSIZE,&set, NULL,NULL,&timeout)==1)
  Do_stuff();
else
  return TIMEOUT;

but if i use following i can see the data being printed

char ch;
while(1)
{
 read(fd,&ch,1);
printf("\n0x%X",ch);
}

Please note: about command in system() function,i got it by issuing stty -F /dev/USB0 -g after having GTKterm opened on /dev/ttyUSB0.(thats when i was able to talk to my modem from my program) so made a guess that GTKterm configured the port,and i used the exact same configuration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:05:21+00:00Added an answer on May 25, 2026 at 7:05 pm

    The first argument to select() is the highest file descriptor in the set plus one. Your statement should be:

    if (select(fd + 1,&set, NULL,NULL,&timeout) == 1)
    {
       ...
    }
    

    EDIT: Also you assume if select() doesn’t return 1, it’s due to a timeout issue, which is only true if 0 is returned. Check for -1 return and report the value of errno. Also ensure that the file descriptor is in non-blocking mode.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this: SELECT * FROM sys.dm_exec_query_stats s CROSS APPLY sys.dm_exec_sql_text( s.sql_handle )
Is it possible using jQuery to select all <a> links which href ends with
We were using stringstream to prepare select queries in C++. But we were strongly
By trying this use master go select * into #TempTable from sys.all_views select *
Does hibernate HQL queries support using select min, max, count and other sql functions?
The name of a temporary table such as #t1 can be determined using select
For example, mysql quote table name using SELECT * FROM `table_name`; notice the `
I have a partial that renders a select box using the following method: <%=
Does anyone know why, using SQLServer 2005 SELECT CONVERT(DECIMAL(30,15),146804871.212533)/CONVERT(DECIMAL (38,9),12499999.9999) gives me 11.74438969709659, but
Using the following query: SELECT pe.prodtree_element_name_l, MAX(rs.resource_value) AS resource_value FROM prodtree_element pe LEFT JOIN

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.