void paramTask(void * prm) { crtpInitTaskQueue(CRTP_PORT_PARAM); while(1) { crtpReceivePacketBlock(CRTP_PORT_PARAM, &p); if (p.channel==TOC_CH) paramTOCProcess(p.data[0]); else if (p.channel==READ_CH) paramReadProcess(p.data[0]); else if (p.channel==WRITE_CH) paramWriteProcess(p.data[0], &p.data[1]); } }
void logTask(void * prm) { crtpInitTaskQueue(CRTP_PORT_LOG); while(1) { crtpReceivePacketBlock(CRTP_PORT_LOG, &p); xSemaphoreTake(logLock, portMAX_DELAY); if (p.crtp_channel==TOC_CH) logTOCProcess(p.crtp_data[0]); if (p.crtp_channel==CONTROL_CH) logControlProcess(); xSemaphoreGive(logLock); } }
void logTask(void * prm) { crtpInitTaskQueue(CRTP_PORT_LOG); while(1) { crtpReceivePacketBlock(CRTP_PORT_LOG, &p); //xSemaphoreTake(logLock, portMAX_DELAY); rt_mutex_take(logLock, RT_WAITING_FOREVER); if (p.channel==TOC_CH) logTOCProcess(p.data[0]); if (p.channel==CONTROL_CH) logControlProcess(); //xSemaphoreGive(logLock); rt_mutex_release(logLock); } }
void memTask(void * param) { crtpInitTaskQueue(CRTP_PORT_MEM); while(1) { crtpReceivePacketBlock(CRTP_PORT_MEM, &p); switch (p.channel) { case MEM_SETTINGS_CH: memSettingsProcess(p.data[0]); break; default: break; } } }
void paramTask(void * prm) { crtpInitTaskQueue(CRTP_PORT_PARAM); while(1) { crtpReceivePacketBlock(CRTP_PORT_PARAM, &p); if (p.channel==TOC_CH) paramTOCProcess(p.data[0]); else if (p.channel==READ_CH) paramReadProcess(p.data[0]); else if (p.channel==WRITE_CH) paramWriteProcess(p.data[0], &p.data[1]); else if (p.channel==MISC_CH) { if (p.data[0] == MISC_SETBYNAME) { int i, nzero = 0; char *group; char *name; uint8_t type; void * valPtr; int error; // If the packet contains at least 2 zeros in the first 28 bytes // The packet decoding algorithm will not crash for (i=0; i<CRTP_MAX_DATA_SIZE; i++) { if (p.data[i] == '\0') nzero++; } if (nzero < 2) return; group = (char*)&p.data[1]; name = (char*)&p.data[1+strlen(group)+1]; type = p.data[1+strlen(group)+1+strlen(name)+1]; valPtr = &p.data[1+strlen(group)+1+strlen(name)+2]; error = paramWriteByNameProcess(group, name, type, valPtr); p.data[1+strlen(group)+1+strlen(name)+1] = error; p.size = 1+strlen(group)+1+strlen(name)+1+1; crtpSendPacket(&p); } } } }
void infoInit() { xTaskCreate(infoTask, (const signed char * const)"Info", configMINIMAL_STACK_SIZE, NULL, /*priority*/2, NULL); crtpInitTaskQueue(crtpInfo); }
void pidCtrlInit() { xTaskCreate(pidCrtlTask, (const signed char * const)"PIDCrtl", configMINIMAL_STACK_SIZE, NULL, /*priority*/2, NULL); crtpInitTaskQueue(6); }
void infoInit() { xTaskCreate(infoTask, (const signed char * const)INFO_TASK_NAME, INFO_TASK_STACKSIZE, NULL, INFO_TASK_PRI, NULL); crtpInitTaskQueue(crtpInfo); }