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

fprintf string

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



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

fprintf string
PostPosted: Wed Jun 28, 2017 7:45 am     Reply with quote

Hi people,

The code below show -> AT+FTPPUTNAME="Test.

But what I need is -> AT+FTPPUTNAME="Test.txt"

What is wrong ?

Thanks.

Code:


char fileName[]="Test.txt";

fprintf(BT,"AT+FTPPUTNAME=\"%s\"\r",fileName);

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 8:00 am     Reply with quote

It works for me in MPLAB vs. 8.92 simulator, compiled with CCS vs. 5.071.
I get this in the output window:
Quote:
AT+FTPPUTNAME="Test.txt"

Test program:
Code:
#include <18F46K22.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, NOPBADEN
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS, stream=BT)

//==============================
void main()
{
char fileName[]="Test.txt";

fprintf(BT,"AT+FTPPUTNAME=\"%s\"\r", fileName);

while(TRUE);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19569

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 8:06 am     Reply with quote

Nothing.

You are probably hitting another problem. Is the stream buffered?. One thing would be if you are using the CCS buffering, this throws away data if you overflow the buffer. So (for instance), my code doing the same thing:
Code:

      printf(GSMputc,"AT+FTPPUTNAME=\"%s\"\r", file_to_send); //set filename

Uses the subroutine 'GSMPutc' to send the characters, which encapsulates the CCS buffering as:
Code:

void GSMputc(int chr) {
   while (tx_buffer_available(GSM) < 2)
      ; //hold if buffer would overflow
   fputc(chr,GSM);
}

To prevent the CCS code from doing this (alternatively use your own buffering).

I see PCM_programmer also posted there was nothing wrong, while I was typing. Smile
Orcino



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 10:05 am     Reply with quote

This is very strange.

If I remove the \" \" show -> AT+FTPPUTNAME=teste.txt

with \" \" show -> AT+FTPPUTNAME="teste.

But if I put a delay aftter fprintf

Code:

fprintf(BT,"AT+FTPPUTNAME=\"%s\"\r\n",fileName);
delay_ms(500);


Show correct -> AT+FTPPUTNAME="teste.txt"
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 10:12 am     Reply with quote

Post your PIC and your CCS compiler version.
Orcino



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 10:21 am     Reply with quote

PIC is 24FJ128GB204 and version of the compiler is 5.071

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19569

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 10:36 am     Reply with quote

Orcino wrote:
This is very strange.

If I remove the \" \" show -> AT+FTPPUTNAME=teste.txt

with \" \" show -> AT+FTPPUTNAME="teste.

But if I put a delay aftter fprintf

Code:

fprintf(BT,"AT+FTPPUTNAME=\"%s\"\r\n",fileName);
delay_ms(500);


Show correct -> AT+FTPPUTNAME="teste.txt"


So, something you are doing immediately after the print, is stopping the UART, or flushing it's buffer.

On your chip, you are losing what is in the hardware buffer. When you exit the print, there can be four characters still left to send. Something you are doing is stopping these from sending.....

If you need to do something to the UART, to wait for these to send, just use:
Code:

    while(Tx_buffer_bytes>0)
        ;


which will wait for the UART to finish transmission.
Orcino



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 11:40 am     Reply with quote

Thanks Ttelmah and PCM programmer.

I was testing in debug mode, in release mode, it is working normally.

Orcino
Ttelmah



Joined: 11 Mar 2010
Posts: 19569

View user's profile Send private message

PostPosted: Wed Jun 28, 2017 12:17 pm     Reply with quote

Guessing you had a breakpoint before the data had finished sending. Remember the hardware _stops_ when you break....
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