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

Need Help and Suggestion

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







Need Help and Suggestion
PostPosted: Wed May 27, 2009 4:45 pm     Reply with quote

Hello everyone,

I got some questions.

I am using three PICs to communicate with Bluetooth.

PIC 1 connects to PIC 2 and PIC 2 sends a number which is 30 to PIC 1 and then PIC 1 uses " Value1=getc( )" to save this value. After that, PIC 1 cuts the communication with PIC 2 and then connects to PIC 3. PIC 3 sends a number which is 60 and then PIC 1 uses "Value2=getc( )" to save the value. I want to do some comparisions between these two values.

My first question is:
Code:

//*** PIC 1 connect to PIC 2***//

if(kbhit())  ======> connect to PIC 2 to get value
  {
    Value1=getc();           
    delay_ms(2500);
   }

//*** PIC 1 connect to PIC 3 ***//

if(kbhit())  ======> connect PIC 3 to get value
  {
    Value2=getc();     
    delay_ms(2000);
  }

The code is like this. If PIC 2 sends the same value twice to PIC 1 and when PIC 1 connects to PIC 3 and use "value2=getc", is it possible for Value2 of the PIC 3 to get the value (because of the buffer) which from PIC2?

How can I to avoid this situation? I mean that Value1 is really from PIC2 and Value 2 is really form PIC 3?

My second question is:
May I use this ==> " if (Value1>Value2+10)" to compare this to value?
I mean that I used this condition but it does not work. Did I do anything wrong?

My third question is:

I want to transmit the value ==> putc(' 30 ' ) or putc(30). Which one is correct for the real figure and which one can be used to be saved to compared.

Any help will be really appreciated.

Sincerely,
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