Skip to main content
Topic: How to create a new file? (Read 989 times) previous topic - next topic

How to create a new file?

I run a modified version of MCstackDemo2.
I would like to ad a type of log file to the webserver. If the log file dosent exist it should be created.
Have anybody tested something like this?



Re: How to create a new file?

Reply #1
No, haven't tried yet, but writing files to the SD card is something that I will want to do ( when I get to that bit ).

If you've configured UART 1correctly, and are able to send data back to a PC using printf() - that is, you've created an implementation of _mon_putc(char c ), something like so:
Code: [Select]
void _mon_putc(char c){
while(U1STAbits.UTXBF == 1); //if buffer is full, wait
    U1TXREG = c;

Then you could log requests to the serial port by simply adding printf() statements in the SM_HTTP_PARSE_REQUEST switch case in HTTP2_MDD.c
Once that's successful, it should be a short jump to writing it to a file instead ( swap printf() from stdio.h to FSvfprintf() from FSIO.h )