From owner-freebsd-bugs@FreeBSD.ORG Tue Jun 7 16:18:52 2005 Return-Path: X-Original-To: freebsd-bugs@FreeBSD.org Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5739B16A41C; Tue, 7 Jun 2005 16:18:52 +0000 (GMT) (envelope-from cravey@gotbrains.org) Received: from www.gotbrains.org (www2.gotbrains.org [206.180.149.129]) by mx1.FreeBSD.org (Postfix) with ESMTP id 20C3A43D48; Tue, 7 Jun 2005 16:18:51 +0000 (GMT) (envelope-from cravey@gotbrains.org) Received: from igor.gotbrains.org (igor.gotbrains.org [206.180.139.69]) by www.gotbrains.org (Postfix) with ESMTP id 3C20A1F4E; Tue, 7 Jun 2005 11:18:51 -0500 (CDT) Date: Tue, 7 Jun 2005 11:18:50 -0500 From: "Stephen P. Cravey" To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org Message-Id: <20050607111850.534cbc41.cravey@gotbrains.org> In-Reply-To: <200506031010.j53AA0QK012412@freefall.freebsd.org> References: <200506031000.j53A0e8S031143@igor.gotbrains.org> <200506031010.j53AA0QK012412@freefall.freebsd.org> X-Mailer: Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-portbld-freebsd5.3) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Subject: Re: bin/81831: [PATCH] morse(6) Farnsworth support X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jun 2005 16:18:52 -0000 This updated patch handles a minor idiocy in the GETOPTOPTS to group the new 'c' flag with 'lpsw' instead of forcing it to come later in the command line. This is a patch to morse.c in cvs, not an additive patch to my previous patch. -Stephen *** morse.c Tue Jun 7 10:50:50 2005 --- morse.c.new Tue Jun 7 10:50:40 2005 *************** *** 266,277 **** void ttyout(const char *); void sighandler(int); ! #define GETOPTOPTS "d:ef:lsw:" #define USAGE \ ! "usage: morse [-els] [-d device] [-w speed] [-f frequency] [string ...]\n" ! static int pflag, lflag, sflag, eflag; ! static int wpm = 20; /* words per minute */ #define FREQUENCY 600 static int freq = FREQUENCY; static char *device; /* for tty-controlled generator */ --- 266,278 ---- void ttyout(const char *); void sighandler(int); ! #define GETOPTOPTS "d:ef:lswc:" #define USAGE \ ! "usage: morse [-els] [-d device] [-w speed] [-c speed] [-f frequency] [string ...]\n" ! static int pflag, lflag, sflag, eflag, cflag; ! static int wpm = 20; /* effective words per minute */ ! static int cpm = 20; /* effective words per minute between characters */ #define FREQUENCY 600 static int freq = FREQUENCY; static char *device; /* for tty-controlled generator */ *************** *** 280,285 **** --- 281,287 ---- #define CHAR_SPACE 3 #define WORD_SPACE (7 - CHAR_SPACE - 1) static float dot_clock; + static float cdot_clock; int spkr, line; struct termios otty, ntty; int olflags; *************** *** 287,296 **** #ifdef SPEAKER tone_t sound; #undef GETOPTOPTS ! #define GETOPTOPTS "d:ef:lpsw:" #undef USAGE #define USAGE \ ! "usage: morse [-elps] [-d device] [-w speed] [-f frequency] [string ...]\n" #endif static const struct morsetab *hightab; --- 289,298 ---- #ifdef SPEAKER tone_t sound; #undef GETOPTOPTS ! #define GETOPTOPTS "d:ef:lpswc:" #undef USAGE #define USAGE \ ! "usage: morse [-elps] [-d device] [-w speed] [-c speed] [-f frequency] [string ...]\n" #endif static const struct morsetab *hightab; *************** *** 327,332 **** --- 329,338 ---- case 'w': wpm = atoi(optarg); break; + case 'c': + cflag = 1; + cpm = atoi(optarg); + break; case '?': default: fputs(USAGE, stderr); *************** *** 340,346 **** fputs("morse: only one of -p, -d and -l, -s allowed\n", stderr); exit(1); } ! if ((pflag || device) && ((wpm < 1) || (wpm > 60))) { fputs("morse: insane speed\n", stderr); exit(1); } --- 346,352 ---- fputs("morse: only one of -p, -d and -l, -s allowed\n", stderr); exit(1); } ! if ((pflag || device) && ((wpm < 1) || (wpm > 60) || (cpm < 1) || (cpm > 60))) { fputs("morse: insane speed\n", stderr); exit(1); } *************** *** 385,390 **** --- 391,405 ---- dot_clock = dot_clock / 2; /* dot_clock runs at twice */ /* the dot rate */ dot_clock = dot_clock * 100; /* scale for ioctl */ + + if (cflag) { + cdot_clock = cpm / 2.4; /* dots/sec */ + cdot_clock = 1 / cdot_clock; /* duration of a dot */ + cdot_clock = cdot_clock / 2; /* dot_clock runs at twice */ + /* the dot rate */ + cdot_clock = cdot_clock * 100;/* scale for ioctl */ + } else + cdot_clock = dot_clock; } argc -= optind; *************** *** 492,498 **** break; case ' ': sound.frequency = 0; ! sound.duration = dot_clock * WORD_SPACE; break; default: sound.duration = 0; --- 507,513 ---- break; case ' ': sound.frequency = 0; ! sound.duration = cdot_clock * WORD_SPACE; break; default: sound.duration = 0; *************** *** 511,517 **** } } sound.frequency = 0; ! sound.duration = dot_clock * CHAR_SPACE; ioctl(spkr, SPKRTONE, &sound); #endif } --- 526,532 ---- } } sound.frequency = 0; ! sound.duration = cdot_clock * CHAR_SPACE; ioctl(spkr, SPKRTONE, &sound); #endif } *************** *** 534,540 **** break; case ' ': on = 0; ! duration = dot_clock * WORD_SPACE; break; default: on = 0; --- 549,555 ---- break; case ' ': on = 0; ! duration = cdot_clock * WORD_SPACE; break; default: on = 0; *************** *** 554,560 **** duration = dot_clock * 10000; usleep(duration); } ! duration = dot_clock * CHAR_SPACE * 10000; usleep(duration); } --- 569,575 ---- duration = dot_clock * 10000; usleep(duration); } ! duration = cdot_clock * CHAR_SPACE * 10000; usleep(duration); }