Parsing commands and parameters


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,260

    Default Parsing commands and parameters

    The project involves an arithmetic keyboard (0-9,*,#) on a device that has a module that can be programmed with parameters.

    In fact it is a portable transmitter with a module programmable with power level, frequency etc.

    My PIC is the good ol' F886 and since it has 8K of flash I d'rather not spend it with if-then tests.

    I would like to have an efficient way for the user to enter commands and parameters for example like this:

    *10
    responds with a beep
    434925
    responds with a beep

    I know this can be done with lots of if-then or select case but maybe there is a better way.

    Ioannis

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,102


    Did you find this post helpful? Yes | No

    Default Re: Parsing commands and parameters

    ask yourself

    what is the biggest command sequence that will be input ?
    how does the pic know when the input seq is complete ?

    when you know those answers then the answer will be obvious
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,260


    Did you find this post helpful? Yes | No

    Default Re: Parsing commands and parameters

    The commands following the * will not be more than 99 so * and two digits for the commands.

    The parameters are max 6.

    Once Melanie had posted a similar example for rs232 communication but has its limits.

    Ioannis

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,102


    Did you find this post helpful? Yes | No

    Default Re: Parsing commands and parameters

    so a command is *99 or *9 or *09 [where 9 == a numeric digit]
    and a parameter is 9 up to 999999

    how do you signal that the command has been input and the parameter begins

    i would be tempted to use the # as enter

    so cmd 33 p2010 would be
    *33#2100#
    you will need to establish a method to cope with numbers bigger than a word

    you need a method first then code it
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,260


    Did you find this post helpful? Yes | No

    Default Re: Parsing commands and parameters

    For a more compact and maybe easier to code the command and data be at defined length.

    So command 9 would be 09 and data 9 (this is extreme but for the sake of discussion) would be 00009.

    So there is no need for extra termination character.

    Also I think word or long variable may not be helpful here. Better an array, since the data are distinct in meaning so a 433925 would mean 433,925MHz in reality as an absolute value.

    The beeps would help user to step with confidence entering the commands and data.

    I think stuffing an array and then select case is the way to do it.

    Ioannis

Similar Threads

  1. Serin parameters ??
    By Rony in forum General
    Replies: 6
    Last Post: - 21st August 2011, 18:01
  2. dc motor parameters
    By iugmoh in forum Off Topic
    Replies: 0
    Last Post: - 10th October 2009, 19:32
  3. DC motor parameters ?
    By iugmoh in forum Off Topic
    Replies: 2
    Last Post: - 28th June 2008, 10:46
  4. MCSP Bootloader Parameters
    By CocaColaKid in forum General
    Replies: 0
    Last Post: - 19th September 2005, 18:15
  5. @ Device Parameters
    By Randy_Suwanee in forum General
    Replies: 2
    Last Post: - 11th August 2004, 14:40

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts