/* * Application entry point. */ int main(void) { Thread *shelltp = NULL; /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD1, NULL); /* * Shell manager initialization. */ shellInit(); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity. */ while (TRUE) { if (!shelltp) shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO); else if (chThdTerminated(shelltp)) { chThdRelease(shelltp); /* Recovers memory of the previous shell. */ shelltp = NULL; /* Triggers spawning of a new shell. */ } #if 0 if (SIU.GPDI[GPIO_BUTTON1].B.PDI) { volatile msg_t result; #if 0 MemoryStream report; msObjectInit(&report, report_buffer, sizeof(report_buffer), 0); result = TestThread(&report); #else result = TestThread(&SD1); #endif } #endif chThdSleepMilliseconds(1000); } return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD1, NULL); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity. */ while (TRUE) { chThdSleepMilliseconds(500); if (!palReadPad(IOPORT2, PIOB_SW1)) sdWrite(&SD1, (uint8_t *)"Hello World!\r\n", 14); if (!palReadPad(IOPORT2, PIOB_SW2)) TestThread(&SD1); } return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. */ palClearPad(IOPORT2, PORTB_LED1); sdStart(&SD1, NULL); /* * Starts the LED blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); TestThread(&SD1); while(TRUE) { chThdSleepMilliseconds(1000); } }
static void *PosixTestThread( void *pData ) { (void)pData; TestThread(); return NULL; }
static DWORD WINAPI WinTestThread( LPVOID lpParameter ) { TestThread(); return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 2 using the driver default configuration. */ sdStart(&SD2, NULL); /* * Starts the LED blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); while(TRUE) { if (!palReadPad(IOPORT5, PORTE_BUTTON)) TestThread(&SD2); chThdSleepMilliseconds(500); } return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 2 using the driver default configuration. */ sdStart(&SD2, NULL); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state. */ while (TRUE) { if (palReadPad(GPIOA, GPIOA_BUTTON)) TestThread(&SD2); chThdSleepMilliseconds(500); } }
/* * Application entry point. */ void main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. * The STM8L-Discovery requires USART1 pins remapping on PA2 and PA3. */ SYSCFG->RMPCR1 = 0x1C; sdStart(&SD1, NULL); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity. */ while (TRUE) { if (palReadPad(GPIOC, PC_BUTTON) == PAL_LOW) TestThread(&SD1); chThdSleepMilliseconds(1000); } }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 2 using the driver default configuration. * PA2(TX) and PA3(RX) are routed to USART2. */ sdStart(&SD2, NULL); palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7)); palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7)); /* * Creates the example thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity, in this demo it just performs * a shell respawn upon its termination. */ while (TRUE) { if (palReadPad(GPIOA, GPIOA_BUTTON)) TestThread(&SD2); chThdSleepMilliseconds(500); } }
void OpenHome::TestFramework::Runner::Main(TInt /*aArgc*/, TChar* /*aArgv*/[], Net::InitialisationParams* aInitParams) { Net::UpnpLibrary::InitialiseMinimal(aInitParams); TestThread(); delete aInitParams; Net::UpnpLibrary::Close(); }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates serial 1 (UART0) using the driver default configuration. */ sdStart(&SD1, NULL); /* * Creates the blinker threads. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL); chThdCreateStatic(waThread3, sizeof(waThread3), NORMALPRIO, Thread3, NULL); TestThread(&SD1); while (1) { chThdSleepMilliseconds(500); } }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD1, NULL); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity, in this demo it does nothing except * checking a button and run a test suite if button was pressed. */ while (TRUE) { if (!palReadPad(IOPORT6, P6_I_BUTTON)) TestThread(&SD1); chThdSleepMilliseconds(500); } return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the SD1 and SPI1 drivers. */ sdStart(&SD4, NULL); /* Default: 38400,8,N,1. */ /* * Creates the blinker threads. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity. */ while (TRUE) { if (!palReadPad(GPIO3, GPIO3_SW_USER1)) { TestThread(&SD4); } chThdSleepMilliseconds(100); } }
/* * Application entry point. */ void main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD1, NULL); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity. */ while (TRUE) { if (palReadPad(IOPORT7, PG_BT5) == PAL_LOW) TestThread(&SD1); if (palReadPad(IOPORT7, PG_BT6) == PAL_LOW) sdWriteTimeout(&SD1, "Hello World!\r\n", 14, TIME_INFINITE); chThdSleepMilliseconds(1000); } }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. * PA9(TX) and PA10(RX) are routed to USART1. */ sdStart(&SD1, NULL); /* * Creates the example threads. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO+1, Thread1, NULL); chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO+1, Thread2, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state, when the button is * pressed the test procedure is launched. */ while (TRUE) { if (palReadPad(GPIOA, GPIOA_BUTTON)) TestThread(&SD1); chThdSleepMilliseconds(500); } }
/* * Entry point, note, the main() function is already a thread in the system * on entry. */ int main(int argc, char **argv) { (void)argc; (void)argv; /* * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD1, NULL); /* * Creates the blinker threads. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state. */ while (TRUE) { if (!palReadPad(GPIO0, GPIO0_SW3)) TestThread(&SD1); chThdSleepMilliseconds(500); } return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); sdStart(&SD2, NULL); /* * Leds initialization. */ led_init(); buttons_init(); chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); while (TRUE) { if ((P3_bit.no1 == 0) || (P7_bit.no6 == 0)) TestThread(&SD2); chThdSleepMilliseconds(100); } return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 6 using the driver default configuration. */ sdStart(&SD6, NULL); palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(8)); palSetPadMode(GPIOC, 7, PAL_MODE_ALTERNATE(8)); /* * Set Pad Mode to PUSHPULL on D0 */ palSetPadMode(GPIOD, GPIOD_PIN0, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOD, GPIOD_PIN0); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Creates the LWIP threads (it changes priority internally). */ chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMALPRIO + 1, lwip_thread, NULL); /* * Creates the HTTP thread (it changes priority internally). */ chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1, http_server, NULL); /* * Creates the MQTT Client thread (it changes priority internally). */ chThdCreateStatic(wa_mqtt_client, sizeof(wa_mqtt_client), NORMALPRIO + 1, mqtt_client, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state. */ while (TRUE) { if (palReadPad(GPIOA, GPIOA_BUTTON)) TestThread(&SD6); chThdSleepMilliseconds(500); } }
static void cmd_test(BaseChannel *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) { chprintf(chp, "Usage: test\r\n"); return; } TestThread(chp); }
/* * Application entry point. */ int main(void) { led_config_t ledRed, ledGreen, ledBlue; /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* Configure RX and TX pins for UART0.*/ palSetPadMode(GPIOA, GPIOA_UART0_RX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1)); palSetPadMode(GPIOA, GPIOA_UART0_TX, PAL_MODE_INPUT | PAL_MODE_ALTERNATE(1)); /* Start the serial driver with the default configuration.*/ sdStart(&SD1, NULL); if (!palReadPad(GPIOF, GPIOF_SW2)) { TestThread(&SD1); } ledRed.port = GPIOF; ledRed.pin = GPIOF_LED_RED; ledRed.sleep = 100; ledGreen.port = GPIOF; ledGreen.pin = GPIOF_LED_GREEN; ledGreen.sleep = 101; ledBlue.port = GPIOF; ledBlue.pin = GPIOF_LED_BLUE; ledBlue.sleep = 102; /* Creating the blinker threads.*/ chThdCreateStatic(waBlinkLedRed, sizeof(waBlinkLedRed), NORMALPRIO, blinkLed, &ledRed); chThdCreateStatic(waBlinkLedGreen, sizeof(waBlinkLedGreen), NORMALPRIO, blinkLed, &ledGreen); chThdCreateStatic(waBlinkLedBlue, sizeof(waBlinkLedBlue), NORMALPRIO, blinkLed, &ledBlue); /* Normal main() thread activity.*/ while (TRUE) { chThdSleepMilliseconds(100); } return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD3, NULL); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Creates the LWIP threads (it changes priority internally). */ chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, HIGHPRIO + 1, lwip_thread, NULL); /* * Creates the UDP echo thread (it changes priority internally). */ chThdCreateStatic(wa_udp_echo_server, sizeof(wa_udp_echo_server), NORMALPRIO + 1, udp_echo_server, NULL); /* * Creates the TCP echo thread (it changes priority internally). */ chThdCreateStatic(wa_tcp_echo_server, sizeof(wa_tcp_echo_server), NORMALPRIO + 1, tcp_echo_server, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state. */ while (TRUE) { if (palReadPad(GPIOA, GPIOA_BUTTON) == 1) TestThread(&SD3); chThdSleepMilliseconds(500); } }
/* * Application entry point. */ int main(void) { uint8_t i; /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the SD1 and SPI1 drivers. */ sdStart(&SD1, NULL); /* Default: 38400,8,N,1. */ spiStart(&SPID1, &spicfg); /* * Creates the blinker threads. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL); /* * Normal main() thread activity, in this demo it updates the 7-segments * display on the LPCXpresso main board using the SPI driver. */ i = 0; while (TRUE) { if (!palReadPad(GPIO0, GPIO0_SW3)) TestThread(&SD1); spiSelect(&SPID1); spiSend(&SPID1, 1, &digits[i]); /* Non polled method. */ spiUnselect(&SPID1); chThdSleepMilliseconds(500); spiSelect(&SPID1); spiPolledExchange(&SPID1, digits[i | 0x10]); /* Polled method. */ spiUnselect(&SPID1); chThdSleepMilliseconds(500); i = (i + 1) & 15; } }
static void runChibioTest(void) { print("EFI_SHAFT_POSITION_INPUT=%d\r\n", EFI_SHAFT_POSITION_INPUT); print("EFI_EMULATE_POSITION_SENSORS=%d\r\n", EFI_EMULATE_POSITION_SENSORS); print("EFI_ANALOG_SENSORS=%d\r\n", EFI_ANALOG_SENSORS); print("EFI_INTERNAL_ADC=%d\r\n", EFI_INTERNAL_ADC); print("EFI_HD44780_LCD=%d\r\n", EFI_HD44780_LCD); print("EFI_MAP_AVERAGING=%d\r\n", EFI_MAP_AVERAGING); print("EFI_WAVE_ANALYZER=%d\r\n", EFI_WAVE_ANALYZER); print("EFI_ENGINE_SNIFFER=%d\r\n", EFI_ENGINE_SNIFFER); print("EFI_SENSOR_CHART=%d\r\n", EFI_SENSOR_CHART); print("EFI_SHAFT_POSITION_INPUT=%d\r\n", EFI_SHAFT_POSITION_INPUT); print("EFI_ENGINE_CONTROL=%d\r\n", EFI_ENGINE_CONTROL); print("CH_DBG_SYSTEM_STATE_CHECK=%d\r\n", CH_DBG_SYSTEM_STATE_CHECK); print("CH_DBG_ENABLE_CHECKS=%d\r\n", CH_DBG_ENABLE_CHECKS); print("CH_DBG_ENABLE_ASSERTS=%d\r\n", CH_DBG_ENABLE_ASSERTS); print("CH_DBG_ENABLE_STACK_CHECK=%d\r\n", CH_DBG_ENABLE_STACK_CHECK); print("CH_DBG_THREADS_PROFILING=%d\r\n", CH_DBG_THREADS_PROFILING); TestThread(getConsoleChannel()); }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. * - uGFX Initialization */ halInit(); chSysInit(); //gfxInit(); /* * Activates the serial driver 1 using the driver default configuration. * PA9 and PA10 are routed to USART1. */ sdStart(&SD1, NULL); palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(1)); /* USART1 TX. */ palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(1)); /* USART1 RX. */ /* Motor Thread */ WORKING_AREA(waMotorThread, 128); chThdCreateStatic(waMotorThread, sizeof(waMotorThread), NORMALPRIO, motorThread, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state, when the button is * pressed the test procedure is launched with output on the serial * driver 1. */ while (TRUE) { if (palReadPad(GPIOA, GPIOA_BUTTON)) TestThread(&SD1); chThdSleepMilliseconds(500); } }
/* * Simulator main. */ int main(int argc, char *argv[]) { (void)argc; (void)argv; /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); conInit(); chSysInit(); TestThread(&CD1); if (test_global_fail) exit(1); else exit(0); }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 2 using the driver default configuration. */ sdStart(&SD1, NULL); /* * The main() function becomes a thread here then the interrupts are * enabled and ChibiOS/RT goes live. */ chSysInit(); /* * Creates the blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop. */ while (TRUE) { if (!palReadPad(IOPORT6, P6_I_BUTTON)) TestThread(&SD1); chThdSleepMilliseconds(500); } return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * GPIOI1 is programmed as output (board LED). */ palClearLine(LINE_ARD_D13); palSetLineMode(LINE_ARD_D13, PAL_MODE_OUTPUT_PUSHPULL); /* * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD1, NULL); /* * Creates the example thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the button state. */ while (true) { if (palReadPad(GPIOI, GPIOI_BUTTON_USER)) TestThread(&SD1); chThdSleepMilliseconds(500); } }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 2 using the driver default configuration. */ sdStart(&SD2, NULL); /* * This initialization requires the OS already active because it uses delay * APIs inside. */ lcdInit(); lcdCmd(LCD_CLEAR); lcdPuts(LCD_LINE1, " ChibiOS/RT "); lcdPuts(LCD_LINE2, " Hello World! "); /* * Starts the LED blinker thread. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); while(TRUE) { if (!palReadPad(IOPORT1, PORTA_BUTTON1)) TestThread(&SD2); chThdSleepMilliseconds(500); } }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Activates the serial driver 1 using the driver default configuration. */ sdStart(&SD1, NULL); /* * Creating blinkers threads. */ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL); /* * Normal main() thread activity, in this demo it does nothing except * sleeping in a loop and check the buttons state and run test procedure. */ while (TRUE) { if (!palReadPad(IOPORT1, PA_BUTTON1)) sdWrite(&SD1, (uint8_t *)"Hello World!\r\n", 14); if (!palReadPad(IOPORT1, PA_BUTTON2)) TestThread(&SD1); chThdSleepMilliseconds(500); } return 0; }
// 扫描开始主函数 void portscannow(int xp) { int sport; char *timenow, timebuf[32]; // 定义默认扫描的端口 char *ports[32] = { "21", "22", "23", "25", "53", "79", "80", "110", "111", "113", "123", "135", "139", "143", "443", "512", "513", "514", "515", "540", "1080", "1433", "1521", "1524", "3306", "3389", "5631", "6000", "6112", "8000", "8080", "12345" //这里你也可以自己定义要扫描的端口 }; // 显示扫描开始的时间 timenow = _strtime(timebuf); printf("\r\nPortScan Start Time: %s\r\n\n", timenow); // 计数器初始化. maxth = 0; scanok = 0; scannum = 0; searched = 0; // 计算要扫描的端口数量 searchnum = hoststop - hoststart + 1; if (xp == 3) searchnum = searchnum * 32; if (xp == 4) searchnum = searchnum * (endport - startport + 1); // 端口扫描开始 for (portip = hoststart; portip <= hoststop; portip++, scannum++) { // *.*.*.0和*.*.*.255 地址处理 if ((portip % 256) == 0 || (portip % 256) == 255) { if (xp == 3) searchnum = searchnum - 32; if (xp == 4) searchnum = searchnum - (endport - startport + 1); scannum--; playx(); continue; } if (i > 11) i = 0; // 默认端口扫描 // scan 192.168.0.1 // scan 192.168.0.1-192.168.0.254 if (xp == 3) { for (sport = 0; sport < 32; sport++, maxth++, searched++) { // 测试当前线程是否大于180 TestThread(180); // 产生新的线程处理端口扫描 CWinThread * pthread = AfxBeginThread(portscan, LPVOID(atoi((char*)ports[sport]))); //延时 Sleep(120); } } // 自定义端口扫描 // scan -p 21 192.168.0.1 // scan -p 21-80 192.168.0.1-192.168.0.254 if (xp == 4) { // 计算要扫描的端口 sport = endport - startport; if (sport > 500) { // 扫描自定义的端口 for (sport = startport; sport <= endport; sport++, maxth++, searched++) { TestThread(2000); // 产生新的线程处理端口扫描 CWinThread * pthread = AfxBeginThread(portscan, LPVOID(sport)); // 延时 Sleep(10); } } else { // 扫描自定义的端口 for (sport = startport; sport <= endport; sport++, maxth++, searched++) { // 测试当前线程是否大于250 TestThread(250); // 产生新的线程处理端口扫描 CWinThread * pthread = AfxBeginThread(portscan, LPVOID(sport)); // 延时 Sleep(100); playx(); } } } } // 等待所有的线程结束 WaitThreadEnd(); // 显示端口扫描结束时间 timenow = _strtime(timebuf); printf("\r\nPortScan End Time: %s", timenow); printf("\r\nScan %d Hosts completed. Open %d Ports!\r\n", scannum, scanok); }