View previous topic :: View next topic |
Author |
Message |
Orcino
Joined: 07 Sep 2003 Posts: 56
|
fprintf string |
Posted: Wed Jun 28, 2017 7:45 am |
|
|
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
|
|
Posted: Wed Jun 28, 2017 8:00 am |
|
|
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
|
|
Posted: Wed Jun 28, 2017 8:06 am |
|
|
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. |
|
|
Orcino
Joined: 07 Sep 2003 Posts: 56
|
|
Posted: Wed Jun 28, 2017 10:05 am |
|
|
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
|
|
Posted: Wed Jun 28, 2017 10:12 am |
|
|
Post your PIC and your CCS compiler version. |
|
|
Orcino
Joined: 07 Sep 2003 Posts: 56
|
|
Posted: Wed Jun 28, 2017 10:21 am |
|
|
PIC is 24FJ128GB204 and version of the compiler is 5.071
Thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19569
|
|
Posted: Wed Jun 28, 2017 10:36 am |
|
|
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
|
|
Posted: Wed Jun 28, 2017 11:40 am |
|
|
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
|
|
Posted: Wed Jun 28, 2017 12:17 pm |
|
|
Guessing you had a breakpoint before the data had finished sending. Remember the hardware _stops_ when you break.... |
|
|
|