From owner-freebsd-bugs@FreeBSD.ORG Fri Jun 3 10:10:01 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B645216A41C for ; Fri, 3 Jun 2005 10:10:01 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3E99543D48 for ; Fri, 3 Jun 2005 10:10:01 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j53AA1rN012420 for ; Fri, 3 Jun 2005 10:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j53AA1GC012419; Fri, 3 Jun 2005 10:10:01 GMT (envelope-from gnats) Resent-Date: Fri, 3 Jun 2005 10:10:01 GMT Resent-Message-Id: <200506031010.j53AA1GC012419@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Stephen P. Cravey" Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 021DE16A41C for ; Fri, 3 Jun 2005 10:00:44 +0000 (GMT) (envelope-from cravey@igor.gotbrains.org) Received: from igor.gotbrains.org (igor.gotbrains.org [206.180.139.69]) by mx1.FreeBSD.org (Postfix) with ESMTP id A03C043D48 for ; Fri, 3 Jun 2005 10:00:43 +0000 (GMT) (envelope-from cravey@igor.gotbrains.org) Received: from igor.gotbrains.org (localhost [127.0.0.1]) by igor.gotbrains.org (8.13.3/8.13.3) with ESMTP id j53A0eGI031144 for ; Fri, 3 Jun 2005 05:00:40 -0500 (CDT) (envelope-from cravey@igor.gotbrains.org) Received: (from cravey@localhost) by igor.gotbrains.org (8.13.3/8.13.3/Submit) id j53A0e8S031143; Fri, 3 Jun 2005 05:00:40 -0500 (CDT) (envelope-from cravey) Message-Id: <200506031000.j53A0e8S031143@igor.gotbrains.org> Date: Fri, 3 Jun 2005 05:00:40 -0500 (CDT) From: "Stephen P. Cravey" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/81831: [PATCH] morse(6) Farnsworth support X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "Stephen P. Cravey" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Jun 2005 10:10:01 -0000 >Number: 81831 >Category: bin >Synopsis: [PATCH] morse(6) Farnsworth support >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Jun 03 10:10:00 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Stephen P. Cravey >Release: 5.4, HEAD >Organization: >Environment: System: 5.4, HEAD >Description: These patches add Farnsworth support to morse.6 and morse.c along with a HISTORY entry. From http://www.arrl.org/files/infoserv/tech/code-std.txt: Farnsworth timing is defined as sending the characters at a faster speed than the words. For example, sending the characters at 20 WPM but adding enough time between them to slow down the rate to 10 WPM. This feature will allow morse(6) to be more useful to those trying to learn morse code. I may be incorrect in my usage of the HISTORY entry. If so, feel free to remove/edit that portion of the patch. >How-To-Repeat: New feature. >Fix: Apply patches to morse.c and morse.6 from RELENG_5_4 and/or HEAD *** /usr/src/games/morse/morse.c Sun May 16 16:49:23 2004 --- morse.c Tue Apr 12 01:48:43 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:lsw:c:" #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:lpsw:c:" #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); } *** /usr/src/games/morse/morse.6 Sun May 16 16:52:48 2004 --- morse.6 Tue Apr 12 02:04:03 2005 *************** *** 44,49 **** --- 44,50 ---- .Op Fl elps .Op Fl d Ar device .Op Fl w Ar speed + .Op Fl c Ar speed .Op Fl f Ar frequency .Op Ar string ... .Sh DESCRIPTION *************** *** 73,78 **** --- 74,86 ---- Set the sending speed in words per minute. If not specified, the default speed of 20 WPM is used. + .It Fl c Ar speed + Farnsworth support. + Set the spacing between characters in words per minute. + This is independent of the speed + that the individual characters are sent. + If not specified, the default + speed of 20 WPM is used. .It Fl f Ar frequency Set the sidetone frequency to something other than the default 600 Hz. .It Fl d Ar device *************** *** 91,96 **** --- 99,106 ---- .Pp The .Fl w + , + .Fl c and .Fl f flags only work in conjunction with either the *************** *** 176,181 **** --- 186,196 ---- Ability to key an external device added by .An J\(:org Wunsch (DL8DTL). + .Pp + Farnsworth support for + .Nm + added by + .An Stephen Cravey (N5UUU). .Sh BUGS Only understands a few European characters (German and French), >Release-Note: >Audit-Trail: >Unformatted: