• AVR Freaks

How to add arguments to my commands

Author
dobrosoft
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2019/05/20 04:44:55
  • Location: 0
  • Status: offline
2019/06/10 23:55:02 (permalink)
0

How to add arguments to my commands

Hello. I create my own commands for harmony SYS_CMD
 
static const SYS_CMD_DESCRIPTOR cmdTbl[]=
{
  {"switchled1",
  CommandLed1,
  ": Switch on LED #1"},
}
 
static int CommandLed1(SYS_CMD_DEVICE_NODE* pCmdIO, int argc, char** argv)
{
  const void* cmdIoParam = pCmdIO->cmdIoParam;
  (*pCmdIO->pCmdApi->msg)(cmdIoParam, LINE_TERM " *** Switching on Led 1 ***\r\n" );
  LED1On();
return 1;
}
 
bool APP_AddCommandFunction()
{
if (!SYS_CMD_ADDGRP(cmdTbl, sizeof(cmdTbl)/sizeof(*cmdTbl),
  "My command", ": switchled1"))
{
  return false;
}
  return true;
}
 
It works perfect, and I can switch on led from usb serial console.
I don't understand, how to add arguments to commands, for example:
>switchled 1 on    //this will switch on led 1
>switchled 2 off.  //this will switch off led 2
 
It's possible to do this with commands ?
#1

3 Replies Related Threads

    dobrosoft
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2019/05/20 04:44:55
    • Location: 0
    • Status: offline
    Re: How to add arguments to my commands 2019/06/11 01:22:01 (permalink)
    0
    It's easy ...
     
    static int CommandLed1(SYS_CMD_DEVICE_NODE* pCmdIO, int argc, char** argv)
    argc - number of parameters, argue - array of parameters.
     
    #2
    ric
    Super Member
    • Total Posts : 22310
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: How to add arguments to my commands 2019/06/11 04:48:58 (permalink)
    5 (2)
    I can't resist.
    So you'd like to buy an argument?
    https://www.youtube.com/watch?v=xpAvcGcEc0k
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    Jim Nickerson
    User 452
    • Total Posts : 5949
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: online
    Re: How to add arguments to my commands 2019/06/11 07:32:13 (permalink)
    0
    ric
    I can't resist.
    So you'd like to buy an argument?
    https://www.youtube.com/watch?v=xpAvcGcEc0k
     


    Thank you ric Smile: Smile
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5