void logControlProcess() { int ret = ENOEXEC; switch (p.data[0]) { case CONTROL_CREATE_BLOCK: ret = logCreateBlock(p.data[1], (struct ops_setting*) &p.data[2], (p.size - 2) / sizeof(struct ops_setting)); break; case CONTROL_APPEND_BLOCK: ret = logAppendBlock(p.data[1], (struct ops_setting*) &p.data[2], (p.size - 2) / sizeof(struct ops_setting)); break; case CONTROL_DELETE_BLOCK: ret = logDeleteBlock(p.data[1]); break; case CONTROL_START_BLOCK: ret = logStartBlock(p.data[1], p.data[2] * 10); break; case CONTROL_STOP_BLOCK: ret = logStopBlock(p.data[1]); break; case CONTROL_RESET: logReset(); ret = 0; break; } //Commands answer p.data[2] = ret; p.size = 3; crtpSendPacket(&p); }
static void logReset(void) { int i; if (isInit) { //Stop and delete all started log blocks for(i=0; i<LOG_MAX_BLOCKS; i++) if (logBlocks[i].id != -1) { logStopBlock(logBlocks[i].id); logDeleteBlock(logBlocks[i].id); } } //Force free all the log block objects for(i=0; i<LOG_MAX_BLOCKS; i++) logBlocks[i].id = BLOCK_ID_FREE; //Force free the log ops for (i=0; i<LOG_MAX_OPS; i++) logOps[i].variable = NULL; }