View previous topic :: View next topic |
Author |
Message |
zonemikel
Joined: 13 Oct 2007 Posts: 53 Location: Texas
|
How long can a printf string be ? |
Posted: Thu Aug 12, 2010 7:42 pm |
|
|
Hello I'm using hardware uart and trying to send a 64byte string. I'm really trying to send my own packet through rs232 and then just chop it up using software; however, I only get part of the string when i just send a bunch of string data using printf
eg
Code: |
fprintf(wireless,"\n %s ::",incPKT);
fprintf(wireless,"11zxcvbnmlkjh");
fprintf(wireless,"gfdsaqwertyui");
fprintf(wireless,"oplkjhgfdsaqw");
fprintf(wireless,"ertyuiopoiuaa");
fprintf(wireless,"aaaaaaaaaaaa");
|
yields
after the "::" that is.
I'm using a 16f887.
Any help or pointers are appreciated. _________________ Smart people know how stupid they are. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 12, 2010 8:07 pm |
|
|
Post a little test program. Specifically, show the array declaration and
initialization or loading of 'incPKT'. |
|
|
zonemikel
Joined: 13 Oct 2007 Posts: 53 Location: Texas
|
|
Posted: Thu Aug 12, 2010 8:26 pm |
|
|
ok ... but the inkPKT was not the problem .. if i'm doing the fprintf with static text as shown and it does not come out on the receiving end the program might as well be
while(1){
printf("kkkkkkkkkkkkksssssssssssssssllllllllllllll");
}
and my output is
kkkkkkkkkkks
but here goes
Code: |
// the declaration ...
int8 incPKT[incPKT_sz]; // x byte incoming packet
// the loading
#int_rda
void serial_isr() {
incPKT[pktIndex] = fgetc(wireless);
// if it is for us then start filling buffer, else we stay at 0
if(pktIndex == 0 && incPKT[pktIndex] == ID){
pktIndex++;}
// if it is from the server we want to lisetn too then continue
else if(pktIndex == 1 && incPKT[pktIndex] == serverID){
pktIndex++; }
// if its for us from the guy we want to listen too get it !
else if(pktIndex < incPKT_sz && pktIndex > 1){
pktIndex++; }
// if we are on 63 we have received 64 bytes our packet is done
else if(pktIndex >= incPKT_sz){
state = NEWPACKET; // set new packet to 1 so we process the packet
if(pktCount < 255){pktCount++;}else{pktCount = 0;} // int8 max = 255
pktIndex = 0; // reset our index
}else{
pktIndex = 0; // first two bytes were incorrect, start over
}// end if
}
|
_________________ Smart people know how stupid they are. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 12, 2010 8:40 pm |
|
|
Then make a program that uses the code below, that fails. Post the
#include for the PIC, #fuses, #use delay(), main(), #define statements
and variable declarations. The program should compile with no errors.
Also post your compiler version.
Code: |
while(1){
printf("kkkkkkkkkkkkksssssssssssssssllllllllllllll");
}
|
Also, what device is receiving and displaying the bad data ?
Is it a PC running a terminal program ? If so, what terminal program ? |
|
|
zonemikel
Joined: 13 Oct 2007 Posts: 53 Location: Texas
|
|
Posted: Thu Aug 12, 2010 9:00 pm |
|
|
Ya, you suspected right ... dont know why I dont !
It was my crappy c# program not printing the data, when i opened up another terminal program it printed out fine well most of it anyway
112©ssssssssssssssssskkkkkkkkkkkkkkkkkkk::::::::::sssssssssssss
printed out which is much longer than my other program was getting. It must have something to do with the buffer on the receiving terminal program's end.
sorry for the question, it isnt really pic or ccs related. _________________ Smart people know how stupid they are. |
|
|
|