CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

int16 over rs232
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wgalaugher



Joined: 10 Jan 2011
Posts: 18

View user's profile Send private message

PostPosted: Wed Sep 14, 2011 3:28 pm     Reply with quote

I finally got it. I understand most of the code except for this part


Code:

signed int16 wait_for_number(int16 loopfor)
 {
   int16 temp=0;
   int8 chr;
   do {
       if (!bkbhit)
      {
          chr=bgetc();
          if (chr>='0' && chr<='9') {
              //Have received a number
              temp=temp*10;
              temp=temp+(chr-'0'); //Add in the digit
          }
          if (chr=='\r') {
              //Have carriage return
              return temp;
          }
        }
       
        delay_us(90);         
       
   }   while (loopfor--);
  return -1L; //flag for 'timeout'




I would like to use this code as basis of an input screen and I need to clear the buffer for the next set of numbers. How do I do that so I can input a series of values each followed by a carrage return.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group