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 support@ccsinfo.com

Time limit for rs232

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



Joined: 21 Aug 2007
Posts: 6

View user's profile Send private message

Time limit for rs232
PostPosted: Fri Aug 31, 2007 10:50 am     Reply with quote

Hello,
I'm using the pic18f4455 with module ethernet tibbo em202, but i'dont know when i loose the connection ethernet.
How i can detect if the connection rs232 is failed or interrupt receiving data if the time is so longer?

Thanks
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Sep 01, 2007 9:02 am     Reply with quote

V4 include new RS232 features that would be useful in this case, for example:

int mygetc(char *c, int n=500);

This function waits n milliseconds for a character over RS232 and return accordingly
TRUE or FALSE.


Humberto
Guest








PostPosted: Tue Sep 04, 2007 11:53 am     Reply with quote

It's works. Thanks for your help.
Tuga



Joined: 21 Aug 2007
Posts: 6

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 12:52 pm     Reply with quote

lol

i use the version 4, and my compiler show this message: Undefined identifier mygetc

Code:
#use rs232(baud=38400, xmit=pin_d1, rcv=pin_d0)
void putnet( char c )
{
   putc(c);
}

char getnet()
{
   return(getc());
}

int getnett(char c, int time)
{
   int valor=0;
   valor=mygetc(&c, 200);
   return valor;
}


it's necessary use other library?

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 1:09 pm     Reply with quote

Here is a demo program for the new getc() timeout feature in Vs. 4 of
the compiler. The timeout is specified in the #use rs232 statement
as shown below. In this example it's set for 5000 ms (5 seconds).

Here is the output of the program. If you press a key in your terminal
window within 5 seconds, the program will get the key and display it.
If it doesn't get a keypress within 5 seconds it will display "Timed out".
Quote:

Timed out
Timed out
Received: a
Received: a
Received: a
Received: a
Timed out


Code:

#include <16F877.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000) 
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS, TIMEOUT=5000)
   
//====================================
void main()
{
char c;


while(1)
  {
   c = getc();

   if(c == 0)
      printf("Timed out \n\r");
   else
      printf("Received: %c \n\r", c);
  }
     
}       

This was tested with PCM vs. 4.053 on a PicDem2-Plus board.
Tuga



Joined: 21 Aug 2007
Posts: 6

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 2:23 pm     Reply with quote

Thanks, it's work now, but i need change the pins for time limit work's:
d1->c6 and d0->c7,
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