<!--
	Rig definition file for use with fldigi
	
	See separate rigxml.odt (Open Office Writer document) for instructions on creating or maintaining
	this file
-->

<RIGDEF>

<RIG>Elecraft K3</RIG>

<!-- This file is a tweak of the K2  rig.xml file 
-->

<PROGRAMMER>
	Dave Freese			W1HKJ; 
	Leigh L. Klotz, Jr. WA5ZNU and Alan Steele VA3STL
	Tested by:			VA3STL, Alan
</PROGRAMMER>

<STATUS>
	alpha
	Version:	1.0
	Date:		2008 Mar 15
</STATUS>

<TITLE>Rig Control - Elecraft K3</TITLE>

<!-- Instructions for setting up the port
	BAUD     normal baud rate that transceiver operates at for CAT
	DEVICE   full path to the serial device
	ECHO     set to true for CI-V type of interface in which a h/w loop back sends all
	         outgoing data from Tx to Rx, or if the transceiver echos the data stream
	RETRIES  # times that the computer tries to send a command sequence before failure
	TIMEOUT  time in milliseconds between retries
	WAIT     time to wait between successive transmissions
	DTRINIT  inititialized state of the DTR pin, +/- 12 are valid entries.  This is the 
	         voltage level that will be available at the DTR pin.  For some CI-V type of 
	         interfaces this voltage may be used to power the serial converter
	DTRPTT   logic true or false designating whether the DTR pin is used for PTT.
	         PTT ON will toggle the DTRINIT state, ie: if +12 it goes to -12, if -12 it
	         changes to +12.
	RTSINIT  inititialized state of the RTS pin, same as for DTR
	RTSPTT   specifies whether the RTS pin is used for PTT, same logic as with DTR.
	RTSCTS   specifies whether hardware flow control is used with the radio
	         Many of the Kenwood rigs require RTS/CTS flow control.
	         Set to true to enable this type of control
	         NOTE: you cannot use both RTSCTS and RTSPTT.  If you set both to true the RTSCTS
	         flow control will have priority.
-->

<PORT>
	<BAUD>4800</BAUD>
	<DEVICE>/dev/ttyS0</DEVICE>
	<ECHO>false</ECHO>
	<RETRIES>4</RETRIES>
	<TIMEOUT>200</TIMEOUT>
	<WAIT>0</WAIT>
	<DTRINIT>-12</DTRINIT>
	<DTRPTT>false</DTRPTT>
	<RTSINIT>-12</RTSINIT>
	<RTSPTT>false</RTSPTT>
	<RTSCTS>false</RTSCTS>
</PORT>

<MODES>
	<ELEMENT><SYMBOL>LSB</SYMBOL><BYTE>31</BYTE></ELEMENT>
	<ELEMENT><SYMBOL>USB</SYMBOL><BYTE>32</BYTE></ELEMENT>
	<ELEMENT><SYMBOL>CW</SYMBOL><BYTE>33</BYTE></ELEMENT>
	<ELEMENT><SYMBOL>CW-R</SYMBOL><BYTE>37</BYTE></ELEMENT>
	<ELEMENT><SYMBOL>DATA</SYMBOL><BYTE>39</BYTE></ELEMENT>
	<ELEMENT><SYMBOL>DATA-R</SYMBOL><BYTE>36</BYTE></ELEMENT>
</MODES>

<!-- lsb mode strings should match those given in the modes symbol specifier -->

<LSBMODES>
	<STRING>LSB</STRING>
	<STRING>DATA</STRING>
	<STRING>CW-R</STRING>
</LSBMODES>

<!-- if you know the bandwidth values for the 4 IF filters you can substitute the
     numeric values for the strings FL-1 to FL-4, ie 400 for FL-1
-->
     
<BANDWIDTHS>
	<ELEMENT><SYMBOL>FL-1</SYMBOL><BYTE>31</BYTE></ELEMENT>
	<ELEMENT><SYMBOL>FL-2</SYMBOL><BYTE>32</BYTE></ELEMENT>
	<ELEMENT><SYMBOL>FL-3</SYMBOL><BYTE>33</BYTE></ELEMENT>
	<ELEMENT><SYMBOL>FL-4</SYMBOL><BYTE>34</BYTE></ELEMENT>
</BANDWIDTHS>
	
<REPLY>
	<SYMBOL>MODE</SYMBOL>
	<SIZE>4</SIZE>
	<STRING>MD</STRING>
	<DATA>
		<DTYPE>BYTE</DTYPE>
		<SIZE>1</SIZE>
	</DATA>
	<STRING>;</STRING>
</REPLY>

<REPLY>
	<SYMBOL>FREQ</SYMBOL>
	<SIZE>14</SIZE>
	<STRING>FA</STRING>
	<DATA>
		<DTYPE>DECIMAL</DTYPE>
	    <SIZE>11</SIZE>
	    <MAX>99999999999</MAX>
	    <MIN>00001500000</MIN>
	    <RESOL>1</RESOL>
	</DATA>
	<STRING>;</STRING>
</REPLY>	

<!-- 
    Response to a request for Bandwidth
    K2 replies with FWwwwwNA;
    where wwww = filter bandwidth in hz ie, 0400  ===> not used for this implementation
          N    = filter number, 1 to 4 as decimal character
          A    = audio filter state, 0 = OFF, 1 = AF1, 2 = AF2
-->

<REPLY>
	<SYMBOL>BW</SYMBOL> 
	<SIZE>9</SIZE>
	<STRING>FW</STRING>
	<SKIP>4</SKIP>
	<DATA>
		<DTYPE>BYTE</DTYPE>
		<SIZE>1</SIZE>
	</DATA>
	<BYTE>;</BYTE>
</REPLY>

<!-- 
    Initialization command
    K22; sets the extended command mode for the K2 
-->

<COMMAND>
	<SYMBOL>INIT</SYMBOL>
	<SIZE>3</SIZE>
	<STRING>K22;</STRING>
</COMMAND>

<COMMAND>
	<SYMBOL>SETFREQ</SYMBOL>
	<SIZE>14</SIZE>
	<STRING>FA</STRING>
	<DATA>
		<DTYPE>DECIMAL</DTYPE>
	    <SIZE>11</SIZE>
	    <MAX>99999999999</MAX>
	    <MIN>00001500000</MIN>
	    <RESOL>1</RESOL>
	</DATA>
	<STRING>;</STRING>
	<OK>FREQ</OK>
</COMMAND>

<COMMAND>
	<SYMBOL>GETFREQ</SYMBOL>
	<SIZE>3</SIZE>
	<STRING>FA;</STRING>
	<INFO>FREQ</INFO>
</COMMAND>

<COMMAND>
	<SYMBOL>SETMODE</SYMBOL>
	<SIZE>4</SIZE>
	<STRING>MD</STRING>
	<DATA>
		<DTYPE>BYTE</DTYPE>
		<SIZE>1</SIZE>
	</DATA>
	<STRING>;</STRING>
	<OK>MODE</OK>
</COMMAND>

<COMMAND>
	<SYMBOL>GETMODE</SYMBOL>
	<SIZE>3</SIZE>
	<STRING>MD;</STRING>
	<INFO>MODE</INFO>
</COMMAND>

<COMMAND>
	<SYMBOL>SETBW</SYMBOL>
	<SIZE>8</SIZE>
	<STRING>FW0000</STRING>
	<DATA>
		<DTYPE>BYTE</DTYPE>
		<SIZE>1</SIZE>
	</DATA>
	<STRING>;</STRING>
	<OK>OK</OK>
	<BAD>BAD</BAD>
</COMMAND>

<COMMAND>
	<SYMBOL>GETBW</SYMBOL>
	<SIZE>3</SIZE>
	<STRING>FW;</STRING>
	<INFO>BW</INFO>
</COMMAND>

<COMMAND>
	<SYMBOL>PTTON</SYMBOL>
	<SIZE>3</SIZE>
	<STRING>TX;</STRING>
</COMMAND>

<COMMAND>
	<SYMBOL>PTTOFF</SYMBOL>
	<SIZE>3</SIZE>
	<STRING>RX;</STRING>
</COMMAND>

</RIGDEF>
