/* * システムログタスクの本体(受け口関数) */ void eLogTaskBody_main(void) { SYSLOG syslog; uint_t lost; ER_UINT rercd; cSerialPort_open(); syslog_0(LOG_NOTICE, "System logging task is started."); for (;;) { lost = 0U; while ((rercd = cSysLog_read(&syslog)) >= 0) { lost += (uint_t) rercd; if (lost > 0U) { syslog_lostmsg(lost, logtask_putc); lost = 0U; } syslog_print(&syslog, logtask_putc); logtask_putc('\n'); } if (lost > 0U) { syslog_lostmsg(lost, logtask_putc); } dly_tsk(ATTR_interval); } }
/* #[<ENTRY_FUNC>]# eBody_main * name: eBody_main * global_name: tGetCommandTaskBody_eBody_main * oneway: false * #[</ENTRY_FUNC>]# */ void eBody_main() { char buffer[2]; char command = 0; SYSTIM current; static int16_t speed = 0; static int16_t turn = 0; /* シリアルポートをオープン */ cSerialPort_open(); while(1){ command = '\0'; /* シリアルポートから1文字受信 */ syslog(LOG_INFO, "wait serial send time(%d)", current); cSerialPort_read(buffer, 1); syslog(LOG_INFO, "get serial data. buffer(%c) time(%d)", buffer[0], current); /* シリアル受信データの解析 */ if(buffer[0] == '-'){ VAR_sign = -1 * VAR_sign; }else if(buffer[0] >= '0' && buffer[0] <= '9'){ VAR_parameter = VAR_parameter * 10 + (buffer[0] - '0'); }else if(buffer[0] >= 'A'){ if(buffer[0] <= 'Z'){ buffer[0] += 0x20; } if(buffer[0] >= 'a' && buffer[0] <= 'z'){ command = buffer[0]; getTime(¤t); } } /* 各タスクへのコマンドの送信 */ switch(command){ case 'g': /* スタート */ if(cSemaphore_signal() == E_OK){ if((VAR_parameter*VAR_sign & 1) != 0){ cLinetracerControl_setEdge(-1); } else { cLinetracerControl_setEdge(1); } cBalancerControl_calibrate(); //syslog(LOG_NOTICE, "start running. edge(%d) time(%d)", VAR_parameter*VAR_sign, current); } break; case 's': /* ストップ */ cBalancerControl_setSpeed(0); //syslog(LOG_NOTICE, "stop running. time(%d)", current); break; case 'b': /* 光センサの閾値セット */ cLinetracerControl_setLightThreshold(0, VAR_parameter*VAR_sign); //syslog(LOG_NOTICE, "set black light. light(%d) time(%d)", VAR_parameter*VAR_sign, current); break; case 'w': /* 光センサの閾値セット */ cLinetracerControl_setLightThreshold(1, VAR_parameter*VAR_sign); //syslog(LOG_NOTICE, "set white light. light(%d) time(%d)", VAR_parameter*VAR_sign, current); break; case 'l': /* 光センサの閾値セット */ cLinetracerControl_setLightThreshold(2, VAR_parameter*VAR_sign); //syslog(LOG_NOTICE, "set light threshold. light(%d) time(%d)", VAR_parameter*VAR_sign, current); break; case 'i': /* ログマスクをセット */ if(VAR_parameter*VAR_sign >= 3 && VAR_parameter*VAR_sign <= 7){ cSysLog_mask(LOG_UPTO(VAR_parameter*VAR_sign), LOG_UPTO(LOG_EMERG)); //syslog(LOG_NOTICE, "set log mask. log_mask(%d) time(%d)", VAR_parameter*VAR_sign, current); } break; case 'f': /* スピードセット */ if(VAR_parameter != 0){ cBalancerControl_setSpeed((int16_t)VAR_parameter * (int16_t)VAR_sign); //syslog(LOG_NOTICE, "set speed. speed(%d) time(%d)", VAR_parameter*VAR_sign, current); } break; case 't': /* 尻尾角セット */ if(VAR_parameter >= 0){ cTailController_setAngle(VAR_parameter); //syslog(LOG_NOTICE, "set tail angle. angle(%d) time(%d)", VAR_parameter*VAR_sign, current); } break; // --- fujiya added (2013/09/01) from here---- case 'z': /* turn set */ if(VAR_parameter != 0){ cBalancerControl_setTurn((int16_t) VAR_parameter * (int16_t) VAR_sign); //syslog(LOG_NOTICE, "set turn. turn(%d) time(%d)", VAR_parameter*VAR_sign, current); } break; case 'e': /* linetracer_kill */ cLinetracerTask_stop(); //syslog(LOG_NOTICE, "linetracerTask_stoped time(%d)", current); break; case 'd': /* go straight (VAR_parameter[ms])*/ speed = 50; turn = 0; //syslog(LOG_NOTICE, "go straight turn(%d) speed(%d) time(%d)", turn, speed, current); cBalancerControl_setTurn(turn); cBalancerControl_setSpeed(speed); break; case 'c': /* go back (VAR_parameter[ms])*/ speed = -50; turn = 0; //syslog(LOG_NOTICE, "go back turn(%d) speed(%d) time(%d)", turn, speed, current); cBalancerControl_setTurn(turn); cBalancerControl_setSpeed(speed); break; case 'x': /* turn right (VAR_parameter[ms]) */ speed = 50; turn = -50; //syslog(LOG_NOTICE, "turn right turn(%d) speed(%d) time(%d)", turn, speed, current); cBalancerControl_setTurn(turn); cBalancerControl_setSpeed(speed); break; case 'v': /* turn left (VAR_parameter[ms]) */ speed = 50; turn = 50; //syslog(LOG_NOTICE, "turn left turn(%d) speed(%d) time(%d)", turn, speed, current); cBalancerControl_setTurn(turn); cBalancerControl_setSpeed(speed); break; case 'q': //かっとべマグナム speed = 100; turn = 0; //syslog(LOG_NOTICE, "go magunamu turn(%d) speed(%d) time(%d)", turn, speed, current); cBalancerControl_setTurn(turn); cBalancerControl_setSpeed(speed); break; // --- fujiya added (2013/09/01) to here ---- default: /* 特定のcommandが指定されなかった場合は何もしない */ break; } /* 受信バッファのクリア */ if(command){ VAR_parameter = 0; VAR_sign = 1; //syslog(LOG_NOTICE, "command(%d) time(%d): parameter reset.", VAR_parameter*VAR_sign, current); } } }