int main(int argc, char* argv[]) { if (argc < 2) { puts("COM port argument missing."); return 1; } if (os_initialize() < 0) { puts("Failed to initialize serial base"); return 2; } myChannel = io_openSerialPort(argv[1], 115200, NULL); if (! myChannel) { printf("Failed to open port %s\n", argv[1]); goto done; } os_waitForKeyboardInterrupt(); done: if (myChannel) { io_closePort(myChannel); } os_cleanup(); return 0; }
/* * Application and OS initialization. * Should be called prior to running the application. */ BOOL_t appInit() { BOOL_t ok = FALSE; ok = os_initialize(); if( ok == TRUE ) { isInitialized = TRUE; } return ok; }
int main(int argc, char* argv[]) { int status = -1; if (argc < 2) { puts("COM port argument missing."); return 1; } if (os_initialize() < 0) { puts("Failed to initialize serial base"); return 2; } io_setDebugLevel(5); myChannel = io_openSerialPort(argv[1], 115200, NULL); if (! myChannel) { printf("Failed to open port %s\n", argv[1]); goto done; } io_sendData(myChannel, HELLO, sizeof(HELLO) - 1); os_waitForKeyboardInterrupt(); status = 0; done: if (myChannel) { io_closePort(myChannel); } os_cleanup(); return status; }