This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2652RSIP:与 cc2652RSIP 进行通信时、我希望显示所有日志

Guru**** 651100 points
Other Parts Discussed in Thread: CC2652RSIP, SIMPLELINK-CC13XX-CC26XX-SDK, SYSCONFIG, LP-CC2652RSIP
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1099662/cc2652rsip-i-want-to-display-all-the-log-when-communication-is-performed-with-cc2652rsip

器件型号:CC2652RSIP
主题中讨论的其他器件: SIMPLELINK-CC13XX-CC26XX-SDKSysConfig

您好!

我现在正在尝试创建一个使用"rfWsnConcentrator_LP_CC2652RSIP_tirtos_ccs"进行相互通信的程序。
此时、我想使用 UART 等在屏幕上显示日志

我在程序期间的某些地方填写了"Display_printf"、以查看是否可以连续显示日志。
在"clock stert"之前、会连续执行"Display_printf"、但当执行"clock stert"并执行"Display_printf"时、所有内容都不会显示。
这是为什么? 此外、请告诉我是否有显示所有"Display_printf"的方法。

请...

Lina

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Lina、

    请提供有关您问题的更多详细信息。  您正在评估哪个 SIMPLELINK-CC13XX-CC26XX-SDK 版本、您关注哪个特定的 Clock_start 引用、以及执行 Display_printf 后"所有内容都未显示"这一含义是什么?  如果可能、请提供屏幕截图和代码片段。  也许您还可以从 TI 驱动程序 API 调试打印 SimpleLink Academy 实验中获得有用的信息。

    此致、
    Ryan

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Ryan、

    感谢您的回复!
    我目前使用的是"SIMPLELINK-CC13XX-CC26XX-SDK-5.20.00.52"。

    我希望 Display_printf 连续显示。
    目前的方案载于下文。
    此程序是通过"rfWsnConcentrator_LP_CC2652RSIP_tirtos_ccs"快速创建的。

    我想知道的是、我想创建一个程序、使用 Lock 函数始终显示日志 Display_printf。
    目前、我能够制作一次 Display_printf 程序、这比上次稍微好一点。
    然而,在目的中,只有一个被执行,但下列两个都应该被执行。

    Display_printf (hDisplaySerial、0、0、">>>> \n");
    Display_printf (hDisplaySerial、1、1、"!!!!!! \n");


    这是为什么? 此外、是否有显示所有 Display_printf 的好主意?

    如果您知道、请告诉我。
    请...

    Lina

    //执行程序

    它基于"rfWsnConcentrator_LP_CC2652RSIP_tirtos_ccs"。
    我只是想在 Display_printf 中显示日志。
    我想知道时钟是否在运行时工作、因此我强制更改并测试了它。

    /***** Includes *****/
    /* XDCtools Header files */ 
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */ 
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Clock.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/PIN.h>
    #include <ti/display/Display.h>
    #include <ti/display/DisplayExt.h>
    
    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(driverlib/cpu.h)
    
    /* Board Header files */
    #include "ti_drivers_config.h"
    
    /* Application Header files */ 
    #include "ConcentratorRadioTask.h"
    #include "ConcentratorTask.h"
    #include "RadioProtocol.h"
    
    
    /***** Defines *****/
    #define CONCENTRATOR_TASK_STACK_SIZE 1024
    #define CONCENTRATOR_TASK_PRIORITY   3
    
    #define CONCENTRATOR_EVENT_ALL                         0xFFFFFFFF
    #define CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE    (uint32_t)(1 << 0)
    
    #define CONCENTRATOR_MAX_NODES 7
    
    #define CONCENTRATOR_DISPLAY_LINES 8
    
    #define CONCENTRATOR_LED_BLINK_ON_DURATION_MS       100
    #define CONCENTRATOR_LED_BLINK_OFF_DURATION_MS      400
    #define CONCENTRATOR_LED_BLINK_TIMES                5
    
    #define CONCENTRATOR_IDENTIFY_LED CONFIG_PIN_GLED
    
    /***** Type declarations *****/
    struct AdcSensorNode {
        uint8_t address;
        uint16_t latestAdcValue;
        uint8_t button;
        int8_t latestRssi;
    };
    
    
    /***** Variable declarations *****/
    static Task_Params concentratorTaskParams;
    Task_Struct concentratorTask;    /* not static so you can see in ROV */
    static uint8_t concentratorTaskStack[CONCENTRATOR_TASK_STACK_SIZE];
    Event_Struct concentratorEvent;  /* not static so you can see in ROV */
    static Event_Handle concentratorEventHandle;
    static struct AdcSensorNode latestActiveAdcSensorNode;
    struct AdcSensorNode knownSensorNodes[CONCENTRATOR_MAX_NODES];
    static struct AdcSensorNode* lastAddedSensorNode = knownSensorNodes;
    static Display_Handle hDisplayLcd;
    static Display_Handle hDisplaySerial;
    
    /* Pin driver handle */
    static PIN_Handle identifyLedPinHandle;
    static PIN_State identifyLedPinState;
    
    /* Configure LED Pin */
    PIN_Config identifyLedPinTable[] = {
            CONCENTRATOR_IDENTIFY_LED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    
    /* Clock for sensor stub */
    Clock_Struct ledBlinkClock;     /* Not static so you can see in ROV */
    static Clock_Handle ledBlinkClockHandle;
    
    static uint8_t ledBlinkCnt;
    
    /***** Prototypes *****/
    static void concentratorTaskFunction(UArg arg0, UArg arg1);
    static void packetReceivedCallback(union ConcentratorPacket* packet, int8_t rssi);
    static void updateLcd(void);
    static void addNewNode(struct AdcSensorNode* node);
    static void updateNode(struct AdcSensorNode* node);
    static uint8_t isKnownNodeAddress(uint8_t address);
    static void ledBlinkClockCb(UArg arg0);
    
    /***** Function definitions *****/
    void sHubTask_init(void) {
    
        /* Create event used internally for state changes */
        Event_Params eventParam;
        Event_Params_init(&eventParam);
        Event_construct(&concentratorEvent, &eventParam);
        concentratorEventHandle = Event_handle(&concentratorEvent);
    
        /* Create the concentrator radio protocol task */
        Task_Params_init(&concentratorTaskParams);
        concentratorTaskParams.stackSize = CONCENTRATOR_TASK_STACK_SIZE;
        concentratorTaskParams.priority = CONCENTRATOR_TASK_PRIORITY;
        concentratorTaskParams.stack = &concentratorTaskStack;
        Task_construct(&concentratorTask, concentratorTaskFunction, &concentratorTaskParams, NULL);
    
        /* Open Identify LED pin */
        identifyLedPinHandle = PIN_open(&identifyLedPinState, identifyLedPinTable);
        if (!identifyLedPinHandle)
        {
            System_abort("Error initializing board 3.3V domain pins\n");
        }
    
        /* Create Identify Clock to Blink LED */
        Clock_Params clkParams;
        Clock_Params_init(&clkParams);
        clkParams.startFlag = FALSE;
        clkParams.period =100*40/*ms*/;                 //40ms
        Clock_construct(&ledBlinkClock, ledBlinkClockCb, 1000, &clkParams);
        ledBlinkClockHandle = Clock_handle(&ledBlinkClock);
    
        ledBlinkCnt = 0;
    }
    
    static void concentratorTaskFunction(UArg arg0, UArg arg1)
    {
        /* Initialize display and try to open both UART and LCD types of display. */
        Display_Params params;
        Display_Params_init(&params);
        params.lineClearMode = DISPLAY_CLEAR_BOTH;
    
        hDisplayLcd = Display_open(Display_Type_LCD, &params);
        hDisplaySerial = Display_open(Display_Type_UART, &params);
    
        /* Check if the selected Display type was found and successfully opened */
        if (hDisplaySerial)
        {
            Display_printf(hDisplaySerial, 0, 0, "Waiting for nodes...");
            Display_printf(hDisplaySerial, 0, 0, "test2");
        }
    
        /* Check if the selected Display type was found and successfully opened */
        if (hDisplayLcd)
        {
            Display_printf(hDisplayLcd, 0, 0, "Waiting for nodes...");
            Display_printf(hDisplayLcd, 0, 0, "test3");
        }
    
        /* Register a packet received callback with the radio task */
        ConcentratorRadioTask_registerPacketReceivedCallback(packetReceivedCallback);
    
        Clock_start(ledBlinkClockHandle);
    
        /* Enter main task loop */
        while(1) {
            /* Wait for event */
            uint32_t events = Event_pend(concentratorEventHandle, 0, CONCENTRATOR_EVENT_ALL, BIOS_WAIT_FOREVER);
    
            Display_printf(hDisplayLcd, 0, 0, "0w0w0w");
    
            /* If we got a new ADC sensor value */
            if(events & CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE) {
                /* If we knew this node from before, update the value */
                if(isKnownNodeAddress(latestActiveAdcSensorNode.address)) {
                    updateNode(&latestActiveAdcSensorNode);
                }
                else {
                    /* Else add it */
                    addNewNode(&latestActiveAdcSensorNode);
                }
    
                /* Update the values on the LCD */
                updateLcd();
            }
        }
    }
    
    static void packetReceivedCallback(union ConcentratorPacket* packet, int8_t rssi)
    {
        /* If we recived an ADC sensor packet, for backward compatibility */
        if (packet->header.packetType == RADIO_PACKET_TYPE_ADC_SENSOR_PACKET)
        {
            /* Save the values */
            latestActiveAdcSensorNode.address = packet->header.sourceAddress;
            latestActiveAdcSensorNode.latestAdcValue = packet->adcSensorPacket.adcValue;
            latestActiveAdcSensorNode.button = 0; //no button value in ADC packet
            latestActiveAdcSensorNode.latestRssi = rssi;
    
            Event_post(concentratorEventHandle, CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE);
        }
        /* If we recived an DualMode ADC sensor packet*/
        else if(packet->header.packetType == RADIO_PACKET_TYPE_DM_SENSOR_PACKET)
        {
    
            /* Save the values */
            latestActiveAdcSensorNode.address = packet->header.sourceAddress;
            latestActiveAdcSensorNode.latestAdcValue = packet->dmSensorPacket.adcValue;
            latestActiveAdcSensorNode.button = packet->dmSensorPacket.button;
            latestActiveAdcSensorNode.latestRssi = rssi;
    
            Event_post(concentratorEventHandle, CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE);
    
            if( packet->dmSensorPacket.concLedToggle && (ledBlinkCnt == 0) )
            {
                /* Turn LED on */
                PIN_setOutputValue(identifyLedPinHandle, CONCENTRATOR_IDENTIFY_LED, 1);
    
                /* Setup timeout to blink LED */
                Clock_setTimeout(ledBlinkClockHandle,
                        CONCENTRATOR_LED_BLINK_ON_DURATION_MS * 1000 / Clock_tickPeriod);
    
                /* Start sensor stub clock */
                Clock_start(ledBlinkClockHandle);
            }
    
        }
    }
    
    static uint8_t isKnownNodeAddress(uint8_t address) {
        uint8_t found = 0;
        uint8_t i;
        for (i = 0; i < CONCENTRATOR_MAX_NODES; i++)
        {
            if (knownSensorNodes[i].address == address)
            {
                found = 1;
                break;
            }
        }
        return found;
    }
    
    static void updateNode(struct AdcSensorNode* node) {
        uint8_t i;
        for (i = 0; i < CONCENTRATOR_MAX_NODES; i++) {
            if (knownSensorNodes[i].address == node->address)
            {
                knownSensorNodes[i].latestAdcValue = node->latestAdcValue;
                knownSensorNodes[i].latestRssi = node->latestRssi;
                knownSensorNodes[i].button = node->button;
                break;
            }
        }
    }
    
    static void addNewNode(struct AdcSensorNode* node) {
        *lastAddedSensorNode = *node;
    
        /* Increment and wrap */
        lastAddedSensorNode++;
        if (lastAddedSensorNode > &knownSensorNodes[CONCENTRATOR_MAX_NODES-1])
        {
            lastAddedSensorNode = knownSensorNodes;
        }
    }
    
    static void updateLcd(void) {
        struct AdcSensorNode* nodePointer = knownSensorNodes;
        uint8_t currentLcdLine;
    
        /* Clear the display and write header on first line */
        Display_clear(hDisplayLcd);
        Display_printf(hDisplayLcd, 0, 0, "Nodes Value SW  RSSI");
    
        //clear screen, put cuser to beggining of terminal and print the header
        Display_printf(hDisplaySerial, 0, 0, "\033[2J \033[0;0HNodes   Value   SW    RSSI");
    
        /* Start on the second line */
        currentLcdLine = 1;
    
        /* Write one line per node */
        while ((nodePointer < &knownSensorNodes[CONCENTRATOR_MAX_NODES]) &&
              (nodePointer->address != 0) &&
              (currentLcdLine < CONCENTRATOR_DISPLAY_LINES))
        {
            /* print to LCD */
            Display_printf(hDisplayLcd, currentLcdLine, 0, "0x%02x  0x%02x  %d   %04d",
                    nodePointer->address, nodePointer->latestAdcValue, nodePointer->button,
                    nodePointer->latestRssi);
    
            /* print to UART */
            Display_printf(hDisplaySerial, 0, 0, "0x%02x    0x%02x    %d    %04d",
                    nodePointer->address, nodePointer->latestAdcValue, nodePointer->button,
                    nodePointer->latestRssi);
    
            nodePointer++;
            currentLcdLine++;
        }
    }
    
    static void ledBlinkClockCb(UArg arg0)
    {
        Display_printf(hDisplaySerial, 0, 0, ">>>>>>\n");
        Display_printf(hDisplaySerial, 1, 1, "!!!!!!\n");
    
        if(ledBlinkCnt < CONCENTRATOR_LED_BLINK_TIMES)
        {
            uint32_t ledState = PIN_getOutputValue(CONCENTRATOR_IDENTIFY_LED);
    
            if(ledState)
            {
                ledBlinkCnt++;
    
                /* turn off LED */
                PIN_setOutputValue(identifyLedPinHandle, CONCENTRATOR_IDENTIFY_LED, 0);
    
                /* Setup timeout to turn LED on */
                Clock_setTimeout(ledBlinkClockHandle,
                    CONCENTRATOR_LED_BLINK_OFF_DURATION_MS * 1000 / Clock_tickPeriod);
    
                /* Start sensor stub clock */
                Clock_start(ledBlinkClockHandle);
            }
            else
            {
                /* turn on LED */
                PIN_setOutputValue(identifyLedPinHandle, CONCENTRATOR_IDENTIFY_LED, 1);
    
                /* Setup timeout to turn LED off */
                Clock_setTimeout(ledBlinkClockHandle,
                    CONCENTRATOR_LED_BLINK_ON_DURATION_MS * 1000 / Clock_tickPeriod);
    
                /* Start sensor stub clock */
                Clock_start(ledBlinkClockHandle);
            }
        }
        else
        {
            PIN_setOutputValue(identifyLedPinHandle, CONCENTRATOR_IDENTIFY_LED, 0);
            ledBlinkCnt = 0;
        }
    }
    

    //执行结果

    Waiting for nodes...
    test2
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    
    >>>>>>
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    由于通过 SysConfig 模块在显示屏上禁用 ANSI、因此、一旦从节点头的 Display_printf 命令中删除了 Clear Lines 命令(\033[2J \033[0;0H)、并将所有第二个和第三个 Display_printf 参数更改为零、则日志函数将如预期的那样正常工作。  下面是我测试过的代码(使用 SIMPLELINK-CC13XX-CC26XX-SDK 6.10版、这与此特定功能无关):

    /******************************************************************************
    
     @file ConcentratorTask.c
    
     @brief Easylink Concentrator Example Application
    
     Group: CMCU LPRF
     Target Device: cc13xx_cc26xx
    
     ******************************************************************************
     
     Copyright (c) 2015-2022, Texas Instruments Incorporated
     All rights reserved.
    
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:
    
     *  Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
    
     *  Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
    
     *  Neither the name of Texas Instruments Incorporated nor the names of
        its contributors may be used to endorse or promote products derived
        from this software without specific prior written permission.
    
     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
     ******************************************************************************
     
     
     *****************************************************************************/
    
    /***** Includes *****/
    /* XDCtools Header files */ 
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */ 
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Clock.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/display/Display.h>
    #include <ti/display/DisplayExt.h>
    
    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(driverlib/cpu.h)
    
    /* Board Header files */
    #include "ti_drivers_config.h"
    
    /* Application Header files */ 
    #include "ConcentratorRadioTask.h"
    #include "ConcentratorTask.h"
    #include "RadioProtocol.h"
    
    
    /***** Defines *****/
    #define CONCENTRATOR_TASK_STACK_SIZE 1024
    #define CONCENTRATOR_TASK_PRIORITY   3
    
    #define CONCENTRATOR_EVENT_ALL                         0xFFFFFFFF
    #define CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE    (uint32_t)(1 << 0)
    
    #define CONCENTRATOR_MAX_NODES 7
    
    #define CONCENTRATOR_DISPLAY_LINES 8
    
    #define CONCENTRATOR_LED_BLINK_ON_DURATION_MS       100
    #define CONCENTRATOR_LED_BLINK_OFF_DURATION_MS      400
    #define CONCENTRATOR_LED_BLINK_TIMES                5
    
    #define CONCENTRATOR_IDENTIFY_LED CONFIG_GPIO_GLED
    
    /***** Type declarations *****/
    struct AdcSensorNode {
        uint8_t address;
        uint16_t latestAdcValue;
        uint8_t button;
        int8_t latestRssi;
    };
    
    
    /***** Variable declarations *****/
    static Task_Params concentratorTaskParams;
    Task_Struct concentratorTask;    /* not static so you can see in ROV */
    static uint8_t concentratorTaskStack[CONCENTRATOR_TASK_STACK_SIZE];
    Event_Struct concentratorEvent;  /* not static so you can see in ROV */
    static Event_Handle concentratorEventHandle;
    static struct AdcSensorNode latestActiveAdcSensorNode;
    struct AdcSensorNode knownSensorNodes[CONCENTRATOR_MAX_NODES];
    static struct AdcSensorNode* lastAddedSensorNode = knownSensorNodes;
    //static Display_Handle hDisplayLcd;
    static Display_Handle hDisplaySerial;
    
    /* Clock for sensor stub */
    Clock_Struct ledBlinkClock;     /* Not static so you can see in ROV */
    static Clock_Handle ledBlinkClockHandle;
    
    static uint8_t ledBlinkCnt;
    
    /***** Prototypes *****/
    static void concentratorTaskFunction(UArg arg0, UArg arg1);
    static void packetReceivedCallback(union ConcentratorPacket* packet, int8_t rssi);
    static void updateLcd(void);
    static void addNewNode(struct AdcSensorNode* node);
    static void updateNode(struct AdcSensorNode* node);
    static uint8_t isKnownNodeAddress(uint8_t address);
    static void ledBlinkClockCb(UArg arg0);
    
    /***** Function definitions *****/
    void ConcentratorTask_init(void) {
    
        /* Create event used internally for state changes */
        Event_Params eventParam;
        Event_Params_init(&eventParam);
        Event_construct(&concentratorEvent, &eventParam);
        concentratorEventHandle = Event_handle(&concentratorEvent);
    
        /* Create the concentrator radio protocol task */
        Task_Params_init(&concentratorTaskParams);
        concentratorTaskParams.stackSize = CONCENTRATOR_TASK_STACK_SIZE;
        concentratorTaskParams.priority = CONCENTRATOR_TASK_PRIORITY;
        concentratorTaskParams.stack = &concentratorTaskStack;
        Task_construct(&concentratorTask, concentratorTaskFunction, &concentratorTaskParams, NULL);
    
        /* Set config of LED pin */
        GPIO_setConfig(CONCENTRATOR_IDENTIFY_LED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Create Identify Clock to Blink LED */
        Clock_Params clkParams;
        Clock_Params_init(&clkParams);
    
        clkParams.startFlag = FALSE;
        Clock_construct(&ledBlinkClock, ledBlinkClockCb, 1, &clkParams);
        ledBlinkClockHandle = Clock_handle(&ledBlinkClock);
    
        ledBlinkCnt = 0;
    }
    
    static void concentratorTaskFunction(UArg arg0, UArg arg1)
    {
        /* Initialize display and try to open both UART and LCD types of display. */
        Display_Params params;
        Display_Params_init(&params);
        params.lineClearMode = DISPLAY_CLEAR_BOTH;
    
        /* Open both an available LCD display and an UART display.
         * Whether the open call is successful depends on what is present in the
         * Display_config[] array of the board file.
         *
         * Note that for SensorTag evaluation boards combined with the SHARP96x96
         * Watch DevPack, there is a pin conflict with UART such that one must be
         * excluded, and UART is preferred by default. To display on the Watch
         * DevPack, add the precompiler define BOARD_DISPLAY_EXCLUDE_UART.
         */
    //    hDisplayLcd = Display_open(Display_Type_LCD, &params);
        hDisplaySerial = Display_open(Display_Type_UART, &params);
    
        /* Check if the selected Display type was found and successfully opened */
        if (hDisplaySerial)
        {
            Display_printf(hDisplaySerial, 0, 0, "Waiting for nodes...");
        }
    
        /* Check if the selected Display type was found and successfully opened */
    //    if (hDisplayLcd)
    //    {
    //        Display_printf(hDisplayLcd, 0, 0, "Waiting for nodes...");
    //    }
    
        /* Register a packet received callback with the radio task */
        ConcentratorRadioTask_registerPacketReceivedCallback(packetReceivedCallback);
    
        /* Enter main task loop */
        while(1) {
            /* Wait for event */
            uint32_t events = Event_pend(concentratorEventHandle, 0, CONCENTRATOR_EVENT_ALL, BIOS_WAIT_FOREVER);
    
            /* If we got a new ADC sensor value */
            if(events & CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE) {
                /* If we knew this node from before, update the value */
                if(isKnownNodeAddress(latestActiveAdcSensorNode.address)) {
                    updateNode(&latestActiveAdcSensorNode);
                }
                else {
                    /* Else add it */
                    addNewNode(&latestActiveAdcSensorNode);
                }
    
                /* Update the values on the LCD */
                updateLcd();
            }
        }
    }
    
    static void packetReceivedCallback(union ConcentratorPacket* packet, int8_t rssi)
    {
        /* If we recived an ADC sensor packet, for backward compatibility */
        if (packet->header.packetType == RADIO_PACKET_TYPE_ADC_SENSOR_PACKET)
        {
            /* Save the values */
            latestActiveAdcSensorNode.address = packet->header.sourceAddress;
            latestActiveAdcSensorNode.latestAdcValue = packet->adcSensorPacket.adcValue;
            latestActiveAdcSensorNode.button = 0; //no button value in ADC packet
            latestActiveAdcSensorNode.latestRssi = rssi;
    
            Event_post(concentratorEventHandle, CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE);
        }
        /* If we recived an DualMode ADC sensor packet*/
        else if(packet->header.packetType == RADIO_PACKET_TYPE_DM_SENSOR_PACKET)
        {
    
            /* Save the values */
            latestActiveAdcSensorNode.address = packet->header.sourceAddress;
            latestActiveAdcSensorNode.latestAdcValue = packet->dmSensorPacket.adcValue;
            latestActiveAdcSensorNode.button = packet->dmSensorPacket.button;
            latestActiveAdcSensorNode.latestRssi = rssi;
    
            Event_post(concentratorEventHandle, CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE);
    
            if( packet->dmSensorPacket.concLedToggle && (ledBlinkCnt == 0) )
            {
                /* Turn LED on */
                GPIO_write(CONCENTRATOR_IDENTIFY_LED, CONFIG_GPIO_LED_ON);
    
                /* Setup timeout to blink LED */
                Clock_setTimeout(ledBlinkClockHandle,
                        CONCENTRATOR_LED_BLINK_ON_DURATION_MS * 1000 / Clock_tickPeriod);
    
                /* Start sensor stub clock */
                Clock_start(ledBlinkClockHandle);
            }
    
        }
    }
    
    static uint8_t isKnownNodeAddress(uint8_t address) {
        uint8_t found = 0;
        uint8_t i;
        for (i = 0; i < CONCENTRATOR_MAX_NODES; i++)
        {
            if (knownSensorNodes[i].address == address)
            {
                found = 1;
                break;
            }
        }
        return found;
    }
    
    static void updateNode(struct AdcSensorNode* node) {
        uint8_t i;
        for (i = 0; i < CONCENTRATOR_MAX_NODES; i++) {
            if (knownSensorNodes[i].address == node->address)
            {
                knownSensorNodes[i].latestAdcValue = node->latestAdcValue;
                knownSensorNodes[i].latestRssi = node->latestRssi;
                knownSensorNodes[i].button = node->button;
                break;
            }
        }
    }
    
    static void addNewNode(struct AdcSensorNode* node) {
        *lastAddedSensorNode = *node;
    
        /* Increment and wrap */
        lastAddedSensorNode++;
        if (lastAddedSensorNode > &knownSensorNodes[CONCENTRATOR_MAX_NODES-1])
        {
            lastAddedSensorNode = knownSensorNodes;
        }
    }
    
    static void updateLcd(void) {
        struct AdcSensorNode* nodePointer = knownSensorNodes;
    //    uint8_t currentLcdLine;
    
    //    /* Clear the display and write header on first line */
    //    Display_clear(hDisplayLcd);
    //    Display_printf(hDisplayLcd, 0, 0, "Nodes Value SW  RSSI");
    
        //clear screen, put cuser to beggining of terminal and print the header
        Display_printf(hDisplaySerial, 0, 0, "Nodes   Value   SW    RSSI");
    
        /* Start on the second line */
    //    currentLcdLine = 1;
    
        /* Write one line per node */
        while ((nodePointer < &knownSensorNodes[CONCENTRATOR_MAX_NODES]) &&
              (nodePointer->address != 0) )//&&
    //          (currentLcdLine < CONCENTRATOR_DISPLAY_LINES))
        {
            /* print to LCD */
    //        Display_printf(hDisplayLcd, currentLcdLine, 0, "0x%02x  0x%02x  %d   %04d",
    //                nodePointer->address, nodePointer->latestAdcValue, nodePointer->button,
    //                nodePointer->latestRssi);
    
            /* print to UART */
            Display_printf(hDisplaySerial, 0, 0, "0x%02x    0x%02x    %d    %04d",
                    nodePointer->address, nodePointer->latestAdcValue, nodePointer->button,
                    nodePointer->latestRssi);
    
            nodePointer++;
    //        currentLcdLine++;
        }
    }
    
    static void ledBlinkClockCb(UArg arg0)
    {
        Display_printf(hDisplaySerial, 0, 0, ">>>>>>\n");
        Display_printf(hDisplaySerial, 0, 0, "!!!!!!\n");
        if(ledBlinkCnt < CONCENTRATOR_LED_BLINK_TIMES)
        {
            uint32_t ledState = GPIO_read(CONCENTRATOR_IDENTIFY_LED);
    
            if(ledState)
            {
                ledBlinkCnt++;
    
                /* turn off LED */
                GPIO_write(CONCENTRATOR_IDENTIFY_LED, CONFIG_GPIO_LED_OFF);
    
                /* Setup timeout to turn LED on */
                Clock_setTimeout(ledBlinkClockHandle,
                    CONCENTRATOR_LED_BLINK_OFF_DURATION_MS * 1000 / Clock_tickPeriod);
    
                /* Start sensor stub clock */
                Clock_start(ledBlinkClockHandle);
            }
            else
            {
                /* turn on LED */
                GPIO_write(CONCENTRATOR_IDENTIFY_LED, CONFIG_GPIO_LED_ON);
    
                /* Setup timeout to turn LED off */
                Clock_setTimeout(ledBlinkClockHandle,
                    CONCENTRATOR_LED_BLINK_ON_DURATION_MS * 1000 / Clock_tickPeriod);
    
                /* Start sensor stub clock */
                Clock_start(ledBlinkClockHandle);
            }
        }
        else
        {
            GPIO_write(CONCENTRATOR_IDENTIFY_LED, CONFIG_GPIO_LED_OFF);
            ledBlinkCnt = 0;
        }
    }
    

    以下是供您参考的输出:

    Waiting for nodes...
    Nodes   Value   SW    RSSI
    0xaf    0x279    0    -030
    Nodes   Value   SW    RSSI
    0xaf    0x287    0    -045
    Nodes   Value   SW    RSSI
    0xaf    0x28c    0    -054
    Nodes   Value   SW    RSSI
    0xaf    0x290    0    -052
    Nodes   Value   SW    RSSI
    0xaf    0x28d    0    -052
    Nodes   Value   SW    RSSI
    0xaf    0x290    0    -052
    

    此致、
    Ryan

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Ryan、


    感谢您的回复!
    打扰一下、请告诉我更多信息。
    您的意思是「一旦从节点头」的 Display_printf 命令中删除了 Clear Lines 命令(\033[2J \033[0;0H)
    从 Display.h 和 Display .c 中删除 Display_clear 是否正确?
    很抱歉、我听说过这么多...

    Lina

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您会注意到我使用了 Display_printf (hDisplaySerial、0、0、"节点  值  SW   RSSI");代替 Display_printf (hDisplaySerial、0、0、"\033[2J \033[0;0HNodes  值  SW   RSSI");Display_Clear 或 Display.c/h 资源无需更改

    此致、
    Ryan

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    抱歉、

    当我运行您教授的程序时、我能够如上所述连续显示该程序。
    但是、我想知道"Displat printf、它可以在时钟函数定期运行时可靠地显示日志"。

    请查看以下执行示例。
    这是一个锁定函数定期运行的程序。
    我希望在 TeraTerm 中显示所有 Display_printf。 但是,这是不可能的。
    执行并打印顶部、但底部的两个不是。

    Display_printf (hDisplaySerial、0、0、">>>> ");//No2 Display_printf

    Display_printf (hDisplaySerial、0、0、"!!!!!! ");//No3 Display_printf
    Display_printf (hDisplaySerial、0、0、"count");//No1 Display_printf

    这是为什么?

    Lina

    //rfWsnConcentrator.c

    /******************************************************************************
    
     @file rfWsnConcentrator.c
    
     @brief Easylink Concentrator Example Application
    
     Group: CMCU LPRF
     Target Device: cc13x2_26x2
    
     ******************************************************************************
     
     Copyright (c) 2015-2021, Texas Instruments Incorporated
     All rights reserved.
    
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:
    
     *  Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
    
     *  Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
    
     *  Neither the name of Texas Instruments Incorporated nor the names of
        its contributors may be used to endorse or promote products derived
        from this software without specific prior written permission.
    
     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
     ******************************************************************************
     
     
     *****************************************************************************/
    
    /*
     *  ======== rfWsnconcentrator.c ========
     */
    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/drivers/Power.h>
    #include <ti/drivers/power/PowerCC26XX.h>
    
    /* TI-RTOS Header files */
    #include <ti/display/Display.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/UART.h>
    #include <ti/drivers/SPI.h>
    
    /* Board Header files */
    #include "ti_drivers_config.h"
    
    /* Application Header files */ 
    #include "ConcentratorRadioTask.h"
    #include "ConcentratorTask.h"
    
    /*
     *  ======== main ========
     */
    int main(void)
    {
        /* Call driver init functions. */
        Board_initGeneral();
    
        /* Initialize the UART and SPI for the display driver. */
        Display_init();
        UART_init();
        SPI_init();
    
        /* Initialize concentrator tasks */
        //ConcentratorRadioTask_init();
        ConcentratorTask_init();
    
        /* Start BIOS */
        BIOS_start();
    
        return (0);
    }
    

    //ConcentratorTask.c   已更改版本

    /******************************************************************************
    
     @file ConcentratorTask.c
    
     @brief Easylink Concentrator Example Application
    
     Group: CMCU LPRF
     Target Device: cc13xx_cc26xx
    
     ******************************************************************************
     
     Copyright (c) 2015-2022, Texas Instruments Incorporated
     All rights reserved.
    
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:
    
     *  Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
    
     *  Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
    
     *  Neither the name of Texas Instruments Incorporated nor the names of
        its contributors may be used to endorse or promote products derived
        from this software without specific prior written permission.
    
     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
     ******************************************************************************
     
     
     *****************************************************************************/
    
    /***** Includes *****/
    /* XDCtools Header files */ 
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */ 
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Clock.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/display/Display.h>
    #include <ti/display/DisplayExt.h>
    
    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(driverlib/cpu.h)
    
    /* Board Header files */
    #include "ti_drivers_config.h"
    
    /* Application Header files */ 
    #include "ConcentratorRadioTask.h"
    #include "ConcentratorTask.h"
    #include "RadioProtocol.h"
    
    
    /***** Defines *****/
    #define CONCENTRATOR_TASK_STACK_SIZE 1024
    #define CONCENTRATOR_TASK_PRIORITY   3
    
    #define CONCENTRATOR_EVENT_ALL                         0xFFFFFFFF
    #define CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE    (uint32_t)(1 << 0)
    
    #define CONCENTRATOR_MAX_NODES 7
    
    #define CONCENTRATOR_DISPLAY_LINES 8
    
    #define CONCENTRATOR_LED_BLINK_ON_DURATION_MS       100
    #define CONCENTRATOR_LED_BLINK_OFF_DURATION_MS      400
    #define CONCENTRATOR_LED_BLINK_TIMES                5
    
    #define CONCENTRATOR_IDENTIFY_LED CONFIG_GPIO_GLED
    
    /***** Type declarations *****/
    struct AdcSensorNode {
        uint8_t address;
        uint16_t latestAdcValue;
        uint8_t button;
        int8_t latestRssi;
    };
    
    
    /***** Variable declarations *****/
    static Task_Params concentratorTaskParams;
    Task_Struct concentratorTask;    /* not static so you can see in ROV */
    static uint8_t concentratorTaskStack[CONCENTRATOR_TASK_STACK_SIZE];
    Event_Struct concentratorEvent;  /* not static so you can see in ROV */
    static Event_Handle concentratorEventHandle;
    struct AdcSensorNode knownSensorNodes[CONCENTRATOR_MAX_NODES];
    
    //static Display_Handle hDisplayLcd;
    static Display_Handle hDisplaySerial;
    
    /* Clock for sensor stub */
    Clock_Struct ledBlinkClock;     /* Not static so you can see in ROV */
    static Clock_Handle ledBlinkClockHandle;
    
    /***** Prototypes *****/
    static void concentratorTaskFunction(UArg arg0, UArg arg1);
    static void ledBlinkClockCb(UArg arg0);
    
    /***** Function definitions *****/
    void ConcentratorTask_init(void) {
    
        /* Create event used internally for state changes */
        Event_Params eventParam;
        Event_Params_init(&eventParam);
        Event_construct(&concentratorEvent, &eventParam);
        concentratorEventHandle = Event_handle(&concentratorEvent);
    
        /* Create the concentrator radio protocol task */
        Task_Params_init(&concentratorTaskParams);
        concentratorTaskParams.stackSize = CONCENTRATOR_TASK_STACK_SIZE;
        concentratorTaskParams.priority = CONCENTRATOR_TASK_PRIORITY;
        concentratorTaskParams.stack = &concentratorTaskStack;
        Task_construct(&concentratorTask, concentratorTaskFunction, &concentratorTaskParams, NULL);
    
        /* Set config of LED pin */
        GPIO_setConfig(CONCENTRATOR_IDENTIFY_LED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Create Identify Clock to Blink LED */
        Clock_Params clkParams;
        Clock_Params_init(&clkParams);
        clkParams.period =100*80/*ms*/;
        clkParams.startFlag = FALSE;
        Clock_construct(&ledBlinkClock, ledBlinkClockCb, 1000, &clkParams);
        ledBlinkClockHandle = Clock_handle(&ledBlinkClock);
    }
    
    static void concentratorTaskFunction(UArg arg0, UArg arg1)
    {
        /* Initialize display and try to open both UART and LCD types of display. */
        Display_Params params;
        Display_Params_init(&params);
        params.lineClearMode = DISPLAY_CLEAR_BOTH;
    
        hDisplaySerial = Display_open(Display_Type_UART, &params);
    
        /* Check if the selected Display type was found and successfully opened */
        if (hDisplaySerial)
        {
            Display_printf(hDisplaySerial, 0, 0, "Waiting for nodes...");
        }
    
        Display_printf(hDisplaySerial, 0, 0, "Clock_start ready...");
    
        Clock_start(ledBlinkClockHandle);
    
        Display_printf(hDisplaySerial, 0, 0, "Clock_start!");
    
        /* Enter main task loop */
        while(1) {
            /* Wait for event */
    
            Display_printf(hDisplaySerial, 0, 0, "Event_pend");
    
            uint32_t events = Event_pend(concentratorEventHandle, NULL, CONCENTRATOR_EVENT_ALL, BIOS_WAIT_FOREVER);
    
            /* If we got a new ADC sensor value */
            if(events & CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE) {
    
                /* Test_Event executed*/
                Display_printf(hDisplaySerial, 0, 0, "count");      //No1 Display_printf
    
            }
        }
    }
    
    static void ledBlinkClockCb(UArg arg0)
    {
        Display_printf(hDisplaySerial, 0, 0, ">>>>>>");           //No2 Display_printf
        Display_printf(hDisplaySerial, 0, 0, "!!!!!!");           //No3 Display_printf
    
        /* Test_Event */
        Event_post(concentratorEventHandle, CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE);
    
    }

    //示例执行

    Waiting for nodes...
    Clock_start ready...
    Clock_start!
    Event_pend
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>>

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您从何处获取时钟和事件代码?  我提出这一问题是因为缺少"Event_pend"消息意味着您的代码永远不会处理事件和通过主任务循环的循环、而是似乎停留在 ledBlinkClockCb 内部、您可以通过调试应用来确认这些事件和循环。  有关详细信息、请参阅以下资源:

    https://dev.ti.com/tirex/explore/content/simplelink_cc13xx_cc26xx_sdk_6_10_00_29/docs/proprietary-rf/proprietary-rf-users-guide/tirtos/synchronization.html?highlight=event_pend
    https://dev.ti.com/tirex/content/simplelink_cc13xx_cc26xx_sdk_6_10_00_29/docs/tirtos/sysbios/docs/cdoc/index.html 

    您可以在 Display_printf 之间引入一个较小的延迟">>>>> 和“!!!!!!! "来确定这是否会改变行为。

    此致、
    Ryan

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    非常感谢教我!


    从 ResourceExplorer 中的示例引用了时钟和事件代码。
    我阅读了您发布的链接。但我无法理解您所说的"缺少 Event_pend "。

    因此、我将其更改为仅使用时钟函数的程序、但这种情况也会发生相同的现象。
    为什么在时钟函数开始之前显示所有 Display_printf、而不是在时钟启动时显示?

    我的时钟函数的设置值是否错误?
    但是,在 ResourceExplorer 中检查该示例后,它看起来与相同的设置方法类似。
    为什么会有延迟?

    请告诉我...

    Lina

    Time:0,count:0
    Waiting for nodes...
    Time:4,count:0
    test2
    Time:16,count:0
    
    Time:96,count:1
    
    Time:176,count:2
    
    Time:256,count:3
    
    Time:336,count:4
    
    Time:416,count:5
    
    Time:496,count:6
    
    Time:576,count:7
    
    Time:656,count:8
    
    Time:736,count:9
    
    Time:816,count:10
    
    Time:896,count:11
    
    Time:976,count:12
    
    Time:1056,count:13
    
    Time:1136,count:14
    
    Time:1216,count:15
    
    Time:1296,count:16
    
    Time:1376,count:17
    
    Time:1456,count:18
    
    ...

    /***** Includes *****/
    /* XDCtools Header files */ 
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */ 
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Clock.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/PIN.h>
    #include <ti/display/Display.h>
    #include <ti/display/DisplayExt.h>
    
    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(driverlib/cpu.h)
    
    /* Board Header files */
    #include "ti_drivers_config.h"
    
    /* Application Header files */ 
    #include "ConcentratorRadioTask.h"
    #include "ConcentratorTask.h"
    #include "RadioProtocol.h"
    
    
    /***** Defines *****/
    #define CONCENTRATOR_TASK_STACK_SIZE 1024
    #define CONCENTRATOR_TASK_PRIORITY   3
    #define CONCENTRATOR_EVENT_ALL                         0xFFFFFFFF
    #define CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE    (uint32_t)(1 << 0)
    #define CONCENTRATOR_MAX_NODES 7
    #define CONCENTRATOR_DISPLAY_LINES 8
    #define CONCENTRATOR_LED_BLINK_ON_DURATION_MS       100
    #define CONCENTRATOR_LED_BLINK_OFF_DURATION_MS      400
    #define CONCENTRATOR_LED_BLINK_TIMES                5
    
    #define CONCENTRATOR_IDENTIFY_LED CONFIG_PIN_GLED
    
    /***** Type declarations *****/
    struct AdcSensorNode {
        uint8_t address;
        uint16_t latestAdcValue;
        uint8_t button;
        int8_t latestRssi;
    };
    
    int count=0;
    
    /***** Variable declarations *****/
    static Task_Params concentratorTaskParams;
    Task_Struct concentratorTask;    /* not static so you can see in ROV */
    static uint8_t concentratorTaskStack[CONCENTRATOR_TASK_STACK_SIZE];
    Event_Struct concentratorEvent;  /* not static so you can see in ROV */
    static Event_Handle concentratorEventHandle;
    struct AdcSensorNode knownSensorNodes[CONCENTRATOR_MAX_NODES];
    static Display_Handle hDisplaySerial;
    
    /* Clock for sensor stub */
    Clock_Struct ledBlinkClock;     /* Not static so you can see in ROV */
    static Clock_Handle ledBlinkClockHandle;
    
    
    /***** Prototypes *****/
    static void concentratorTaskFunction(UArg arg0, UArg arg1);
    static void ledBlinkClockCb(UArg arg0);
    
    /***** Function definitions *****/
    void sHubTask_init(void) {
    
        /* Create event used internally for state changes */
        Event_Params eventParam;
        Event_Params_init(&eventParam);
        Event_construct(&concentratorEvent, &eventParam);
        concentratorEventHandle = Event_handle(&concentratorEvent);
    
        /* Create the concentrator radio protocol task */
        Task_Params_init(&concentratorTaskParams);
        concentratorTaskParams.stackSize = CONCENTRATOR_TASK_STACK_SIZE;
        concentratorTaskParams.priority = CONCENTRATOR_TASK_PRIORITY;
        concentratorTaskParams.stack = &concentratorTaskStack;
        Task_construct(&concentratorTask, concentratorTaskFunction, &concentratorTaskParams, NULL);
    
        /* Create Identify Clock to Blink LED */
        Clock_Params clkParams;
        Clock_Params_init(&clkParams);
        clkParams.startFlag = FALSE;
        clkParams.period =100*80/*ms*/;
        Clock_construct(&ledBlinkClock, (Clock_FuncPtr)ledBlinkClockCb, 1000, &clkParams);
        ledBlinkClockHandle = Clock_handle(&ledBlinkClock);
    
    }
    
    static void concentratorTaskFunction(UArg arg0, UArg arg1)
    {
        /* Initialize display and try to open both UART and LCD types of display. */
        Display_Params params;
        Display_Params_init(&params);
        params.lineClearMode = DISPLAY_CLEAR_BOTH;
    
        hDisplaySerial = Display_open(Display_Type_UART, &params);
    
        /* Check if the selected Display type was found and successfully opened */
        if (hDisplaySerial)
        {
            Display_printf(hDisplaySerial, 0, 0, "Time:%d,count:%d",RF_getCurrentTime()/4000,count);
            Display_printf(hDisplaySerial, 0, 0, "Waiting for nodes...");
            Display_printf(hDisplaySerial, 0, 0, "Time:%d,count:%d",RF_getCurrentTime()/4000,count);
            Display_printf(hDisplaySerial, 0, 0, ">>>>>>\n");
        }
    
        Clock_start(ledBlinkClockHandle);
    
        /* Enter main task loop */
    //    while(1) {
            /* Wait for event */
    //            uint32_t events = Event_pend(concentratorEventHandle, 0, CONCENTRATOR_EVENT_ALL, BIOS_WAIT_FOREVER);
    
    
            //Display_clear(hDisplaySerial);
    
    
            /* If we got a new ADC sensor value */
    //            if(events & CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE) {
                /* If we knew this node from before, update the value */
    
    //                Display_printf(hDisplaySerial, 0, 0, "\n");
    
    //           }
    //        }
    }
    
    static void ledBlinkClockCb(UArg arg0)
    {
    
        Display_printf(hDisplaySerial, 0, 0, "Time:%d,count:%d\n",RF_getCurrentTime()/4000,count);
        count=count+1;
        Display_printf(hDisplaySerial, 0, 0, ">>>>>>\n");
    
    //    Event_post(concentratorEventHandle, CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE);
    
    }
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    使用您提供的相同代码、我将获得以下输出:

    Time:5,count:0
    >>>>>>
    
    Time:19,count:0
    
    >>>>>>
    
    Time:99,count:1
    
    >>>>>>
    
    Time:179,count:2
    
    >>>>>>
    
    Time:259,count:3
    
    >>>>>>
    
    Time:339,count:4
    
    >>>>>>
    
    Time:419,count:5
    
    >>>>>>
    

    因此、您的观察结果可能是由于您的终端设置所致。  SysConfig 设置也可能有所不同、我使用的是 rfWsnConcentrator 项目的默认设置。  我还在使用 LAUNCHXL-CC26X2R、因为我目前没有 LP-CC2652RSIP 可用。  请注意、在第五次计数后、我的工程会达到错误、默认示例不会发生这种情况。

    此致、
    Ryan

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢您的回复。

    我已经尝试使用 rfWsnConcentrateor 编写程序。
    但结果并不像您教授的处理结果。

    我将尝试找出其他原因。
    谢谢你。

    Lina

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我还没有弄清楚原因。
    仅使用 UART_WRITE 完成一个。
    在 SysConfig 设置中创建和执行 UART 并不好。

    使用类似这样的 UART_WRITE、他们也没有打印多个内容。
    有人能给我一个提示吗?

    Lina

    #ifndef LOG_H
    #define LOG_H
    
    //#include "config.h"
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Task.h>
    #include "ti_drivers_config.h"      /* Driver configuration */
    
    #define   log_printf( fmt, ...)         uart_log( fmt, ##__VA_ARGS__)
    
    extern void log_init();
    extern int uart_log(char* fmt, ...);
    
    #endif
    
    

    /* XDCtools Header files */
    #include <xdc/runtime/Assert.h>
    #include <xdc/runtime/System.h>
    #include <xdc/std.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/hal/Hwi.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/SPI.h>
    #include <ti/drivers/UART.h>
    
    #include "ti_drivers_config.h"      /* Driver configuration */
    
    /* Application specific Header files */
    #include "log_cc2652.h"
    
    UART_Handle uart;
    UART_Params uartParams;
    
    #define     TMPBUFF_SIZE    128
    static      uint8_t tmpbuff[TMPBUFF_SIZE+10];
    uint8_t AMN[]="HELLOW0\n";
    uint8_t CHE[]="CHE\n";
    
    
    /* Menu task main function */
    void log_init();
    int uart_log();
    int vtsprintf(char* buff,char* fmt,va_list arg);
    
    
    
    int uart_log(char* fmt, ...){
    
        va_list arg;
        int     len;
        UInt    key;
    
        UART_write(uart, CHE, sizeof(CHE));
        //Task_sleep(15);
        UART_write(uart, AMN, sizeof(AMN));
    
        key = Hwi_disable();
    
        va_start(arg, fmt);
    
        //UART_write(uart, CHE, sizeof(CHE));
        len = vtsprintf((char *)tmpbuff,fmt,arg);
    
        va_end(arg);
    
        if(len <= TMPBUFF_SIZE){
    
            UART_write(uart, tmpbuff, sizeof(tmpbuff));
            Hwi_restore(key);
            return(1);
        }else{
    
            Hwi_restore(key);
            return(0);
        }
    }
    
    int vtsprintf(char* buff,char* fmt,va_list arg){
    
        int len=0;
        int size=0;
        int zeroflag=0;
        int width=0;
    
        size = 0;
        len = 0;
    
        tmpbuff[0]=1;
        UART_write(uart, "1", 1);
    
    
    //    while(*fmt){
    //        if(len > TMPBUFF_SIZE){
    //            return (len);
    //        }
    //
    //        if(*fmt=='%'){      /* % に関する処理 */
    //            zeroflag = width = 0;
    //            fmt++;
    
    //            if (*fmt == '0'){
    //                fmt++;
    //                zeroflag = 1;
    //            }
    //            if ((*fmt >= '0') && (*fmt <= '9')){
    //                width = *(fmt++) - '0';
    //            }
    
                /* printf ("zerof = %d,width = %d\n",zeroflag,width); */
    
    //            switch(*fmt){
    //            case 'd':       /* 10進数 */
    //                size = tsprintf_decimal(va_arg(arg,signed long),buff,zeroflag,width);
    //                break;
    //            case 'x':       /* 16進数 0-f */
    //                size = tsprintf_hexadecimal(va_arg(arg,unsigned long),buff,0,zeroflag,width);
    //                break;
    //            case 'X':       /* 16進数 0-F */
    //                size = tsprintf_hexadecimal(va_arg(arg,unsigned long),buff,1,zeroflag,width);
    //                break;
    //            case 'c':       /* キャラクター */
    //                size = tsprintf_char(va_arg(arg,int),buff);
    //                break;
    //            case 's':       /* ASCIIZ文字列 */
    //                size = tsprintf_string(va_arg(arg,char*),buff);
    //                break;
    //            default:        /* コントロールコード以外の文字 */
                    /* %%(%に対応)はここで対応される */
    //                len++;
    //                *(buff++) = *fmt;
    //                break;
    //            }
    //            len += size;
    //            buff += size;
    //            fmt++;
    //        } else {
    //            *(buff++) = *(fmt++);
    //            len++;
    //        }
    //    }
    
        *buff = '\0';       /* 終端を入れる */
        len=0;
    
    //  va_end(arg);
        return (len);
    
    }
    
    
    void log_init()
    {
    
        /* Create a UART with data processing off. */
        UART_Params_init(&uartParams);
        uartParams.writeDataMode = UART_DATA_BINARY;
        uartParams.readDataMode = UART_DATA_BINARY;
        uartParams.readReturnMode = UART_RETURN_FULL;
        uartParams.baudRate = 115200;
        uart = UART_open(CONFIG_UART_0, &uartParams);
    
        if (uart == NULL) {
            /* UART_open() failed */
            while (1);
        }
    
    }
    

    static void HubFunction(UArg arg0, UArg arg1)
    {
    
        /* Call driver init functions */
        GPIO_init();
        UART_init();
    
        /* Configure the LED pin */
        GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* log_cc2652/c */
        log_init();
    
        /* Turn on user LED to indicate successful initialization */
        GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
    
        //UART_write(uart, echoPrompt, sizeof(echoPrompt));
    
        Clock_start(functionClockHandle);
        /* Loop forever echoing */
    
        while (1) {
            //UART_read(uart, &input, 1);
            //UART_write(uart, &input, 1);
        }
    }
    
    static void Tasksort(UArg arg0)
    {
        log_printf("Start %d\n",input);
        cnt=cnt+1;
        if(cnt%2==0){
            //UART_write(uart, input1, sizeof(input1));
        }else{
            //UART_write(uart, input2, sizeof(input2));
        }
    
    
    
    }

    //ti_drivers_config.h
    
    /*
     *  ======== ti_drivers_config.h ========
     *  Configured TI-Drivers module declarations
     *
     *  The macros defines herein are intended for use by applications which
     *  directly include this header. These macros should NOT be hard coded or
     *  copied into library source code.
     *
     *  Symbols declared as const are intended for use with libraries.
     *  Library source code must extern the correct symbol--which is resolved
     *  when the application is linked.
     *
     *  DO NOT EDIT - This file is generated for the LP_CC2652RSIP
     *  by the SysConfig tool.
     */
    #ifndef ti_drivers_config_h
    #define ti_drivers_config_h
    
    #define CONFIG_SYSCONFIG_PREVIEW
    
    #define CONFIG_LP_CC2652RSIP
    #ifndef DeviceFamily_CC26X2
    #define DeviceFamily_CC26X2
    #endif
    
    #include <ti/devices/DeviceFamily.h>
    
    #include <stdint.h>
    
    /* support C++ sources */
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    
    /*
     *  ======== CCFG ========
     */
    
    
    /*
     *  ======== GPIO ========
     */
    
    /* DIO6, LaunchPad LED Red */
    extern const uint_least8_t              CONFIG_GPIO_LED_0_CONST;
    #define CONFIG_GPIO_LED_0               0
    #define CONFIG_TI_DRIVERS_GPIO_COUNT    1
    
    /* LEDs are active high */
    #define CONFIG_GPIO_LED_ON  (1)
    #define CONFIG_GPIO_LED_OFF (0)
    
    #define CONFIG_LED_ON  (CONFIG_GPIO_LED_ON)
    #define CONFIG_LED_OFF (CONFIG_GPIO_LED_OFF)
    
    
    /*
     *  ======== PIN ========
     */
    #include <ti/drivers/PIN.h>
    
    extern const PIN_Config BoardGpioInitTable[];
    
    /* LaunchPad LED Red, Parent Signal: CONFIG_GPIO_LED_0 GPIO Pin, (DIO6) */
    #define CONFIG_PIN_0                   0x00000006
    /* XDS110 UART, Parent Signal: CONFIG_UART_0 TX, (DIO13) */
    #define CONFIG_PIN_1                   0x0000000d
    /* XDS110 UART, Parent Signal: CONFIG_UART_0 RX, (DIO12) */
    #define CONFIG_PIN_2                   0x0000000c
    #define CONFIG_TI_DRIVERS_PIN_COUNT    3
    
    
    
    
    /*
     *  ======== UART ========
     */
    
    /*
     *  TX: DIO13
     *  RX: DIO12
     *  XDS110 UART
     */
    extern const uint_least8_t              CONFIG_UART_0_CONST;
    #define CONFIG_UART_0                   0
    #define CONFIG_TI_DRIVERS_UART_COUNT    1
    
    
    /*
     *  ======== Watchdog ========
     */
    
    extern const uint_least8_t                  CONFIG_WATCHDOG_0_CONST;
    #define CONFIG_WATCHDOG_0                   0
    #define CONFIG_TI_DRIVERS_WATCHDOG_COUNT    1
    
    
    /*
     *  ======== Board_init ========
     *  Perform all required TI-Drivers initialization
     *
     *  This function should be called once at a point before any use of
     *  TI-Drivers.
     */
    extern void Board_init(void);
    
    /*
     *  ======== Board_initGeneral ========
     *  (deprecated)
     *
     *  Board_initGeneral() is defined purely for backward compatibility.
     *
     *  All new code should use Board_init() to do any required TI-Drivers
     *  initialization _and_ use <Driver>_init() for only where specific drivers
     *  are explicitly referenced by the application.  <Driver>_init() functions
     *  are idempotent.
     */
    #define Board_initGeneral Board_init
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif /* include guard */
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我能够使用 uart2echo TI 驱动程序示例创建项目(因为 UART 很快就会被弃用、如 TI 驱动程序运行时 API 中所述)。

    /*
     *  ======== uart2echo.c ========
     */
    #include <stdint.h>
    #include <stddef.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/UART2.h>
    #include <ti/sysbios/knl/Task.h>
    
    /* Driver configuration */
    #include "ti_drivers_config.h"
    
    uint8_t AMN[]="HELLOW0\r\n";
    uint8_t CHE[]="CHE\r\n";
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        UART2_Handle uart;
        UART2_Params uartParams;
        size_t       bytesWritten = 0;
    
        /* Call driver init functions */
        GPIO_init();
    
        /* Configure the LED pin */
        GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Create a UART where the default read and write mode is BLOCKING */
        UART2_Params_init(&uartParams);
        uartParams.baudRate = 115200;
    
        uart = UART2_open(CONFIG_UART2_0, &uartParams);
    
        if (uart == NULL) {
            /* UART2_open() failed */
            while (1);
        }
    
        /* Turn on user LED to indicate successful initialization */
        GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
    
        /* Loop forever echoing */
        while (1) {
    
            UART2_write(uart, CHE, sizeof(CHE), &bytesWritten);
            UART2_write(uart, AMN, sizeof(AMN), &bytesWritten);
            Task_sleep(500000);
        }
    
    }
    

    此致、
    Ryan

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢您的告知。
    我也可以运行该示例。
    但是、我真正想知道的是、在看门狗计时器运行时持续输出 UART。
    我现在正在寻找一个解决方案、因为我无法做到这一点。

    如果您使用的是 cc2652RSIP、则可能是每个人都以不使用周期性时钟的方式运行。
    非常感谢。
    Lina

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我能够将看门狗 TI 驱动程序添加到最后一个示例中:

    /*
     *  ======== uart2echo.c ========
     */
    #include <stdint.h>
    #include <stddef.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/UART2.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/drivers/Watchdog.h>
    
    /* Driver configuration */
    #include "ti_drivers_config.h"
    
    uint8_t AMN[]="HELLOW0\r\n";
    uint8_t CHE[]="CHE\r\n";
    
    /*
     *  ======== watchdogCallback ========
     */
    void watchdogCallback(uintptr_t watchdogHandle)
    {
        /*
         * If the Watchdog Non-Maskable Interrupt (NMI) is called,
         * loop until the device resets. Some devices will invoke
         * this callback upon watchdog expiration while others will
         * reset. See the device specific watchdog driver documentation
         * for your device.
         */
        while (1) {}
    }
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        UART2_Handle uart;
        UART2_Params uartParams;
        size_t       bytesWritten = 0;
    
        Watchdog_Handle watchdogHandle;
        Watchdog_Params params;
        uint32_t        reloadValue;
    
        /* Call driver init functions */
        GPIO_init();
        Watchdog_init();
    
        /* Configure the LED pin */
        GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Create a UART where the default read and write mode is BLOCKING */
        UART2_Params_init(&uartParams);
        uartParams.baudRate = 115200;
    
        uart = UART2_open(CONFIG_UART2_0, &uartParams);
    
        if (uart == NULL) {
            /* UART2_open() failed */
            while (1);
        }
    
        /* Open a Watchdog driver instance */
        Watchdog_Params_init(&params);
        params.callbackFxn = (Watchdog_Callback) watchdogCallback;
        params.debugStallMode = Watchdog_DEBUG_STALL_ON;
        params.resetMode = Watchdog_RESET_ON;
    
        watchdogHandle = Watchdog_open(CONFIG_WATCHDOG_0, &params);
        if (watchdogHandle == NULL) {
            /* Error opening Watchdog */
            while (1) {}
        }
    
        /*
         * The watchdog reload value is initialized during the
         * Watchdog_open() call. The reload value can also be
         * set dynamically during runtime.
         *
         * Converts TIMEOUT_MS to watchdog clock ticks.
         * This API is not applicable for all devices.
         * See the device specific watchdog driver documentation
         * for your device.
         */
        reloadValue = Watchdog_convertMsToTicks(watchdogHandle, 1000);
    
        /*
         * A value of zero (0) indicates the converted value exceeds 32 bits
         * OR that the API is not applicable for this specific device.
         */
        if (reloadValue != 0) {
            Watchdog_setReload(watchdogHandle, reloadValue);
        }
    
        /* Turn on user LED to indicate successful initialization */
        GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
    
        /* Loop forever echoing */
        while (1) {
    
            UART2_write(uart, CHE, sizeof(CHE), &bytesWritten);
            UART2_write(uart, AMN, sizeof(AMN), &bytesWritten);
            Task_sleep(500000);
            Watchdog_clear(watchdogHandle);
        }
    
    }
    

    运行项目时没有问题。  请确保使用的 SysConfig 看门狗周期大于调用 Watchdog_clear 的速率、例如、由于看门狗大约每5秒清除一次、因此我的看门狗计数为10000。

    Reagards、
    Ryan