Cwdaemon-0.8
=========

Cwdaemon is a small daemon which uses the pc parallel or serial port and a 
simple transistor switch to output morse code to a transmitter from a text 
message sent to it via the udp internet protocol. The program uses the PC 
speaker to generate a sidetone.

It is called as root, with "cwdaemon -p <portnumber> -d <device>". If no 
portnumber is given, the default portnumber 6789 is used. Device can be one of 
the serial (ttyS0, ttyS1, etc) or parallel (parport0, parport1, etc) ports.
Default is parport0.

Cwdaemon also handles PTT, and band index output for automatic switching of
antennas, filters etc. Pinout is compatible with the standard (CT, TRlog).

Please note
-----------
Linux is not a real-time operating system. The timer resolution of the linux
kernel is 10 milliseconds. You may especially notice this when using PTT and
setting the PTT delay value. If you experience timing problems, you might try
using the -P flag. This will set cwdaemon's priority. The default is zero,
any negative value will be a higher priority, the maximum being -20.

Quickstart
----------
Run the cwsetup.sh script and next run cwdaemon with the -n flag. If this does
not work, read the next paragraphs....

Setting up parallel port(s) for cwdaemon
----------------------------------------
You need the parport devices to use cwdaemon. Check if you have them:

  ls -al /dev/parport*

If you don't see any files, create the with MAKEDEV (as root user):

  cd /dev; ./MAKEDEV parport

Next, check whether the parport and parport_pc kernel modules are loaded: when
you type 'lsmod', you should (on the i386 architecture) see something like:

  parport_pc             23304   0 (autoclean)
  parport                25992   0 (autoclean) [parport_pc]

The lp module should not be loaded, it is only needed if you want to use a 
printer and it will block the parallel port if you use cwdaemon. You can unload
it with the command 'rmmod lp' as root.

If you don't see any parport modules please check whether you have the line:

  alias parport_lowlevel parport_pc

in your /etc/modules.conf file and load the modules with:

  modprobe parport
  modprobe parport_pc

Be sure that parallel port support is enabled in your BIOS! If you use odd 
ioports or interrupts, you can do things like:

  modprobe parport_pc io=0x3bc,0x378,0x278 irq=none,7,auto

which configures 3 parallel ports with the second port using irq 7 and the
third port some auto-detected irq.

When cwdaemon is run, the ppdev kernel module should be loaded automatically. 
In case it doesn't, just type:

  modprobe ppdev

PLEASE NOTE: you should probably run a 2.4 kernel to use the ppdev device with
cwdaemon.


Setting up serial port(s) for cwdaemon
--------------------------------------
Setting up your serial ports is straightforward. Here are some commands to get
you started:

  setserial -g /dev/ttyS*

will tell you what serial lines are configured. If you see a line with 
"UART: unknown", this probably means there is no serial port for the device.

  setserial /dev/ttyS0 -v autoconfig

will try to autoconfigure your first serial port. You need to run this command
as root.

Other valid commands are:

  setserial /dev/ttyS1 auto_irq skip_test autoconfig
  setserial /dev/ttyS3 irq 5 uart 16550A skip_test

Newer distributions use a file called '/etc/serial.conf' where the information
for your serial ports are stored.


How cwdaemon works
------------------
After starting, the program detaches from its controlling terminal,
after that the program can be controlled via its network udp input port.

The message formats are:

<ESC>"0"                 Reset to default values
<ESC>"2"<"speed value">  Set keying speed (5 ... 60 wpm)
<ESC>"3"<"tone value">   Set sidetone (300 ... 1000 Hz)
<ESC>"3"<"0">            Sound off
<ESC>"4"                 Abort message
<ESC>"5"                 Stop (Exit) the daemon
<ESC>"6"                 Set uninterruptable (word- ) mode for simulator
<ESC>"7"<"weight value"> Set weigthing (-50 ... 50)
<ESC>"8"<"device">       Set device for keying (same as -d)
<ESC>"9"<"port number">  Obsolete
<ESC>"a"<"0|1">          PTT keying off or on
<ESC>"b"<"0|1">          SSB signal from microphone or soundcard
<ESC>"c"<"x">            Tune x seconds long (limit = 10 seconds)
<ESC>"d"<"delay">        PTT on delay 0..50 (0 .. 50ms)
<ESC>"e"<"bandindex">	 Band info output on pins 2, 7, 8, 9 of the parport
                         (pin 2 = lsb, 9 = msb, e.g. 1000 = 160m, 1001 = 10m)
<ESC>"f"<"sound device"> Set sound device, same as -x.
<ESC>"g"<"volume">       Set soundcard volume (0 .. 100).
Any message              Send morse code message  (max 1 packet!)
qrz de pa0rct ++test--   In- and decrease speed on the fly in 2 wpm steps
de d~l~2~w~r~j pse k     Add half-space delay after each character


Default startup values
----------------------
Speed = 24 wpm
Tone = 800 Hz
Sound = on
Wordmode = off
Weight = 0
UDP port = 6789
PTT delay = 0 (off)
Device = parport0
Sound Device = console


Cwdaemon supports the following special characters
--------------------------------------------------
*	AR
=	BT
<	SK
(	KN
!	SN
&	AS
>	BK


Cwdaemon parallel and serial port circuitry
-------------------------------------------
See the examples is the schematics directory.


Testing cwdaemon
----------------
Please review and run the test/cwtest.sh test program. It only works with
netcat installed.

Credits
-------
Conversion to stand-alone utility, basic work, POSIX porting and integration
with unixcw by PG4I.
Networking, daemon mode and band switching by PA0R.
Rework of the device handling by OK1ZIA.
Many contributions by DL2WRJ.
Unixcw library by G0FRD.

All of this code is distributed under the GNU GPL license.
