writing data using MSFS

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

writing data using MSFS

2,823 次查看
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, 

标签 (1)
标记 (1)
0 项奖励
回复
4 回复数

809 次查看
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 项奖励
回复

809 次查看
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 项奖励
回复

809 次查看
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 项奖励
回复

809 次查看
JuroV
NXP Employee
NXP Employee

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

0 项奖励
回复