0
\$\begingroup\$

I am using TI Simplelink CC2652RB LP for my project.

I have to store UART incoming data in text file created in SD card interfaced with cc2652RB LP via SPI.

Can I use the following logic along with other declarations?

char str = uart_read(uart, &input,1) fwrite(str, 1, strlen(str), src) 
\$\endgroup\$
1
  • \$\begingroup\$ No, not only is it unclear if these functions would work on your platform, even on a platform where they exist they are being horribly misused. You are confusing char str with char str[some_length] and the likely success or failure return value of uart_read() with the actual data which is presumably written to input, and you are confusing the final argument of fwrite() which should probably be some sort of at least pseudo FILE * with some random "src" that sounds more like a source or destination. Voting to close as this is hopelessly confused, try to find a logger example. \$\endgroup\$ Commented Jun 27, 2020 at 17:30

1 Answer 1

1
\$\begingroup\$

I have to store UART incoming data in text file created in SD card interfaced with cc2652RB LP via SPI.

That means you not only need to have a driver in your firmware that knows how to talk "SD card protocol over the SPI controller in your microcontroller", but also that you need a file system driver (otherwise, the concept "file" doesn't exist). That file system driver needs to read the structure of data on the SD card, and know what a file is, how to create one, how to write the data into the right places...

So, look for SD Card drivers and file systems for your microcontroller. I'm sure the examples of your board come with something like that.

Can I use the following logic along with other declarations?

that means nothing, because it literally says "Can I use the following code, but after completely replacing it with something else".

fwrite(str, 1, strlen(str), src) 

aside from the missing semicolon:

No. fwrite is a POSIX operating system function. Your microcontroller isn't running a POSIX operating system.

You need to find a file system driver for your board / microcontroller and read the documentation of that.

\$\endgroup\$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.