From cravey@igor.gotbrains.org  Fri Jun  3 10:00:44 2005
Return-Path: <cravey@igor.gotbrains.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 021DE16A41C
	for <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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" <cravey@gotbrains.org>
Reply-To: "Stephen P. Cravey" <cravey@gotbrains.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] morse(6) Farnsworth support 
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         81831
>Category:       bin
>Synopsis:       [PATCH] morse(6) Farnsworth support
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 03 10:10:00 GMT 2005
>Closed-Date:    Sat Jun 25 08:23:57 MEST 2005
>Last-Modified:  Sat Jun 25 08:23:57 MEST 2005
>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:

From: "Stephen P. Cravey" <cravey@gotbrains.org>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Cc:  
Subject: Re: bin/81831: [PATCH] morse(6) Farnsworth support
Date: Tue, 7 Jun 2005 11:18:50 -0500

 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);
   }
   

From: "Stephen P. Cravey" <cravey@gotbrains.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Fw: Re: bin/81831: [PATCH] morse(6) Farnsworth support
Date: Tue, 7 Jun 2005 11:28:11 -0500

 Sorry, sent the last one to gnats-submit. Apologies to the gnats
 maintainers.
 
 
 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);
   }
   
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Sat Jun 25 08:23:19 MEST 2005 
State-Changed-Why:  
Fix committed quite some time ago. 

Thanks Stephen for submitting the patch, and also thanks for reminding 
me to close the PR. ;-) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=81831 
>Unformatted:
