writing data using MSFS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

writing data using MSFS

2,551 Views
bonzo
NXP Employee
NXP Employee

Got the MSFS file RAMDISK demo running.  Using the shell, I can write to a file.  If I specify 6 bytes, and read it back, I get "012345".

 

Now I want to write my own data using MSFS.  How do I do this?  Do I use a printf?  Or _io_write?  How do I convert the numbers?  Do I use the standard conversion specifier like you would in a printf/fprintf (e.g. d, f, x, etc)

 

Thanks, 

Labels (1)
Tags (1)
0 Kudos
4 Replies

537 Views
EAI
Contributor IV

Yes to all of your questions.

 

You can use _io_write (or write) to write binary or untranslated text data to the file.

You can use the formatted I/O functions (fprintf, etc) to write test to a file. An you can use the standard conversion specifiers.

 

Look at logging_task.c in the hvac demo for a simple example using write.

0 Kudos

537 Views
javax
Contributor I

Hello

I have goot running mfs_sdcard_twrmcf51cn128 demo. I have been testing all commands. Whe I try "write" command,

parameters  <seek_mode> and <offset> seem  to have no effect. Any try a do, I got some thing like:

01010123456789...@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz0123456789:;<=>?@ABCDEFG.............

 

Could be this a bug? or am I making some mistake?

 

I´ll appreciate any help

0 Kudos

537 Views
javax
Contributor I

Hello

 Looking at file:

C:\ProgramFiles\Freescale\Freescale MQX 3.6\shell\source\mfs\sh_write.c

 I founf these lines

// generate data to buf
               for (i = 0, c = '0', bi = 0; i < count;i++) {
                 
                  buf[bi++] = c;
                 
                  if (bi > SHELL_BLOCK_SIZE - 1) {
                     write(fd, buf, SHELL_BLOCK_SIZE);
                     bi = 0;
                  }
                 
                  if (c == 'z')
                     c='0';
                  else
                     c++;
               }

third parameter(offset) is not taken into account when data is generate. After figuring out this code , command "write" could be inproved by user. It is important that any addition you come up with to keep function reentrance feature.

 

Thanks. 

0 Kudos

537 Views
JuroV
NXP Employee
NXP Employee

Hello, I did not understand your last comment. Are you reporting a bug / improvement?

0 Kudos