--- arduino-serial.c.orig 2006-12-07 08:49:06.000000000 -0800 +++ arduino-serial.c 2006-12-08 12:47:13.000000000 -0800 @@ -29,6 +29,7 @@ int serialport_init(const char* serialport, int baud); int serialport_write(int fd, const char* str); int serialport_read_until(int fd, char* buf, char until); +void usage(void); void usage() { printf("Usage: arduino-serial -p [OPTIONS]\n" @@ -51,6 +52,11 @@ int baudrate = B9600; // default char buf[256]; + if (argc==1) { + usage(); + exit(EXIT_SUCCESS); + } + /* parse options */ int option_index = 0, opt; static struct option loptions[] = { @@ -88,12 +94,9 @@ break; } } - if (argc==1) { - usage(); - return 0; - } - -} + + exit(EXIT_SUCCESS); +} // End main int serialport_write(int fd, const char* str) { @@ -119,6 +122,7 @@ } while( b[0] != until ); buf[i] = 0; // null terminate the string + return 0; } // takes the string name of the serial port (e.g. "/dev/tty.usbserial","COM1") @@ -147,9 +151,13 @@ switch(baud) { case 4800: brate=B4800; break; case 9600: brate=B9600; break; +#ifndef OSNAME_LINUX case 14400: brate=B14400; break; +#endif case 19200: brate=B19200; break; +#ifndef OSNAME_LINUX case 28800: brate=B28800; break; +#endif case 38400: brate=B38400; break; case 57600: brate=B57600; break; case 115200: brate=B115200; break;