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.
工具与软件:
您好!
我正在使用 CC2642R、以利用 BLE 并将 UART 数据发送到另一个控制器。 我已在某个特征的读取回调中插入了用户定义的函数。 数据已成功存储在存储器位置。 但是、当我尝试调用另一个通过 UART 发送特定数据的用户定义函数时、程序会卡在 HAL_ASSERT_SPINLOCK 中。 可能的原因是什么?
我的代码:
-->我的写回调函数:
bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue, uint16_t len, uint16_t offset, uint8_t method) { bStatus_t status = SUCCESS; uint8 notifyApp = 0xFF; if ( pAttr->type.len == ATT_BT_UUID_SIZE ) { // 16-bit UUID uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]); switch ( uuid ) { case SIMPLEPROFILE_CHAR3_UUID: // Validate the value // Make sure it's not a blob operation if ( offset == 0 ) { if ( len > 40 ) { status = ATT_ERR_INVALID_VALUE_SIZE; } } else { status = ATT_ERR_ATTR_NOT_LONG; } //Write the value if ( status == SUCCESS ) { uint8 *pCurValue = (uint8 *)pAttr->pValue; *pCurValue = pValue[0]; inputSize = len; for(int i = 0; i < len;i++) { completePacket[counter] = pValue[i]; counter = counter + 1; if(counter == 256) { counter = 0; packetWriteFlag = 1; break; } } if(packetWriteFlag == 1) { cloud_packet_decode_and_decrypt(completePacket); app_command_parse_and_generate_new(completePacket); counter = 0; packetWriteFlag = 0; } //value_validator(input); // app_command_parse_and_generate_new(input,len); // notifyApp = SIMPLEPROFILE_CHAR3; } break; case SIMPLEPROFILE_CHAR1_UUID: // Validate the value // Make sure it's not a blob operation if ( offset == 0 ) { if ( len > 40 ) { status = ATT_ERR_INVALID_VALUE_SIZE; } } else { status = ATT_ERR_ATTR_NOT_LONG; } //Write the value if ( status == SUCCESS ) { uint8 *pCurValue = (uint8 *)pAttr->pValue; *pCurValue = pValue[0]; inputSize = len; for(int i = 0; i < len;i++) { input[i] = pValue[i]; } if(splitFlag == 1) { // app_command_parse_and_generate_new(decryptedCloudInput); commandImplementFlag = 1; splitFlag = 0; } // else if(commandImplementFlag == 1) // { // //uart_and_RS485("probe"); // //uart_and_RS485("probe"); // // // sem_post(&sem1); // //commandImplementFlag = 0; // } else { check_other_command(input,1); } if(input[0] == '0') { memset(completePacket,0,260); counter = 0; } } break; case GATT_CLIENT_CHAR_CFG_UUID: status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY ); break; default: // Should never get here! (characteristics 2 and 4 do not have write permissions) status = ATT_ERR_ATTR_NOT_FOUND; break; } } else { // 128-bit UUID status = ATT_ERR_INVALID_HANDLE; } // // If a characteristic value changed then callback function to notify application of change // if ( (notifyApp != 0xFF ) && simpleProfile_AppCBs && simpleProfile_AppCBs->pfnSimpleProfileChange ) // { // simpleProfile_AppCBs->pfnSimpleProfileChange(2); // } return ( status ); }
您好!
感谢您联系我们。
为了解相关信息、我编辑了您的消息、以使用代码块、因为阅读代码非常困难。 下次请使用论坛的代码插入功能。
针对您的问题、我相信您可能正在尝试在回调上下文中执行过多的代码。 我无法访问您的 cloud_packet_decode_and_decrypt()和 app_command_parse_and_generate_new ()实现 ,但如果它们可能应该在任务上下文中而不是在中断上下文中执行。
我希望这将有所帮助、
此致、
您好!
抱歉、导致该问题肯定会使用代码插入函数。
您能否更详细地解释最后一点:
"也许可以在任务运行环境中执行、而不是在中断运行环境中执行。"
因为我还尝试在任务环境中实现
int main() { /* Register Application callback to trap asserts raised in the Stack */ halAssertCback = AssertHandler; Board_initGeneral(); // Enable iCache prefetching VIMSConfigure(VIMS_BASE, TRUE, TRUE); // Enable cache VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); /* Register Application callback to trap asserts raised in the Stack */ RegisterAssertCback(AssertHandler); #if !defined( POWER_SAVING ) || defined( USE_FPGA ) /* Set constraints for Standby, powerdown and idle mode */ // PowerCC26XX_SB_DISALLOW may be redundant Power_setConstraint(PowerCC26XX_SB_DISALLOW); Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW); #endif // POWER_SAVING | USE_FPGA /* Update User Configuration of the stack */ user0Cfg.appServiceInfo->timerTickPeriod = Clock_tickPeriod; user0Cfg.appServiceInfo->timerMaxMillisecond = ICall_getMaxMSecs(); //SET RTC FOR TIMESTAMP AND OTHER RELATED PARAMETERS UTC_init(); UTC_setClock(1735809775); //NVS CHECK FOR NUMBER OF CONTROLLERS WHICH ARE CURRENTLY BEING CONNECTED //controllers_connected_counter(); //Now enabling The required GPIO as trigger /* Install Button callback */ // GPIO_setCallback(INPUT_A, gpioInputFxnA); // GPIO_enableInt(INPUT_A); //Now starting the low power clock based circuitry /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); pthread_t thread; pthread_attr_t attrs; struct sched_param priParam; int retc; pthread_attr_init(&attrs); /* Set priority, detach state, and stack size attributes */ priParam.sched_priority = 1; retc = pthread_attr_setschedparam(&attrs, &priParam); retc |= pthread_attr_setdetachstate(&attrs, 1); retc |= pthread_attr_setstacksize(&attrs, 4096); if (retc != 0) { /* failed to set attributes */ while (1) {} } retc = pthread_create(&thread, &attrs, mainThread, NULL); if (retc != 0) { /* pthread_create() failed */ while (1) {} } /* Kick off application - Priority 1 */ multi_role_createTask(); /* enable interrupts and start SYS/BIOS */ BIOS_start(); return 0; }
所以我创建了另外一个任务、在这个任务中、我尝试调用这些函数。 不过、我会获得与 HAL_ASSERT_SPINLOCK 相同的错误(更具体地说是 HAL_ASSERT_CAUSD_ERROR)
您好!
感谢您共享此代码片段。 你创建新线程的方式、以及你为其分配的优先级看起来是正确的。
您是否还可以共享该新主题的内容? 除其他外、我想确保新创建的任务是启用 ICALL - https://software-dl.ti.com/simplelink/esd/simplelink_cc13xx_cc26xx_sdk/7.40.00.77/exports/docs/ble5stack/ble_user_guide/html/ble-stack-5.x/the-application.html#creating-additional-icall-enabled-tasks
此致、
void *mainThread(void *arg0) { while(1) { Task_sleep(1000000); if(commandImplementFlag == 1) { cloud_packet_decode_and_decrypt(completePacket); app_command_parse_and_generate_new(decryptedCloudInput); uart_and_RS485("probe"); commandImplementFlag = 0; } } }
您好!
另外、在 BLE 的读取回调函数中、我将阵列最多填充256个字节、然后将布尔变量设置为高电平。 此任务检查该变量、然后实现有待执行的函数。
我已经浏览过启用 ICall 的任务文档、但我想了解必须如何准确地初始化任务才能使任务成为启用 ICall 的任务。 更具体地说
// ****************************************************************** // N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp // ****************************************************************** // Register the current thread as an ICall dispatcher application // so that the application can send and receive messages. ICall_registerApp(&selfEntity, &syncEvent);
考虑到我的线程、将要输入到 ICall 寄存器应用函数的参数将是什么...
很抱歉花了你的时间,但我试图理解 iCall 的工作.....
谢谢
您好!
SDK 中提供的示例应用程序创建线程 ICall 已启用、您可以参考这些应用程序。
下面的代码片段显示了如何定义 selfEntity 和 syncEvent。 请注意、这些符号应该被重命名以避免与示例应用所声明的符号发生冲突。
static ICall_EntityID selfEntity; static ICall_SyncHandle syncEvent;
另请确保按照"Open SysConfig -> BLE -> Advanced Settings -> ICALL (打开 SysConfig ->高级设置-> ICALL)"步骤操作、并在"Max Number of ICall Enabled Tasks (启用 ICALL 任务的最大数量)"条目中添加一个。 我在前一条消息中指出的指南中定义了相应的定义。
此致、