|
|
View previous topic :: View next topic |
Author |
Message |
arys
Joined: 09 Mar 2007 Posts: 31
|
Rx problem |
Posted: Mon Jan 21, 2008 3:52 am |
|
|
Hi.
as I know PIC receive 8bit character at Rx. But i want PIC receive string from PC. I'm using getc() function to get string input and it's not work. Is there any function could convert or receive string from PC ? |
|
|
Ttelmah Guest
|
|
Posted: Mon Jan 21, 2008 4:25 am |
|
|
Built into the language, gets(). In the libraries, in "input.c", get_string().
Now be aware of the 'caveats'. You _must_ have enough space to hold the whole string, _and it's terminating '\0' character_. This is the real 'danger' of gets, in that if you have storage for a 20 character string, and somebody types 21 characters, then the memory buffer will overflow, destroying data. 'get_string', allows you to specify a 'maximum length' to avoid this. There have also been published here, routines to perform a 'timeout' on serial I/O, and the get_string code, can be adapted to use these, to get round the problem of your program being 'hung' waiting for the data to arrive.
Best Wishes |
|
|
arys
Joined: 09 Mar 2007 Posts: 31
|
|
Posted: Wed Jan 23, 2008 10:04 pm |
|
|
sorry...
just delete the post. I will not do it again. |
|
|
|
|
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
|