#include #include #include #include #include #include int main(int argc, char *argv[]) { int flag = ( O_RDWR | O_NOCTTY | O_NDELAY ); int handle = -1; char* port = "/dev/ttyS0"; printf("Attempting to open port \"%s\"\n", port); if( (handle = open(port, flag)) == -1) { /* An error has occured in opening the port, log an error report */ printf("ERROR: An error has occured during opening of comport.\n"); printf(" Error number = [%d] => description: %s", errno, strerror(errno)); exit(EXIT_FAILURE); return 0; } printf("Success occured during opening of comport.\n"); close(handle); exit(EXIT_SUCCESS); return 1; }