Is there a way to send shell commands from a script instead of manually typing them when using KSDK1.2.0 shell interface

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

Is there a way to send shell commands from a script instead of manually typing them when using KSDK1.2.0 shell interface

614 Views
roseersin
Contributor I

I am using shell MQX task to get the commands from serial port on FRDM-K22F board but I am unable to figure out how to automate this. I can manually type in the command and shell interface compares the command with the list I provided in SHELL_COMMAND_STRUCT but I would like to be able to send these commands using a script. I am currently using putty to type the commands but even if I use plink (which is a command line tool for putty), I still get the same shell interface and I couldn't figure out how I can automate this. Any help would be appreciated.

pastedImage_0.png

Tags (2)
0 Kudos
1 Reply

386 Views
DavidS
NXP Employee
NXP Employee

Hi Rose,

A method to input Shell command via "C" code is below:

void my_task(uint_32)

{

  char_ptr   ARGV[4];

  char       CMD_LINE[40]="copy a:\\test.txt c:\\my.txt";

    /* create lwevent group */

    if (_lwevent_create(&lwevent_FS,0) != MQX_OK) {

    printf("\nMake event failed");

    _task_block();

    }

    while(TRUE)

    {

    snprintf(CMD_LINE, 28, "copy a:\\test.txt c:\\my.txt");

  if (_lwevent_wait_ticks(&lwevent_FS,0b11,TRUE,0) != MQX_OK)

  {

  printf("\nEvent Wait failed");

  _task_block();

  }

  printf("\nbefore copying\n");

  printf("%s",CMD_LINE);

  Shell_parse_command_line(CMD_LINE, ARGV);

  Shell_copy(3, ARGV);

  printf("\nafter copying\n");

  if (_lwevent_clear(&lwevent_FS,0b11) != MQX_OK) {

    printf("\nEvent Clear failed");

    _task_block();

  }

    }

}

Regards,

David