bin/81831: [PATCH] morse(6) Farnsworth support
Stephen P. Cravey
cravey at gotbrains.org
Fri Jun 3 10:10:01 GMT 2005
>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:
More information about the freebsd-bugs
mailing list