This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C167 Reading data from files

Hello,

I am currently doing a project and wanted a workaround to read in data from files to char arrays like the fopen function does in C for example.
I am not allowed to use the CAN Bus and thus have to do a workaround.

If somebody happens to know what I should start looking after or has some ideas please feel free to share it with me, thank you in advance!

Parents Reply Children
  • Hello,

    Thanks for the advice I will try that out.

    The file is located on the pc which is connected through the ASC0 of the C167.

  • The nearest thing to your setup would be the File_ex1 example,
    solely because it uses a serial interface. The product team offers trial PSN's, at their discretion:
    You'll want to download a ARTX update:
    http://www.keil.com/update/ar166.asp
    to get access to the File_ex1 example.

    The example stores input from the serial interface into a file stored in SRAM, rather than taking data from a file on the PC to an array of char's.
    The File_ex1 example could only be used as an example of the interface.

    Anyways, you don't even need a file system on the microcontroller, for what you are trying to do. Just output the file data over a serial interface from the PC:
    stackoverflow.com/.../how-to-send-file-over-serial-port-in-windows-command-prompt
    via some kind of trigger.

    Then transfer data from peripheral buffer to the array of chars.

    A file system helps:
    --increase robustness for larger data transfers,
    --(with flash) store data, in non-volatile memory, to add some protection to data (ex. during a power loss),
    --store used data and remove unused data in a very organized way, and
    --provide easy compatibility for data transfers back to the PC,
    at least, when compared to multiple arrays of chars.

  • Hello,

    thank you for all your help in the first place. I will try these things out thanks for answering!

  • You can't just read a file from a PC through the COM port.

    You need some software on the PC that reads the file and then transmits the contents to the COM port.

    Do you want this to be all fully automatic, or is it sufficient to have a user on the PC select the file and give a 'send' command ... ?