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.

[参考译文] CC1312R:1000字节长度的数据传输在4分钟后停止

Guru**** 2555630 points
Other Parts Discussed in Thread: CC1312R

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

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/993297/cc1312r-transmission-of-data-which-is-1000-byte-length-stops-after-4-minute

器件型号:CC1312R

大家好、

我有一个基于 cc1312R 的定制板。 我有具有1000字节长度(一个数据包)的 RF_Buffer。  我每8秒将该缓冲器传输到接收器一次。 RF_buffer 仅包含固定数字。

我能够在大约4分钟内发送该缓冲区。 对于一分钟7-8数据包、 完全可以发送28-30数据包。 但之后不再有传输。 因为程序不再进入 txtaskfunction 内部。

我使用此参数。


#define TX_STACK_SIZE 512

PAYLOAD_LENGTH = 1000

unsigned char rf_Buffer[PAYLOAD_LENGTH+2];

void txTaskFunction(UArg arg0, UArg arg1)
{
    uint16_t index_2;
    uint32_t RFtime;
    RF_Params rfParams;
    RF_Params_init(&rfParams);

    if( RFQueue_defineQueue(&dataQueue,
            rxDataEntryBuffer,
            sizeof(rxDataEntryBuffer),
            NUM_DATA_ENTRIES,
            MAX_LENGTH + NUM_APPENDED_BYTES))
    {   while(1);}

    RF_cmdPropTxAdv.pktLen =  PAYLOAD_LENGTH+2;
    RF_cmdPropTxAdv.pPkt = RF_Buffer;
    RF_cmdPropTxAdv.startTrigger.triggerType = TRIG_ABSTIME;
    RF_cmdPropTxAdv.startTrigger.pastTrig = 1;

    if (!rfHandle){
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
        RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    }
    RFtime = RF_getCurrentTime();

    while(1)
    {
        Semaphore_pend(semTxHandle, BIOS_WAIT_FOREVER);
        {
            RF_Buffer[1]=(uint8_t)(PAYLOAD_LENGTH >> 8);
            RF_Buffer[0]=(uint8_t)(PAYLOAD_LENGTH);

            for(index_2 = 2; index_2 < PAYLOAD_LENGTH+2; index_2 ++)
            {
                RF_Buffer[index_2] = ALL_Buffer[index_2-2];
            }
            RF_Buffer[1000]='\r';
            RF_Buffer[1001]='\n';
            RFtime += PACKET_INTERVAL;
            RF_cmdPropTxAdv.startTime = RFtime;

            RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);

            if (!(result & RF_EventLastCmdDone))
            {   while(1);}
        }
        memset(RF_Buffer, 0, sizeof(RF_Buffer));
        PIN_setOutputValue(hPin, STA_LED,!PIN_getOutputValue(STA_LED));
    }
}

您对此问题有何看法? 它可以阻止数据传输或  在几分钟后进入 txtaskfunction 内部。

谢谢你  

BR

Bekir

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

    你(们)好

    如何知道您没有进入 txtaskfunction? 是否还有其他任务正在运行、或者您是否以接收器停止接收为基础? 您是否检查过您的堆栈是否足够大等?

    您可以接收使用上述代码发送的数据包。

    您撰写的内容:

    RF_Buffer[0]= 0xE8

    RF_Buffer[1]= 0x03、而不是相反。

    至少对于 RX 代码(使用2字节长报头时)、这将被解释为0xE803 (而不是0x03E8)、并且数据包将被过滤掉、因为我的代码不接受长度为如此长的字节。

    下面是我测试过的一些代码(RX 和 TX)、以查看我是否可以发送/接收长度为1000的数据包:

    // TX
    
    #define PAYLOAD_LENGTH          1000    // Max 255 if SIZE_OF_LENGHT_FIELD = 1
    #define PACKET_INTERVAL         500000  // Set packet interval to 500 ms
    
    /***** Prototypes *****/
    
    /***** Variable declarations *****/
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    static uint8_t packet[PAYLOAD_LENGTH + 2];
    
    /*
     * Application LED pin configuration table:
     *   - All LEDs board LEDs are off.
     */
    PIN_Config pinTable[] =
    {
        CONFIG_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    
    /***** Function definitions *****/
    
    void *mainThread(void *arg0)
    {
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        /* Open LED pins */
        ledPinHandle = PIN_open(&ledPinState, pinTable);
        if (ledPinHandle == NULL)
        {
            while(1);
        }
    
        RF_cmdPropTxAdv.pktLen = PAYLOAD_LENGTH + 2;
        RF_cmdPropTxAdv.pPkt = packet;
        RF_cmdPropTxAdv.startTrigger.triggerType = TRIG_NOW;
        RF_cmdPropTxAdv.condition.rule = 1;
        RF_cmdPropTxAdv.pktConf.bUseCrc = 1;
    
        /* Request access to the radio */
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    
        /* Set the frequency */
        RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    
        while(1)
        {
            uint16_t i;
    
            packet[0] = (uint8_t)(PAYLOAD_LENGTH >> 8);
            packet[1] = (uint8_t)(PAYLOAD_LENGTH);
    
            for (i = 2; i < PAYLOAD_LENGTH + 2; i++)
            {
                packet[i] = 0x55;
            }
    
            /* Send packet */
            RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);
    
            PIN_setOutputValue(ledPinHandle, CONFIG_PIN_GLED,!PIN_getOutputValue(CONFIG_PIN_GLED));
    
            /* Power down the radio */
            RF_yield(rfHandle);
    
            /* Sleep for PACKET_INTERVAL us */
            usleep(PACKET_INTERVAL);
    
            while(1);
        }
    }

    // RX
    
    #define DATA_ENTRY_HEADER_SIZE 8   /* Constant header size of a Generic Data Entry */
    #define MAX_LENGTH             1000 /* Max length byte the radio will accept */
                                       /* Must be less than 256 if SIZE_OF_LENGHT_FIELD = 1 */
    #define NUM_DATA_ENTRIES       2   /* NOTE: Only two data entries supported at the moment */
    #define SIZE_OF_LENGHT_FIELD   2
    #define NUM_APPENDED_BYTES     1 +  SIZE_OF_LENGHT_FIELD /* The Data Entries data field will contain:
                                                              * 1 or 2 header byte(s) (containing the length)
                                                              * A maximum of MAX_LENGTH payload bytes
                                                              * 1 status byte (RF_cmdPropRxAdv.rxConf.bAppendStatus = 0x1) */
    
    
    
    /***** Prototypes *****/
    static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
    
    /***** Variable declarations *****/
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    /* Buffer which contains all Data Entries for receiving data.
     * Pragmas are needed to make sure this buffer is 4 byte aligned (requirement from the RF Core) */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN (rxDataEntryBuffer, 4);
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                      MAX_LENGTH,
                                                      NUM_APPENDED_BYTES)];
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment = 4
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                      MAX_LENGTH,
                                                      NUM_APPENDED_BYTES)];
    #elif defined(__GNUC__)
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                      MAX_LENGTH,
                                                      NUM_APPENDED_BYTES)]
                                                      __attribute__((aligned(4)));
    #else
    #error This compiler is not supported.
    #endif
    
    /* Receive dataQueue for RF Core to fill in data */
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    static uint16_t packetLength;
    static uint8_t* packetDataPointer;
    static rfc_propRxOutput_t rxStatistics;
    
    static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES];
    
    /*
     * Application LED pin configuration table:
     *   - All LEDs board LEDs are off.
     */
    PIN_Config pinTable[] =
    {
        CONFIG_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    	PIN_TERMINATE
    };
    
    /***** Function definitions *****/
    
    void *mainThread(void *arg0)
    {
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        /* Open LED pins */
        ledPinHandle = PIN_open(&ledPinState, pinTable);
        if (ledPinHandle == NULL)
        {
            while(1);
        }
    
        if( RFQueue_defineQueue(&dataQueue,
                                rxDataEntryBuffer,
                                sizeof(rxDataEntryBuffer),
                                NUM_DATA_ENTRIES,
                                MAX_LENGTH + NUM_APPENDED_BYTES))
        {
            /* Failed to allocate space for all data entries */
            while(1);
        }
    
        /* Modify CMD_PROP_RX command for application needs */
        /* Set the Data Entity queue for received data */
        RF_cmdPropRxAdv.pQueue = &dataQueue;
        /* Discard ignored packets from Rx queue */
        RF_cmdPropRxAdv.rxConf.bAutoFlushIgnored = 1;
        /* Discard packets with CRC error from Rx queue */
        RF_cmdPropRxAdv.rxConf.bAutoFlushCrcErr = 1;
        /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
        RF_cmdPropRxAdv.maxPktLen = MAX_LENGTH;
        RF_cmdPropRxAdv.pktConf.bRepeatOk = 1;
        RF_cmdPropRxAdv.pktConf.bRepeatNok = 1;
        RF_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics;
    
        RF_cmdPropRxAdv.condition.rule = 1;
        RF_cmdPropRxAdv.pktConf.bUseCrc = 0x1;
        RF_cmdPropRxAdv.rxConf.bIncludeHdr = 0x1;
        RF_cmdPropRxAdv.rxConf.bAppendStatus = 0x1;
        RF_cmdPropRxAdv.endTrigger.triggerType = 0x1;
        RF_cmdPropRxAdv.pktConf.bCrcIncHdr = 0x1;
    
        RF_cmdPropRxAdv.hdrConf.numHdrBits = 16;
        RF_cmdPropRxAdv.hdrConf.numLenBits = 16;
    
        /* Request access to the radio */
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    
        /* Set the frequency */
        RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    
        /* Enter RX mode and stay forever in RX */
        RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxAdv, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
        while(1);
    }
    
    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
        if (e & RF_EventRxEntryDone)
        {
            /* Toggle pin to indicate RX */
            PIN_setOutputValue(ledPinHandle, CONFIG_PIN_RLED,
                               !PIN_getOutputValue(CONFIG_PIN_RLED));
    
            /* Get current unhandled data entry */
            currentDataEntry = RFQueue_getDataEntry();
    
            packetLength = ((uint16_t)((*(uint8_t*)(&currentDataEntry->data+1)) << 8) |
                            (uint16_t)(*(uint8_t*)(&currentDataEntry->data)));
            packetDataPointer = (uint8_t*)(&currentDataEntry->data + SIZE_OF_LENGHT_FIELD);
    
            /* Copy the payload and the status bytes to the packet variable */
            memcpy(packet, packetDataPointer, (packetLength + NUM_APPENDED_BYTES - SIZE_OF_LENGHT_FIELD));
        }
        RFQueue_nextEntry();
    }

    Siri

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

    感谢您的回答、有3个原因导致我认为不进入 txTaskFunction。首先、接收器停止接收数据。 其次、正如您在 txTaskFunc 中看到的代码、我将 LED 闪烁代码放在那里。 因此、使用 RF 时、LED 也会在4分钟后停止闪烁。 它永远不会再次闪烁。 我还通过调试检查了我是否进入 txTaskFunction 内部,4分钟后我也没有进入函数。

    问题可能是因为我的堆栈。 但我不知道如何检查,它是否足够大,我如何检查它? 您能否向我展示您的堆栈是什么以及堆栈是满的。

    谢谢你

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

    您可以从增加#define TX_STACK_SIZE 512开始、看看该值是否有任何变化。 如果不是、我强烈建议您测试我发布的代码、因为此代码已验证可以正常工作。 应使用 rfPacketRX 和 rfPacketTX 作为起点。 启动并运行后、您可以开始针对应用程序进行修改、并查看哪些步骤会导致代码失败。

    Siri

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

    我分别设置  TX_STACK_SIZE = 512、1024、2048 、但没有任何变化。我将从起点开始进行测试。 现在、我在 ROV 中看到停止发送数据后出现此错误。

    这些图能告诉我们问题是什么吗? 我们必须在 ARM 连接器中设置什么吗?

    谢谢你。

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

    遗憾的是、我无法根据您的输入判断问题是什么。 正如我说过的、我强烈建议您从 rfPacketRX 和/或 rfPacketTX 示例开始、并实现所需的更改。 首先、只需发送任何接收数据包、如上一个帖子中所示。 如果在之后开始更改代码时遇到问题、我们可以更轻松地在此处重新生成和调试代码、如果我们可以对相同的示例进行相同的更改、并在此处看到相同的故障。

    Siri

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

    你(们)好、Siri

    我发现问题是什么。 出现问题的原因是 RFtime = RF_getCurrentTime();我将此命令放在 while (1)之外。 当它被填满时、它不会被清除。 因此我将 rftime 放入 while (1)中。 现在它将清除/复位。 现在问题消失了。

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

    很高兴你能够启动并运行它。

    BR

    Siri