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

String problem with one more ENTER

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
carlosma



Joined: 24 Mar 2004
Posts: 53
Location: Portugal

View user's profile Send private message Send e-mail MSN Messenger

String problem with one more ENTER
PostPosted: Thu Jul 22, 2004 3:40 am     Reply with quote

Hello
to select Write or Read data from RS232 to EEPROM, I have two functions like this:
WRITE TO EEPROM
Code:

void anexoW(){
fprintf(COM_A, "\r\nMens Liga: ");
get_string(string, ROM_MENS_LIGA_SIZE);
write_eeprom_string(string, ROM_MENS_LIGA, ROM_MENS_LIGA_SIZE);
         
fprintf(COM_A, "\r\nMens Desl: ");
get_string(string, ROM_MENS_DESL_SIZE);
write_eeprom_string(string, ROM_MENS_DESL, ROM_MENS_DESL_SIZE);
//...
fprintf(COM_A, "\r\nSaved\r\n");
}


READ FROM EEPROM
Code:

void anexoR(){

      read_eeprom_string(s, ROM_EPASSW, ROM_EPASSW_SIZE);
      fprintf(COM_A,"AT#EPASSW=\"%s\"\r\n",s);
     //...
      read_eeprom_string(s, ROM_EADDR, ROM_EADDR_SIZE);
      fprintf(COM_A,"AT#EADDR=\"%s\"\r\n",s);
}

But when I call to anexoW(), never back to principal program, needs one more Enter to back. I have in my principal program a real time clock with interrupt and STOP.
I do not understand, why needs a Enter.

Thank you Carlos
valemike
Guest







PostPosted: Thu Jul 22, 2004 8:11 am     Reply with quote

I've had this problem before, not only on PIC stuff, but also PowerPC-based routers and PBXes that use serial lines to a PC or Linux workstation.

You can eliminate the extra carriage return necessary by putting in a:
Code:

    getchar();


This will "eat" up the pending carriage return.

-Mike

p.s. I'm not sure why it does it, but may be something to do with Hyperterminal (Windows), Kermit (Linux/Unix), etc. I'm shooting in the air, but i think it can be described as "raw" or "cooked" mode for your terminal i/o.
valemike
Guest







PostPosted: Thu Jul 22, 2004 8:13 am     Reply with quote

To be more specific,

put a "getchar()" exactly after your getstring() function call.
carlosma



Joined: 24 Mar 2004
Posts: 53
Location: Portugal

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Thu Jul 22, 2004 9:38 am     Reply with quote

Thank you for help
Now works

Carlos
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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