/** ウォッチドッグクリア付きウェイト * @param time ウェイト時間 [ms] ****************************************************************************** */ void WDT_Wait( long time ) { for( ; time > 0; time -= WDT_CLEAR_INTERVAL ) { WDT_Clear(); // ウォッチドッグクリア if( time > WDT_CLEAR_INTERVAL ) dly_tsk( WDT_CLEAR_INTERVAL ); else dly_tsk( time ); // サンプリング時間待ち } }
/* * モニタタスク */ void monitor(VP_INT exinf) { INT no, point; B c; /* モニタで使用するデータの初期化 */ mon_portid = mon_default_portid = (ID)exinf; mon_datatype = DATA_BYTE; mon_logmask = LOG_NOTICE; mon_lowmask = LOG_EMERG; current_tskid = MONTASK; mon_infile = stdin; if(mon_portid != CONSOLE_PORTID) syscall(serial_opn_por(mon_portid)); #ifdef NEED_MONITOR if(!need_monitor()) ext_tsk(); #endif /* NEED_MONITOR */ _setup_stdio(&mon_portid); #ifdef MONITOR_DELAY dly_tsk(MONITOR_DELAY); #endif /* MONITOR_DELAY */ #if defined(LOGTASK) && (LOGTASK_PRIORITY <= MONITOR_PRIORITY) chg_pri(LOGTASK, MONITOR_PRIORITY+1); dly_tsk(50); printf("change log task priority %d to %d !\n", LOGTASK_PRIORITY, MONITOR_PRIORITY+1); #endif printf(banner, (TMONITOR_PRVER >> 12) & 0x0f, (TMONITOR_PRVER >> 4) & 0xff, TMONITOR_PRVER & 0x0f); vmsk_log(LOG_UPTO(mon_logmask), LOG_UPTO(mon_lowmask)); syscall(serial_ctl_por(mon_portid, (IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV))); /* モニタのメインのデスパッチ */ do{ prompt(current_tskid); c = monitor_getstring(mon_command, &point); no = dispatch_command(mon_command, &point); putecho('\n'); if(no >= 0) mon_dispatch[no].func(&mon_command[point]); fflush(NULL); }while(c != KEY_EXT); printf("exit monitor !!\n"); }
ER_UINT net_serial_rea_dat (ID portid, char *buf, UINT len) { T_SERIAL_RPOR rpor; UINT off; int ch; if (!wait_accept && !connected) { wait_accept = TRUE; if (TCP_ACP_CEP(TCP_CEPID, TCP_REPID, &dst, TMO_NBLK) != E_WBLK) return 0; } while (TRUE) { if (connected) { off = 0; while (off < len && (ch = get_char(TCP_CEPID)) != EOF) { *(buf + off ++) = ch; if ((net_ioctl & IOCTL_ECHO) != 0) { put_char(TCP_CEPID, ch); flush_snd_buff(TCP_CEPID); } } return off; } else if (serial_ref_por(portid, &rpor) == E_OK && rpor.reacnt > 0) { return serial_rea_dat(portid, buf, len); } dly_tsk(500); } return off; }
/** * Configure video clock out */ void rct_set_vout_freq_hz(u32 freq_hz) { #ifdef __USE_DIRECT_RCT_PROGRAM int i; for (i = 0; ;i++) { if ((G_vout_rct[i].freq == 0) || (G_vout_rct[i].freq == freq_hz)) break; } /* Configure sensor clock out. The reference clock = 27 MHz */ writel(PLL_VIDEO_CTRL_REG, G_vout_rct[i].video_ctrl & (~0x10)); writel(PLL_VIDEO_FRAC_REG, G_vout_rct[i].video_frac); writel(SCALER_VIDEO_POST_REG, G_vout_rct[i].scaler_post); dly_tsk(1); writel(PLL_VIDEO_CTRL_REG, G_vout_rct[i].video_ctrl | 0x01); writel(SCALER_VIDEO_REG, G_vout_rct[i].scaler_pre); vo_clk_freq_hz = G_vout_rct[i].freq; #else if (amb_set_vout_clock_frequency(HAL_BASE_VP, freq_hz) != AMB_HAL_SUCCESS) { DEBUG_MSG("amb_set_vout_clock_frequency() failed"); } #endif }
/* * システムログタスクの本体 */ void logtask_main(intptr_t exinf) { SYSLOG syslog; uint_t lost; ER_UINT rercd; ID my_logtask_portid; my_logtask_portid = (ID) exinf; set_my_logtask_portid(my_logtask_portid); serial_opn_por(my_logtask_portid); syslog_msk_log(LOG_UPTO(LOG_NOTICE), LOG_UPTO(LOG_EMERG)); syslog_1(LOG_NOTICE, "System logging task is started on port %d.", my_logtask_portid); for (;;) { lost = 0U; while ((rercd = syslog_rea_log(&syslog)) >= 0) { lost += (uint_t) rercd; if (syslog.logtype >= LOG_TYPE_COMMENT) { 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); } if(E_OK != dly_tsk(LOGTASK_INTERVAL)){ syslog_0(LOG_NOTICE, "syslog : Error dly_tsk() !"); } } }
/* * システムログタスクの本体 */ void logtask_main(intptr_t exinf) { SYSLOG logbuf; uint_t lostlog; ER_UINT rercd; logtask_portid = (ID) exinf; (void) serial_opn_por(logtask_portid); (void) syslog_msk_log(LOG_UPTO(LOG_NOTICE), LOG_UPTO(LOG_EMERG)); syslog_1(LOG_NOTICE, "System logging task is started on port %d.", logtask_portid); for (;;) { lostlog = 0U; while ((rercd = syslog_rea_log(&logbuf)) >= 0) { lostlog += (uint_t) rercd; if (logbuf.logtype >= LOG_TYPE_COMMENT) { if (lostlog > 0U) { syslog_lostmsg(lostlog, logtask_putc); lostlog = 0U; } syslog_print(&logbuf, logtask_putc); logtask_putc('\n'); } } if (lostlog > 0U) { syslog_lostmsg(lostlog, logtask_putc); } (void) dly_tsk(LOGTASK_INTERVAL); } }
/* * システムログタスクの本体(受け口関数) */ 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); } }
/* 通信途絶チェック */ TASK task4(void) { while(1) { wd = 0; // dly_tsk(200); /* 200 * 10 msec = 2s */ dly_tsk(50); /* 50 * 10 msec = 0.5s */ if(wd == 0) { TPU3.TGRA = (unsigned short)65000; TPU3.TGRB = (unsigned short)65000; TPU3.TGRC = (unsigned short)65000; TPU3.TGRD = (unsigned short)65000; // PE.DR.BIT.B0 = 0x0; // PE.DR.BIT.B3 = 0x0; FRI.FRIPE.BIT.B0 = 0x0; FRI.FRIPE.BIT.B3 = 0x0; /* インヒビット設定*/ P7.DR.BIT.B6 = 0x0; P7.DR.BIT.B7 = 0x0; } else { // PE.DR.BIT.B0 = 0x1; // PE.DR.BIT.B3 = 0x1; FRI.FRIPE.BIT.B0 = 0x1; FRI.FRIPE.BIT.B3 = 0x1; /* インヒビット解除*/ P7.DR.BIT.B6 = 0x1; P7.DR.BIT.B7 = 0x1; } // PE.DR.BIT.B4 = ~PE.DR.BIT.B4; FRI.FRIPE.BIT.B4 = ~FRI.FRIPE.BIT.B4; } ext_tsk(); }
/** * Guarantee the QoS of Bluetooth communication by raising the priority of BT_TSK periodically */ void bluetooth_qos_task(intptr_t unused) { while(1) { chg_pri(BT_TSK, TPRI_BLUETOOTH_HIGH); dly_tsk(BT_HIGH_PRI_TIME_SLICE); chg_pri(BT_TSK, TPRI_BLUETOOTH_LOW); dly_tsk(BT_LOW_PRI_TIME_SLICE); // tslp_tsk(500); // syslog(LOG_ERROR, "UART2.LSR: 0x%x", UART2.LSR); // syslog(LOG_ERROR, "UART2.IER: 0x%x", UART2.IER); // syslog(LOG_ERROR, "UART2.IIR: 0x%x", UART2.IIR_FCR); // syslog(LOG_ERROR, "UART2.MSR: 0x%x", UART2.MSR); // syslog(LOG_ERROR, "rx_size: %d", rx_size); } }
void task2(intptr_t exinf) { ER_UINT ercd; switch (++task2_count) { case 1: check_point(2); ercd = slp_tsk(); check_ercd(ercd, E_NOSPT); ercd = tslp_tsk(TEST_TIME_PROC); check_ercd(ercd, E_NOSPT); ercd = dly_tsk(TEST_TIME_PROC); check_ercd(ercd, E_NOSPT); ercd = wai_sem(SEM1); check_ercd(ercd, E_NOSPT); ercd = pol_sem(SEM1); check_ercd(ercd, E_OK); ercd = pol_sem(SEM1); check_ercd(ercd, E_TMOUT); ercd = twai_sem(SEM1, TEST_TIME_PROC); check_ercd(ercd, E_NOSPT); ercd = ext_tsk(); check_ercd(ercd, E_OK); check_point(0); case 2: check_point(6); ercd = rot_rdq(MID_PRIORITY); check_ercd(ercd, E_NOSPT); ercd = ext_tsk(); check_ercd(ercd, E_OK); check_point(0); case 3: check_point(10); ercd = rot_rdq(MID_PRIORITY); check_ercd(ercd, E_OK); ercd = ext_tsk(); check_ercd(ercd, E_OK); check_point(0); default: check_point(0); } check_point(0); }
/* * 並行実行されるタスク */ void task(VP_INT exinf) { _toppers_cxxrt_reset_specific(); volatile UW i; INT n = 0; INT tskno = (INT) exinf; char *graph[] = { "|", " +", " *" }; char c; ena_tex(); while (1) { syslog(LOG_NOTICE, "task%d is running (%03d). %s", tskno, ++n, graph[tskno-1]); for (i = 0; i < task_loop; i++); c = message[tskno-1]; message[tskno-1] = 0; switch (c) { case 'e': syslog(LOG_INFO, "#%d#ext_tsk()", tskno); ext_tsk(); case 's': syslog(LOG_INFO, "#%d#slp_tsk()", tskno); syscall(slp_tsk()); break; case 'S': syslog(LOG_INFO, "#%d#tslp_tsk(10000)", tskno); syscall(tslp_tsk(10000)); break; case 'd': syslog(LOG_INFO, "#%d#dly_tsk(10000)", tskno); syscall(dly_tsk(10000)); break; case 'y': syslog(LOG_INFO, "#%d#dis_tex()", tskno); syscall(dis_tex()); break; case 'Y': syslog(LOG_INFO, "#%d#ena_tex()", tskno); syscall(ena_tex()); break; #ifdef CPUEXC1 case 'z': syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno); RAISE_CPU_EXCEPTION; break; case 'Z': loc_cpu(); syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno); RAISE_CPU_EXCEPTION; unl_cpu(); break; #endif /* CPUEXC1 */ default: break; } } }
/* * 並行実行されるタスク */ void task(intptr_t exinf) { volatile ulong_t i; int_t n = 0; int_t tskno = (int_t) exinf; const char *graph[] = { "|", " +", " *" }; char c; SVC_PERROR(ena_tex()); while (true) { syslog(LOG_NOTICE, "task%d is running (%03d). %s", tskno, ++n, graph[tskno-1]); for (i = 0; i < task_loop; i++); c = message[tskno-1]; message[tskno-1] = 0; switch (c) { case 'e': syslog(LOG_INFO, "#%d#ext_tsk()", tskno); SVC_PERROR(ext_tsk()); assert(0); case 's': syslog(LOG_INFO, "#%d#slp_tsk()", tskno); SVC_PERROR(slp_tsk()); break; case 'S': syslog(LOG_INFO, "#%d#tslp_tsk(10000)", tskno); SVC_PERROR(tslp_tsk(10000)); break; case 'd': syslog(LOG_INFO, "#%d#dly_tsk(10000)", tskno); SVC_PERROR(dly_tsk(10000)); break; case 'y': syslog(LOG_INFO, "#%d#dis_tex()", tskno); SVC_PERROR(dis_tex()); break; case 'Y': syslog(LOG_INFO, "#%d#ena_tex()", tskno); SVC_PERROR(ena_tex()); break; #ifdef CPUEXC1 case 'z': syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno); RAISE_CPU_EXCEPTION; break; case 'Z': SVC_PERROR(loc_cpu()); syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno); RAISE_CPU_EXCEPTION; SVC_PERROR(unl_cpu()); break; #endif /* CPUEXC1 */ default: break; } } }
/** %jp{適当な時間待つ} */ void rand_wait(void) { int r; wai_sem(SEMID_RAND); r = rand(); sig_sem(SEMID_RAND); dly_tsk((r % 1000) + 10); }
/* * 並行実行されるタスク */ void task(VP_INT exinf) { volatile UW i; INT n = 0; INT tskno = (INT) exinf; const char *graph[] = { "|", " +", " *" }; char c; ena_tex(); while (1) { syslog(LOG_NOTICE, "task%d is running (%03d). %s", tskno, ++n, graph[tskno-1]); for (i = 0; i < task_loop; i++); c = message[tskno-1]; message[tskno-1] = 0; switch (c) { case 'e': syslog(LOG_INFO, "#%d#ext_tsk()", tskno); ext_tsk(); case 's': syslog(LOG_INFO, "#%d#slp_tsk()", tskno); syscall(slp_tsk()); break; case 'S': syslog(LOG_INFO, "#%d#tslp_tsk(10000)", tskno); syscall(tslp_tsk(10000)); break; case 'd': syslog(LOG_INFO, "#%d#dly_tsk(10000)", tskno); syscall(dly_tsk(10000)); break; case 'y': syslog(LOG_INFO, "#%d#dis_tex()", tskno); syscall(dis_tex()); break; case 'Y': syslog(LOG_INFO, "#%d#ena_tex()", tskno); syscall(ena_tex()); break; #ifdef CPUEXC1 case 'z': syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno); RAISE_CPU_EXCEPTION; break; #endif /* CPUEXC1 */ case 'Z': syslog(LOG_NOTICE, "Sample program ends with exception."); kernel_exit(); break; default: break; } } }
/* * システムログ出力の待ち合わせ */ ER logtask_flush(uint_t count) { T_SYSLOG_RLOG rlog; T_SERIAL_RPOR rpor; ER ercd, rercd; ID my_logtask_portid = get_my_logtask_portid(); if (sns_dpn()) { ercd = E_CTX; } else { for (;;) { if (syslog_ref_log(&rlog) < 0) { ercd = E_SYS; goto error_exit; } if (rlog.count <= count) { if (count == 0U) { /* * countが0の場合には,シリアルバッファが空かを確 * 認する. */ if (serial_ref_por(my_logtask_portid, &rpor) < 0) { ercd = E_SYS; goto error_exit; } if (rpor.wricnt == 0U) { ercd = E_OK; goto error_exit; } } else { ercd = E_OK; goto error_exit; } } /* * LOGTASK_FLUSH_WAITミリ秒待つ. */ rercd = dly_tsk(LOGTASK_FLUSH_WAIT); if (rercd < 0) { ercd = (rercd == E_RLWAI) ? rercd : E_SYS; goto error_exit; } } } error_exit: return(ercd); }
void task2(intptr_t exinf) { ER_UINT ercd; switch (++task2_count) { case 1: check_point(2); ercd = slp_tsk(); check_ercd(ercd, E_NOSPT); check_point(3); ercd = tslp_tsk(10); check_ercd(ercd, E_NOSPT); check_point(4); ercd = dly_tsk(10); check_ercd(ercd, E_NOSPT); check_point(5); ercd = ext_tsk(); check_ercd(ercd, E_OK); check_point(0); case 2: check_point(23); ercd = rot_rdq(MID_PRIORITY); check_ercd(ercd, E_NOSPT); check_point(24); ercd = ext_tsk(); check_ercd(ercd, E_OK); check_point(0); case 3: check_point(30); ercd = rot_rdq(MID_PRIORITY); check_ercd(ercd, E_OK); check_point(31); ercd = ext_tsk(); check_ercd(ercd, E_OK); check_point(0); default: check_point(0); } check_point(0); }
/* * システムログ出力の待ち合わせ(受け口関数) */ ER eLogTask_flush(uint_t count) { T_SYSLOG_RLOG rlog; T_SERIAL_RPOR rpor; ER ercd, rercd; if (sns_dpn()) { ercd = E_CTX; } else { for (;;) { if (cSysLog_refer(&rlog) < 0) { ercd = E_SYS; goto error_exit; } if (rlog.count <= count) { if (count == 0U) { /* * countが0の場合には,シリアルバッファが空かを確 * 認する. */ if (cSerialPort_refer(&rpor) < 0) { ercd = E_SYS; goto error_exit; } if (rpor.wricnt == 0U) { ercd = E_OK; goto error_exit; } } else { ercd = E_OK; goto error_exit; } } /* * フラッシュ待ちの単位時間(ATTR_flushWaitμ秒)待つ. */ rercd = dly_tsk(ATTR_flushWait); if (rercd < 0) { ercd = (rercd == E_RLWAI) ? rercd : E_SYS; goto error_exit; } } } error_exit: return(ercd); }
/** ウォッチドッグタイマ試験 ****************************************************************************** */ void WDT_Test( void ) { if( WDT_IsDetect() ) { for( ;; ) { LAMP_DisplayValue( LAMP_COLOR_BLUE, 0x003F ); WDT_Wait( 1000 ); LAMP_DisplayValue( LAMP_COLOR_BLUE, 0x0FC0 ); WDT_Wait( 1000 ); } } LAMP_DisplayValue( LAMP_COLOR_BLUE, 0x0FFF ); dly_tsk( 1000 ); LAMP_DisplayValue( LAMP_COLOR_BLUE, 0x0000 ); WDT_Start(); for( ;; ) { dly_tsk( 10000 ); } }
/* * シリアルI/Oポートからの非同期文字入力 */ INT sio_arcv_chr( void ) { SIOPCB* siopcb ; UH uhBase ; INT c = -1 ; /* * タスクコンテキストからのみ使用可 */ if ( sns_ctx() || sns_loc() || sns_dsp() ) return -1 ; /* * CPUロック状態にする */ loc_cpu() ; /* * 非同期用ポートを開く */ if ( ( siopcb = sio_opn_por( LOGTASK_PORTID, siopcb_table[LOGTASK_PORTID-1].vpiExinf ) ) != NULL ) { uhBase = siopcb->uhBase ; /* * 受信待ち */ while(1) { if ( __SFR(uhBase) & __UxCR_RXREADY ) { c = __SFRW(uhBase+2) & 0xff ; if ( c == '\r' ) { c = '\n' ; siopcb->bLastIsCr = TRUE ; } else { if ( c == '\n' && siopcb->bLastIsCr ) c = -1 ; siopcb->bLastIsCr = FALSE ; } } if ( c != -1 ) break ; unl_cpu() ; dly_tsk( 50 ) ; loc_cpu() ; } } /* * CPUロックを解除 */ unl_cpu() ; return c ; }
/** * @fn static int wink_exe( int argc, char *argv[] ) * @brief COMMAND: LED wink * @note COMMAND: wink */ static int wink_exe( int argc, char *argv[] ) { printf("Start program\n"); printf("Can you see two LEDs are winking?\n"); printf(" -- Hit any key to stop the program. -- \n"); KzLedBlink( eKzLED0, 500, 500 ); dly_tsk(500); KzLedBlink( eKzLED1, 500, 500 ); /* hit any key */ getc(stdin); KzLedOff(eKzLED0); KzLedOff(eKzLED1); printf("End program\n"); return 0; }
void run() { for (;;) { try { // 意図的にデッドロックを発生させる。 left_->take(); syslog(LOG_NOTICE, "#%d take left fork(%d)", tskid_, left_->id()); dly_tsk(100 * (rnd() % 5 + 1)); right_->take(); syslog(LOG_NOTICE, "#%d take right fork(%d)", tskid_, right_->id()); eat(); left_->give(); syslog(LOG_NOTICE, "#%d give left fork(%d)", tskid_, left_->id()); right_->give(); syslog(LOG_NOTICE, "#%d give right fork(%d)", tskid_, right_->id()); think(); } catch (timeout_error&) { // タイムアウトによりデッドロックを検出すると、フォークを放す。 syslog(LOG_NOTICE, "#%d !!!! timeout error !!!!", tskid_); if (left_->is_used()) { left_->give(); syslog(LOG_NOTICE, "#%d give left fork(%d)", tskid_, left_->id()); } if (right_->is_used()) { right_->give(); syslog(LOG_NOTICE, "#%d give right fork(%d)", tskid_, right_->id()); } rot_rdq(TPRI_SELF); } } }
/* * 並行実行されるタスク */ void task(intptr_t exinf) { volatile ulong_t i; int_t n = 0; int_t tskno = (int_t) (exinf); const char *graph[] = { "|", " +", " *", "||", " ++", " **" }; char_t c; while (1) { syslog(LOG_NOTICE, "task%d is running (%03d). %s", tskno, ++n, graph[tskno-1]); for (i = 0; i < task_loop; i++); c = message[tskno-1]; message[tskno-1] = 0; switch (c) { case 'e': syslog(LOG_INFO, "#%d#ext_tsk()", tskno); SVC_PERROR(ext_tsk()); assert(0); case 's': syslog(LOG_INFO, "#%d#slp_tsk()", tskno); SVC_PERROR(slp_tsk()); break; case 'S': syslog(LOG_INFO, "#%d#tslp_tsk(10000)", tskno); SVC_PERROR(tslp_tsk(10000)); break; case 'd': syslog(LOG_INFO, "#%d#dly_tsk(10000)", tskno); SVC_PERROR(dly_tsk(10000)); break; case 'g': syslog(LOG_INFO, "#%d#mig_tsk(0,%d)", tskno,tsk_mig_prc); SVC_PERROR(mig_tsk(0,tsk_mig_prc)); break; default: break; } } }
/* * 並行実行されるタスク */ void task(intptr_t exinf) { volatile ulong_t i; int_t n = 0; int_t tskno = (int_t) exinf; const char *graph[] = { "| ", " + ", " *" }; char c; #ifdef TOPPERS_SUPPORT_OVRHDR T_ROVR pk_rovr; #endif /* TOPPERS_SUPPORT_OVRHDR */ while (true) { #ifdef TOPPERS_SUPPORT_OVRHDR SVC_PERROR(ref_ovr(TSK_SELF, &pk_rovr)); if ((pk_rovr.ovrstat & TOVR_STA) != 0) { syslog(LOG_NOTICE, "task%d is running (%03d). %s [%ld]", tskno, ++n, graph[tskno-1], pk_rovr.leftotm); } else { syslog(LOG_NOTICE, "task%d is running (%03d). %s", tskno, ++n, graph[tskno-1]); } #else /* TOPPERS_SUPPORT_OVRHDR */ syslog(LOG_NOTICE, "task%d is running (%03d). %s", tskno, ++n, graph[tskno-1]); #endif /* TOPPERS_SUPPORT_OVRHDR */ for (i = 0; i < task_loop; i++); c = message[tskno-1]; message[tskno-1] = 0; switch (c) { case 'e': syslog(LOG_INFO, "#%d#ext_tsk()", tskno); SVC_PERROR(ext_tsk()); assert(0); case 's': syslog(LOG_INFO, "#%d#slp_tsk()", tskno); SVC_PERROR(slp_tsk()); break; case 'S': syslog(LOG_INFO, "#%d#tslp_tsk(10000000)", tskno); SVC_PERROR(tslp_tsk(10000000)); break; case 'd': syslog(LOG_INFO, "#%d#dly_tsk(10000000)", tskno); SVC_PERROR(dly_tsk(10000000)); break; case 'y': syslog(LOG_INFO, "#%d#dis_ter()", tskno); SVC_PERROR(dis_ter()); break; case 'Y': syslog(LOG_INFO, "#%d#ena_ter()", tskno); SVC_PERROR(ena_ter()); break; #ifdef CPUEXC1 case 'z': syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno); RAISE_CPU_EXCEPTION; break; case 'Z': SVC_PERROR(loc_cpu()); syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno); RAISE_CPU_EXCEPTION; SVC_PERROR(unl_cpu()); break; #endif /* CPUEXC1 */ default: break; } } }
void task1( unsigned int arg ) { ER ercd; int tests = 0; CYG_TEST_INFO( "Task 1 running" ); ercd = dis_dsp(); CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" ); ercd = sta_tsk( 2, 22222 ); CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" ); ercd = chg_pri( 2, 5 ); CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" ); ercd = ena_dsp(); CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" ); ercd = dly_tsk( 10 ); CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); #ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE tests++; #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = del_mpf( -6 ); CYG_TEST_CHECK( E_ID == ercd, "del_mpf bad ercd !E_ID" ); ercd = del_mpf( 99 ); CYG_TEST_CHECK( E_ID == ercd, "del_mpf bad ercd !E_ID" ); ercd = cre_mpf( -6, &t_cmpf ); CYG_TEST_CHECK( E_ID == ercd, "cre_mpf bad ercd !E_ID" ); ercd = cre_mpf( 99, &t_cmpf ); CYG_TEST_CHECK( E_ID == ercd, "cre_mpf bad ercd !E_ID" ); #endif // we can test bad param error returns // try a pre-existing object // [first get a valid block from it for the freeing test later] ercd = pget_blf( &vp, 3 ); CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" ); ercd = cre_mpf( 3, &t_cmpf ); CYG_TEST_CHECK( E_OBJ == ercd, "cre_mpf bad ercd !E_OBJ" ); // delete it so we can play ercd = del_mpf( 3 ); CYG_TEST_CHECK( E_OK == ercd, "del_mpf bad ercd" ); // check it is deleted ercd = rel_blf( 3, vp ); // vp did come from this pool CYG_TEST_CHECK( E_NOEXS == ercd, "rel_blf bad ercd !E_NOEXS" ); ercd = pget_blf( &vp, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" ); ercd = tget_blf( &vp, 3, 10 ); CYG_TEST_CHECK( E_NOEXS == ercd, "tget_blf bad ercd !E_NOEXS" ); ercd = get_blf( &vp, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" ); ercd = ref_mpf( &t_rmpf, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mpf bad ercd !E_NOEXS" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // now try creating it (badly) #ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR ercd = cre_mpf( 3, NULL ); CYG_TEST_CHECK( E_PAR == ercd, "cre_mpf bad ercd !E_PAR" ); #endif ercd = cre_mpf( 3, NADR ); CYG_TEST_CHECK( E_PAR == ercd, "cre_mpf bad ercd !E_PAR" ); t_cmpf.mpfatr = 0xfff; ercd = cre_mpf( 3, &t_cmpf ); CYG_TEST_CHECK( E_RSATR == ercd, "cre_mpf bad ercd !E_RSATR" ); #endif // we can test bad param error returns t_cmpf.mpfatr = 0; t_cmpf.mpfcnt = 10000; t_cmpf.blfsz = 100; ercd = cre_mpf( 3, &t_cmpf ); CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpf bad ercd" ); t_cmpf.mpfcnt = 100; t_cmpf.blfsz = 100000; ercd = cre_mpf( 3, &t_cmpf ); CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpf bad ercd" ); // now create it well t_cmpf.mpfatr = 0; t_cmpf.mpfcnt = 10; t_cmpf.blfsz = 100; ercd = cre_mpf( 3, &t_cmpf ); CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" ); // and check we can use it ercd = pget_blf( &vp, 3 ); CYG_TEST_CHECK( E_OK == ercd, "pget_blf bad ercd" ); ercd = tget_blf( &vp, 3, 10 ); CYG_TEST_CHECK( E_OK == ercd, "tget_blf bad ercd" ); ercd = get_blf( &vp, 3 ); CYG_TEST_CHECK( E_OK == ercd, "get_blf bad ercd" ); ercd = rel_blf( 3, vp ); // vp did come from new pool CYG_TEST_CHECK( E_OK == ercd, "rel_blf bad ercd" ); ercd = rel_blf( 3, vp ); // vp already freed CYG_TEST_CHECK( E_PAR == ercd, "rel_blf bad ercd !E_PAR" ); ercd = ref_mpf( &t_rmpf, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_mpf bad ercd" ); // In order to wait on the pools, we must first consume all they have: while ( E_OK == (ercd = pget_blf( &vp, 1 )) ) /* nothing */; CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" ); while ( E_OK == (ercd = tget_blf( &vp, 2, 1 )) ) /* nothing */; CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf bad ercd !E_TMOUT" ); // now wait while task 2 deletes the wait objects ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = get_blf( &vp, 1 ); CYG_TEST_CHECK( E_DLT == ercd, "get_blf bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = tget_blf( &vp, 2, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "tget_blf bad ercd !E_DLT" ); // check they are deleted ercd = get_blf( &vp, 1 ); CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" ); ercd = pget_blf( &vp, 2 ); CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" ); // re-create and do it again t_cmpf.mpfcnt = 90; t_cmpf.blfsz = 20; ercd = cre_mpf( 1, &t_cmpf ); CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" ); t_cmpf.mpfcnt = 5; t_cmpf.blfsz = 200; ercd = cre_mpf( 2, &t_cmpf ); CYG_TEST_CHECK( E_OK == ercd, "cre_mpf bad ercd" ); // In order to wait on the pools, we must first consume all they have: while ( E_OK == (ercd = pget_blf( &vp, 1 )) ) /* nothing */; CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blf bad ercd !E_TMOUT" ); while ( E_OK == (ercd = tget_blf( &vp, 2, 1 )) ) /* nothing */; CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blf bad ercd !E_TMOUT" ); // now wait while task 2 deletes the wait objects ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = get_blf( &vp, 1 ); CYG_TEST_CHECK( E_DLT == ercd, "get_blf bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = tget_blf( &vp, 2, 10 ); CYG_TEST_CHECK( E_DLT == ercd, "tget_blf bad ercd !E_DLT" ); // check they are deleted ercd = tget_blf( &vp, 1, 1 ); CYG_TEST_CHECK( E_NOEXS == ercd, "get_blf bad ercd !E_NOEXS" ); ercd = get_blf( &vp, 2 ); CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blf bad ercd !E_NOEXS" ); CYG_TEST_PASS("create/delete fixed mempools"); #endif // CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE #ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE tests++; #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = del_mpl( -6 ); CYG_TEST_CHECK( E_ID == ercd, "del_mpl bad ercd !E_ID" ); ercd = del_mpl( 99 ); CYG_TEST_CHECK( E_ID == ercd, "del_mpl bad ercd !E_ID" ); ercd = cre_mpl( -6, &t_cmpl ); CYG_TEST_CHECK( E_ID == ercd, "cre_mpl bad ercd !E_ID" ); ercd = cre_mpl( 99, &t_cmpl ); CYG_TEST_CHECK( E_ID == ercd, "cre_mpl bad ercd !E_ID" ); #endif // we can test bad param error returns // try a pre-existing object // [first get a valid block from it for the freeing test later] ercd = pget_blk( &vp, 3, 100 ); CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" ); ercd = cre_mpl( 3, &t_cmpl ); CYG_TEST_CHECK( E_OBJ == ercd, "cre_mpl bad ercd !E_OBJ" ); // delete it so we can play ercd = del_mpl( 3 ); CYG_TEST_CHECK( E_OK == ercd, "del_mpl bad ercd" ); // check it is deleted ercd = rel_blk( 3, vp ); // vp did come from this pool CYG_TEST_CHECK( E_NOEXS == ercd, "rel_blk bad ercd !E_NOEXS" ); ercd = pget_blk( &vp, 3, 100 ); CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" ); ercd = tget_blk( &vp, 3, 100, 10 ); CYG_TEST_CHECK( E_NOEXS == ercd, "tget_blk bad ercd !E_NOEXS" ); ercd = get_blk( &vp, 3, 100 ); CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" ); ercd = ref_mpl( &t_rmpl, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mpl bad ercd !E_NOEXS" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // now try creating it (badly) #ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR ercd = cre_mpl( 3, NULL ); CYG_TEST_CHECK( E_PAR == ercd, "cre_mpl bad ercd !E_PAR" ); #endif ercd = cre_mpl( 3, NADR ); CYG_TEST_CHECK( E_PAR == ercd, "cre_mpl bad ercd !E_PAR" ); t_cmpl.mplatr = 0xfff; ercd = cre_mpl( 3, &t_cmpl ); CYG_TEST_CHECK( E_RSATR == ercd, "cre_mpl bad ercd !E_RSATR" ); #endif // we can test bad param error returns t_cmpl.mplatr = 0; t_cmpl.mplsz = 100000000; ercd = cre_mpl( 3, &t_cmpl ); CYG_TEST_CHECK( E_NOMEM == ercd, "cre_mpl bad ercd" ); // now create it well t_cmpl.mplatr = 0; t_cmpl.mplsz = 1000; ercd = cre_mpl( 3, &t_cmpl ); CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" ); // and check we can use it ercd = pget_blk( &vp, 3, 100 ); CYG_TEST_CHECK( E_OK == ercd, "pget_blk bad ercd" ); ercd = pget_blk( &vp, 3, 100000000 ); // way too large CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" ); ercd = tget_blk( &vp, 3, 100, 10 ); CYG_TEST_CHECK( E_OK == ercd, "tget_blk bad ercd" ); ercd = get_blk( &vp, 3, 100 ); CYG_TEST_CHECK( E_OK == ercd, "get_blk bad ercd" ); ercd = rel_blk( 3, vp ); // vp did come from new pool CYG_TEST_CHECK( E_OK == ercd, "rel_blk bad ercd" ); ercd = rel_blk( 3, vp ); // vp already freed CYG_TEST_CHECK( E_PAR == ercd, "rel_blk bad ercd !E_PAR" ); ercd = ref_mpl( &t_rmpl, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_mpl bad ercd" ); // In order to wait on the pools, we must first consume all they have: while ( E_OK == (ercd = pget_blk( &vp, 1, 100 )) ) /* nothing */; CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" ); while ( E_OK == (ercd = tget_blk( &vp, 2, 100, 1 )) ) /* nothing */; CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk bad ercd !E_TMOUT" ); // now wait while task 2 deletes the wait objects ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = get_blk( &vp, 1, 200 ); CYG_TEST_CHECK( E_DLT == ercd, "get_blk bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = tget_blk( &vp, 2, 100, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "tget_blk bad ercd !E_DLT" ); // check they are deleted ercd = get_blk( &vp, 1, 200 ); CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" ); ercd = pget_blk( &vp, 2, 20 ); CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" ); // re-create and do it again ercd = cre_mpl( 1, &t_cmpl ); CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" ); ercd = cre_mpl( 2, &t_cmpl ); CYG_TEST_CHECK( E_OK == ercd, "cre_mpl bad ercd" ); // In order to wait on the pools, we must first consume all they have: while ( E_OK == (ercd = pget_blk( &vp, 1, 20 )) ) /* nothing */; CYG_TEST_CHECK( E_TMOUT == ercd, "pget_blk bad ercd !E_TMOUT" ); while ( E_OK == (ercd = tget_blk( &vp, 2, 400, 1 )) ) /* nothing */; CYG_TEST_CHECK( E_TMOUT == ercd, "tget_blk bad ercd !E_TMOUT" ); // now wait while task 2 deletes the wait objects ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = get_blk( &vp, 1, 200 ); CYG_TEST_CHECK( E_DLT == ercd, "get_blk bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = tget_blk( &vp, 2, 500, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "tget_blk bad ercd !E_DLT" ); // check they are deleted ercd = tget_blk( &vp, 1, 200, 1 ); CYG_TEST_CHECK( E_NOEXS == ercd, "get_blk bad ercd !E_NOEXS" ); ercd = get_blk( &vp, 2, 20 ); CYG_TEST_CHECK( E_NOEXS == ercd, "pget_blk bad ercd !E_NOEXS" ); CYG_TEST_PASS("create/delete variable mempools"); #endif // CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE ercd = ter_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" ); ercd = dly_tsk( 5 ); CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); // all done if ( 0 == tests ) { CYG_TEST_NA( "No objects have create/delete enabled" ); } else { CYG_TEST_EXIT( "All done" ); } ext_tsk(); }
void udp_echo_cli_task (intptr_t exinf) { static char msg[sizeof(MESSAGE_FORMAT)] = MESSAGE_FORMAT; T_IN_ADDR addr; ID tskid, cepid; ER error = E_OK; char *line, *p; int_t rep; uint32_t count, msgno; uint16_t portno; #ifdef USE_UDP_EXTENTIONS T_UDP_CCEP ccep; #endif /* of #ifdef USE_UDP_EXTENTIONS */ get_tid(&tskid); syslog(LOG_NOTICE, "[UDP ECHO CLI:%d,%d] started.", tskid, (ID)exinf); while (true) { if (rcv_dtq(DTQ_UDP_ECHO_CLI, (intptr_t*)&line) == E_OK) { #ifdef USE_UDP_EXTENTIONS ccep.cepatr = UINT_C(0); ccep.myaddr.portno = UDP_PORTANY; #if defined(SUPPORT_INET4) ccep.myaddr.ipaddr = IPV4_ADDRANY; #endif #if defined(SUPPORT_INET6) memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); #endif #ifdef USE_UDP_NON_BLOCKING ccep.callback = (FP)callback_nblk_udp_echo_cli; #else ccep.callback = NULL; #endif if ((error = alloc_udp_cep(&cepid, tskid, &ccep)) != E_OK) { syslog(LOG_NOTICE, "[UEC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error)); continue; } #else /* of #ifdef USE_UDP_EXTENTIONS */ cepid = (ID)exinf; #endif /* of #ifdef USE_UDP_EXTENTIONS */ line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line))); /* IP Address */ if ('0' <= *line && *line <= '9') { /* Port No */ line = get_int(&rep, line); portno = (uint16_t)rep; } else { line ++; portno = ECHO_SRV_PORTNO; } line = skip_blanks(line); if ('0' <= *line && *line <= '9') { /* Repeat */ line = get_int(&rep, line); if (rep > 1000000) rep = 1000000; udp_echo_cli_valid = true; for (count = 0; count ++ < rep; ) { if (!udp_echo_cli_valid) { syslog(LOG_NOTICE, "[UEC:%02d TSK] canceled.", cepid); break; } p = &msg[sizeof(MESSAGE_FORMAT)] - 1; for (msgno = count; msgno > 0; msgno /= 10) *(-- p) = msgno % 10 + '0'; while (*(p - 2) != 'G') *(-- p) = ' '; if ((error = send_udp_echo(cepid, &addr, portno, msg)) != E_OK) break; dly_tsk(10 * SYSTIM_HZ + net_rand() % (10 * SYSTIM_HZ)); } } else /* Single Message */ error = send_udp_echo(cepid, &addr, portno, line); if (error != E_OK) syslog(LOG_NOTICE, "[UEC:%02d TSK] error: %s", cepid, itron_strerror(error)); #ifdef USE_UDP_EXTENTIONS if ((error = free_udp_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK) syslog(LOG_NOTICE, "[UEC:%02d TSK] CEP delete error: %s", cepid, itron_strerror(error)); #endif /* of #ifdef USE_UDP_EXTENTIONS */ } } }
/** * @brief ミリ秒スリープ * * @param msec 待ち時間[msec] */ void hk_msleep(uint16_t msec) { (void)dly_tsk(msec); }
void task1( unsigned int arg ) { ER ercd; int i; T_RSYS rsys; CYG_TEST_INFO( "Task 1 running" ); // check initial state ercd = ref_sys( &rsys ); CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" ); CYG_TEST_CHECK( TSS_TSK == rsys.sysstat, "system state not TSS_TSK" ); // disable intrs and check state ercd = loc_cpu(); CYG_TEST_CHECK( E_OK == ercd, "loc_cpu bad ercd" ); ercd = ref_sys( &rsys ); CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" ); CYG_TEST_CHECK( TSS_LOC == rsys.sysstat, "system state not TSS_LOC" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // try an illegal op ercd = dly_tsk( 10 ); CYG_TEST_CHECK( E_CTX == ercd, "dly_tsk bad ercd !E_CTX" ); #endif // CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // enable intrs and check state and a legal sleep ercd = unl_cpu(); CYG_TEST_CHECK( E_OK == ercd, "unl_cpu bad ercd" ); ercd = ref_sys( &rsys ); CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" ); CYG_TEST_CHECK( TSS_TSK == rsys.sysstat, "system state not TSS_TSK" ); ercd = dly_tsk( 1 ); CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); // disable intrs and try scheduler illegal ops ercd = loc_cpu(); CYG_TEST_CHECK( E_OK == ercd, "loc_cpu bad ercd" ); ercd = ref_sys( &rsys ); CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" ); CYG_TEST_CHECK( TSS_LOC == rsys.sysstat, "system state not TSS_LOC" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = dis_dsp(); CYG_TEST_CHECK( E_CTX == ercd, "dis_dsp bad ercd !E_CTX" ); ercd = ena_dsp(); CYG_TEST_CHECK( E_CTX == ercd, "ena_dsp bad ercd !E_CTX" ); #endif // CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // enable again and check state ercd = unl_cpu(); CYG_TEST_CHECK( E_OK == ercd, "unl_cpu bad ercd" ); ercd = ref_sys( &rsys ); CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" ); CYG_TEST_CHECK( TSS_TSK == rsys.sysstat, "system state not TSS_TSK" ); // disable the scheduler and check state ercd = dis_dsp(); CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" ); ercd = ref_sys( &rsys ); CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" ); CYG_TEST_CHECK( TSS_DDSP == rsys.sysstat, "system state not TSS_DDSP" ); // disable intrs and check state ercd = loc_cpu(); CYG_TEST_CHECK( E_OK == ercd, "loc_cpu bad ercd" ); ercd = ref_sys( &rsys ); CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" ); CYG_TEST_CHECK( TSS_LOC == rsys.sysstat, "system state not TSS_LOC" ); // then unlock and check state ercd = unl_cpu(); CYG_TEST_CHECK( E_OK == ercd, "unl_cpu bad ercd" ); ercd = ref_sys( &rsys ); CYG_TEST_CHECK( E_OK == ercd, "ref_sys bad ercd" ); CYG_TEST_CHECK( TSS_TSK == rsys.sysstat, "system state not TSS_TSK" ); CYG_TEST_PASS( "Interrupt dis/enabling and interactions" ); // and now we can do the rest of the test #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = rel_wai( 2 ); CYG_TEST_CHECK( E_OBJ == ercd, "rel_wai bad ercd !E_OBJ" ); ercd = rel_wai( 1 ); CYG_TEST_CHECK( E_OBJ == ercd, "rel_wai(me) bad ercd !E_OBJ" ); ercd = rel_wai( -6 ); CYG_TEST_CHECK( E_ID == ercd, "rel_wai bad ercd !E_ID" ); ercd = rel_wai( 99 ); CYG_TEST_CHECK( E_ID == ercd, "rel_wai bad ercd !E_ID" ); #endif // we can test bad param error returns ercd = dis_dsp(); CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" ); ercd = sta_tsk( 2, 22222 ); CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" ); ercd = chg_pri( 2, 5 ); CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" ); ercd = ena_dsp(); CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = rel_wai( 2 ); CYG_TEST_CHECK( E_OBJ == ercd, "rel_wai bad ercd !E_OBJ" ); ercd = rel_wai( 1 ); CYG_TEST_CHECK( E_OBJ == ercd, "rel_wai(me) bad ercd !E_OBJ" ); #endif // we can test bad param error returns ercd = wai_sem( 1 ); CYG_TEST_CHECK( E_RLWAI == ercd, "wai_sem bad ercd !E_RLWAI" ); ercd = twai_sem( 1, 20 ); CYG_TEST_CHECK( E_RLWAI == ercd, "twai_sem bad ercd !E_RLWAI" ); ercd = wai_flg( &scratch, 1, 9999, 0 ); CYG_TEST_CHECK( E_RLWAI == ercd, "wai_flg bad ercd !E_RLWAI" ); ercd = twai_flg( &scratch, 1, 9999, 0, 10 ); CYG_TEST_CHECK( E_RLWAI == ercd, "twai_flg bad ercd !E_RLWAI" ); ercd = rcv_msg( &t_msg, 1 ); CYG_TEST_CHECK( E_RLWAI == ercd, "rcv_msg bad ercd !E_RLWAI" ); ercd = trcv_msg( &t_msg, 1, 10 ); CYG_TEST_CHECK( E_RLWAI == ercd, "trcv_msg bad ercd !E_RLWAI" ); // these are loops so as to consume the whole of the mempool // in order to wait at the end for ( i = 0; i < 10; i++ ) if ( E_OK != (ercd = get_blf( &vp, 3 ) ) ) break; CYG_TEST_CHECK( E_RLWAI == ercd, "get_blf bad ercd !E_RLWAI" ); for ( i = 0; i < 10; i++ ) if ( E_OK != (ercd = tget_blf( &vp, 3, 10 ) ) ) break; CYG_TEST_CHECK( E_RLWAI == ercd, "tget_blf bad ercd !E_RLWAI" ); for ( i = 0; i < 10; i++ ) if ( E_OK != (ercd = get_blk( &vp, 1, 1000 ) ) ) break; CYG_TEST_CHECK( E_RLWAI == ercd, "get_blk bad ercd !E_RLWAI" ); for ( i = 0; i < 10; i++ ) if ( E_OK != (ercd = tget_blk( &vp, 1, 1000, 10 ) ) ) break; CYG_TEST_CHECK( E_RLWAI == ercd, "tget_blk bad ercd !E_RLWAI" ); ercd = dly_tsk( 10 ); CYG_TEST_CHECK( E_RLWAI == ercd, "dly_tsk bad ercd !E_RLWAI" ); ercd = tslp_tsk( 10 ); CYG_TEST_CHECK( E_RLWAI == ercd, "tslp_tsk bad ercd !E_RLWAI" ); ercd = slp_tsk(); CYG_TEST_CHECK( E_RLWAI == ercd, "slp_tsk bad ercd !E_RLWAI" ); ercd = ter_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" ); ercd = dly_tsk( 10 ); CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); CYG_TEST_PASS("release wait: various waiting calls"); // all done CYG_TEST_EXIT( "All done" ); ext_tsk(); }
void task4(intptr_t exinf) { ER_UINT ercd; ID somid; check_point(17); ercd = get_som(&somid); check_ercd(ercd, E_OK); check_assert(somid == TSOM_STP); ercd = stp_cyc(CYC1); check_ercd(ercd, E_OK); ercd = dly_tsk(TEST_TIME_PROC); check_ercd(ercd, E_OK); check_point(18); ercd = chg_som(SOM1); check_ercd(ercd, E_OK); check_point(22); ercd = get_som(&somid); check_ercd(ercd, E_OK); check_assert(somid == TSOM_STP); ercd = stp_cyc(CYC1); check_ercd(ercd, E_OK); ercd = chg_pri(TSK_SELF, HIGH_PRIORITY); check_ercd(ercd, E_OK); check_point(23); ercd = chg_som(SOM1); check_ercd(ercd, E_OK); check_point(24); ercd = sta_cyc(CYC1); check_ercd(ercd, E_OK); ercd = get_som(&somid); check_ercd(ercd, E_OK); check_assert(somid == SOM1); ercd = chg_pri(TSK_SELF, LOW_PRIORITY); check_ercd(ercd, E_OK); check_point(28); ercd = get_som(&somid); check_ercd(ercd, E_OK); check_assert(somid == TSOM_STP); ercd = stp_cyc(CYC1); check_ercd(ercd, E_OK); ercd = dis_dsp(); check_ercd(ercd, E_OK); check_point(29); ercd = chg_som(SOM1); check_ercd(ercd, E_OK); ercd = sta_cyc(CYC1); check_ercd(ercd, E_OK); ercd = get_som(&somid); check_ercd(ercd, E_OK); check_assert(check_somid(somid)); ercd = ena_dsp(); check_ercd(ercd, E_OK); check_point(0); }
void task1( unsigned int arg ) { ER ercd; int tests = 0; CYG_TEST_INFO( "Task 1 running" ); ercd = dis_dsp(); CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" ); ercd = sta_tsk( 2, 22222 ); CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" ); ercd = chg_pri( 2, 5 ); CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" ); ercd = ena_dsp(); CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" ); ercd = dly_tsk( 10 ); CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); #ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE tests++; #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = del_sem( -6 ); CYG_TEST_CHECK( E_ID == ercd, "del_sem bad ercd !E_ID" ); ercd = del_sem( 99 ); CYG_TEST_CHECK( E_ID == ercd, "del_sem bad ercd !E_ID" ); ercd = cre_sem( -6, &t_csem ); CYG_TEST_CHECK( E_ID == ercd, "cre_sem bad ercd !E_ID" ); ercd = cre_sem( 99, &t_csem ); CYG_TEST_CHECK( E_ID == ercd, "cre_sem bad ercd !E_ID" ); #endif // we can test bad param error returns // try a pre-existing object ercd = cre_sem( 3, &t_csem ); CYG_TEST_CHECK( E_OBJ == ercd, "cre_sem bad ercd !E_OBJ" ); // delete it so we can play ercd = del_sem( 3 ); CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" ); // check it is deleted ercd = sig_sem( 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" ); ercd = preq_sem( 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "preq_sem bad ercd !E_NOEXS" ); ercd = twai_sem( 3, 10 ); CYG_TEST_CHECK( E_NOEXS == ercd, "twai_sem bad ercd !E_NOEXS" ); ercd = wai_sem( 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "wai_sem bad ercd !E_NOEXS" ); ercd = ref_sem( &t_rsem, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "ref_sem bad ercd !E_NOEXS" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // now try creating it (badly) #ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR ercd = cre_sem( 3, NULL ); CYG_TEST_CHECK( E_PAR == ercd, "cre_sem bad ercd !E_PAR" ); #endif ercd = cre_sem( 3, NADR ); CYG_TEST_CHECK( E_PAR == ercd, "cre_sem bad ercd !E_PAR" ); t_csem.sematr = 0xfff; ercd = cre_sem( 3, &t_csem ); CYG_TEST_CHECK( E_RSATR == ercd, "cre_sem bad ercd !E_RSATR" ); t_csem.sematr = 0; #endif // we can test bad param error returns ercd = cre_sem( 3, &t_csem ); CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); // and check we can use it ercd = sig_sem( 3 ); CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" ); ercd = wai_sem( 3 ); CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" ); ercd = preq_sem( 3 ); CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" ); ercd = twai_sem( 3, 2 ); CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem bad ercd !E_TMOUT" ); ercd = ref_sem( &t_rsem, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" ); // now wait while task 2 deletes the wait objects ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = wai_sem( 1 ); CYG_TEST_CHECK( E_DLT == ercd, "wai_sem bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = twai_sem( 2, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_sem bad ercd !E_DLT" ); // check they are deleted ercd = sig_sem( 1 ); CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" ); ercd = sig_sem( 2 ); CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" ); // re-create and do it again ercd = cre_sem( 1, &t_csem ); CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); ercd = cre_sem( 2, &t_csem ); CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" ); // now wait while task 2 deletes the wait objects again ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = wai_sem( 1 ); CYG_TEST_CHECK( E_DLT == ercd, "wai_sem bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = twai_sem( 2, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_sem bad ercd !E_DLT" ); // check they are deleted ercd = sig_sem( 1 ); CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" ); ercd = sig_sem( 2 ); CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" ); CYG_TEST_PASS("create/delete semaphores"); #endif // CYGPKG_UITRON_SEMAS_CREATE_DELETE #ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE tests++; #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = del_flg( -6 ); CYG_TEST_CHECK( E_ID == ercd, "del_flg bad ercd !E_ID" ); ercd = del_flg( 99 ); CYG_TEST_CHECK( E_ID == ercd, "del_flg bad ercd !E_ID" ); ercd = cre_flg( -6, &t_cflg ); CYG_TEST_CHECK( E_ID == ercd, "cre_flg bad ercd !E_ID" ); ercd = cre_flg( 99, &t_cflg ); CYG_TEST_CHECK( E_ID == ercd, "cre_flg bad ercd !E_ID" ); #endif // we can test bad param error returns // try a pre-existing object ercd = cre_flg( 3, &t_cflg ); CYG_TEST_CHECK( E_OBJ == ercd, "cre_flg bad ercd !E_OBJ" ); // delete it so we can play ercd = del_flg( 3 ); CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" ); // check it is deleted ercd = set_flg( 3, 0x6789 ); CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" ); ercd = clr_flg( 3, 0x9876 ); CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" ); ercd = pol_flg( &scratch, 3, 0xdddd, TWF_ANDW ); CYG_TEST_CHECK( E_NOEXS == ercd, "pol_flg bad ercd !E_NOEXS" ); ercd = twai_flg( &scratch, 3, 0x4444, TWF_ORW, 10 ); CYG_TEST_CHECK( E_NOEXS == ercd, "twai_flg bad ercd !E_NOEXS" ); ercd = wai_flg( &scratch, 3, 0xbbbb, TWF_ANDW | TWF_CLR ); CYG_TEST_CHECK( E_NOEXS == ercd, "wai_flg bad ercd !E_NOEXS" ); ercd = ref_flg( &t_rflg, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "ref_flg bad ercd !E_NOEXS" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // now try creating it (badly) #ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR ercd = cre_flg( 3, NULL ); CYG_TEST_CHECK( E_PAR == ercd, "cre_flg bad ercd !E_PAR" ); #endif ercd = cre_flg( 3, NADR ); CYG_TEST_CHECK( E_PAR == ercd, "cre_flg bad ercd !E_PAR" ); t_cflg.flgatr = 0xfff; ercd = cre_flg( 3, &t_cflg ); CYG_TEST_CHECK( E_RSATR == ercd, "cre_flg bad ercd !E_RSATR" ); #endif // we can test bad param error returns // now create it well t_cflg.flgatr = 0; t_cflg.iflgptn = 0; ercd = cre_flg( 3, &t_cflg ); CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" ); // and check we can use it ercd = clr_flg( 3, 0x7256 ); CYG_TEST_CHECK( E_OK == ercd, "clr_flg bad ercd" ); ercd = set_flg( 3, 0xff ); CYG_TEST_CHECK( E_OK == ercd, "set_flg bad ercd" ); ercd = wai_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR ); CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" ); ercd = pol_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR ); CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" ); ercd = twai_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR, 2 ); CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg bad ercd !E_TMOUT" ); ercd = ref_flg( &t_rflg, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" ); CYG_TEST_CHECK( 0 == t_rflg.flgptn, "ref_flg bad ercd" ); // now create it again with a preset pattern and check that we can // detect that pattern: ercd = del_flg( 3 ); CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" ); t_cflg.flgatr = 0; t_cflg.iflgptn = 0x1234; ercd = cre_flg( 3, &t_cflg ); CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" ); // and check we can use it ercd = wai_flg( &scratch, 3, 0x1200, TWF_ANDW ); CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" ); ercd = pol_flg( &scratch, 3, 0x0034, TWF_ANDW ); CYG_TEST_CHECK( E_OK == ercd, "pol_flg bad ercd" ); ercd = twai_flg( &scratch, 3, 0x1004, TWF_ANDW, 10 ); CYG_TEST_CHECK( E_OK == ercd, "twai_flg bad ercd" ); ercd = pol_flg( &scratch, 3, 0xffedcb, TWF_ORW ); CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" ); ercd = ref_flg( &t_rflg, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" ); CYG_TEST_CHECK( 0x1234 == t_rflg.flgptn, "ref_flg bad ercd" ); ercd = clr_flg( 3, 0 ); ercd = ref_flg( &t_rflg, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" ); CYG_TEST_CHECK( 0 == t_rflg.flgptn, "ref_flg bad ercd" ); // now wait while task 2 deletes the wait objects ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = wai_flg( &scratch, 1, 0xaa, TWF_ANDW ); CYG_TEST_CHECK( E_DLT == ercd, "wai_flg bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = twai_flg( &scratch, 2, 0x55, TWF_ANDW, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_flg bad ercd !E_DLT" ); // check they are deleted ercd = set_flg( 1, 0x22 ); CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" ); ercd = clr_flg( 2, 0xdd ); CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" ); // re-create and do it again t_cflg.iflgptn = 0x5555; ercd = cre_flg( 1, &t_cflg ); CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" ); t_cflg.iflgptn = 0; ercd = cre_flg( 2, &t_cflg ); CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" ); // now wait while task 2 deletes the wait objects again ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = wai_flg( &scratch, 1, 0xaaaa, TWF_ORW | TWF_CLR ); CYG_TEST_CHECK( E_DLT == ercd, "wai_flg bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = twai_flg( &scratch, 2, 0xffff, TWF_ORW, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_flg bad ercd !E_DLT" ); // check they are deleted ercd = clr_flg( 1, 0xd00d ); CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" ); ercd = set_flg( 2, 0xfff00 ); CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" ); CYG_TEST_PASS("create/delete flags"); #endif // CYGPKG_UITRON_FLAGS_CREATE_DELETE #ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE tests++; #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS ercd = del_mbx( -6 ); CYG_TEST_CHECK( E_ID == ercd, "del_mbx bad ercd !E_ID" ); ercd = del_mbx( 99 ); CYG_TEST_CHECK( E_ID == ercd, "del_mbx bad ercd !E_ID" ); ercd = cre_mbx( -6, &t_cmbx ); CYG_TEST_CHECK( E_ID == ercd, "cre_mbx bad ercd !E_ID" ); ercd = cre_mbx( 99, &t_cmbx ); CYG_TEST_CHECK( E_ID == ercd, "cre_mbx bad ercd !E_ID" ); #endif // we can test bad param error returns // try a pre-existing object ercd = cre_mbx( 3, &t_cmbx ); CYG_TEST_CHECK( E_OBJ == ercd, "cre_mbx bad ercd !E_OBJ" ); // delete it so we can play ercd = del_mbx( 3 ); CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" ); // check it is deleted ercd = snd_msg( 3, t_msg ); CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" ); ercd = rcv_msg( &msg, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "rcv_msg bad ercd !E_NOEXS" ); ercd = trcv_msg( &msg, 3, 10 ); CYG_TEST_CHECK( E_NOEXS == ercd, "trcv_msg bad ercd !E_NOEXS" ); ercd = prcv_msg( &msg, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "prcv_msg bad ercd !E_NOEXS" ); ercd = ref_mbx( &t_rmbx, 3 ); CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mbx bad ercd !E_NOEXS" ); #ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS // now try creating it (badly) #ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR ercd = cre_mbx( 3, NULL ); CYG_TEST_CHECK( E_PAR == ercd, "cre_mbx bad ercd !E_PAR" ); #endif ercd = cre_mbx( 3, NADR ); CYG_TEST_CHECK( E_PAR == ercd, "cre_mbx bad ercd !E_PAR" ); t_cmbx.mbxatr = 0xfff; ercd = cre_mbx( 3, &t_cmbx ); CYG_TEST_CHECK( E_RSATR == ercd, "cre_mbx bad ercd !E_RSATR" ); t_cmbx.mbxatr = 0; #endif // we can test bad param error returns ercd = cre_mbx( 3, &t_cmbx ); CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" ); // and check we can use it ercd = snd_msg( 3, t_msg ); CYG_TEST_CHECK( E_OK == ercd, "snd_msg bad ercd" ); ercd = rcv_msg( &msg, 3 ); CYG_TEST_CHECK( E_OK == ercd, "rcv_msg bad ercd" ); ercd = trcv_msg( &msg, 3, 2 ); CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg bad ercd !E_TMOUT" ); ercd = prcv_msg( &msg, 3 ); CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" ); ercd = ref_mbx( &t_rmbx, 3 ); CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" ); // now wait while task 2 deletes the wait objects ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = rcv_msg( &msg, 1 ); CYG_TEST_CHECK( E_DLT == ercd, "wai_mbx bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = trcv_msg( &msg, 2, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_mbx bad ercd !E_DLT" ); // check they are deleted ercd = snd_msg( 1, t_msg ); CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" ); ercd = snd_msg( 2, t_msg ); CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" ); // re-create and do it again ercd = cre_mbx( 1, &t_cmbx ); CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" ); ercd = cre_mbx( 2, &t_cmbx ); CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" ); // now wait while task 2 deletes the wait objects again ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = rcv_msg( &msg, 1 ); CYG_TEST_CHECK( E_DLT == ercd, "wai_mbx bad ercd !E_DLT" ); ercd = wup_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" ); ercd = trcv_msg( &msg, 2, 20 ); CYG_TEST_CHECK( E_DLT == ercd, "twai_mbx bad ercd !E_DLT" ); // check they are deleted ercd = snd_msg( 1, t_msg ); CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" ); ercd = snd_msg( 2, t_msg ); CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" ); CYG_TEST_PASS("create/delete mboxes"); #endif // CYGPKG_UITRON_MBOXES_CREATE_DELETE ercd = ter_tsk( 2 ); CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" ); ercd = dly_tsk( 5 ); CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" ); // all done if ( 0 == tests ) { CYG_TEST_NA( "No objects have create/delete enabled" ); } else { CYG_TEST_EXIT( "All done" ); } ext_tsk(); }
/* Delay for the specified number of milliSeconds */ void osDelay(uint32_t ms) { // uint32_t to = ms + systick_timems; // while (to > systick_timems); dly_tsk(ms); }