r2128 - trunk/src/target/gsm/src/gsmd

laforge at sita.openmoko.org laforge at sita.openmoko.org
Sat Jun 2 13:49:58 CEST 2007


Author: laforge
Date: 2007-06-02 13:49:58 +0200 (Sat, 02 Jun 2007)
New Revision: 2128

Modified:
   trunk/src/target/gsm/src/gsmd/gsmd.c
Log:
remove stupid default serial port /dev/ttyUSB0


Modified: trunk/src/target/gsm/src/gsmd/gsmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/gsmd.c	2007-06-02 11:43:55 UTC (rev 2127)
+++ trunk/src/target/gsm/src/gsmd/gsmd.c	2007-06-02 11:49:58 UTC (rev 2128)
@@ -163,11 +163,15 @@
 	{ 0, 0, 0, 0 }
 };
 
-static void print_help(void)
+static void print_header(void)
 {
 	printf("gsmd - (C) 2006-2007 by Harald Welte <laforge at gnumonks.org>\n"
-	       "This program is FREE SOFTWARE under the terms of GNU GPL\n\n"
-	       "Usage:\n"
+	       "This program is FREE SOFTWARE under the terms of GNU GPL\n\n");
+}
+
+static void print_usage(void)
+{
+	printf("Usage:\n"
 	       "\t-V\t--version\tDisplay program version\n"
 	       "\t-d\t--daemon\tDeamonize\n"
 	       "\t-h\t--help\t\tDisplay this help message\n"
@@ -202,7 +206,7 @@
 	int daemonize = 0;
 	int bps = 115200;
 	int hwflow = 0;
-	char *device = "/dev/ttyUSB0";
+	char *device = NULL;
 	char *logfile = "syslog";
 	char *vendor_name = NULL;
 	char *machine_name = NULL;
@@ -214,6 +218,8 @@
 	
 	gsmd_tallocs = talloc_named_const(NULL, 1, "GSMD");
 
+	print_header();
+
 	/*FIXME: parse commandline, set daemonize, device, ... */
 	while ((argch = getopt_long(argc, argv, "FVLdhp:s:l:v:m:", opts, NULL)) != -1) {
 		switch (argch) {
@@ -231,7 +237,7 @@
 			break;
 		case 'h':
 			/* FIXME */
-			print_help();
+			print_usage();
 			exit(0);
 			break;
 		case 'p':
@@ -255,6 +261,12 @@
 		}
 	}
 
+	if (!device) {
+		fprintf(stderr, "ERROR: you have to specify a port (-p port)\n");
+		print_usage();
+		exit(2);
+	}
+
 	/* use direct access to device node ([virtual] tty device) */
 	fd = open(device, O_RDWR);
 	if (fd < 0) {





More information about the commitlog mailing list