Пример #1
0
bool terminalTask::regTlm(void)
{
    #if SYS_CFG_ENABLE_TLM
    return (TLM_REG_VAR(tlm_component_get_by_name(SYS_CFG_DEBUG_TLM_NAME), mCommandCount, tlm_uint) &&
            TLM_REG_VAR(tlm_component_get_by_name(SYS_CFG_DEBUG_TLM_NAME), mDiskTlmSize, tlm_uint));
    #else
    return true;
    #endif
}
Пример #2
0
bool terminalTask::regTlm(void)
{
    #if ENABLE_TELEMETRY
    return (TLM_REG_VAR(tlm_component_get_by_name("debug"), mCommandCount, tlm_uint) &&
            TLM_REG_VAR(tlm_component_get_by_name("debug"), mDiskTlmSize, tlm_uint));
    #else
    return true;
    #endif
}
Пример #3
0
const tlm_reg_var_type* tlm_variable_get_by_comp_and_name(const char *comp_name, const char *name)
{
    tlm_reg_var_type *reg_var = NULL;
    tlm_component *comp_ptr = tlm_component_get_by_name(comp_name);

    if (NULL != comp_ptr && NULL != name && '\0' != *name) {
        reg_var = c_list_find_elm(comp_ptr->var_list, tlm_component_find_callback,
                                  (void*)name, NULL, NULL);
    }

    return reg_var;
}
Пример #4
0
bool example_nv_vars::regTlm(void)
{
    #if SYS_CFG_ENABLE_TLM
        // Get the "disk" component list, this list is saved on disk periodically when variables change value
        tlm_component *disk = tlm_component_get_by_name(SYS_CFG_DISK_TLM_NAME);

        // Register the variable as "disk variable" whose value will be saved
        TLM_REG_VAR(disk, mVarWeDontWantToLose, tlm_int);
    #endif

    // Notice that after about 2 min of no terminal command, a message will print something like :
    // "disk variables changed, changes saved to disk"
    // Even if you reboot the board, this variable will not start from 0, but from the value
    // that was saved to the disk.
    return true;
}
Пример #5
0
bool tlm_stream_decode_file(FILE *file)
{
    uint32_t num_vars_in_stream = 0;
    tlm_component *component = NULL;
    bool success = false;

    /* Telemetry begins with: "START:<name>:<#>\n"
     * A file can contain telemetry of multiple components so it may have
     * START ... END
     * START ... END
     * We will continue to decode till end of file.
     */
    char line[128] = { 0 };
    while (fgets(line, sizeof(line)-1, file)) {
        if (line == strstr(line, "START:")) {
            char *name = strstr(line, ":") + 1;
            char *count = strstr(name, ":");
            if (NULL != count) {
                *count++ = '\0';
                component = tlm_component_get_by_name(name);
                if (NULL != component) {
                    num_vars_in_stream = atoi(count);
                    success = true;
                }
            }
        }

        /* Number of variables in stream will be greater than zero only
         * when we have correctly decoded STARTing header.  This loop
         * will decode data until end of this components' stream.
         */
        while (num_vars_in_stream > 0) {
            if(tlm_stream_decode(file, component)) {
                --num_vars_in_stream;
            }
            else {
                success = false;
                return success;
            }
        }
    } // fgets()

    /* success only changed to true if we got atleast one "START" in the file */
    return success;
}
Пример #6
0
bool terminalTask::taskEntry()
{
    /* remoteTask() creates shared object in its init(), so we can get it now */
    CommandProcessor &cp = mCmdProc;

    // System information handlers
    cp.addHandler(taskListHandler, "info",    "Task/CPU Info.  Use 'info 200' to get CPU during 200ms");
    cp.addHandler(memInfoHandler,  "meminfo", "See memory info");
    cp.addHandler(healthHandler,   "health",  "Output system health");
    cp.addHandler(timeHandler,     "time",    "'time' to view time.  'time set MM DD YYYY HH MM SS Wday' to set time");

    // File I/O handlers:
    cp.addHandler(catHandler,    "cat",   "Read a file.  Ex: 'cat 0:file.txt' or "
                                          "'cat 0:file.txt -noprint' to test if file can be read");
    cp.addHandler(cpHandler,     "cp",    "Copy files from/to Flash/SD Card.  Ex: 'cp 0:file.txt 1:file.txt'");
    cp.addHandler(dcpHandler,    "dcp",   "Copy all files of a directory to another directory.  Ex: 'dcp 0:src 1:dst'");
    cp.addHandler(lsHandler,     "ls",    "Use 'ls 0:' for Flash, or 'ls 1:' for SD Card");
    cp.addHandler(mkdirHandler,  "mkdir", "Create a directory. Ex: 'mkdir test'");
    cp.addHandler(mvHandler,     "mv",    "Rename a file. Ex: 'rm 0:file.txt 0:new.txt'");
    cp.addHandler(newFileHandler,"nf",    "Write a new file. Ex: 'nf <file.txt>");
    cp.addHandler(rmHandler,     "rm",    "Remove a file. Ex: 'rm 0:file.txt'");

    // Misc. handlers
    cp.addHandler(i2cIoHandler,   "i2c",   "'i2c read 0x01 0x02 <count>' : Reads  device 0x01, and register 0x02\n"
                                           "'i2c write 0x01 0x02 0x03'   : Writes device 0x01, reg 0x02, data 0x03\n"
                                           "'i2c discover' : Discover I2C devices");
#if TERMINAL_USE_CAN_BUS_HANDLER
    CMD_HANDLER_FUNC(canBusHandler);
    cp.addHandler(canBusHandler,  "canbus", "'canbus init' : initialize CAN-1\n"
                                            "'canbus filter <id>' : Add 29-bit ID fitler\n"
                                            "'canbus tx <msg id> <len> <byte0> <byte1> ...' : Send CAN Message\n"
                                            "'canbus rx <timeout in ms>' : Receive a CAN message\n"
                                            "'canbus registers' : See some of CAN BUS registers");
#endif

    cp.addHandler(storageHandler,  "storage",  "Parameters: 'format sd', 'format flash', 'mount sd', 'mount flash'");
    cp.addHandler(rebootHandler,   "reboot",   "Reboots the system");
    cp.addHandler(logHandler,      "log",      "'log <hello>': log an info message\n"
                                               "'log flush'  : flush the logs\n"
                                               "' log status': get status of the logger\n"
                                               "'log enableprint debug/info/warn/error' : Enables logger calls to printf\n"
                                               "'log disableprint debug/info/warn/error': Disables logger calls to printf\n"
                                               );
    cp.addHandler(learnIrHandler,  "learn",    "Begin to learn IR codes for numbers 0-9");
    cp.addHandler(wirelessHandler, "wireless", "Use 'wireless' to see the nested commands");

    /* Firmware upgrade handlers
     * Please read "netload_readme.txt" at ref_and_datasheets directory.
     */
    CMD_HANDLER_FUNC(getFileHandler);
    CMD_HANDLER_FUNC(flashProgHandler);
    cp.addHandler(getFileHandler,   "file",  "Get a file using netload.exe or by using the following protocol:\n"
                                             "Write buffer: buffer <offset> <num bytes> ...\n"
                                             "Write buffer to file: commit <filename> <file offset> <num bytes from buffer>");
    cp.addHandler(flashProgHandler, "flash", "'flash <filename>' Will flash CPU with this new binary file");

    #if (SYS_CFG_ENABLE_TLM)
    cp.addHandler(telemetryHandler, "telemetry", "Outputs registered telemetry: "
                                                 "'telemetry save' : Saves disk tel\n"
                                                 "'telemetry ascii' : Prints all telemetry in human readable format\n"
                                                 "'telemetry <comp. name> <name> <value>' to set a telemetry variable\n"
                                                 "'telemetry get <comp. name> <name>' to get variable value\n");
    #endif

    // Initialize Interrupt driven version of getchar & putchar
    Uart0& uart0 = Uart0::getInstance();
    bool success = uart0.init(SYS_CFG_UART0_BPS, 32, SYS_CFG_UART0_TXQ_SIZE);
    uart0.setReady(true);
    sys_set_inchar_func(uart0.getcharIntrDriven);
    sys_set_outchar_func(uart0.putcharIntrDriven);

    /* Add UART0 to command input/output */
    addCommandChannel(&uart0, true);

    #if TERMINAL_USE_NRF_WIRELESS
    do {
        NordicStream& nrf = NordicStream::getInstance();
        nrf.setReady(true);
        addCommandChannel(&nrf, false);
    } while(0);
    #endif

    #if SYS_CFG_ENABLE_TLM
    /* Telemetry should be registered at this point, so initialize the binary
     * telemetry space that we periodically check to save data to disk
     */
    tlm_component *disk = tlm_component_get_by_name(SYS_CFG_DISK_TLM_NAME);
    mDiskTlmSize = tlm_binary_get_size_one(disk);
    mpBinaryDiskTlm = new char[mDiskTlmSize];
    if (success) {
        success = (NULL != mpBinaryDiskTlm);
    }

    /* Now update our copy of disk telemetry */
    tlm_binary_get_one(disk, mpBinaryDiskTlm);
    #endif

    /* Display "help" command on UART0 */
    STR_ON_STACK(help, 8);
    help = "help";
    mCmdProc.handleCommand(help, uart0);

    return success;
}