Sounds like we need to do some code cleanup, refactoring, etc.  Also some documentation.

Comments?

Bill

On 5/24/2024 9:35 AM, Burns Fisher (AMSAT) via pacsat-dev wrote:
This is just how to add a command.  I'll give an example that could easily be used for temporarily raising the power.  Adding it to the MRAM requires additional work.

This is all in the module ConsoleTask.c.   I'll use the existing command "raise tx freq" as an example.  You need both the command itself (raise tx freq) which can be any lower case string, and a label (RaiseTxFreq) which has to be name that will work for a C variable.

I'll use 'raise tx power' as an example to add, but you can look at "raise tx freq" as an existing example.

First create the label by adding it to the list of enums around line 85.  It does not matter where it goes in that list of enums. 
enum {
    nada=0
    ,getTemp
    ,reset
    ,resetBoth
    ,startWD
    ,preflight
    ,raiseTxFreq <----

etc etc
}

The commands are in three groups:  Setup Commands, Debug Commands, and Common Commands.  Which one you choose only matters insofar as it determines which help command they show up on.  (helpall, helpdevo, helpsetup, help).  Anyway, chose one and add the new command.  Example:

commandPairs setupCommands[] = {
                                {"init new proc","Init DCT stuff that will be set once for each unit",initSaved}
                                ,{"start tx tone", "Send a tone with 5043", toneTx}
                                ,{"stop tx tone", "Stop sending the tone",noToneTx}
          ---->               ,{"raise tx freq","Raise the telem frequency by n Hz",RaiseTxFreq}
                                ,{"lower tx freq","Lower the telem frequency by n Hz",LowerTxFreq}
                                ,{"raise rx freq","Raise the command frequency by n Hz",RaiseRxFreq}
 
The text in the middle is printed when you say help.

Then finally, there is a switch statement that takes up most of the module.  You want to add a new case with the label you created above.  For example

        case RaiseTxFreq:{
            int number = parseNumber(afterCommand);
            DCTTxFreq += number;
            printf("TxFreq=%d\n",DCTTxFreq);
            quick_setfreq(AX5043Dev1, DCTTxFreq);
            break;
        }

Notice that you can also use get a number that has been typed after the command (i.e. raise tx freq 20).  Also, this one just adds to the static variable DCTTxFreq.  Static meaning that it only exists within the ConsoleTask.c module, but it does not get changed unless you change it, or the next time the processor reboots.  This also just calls an AX5043 routine to change frequency. 

===============================
I know Bob wants to be able to change the power.  Do NOT look at "GetRfPower", SelectRFPowerLevels, SetDCTDrivePower, etc.  I think Chris has 'disconnected' these, and besides they do not change the power level immediately.  They really just write into MRAM to be used for another time.  On Golf there is a routine named "ax5043_set_power" but that has apparently been deprecated in pacsat.  But I would recommend some similar routine in one of the AX5043 modules under device support rather than writing directly into the register in the ConsoleTask.c module.  We've tried to keep device-specific routines together.

I hope this is useful.

73,

Burns Fisher, WB1FJ
AMSAT(R) Engineering -- Flight Software

-----------------------------------------------------------

pacsat-dev mailing list -- pacsat-dev@amsat.org
View archives of this mailing list at https://mailman.amsat.org/hyperkitty/list/pacsat-dev@amsat.org
To unsubscribe send an email to pacsat-dev-leave@amsat.org
Manage all of your AMSAT-NA mailing list preferences at https://mailman.amsat.org