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

How long can a printf string be ?

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



Joined: 13 Oct 2007
Posts: 53
Location: Texas

View user's profile Send private message Visit poster's website Yahoo Messenger

How long can a printf string be ?
PostPosted: Thu Aug 12, 2010 7:42 pm     Reply with quote

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



Quote:

::11zxcvbnmlkj
h

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

View user's profile Send private message

PostPosted: Thu Aug 12, 2010 8:07 pm     Reply with quote

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

View user's profile Send private message Visit poster's website Yahoo Messenger

PostPosted: Thu Aug 12, 2010 8:26 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 12, 2010 8:40 pm     Reply with quote

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

View user's profile Send private message Visit poster's website Yahoo Messenger

PostPosted: Thu Aug 12, 2010 9:00 pm     Reply with quote

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.
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