<?xml version="1.0" encoding="utf-8"?>
<!--

  IC-F8101 RigCAT definitions for use with fldigi

  Very strong recommendations:
    Read the fldigi user's manual!
    Search for "Rig Xml How" and you'll find a lot of valuable details.

  fldigi is part of the fl* suite of programs developed by Dave Freese,
  W1HKJ, the winner of the 2014 ARRL Technical Excellence Award.
  All programs of the suite are developed using the Fast Light Toolkit.
  They are open-source, cross-platform solutions running on OS X, Linux,
  BSD, and Windows.

  General Information

  IC-F8101 (v4.01 or later) CI-V address is 8A  (default)
  fldigi RigCAT controller address is E0 (default)

  If this is changed all CI-V -Commands below MUST be changed too!

  Operating Environment

  I run fldigi on Linux MINT 17.3. Hence all my fldigi experience I
  gained in this environment.  However, it shouldn't be a big deal to
  adapt this file to any fldigi operating environment.  In fact, no
  changes should be necessary, but it wasn't tested ...

  Storage:
  This file should be stored in this directory (folder)

  on Linux  : /home/[login]/.fldigi/rigs/
  on OS X   : /Users/[login]/.fldigi/rigs/
  on XP     : C:\Documents and Settings\[login]\fldigi.files\rigs\
  on Vista  :
     Win-7  :
     Win-8  :
     Win-10 : C:\User\[login]\fldigi.files\rigs\

  Serial Device:

  My USB serial port device is

  /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART...

  If there are multiple serial USB port controllers connected it's
  VERY important to connect to the correct CP2102 controller :-)

  IC-F8101 Settings

  Select Menu / Set / Connectors

-->

<RIGDEF>

  <RIG>Icom IC-F8101</RIG>

  <PROGRAMMER>
    Originator : Karl-Heinz  DC4PC
    Tested by  : DC4PC
    Updated by : John, KB0NE
               : Cliff, AE5ZA
               : David, W1HKJ
               : Modified for F8101 from 7300 by Ray Montagne (W7CIA)
  </PROGRAMMER>

  <STATUS>
    Tested:     W7CIA
    Version:    1.00
    Date:       March 1, 2019
  </STATUS>

  <TITLE>RigCAT - IC-F8101</TITLE>

<!--    default settings for initial setup  -->

<!-- 50ms Time Out  -->
  <TIMEOUT>50</TIMEOUT>
<!-- Max. 5 retries before failure  -->
  <RETRIES>5</RETRIES>
<!-- No write delay: Send commands immediately  -->
  <WRITE_DELAY>0</WRITE_DELAY>
<!-- TT in milliseconds, not used -->
<!-- <POST_WRITE_DELAY>TT</POST_WRITE_DELAY>  -->

<!--    Serial Interface definitions 38400-8N1 would be shorter :-) -->
<!-- Set something reasonable fast  -->
  <BAUDRATE>38400</BAUDRATE>
<!-- One Stop-Bit   -->
  <STOPBITS>1</STOPBITS>

<!-- CI-V-CAT-Commands are used to control the PTT. See comments at the
     end of this file to read more!
-->
<!-- true:  H/W handshake data flow control -->
  <RTSCTS>false</RTSCTS>
<!-- RTS / DTR are not used for PTT: Do not change this unless you
     know what you are doing! -->
<!-- true:  toggle RTS signal line for PTT  -->
  <RTSPTT>false</RTSPTT>
<!-- true:  toggle DTR signal line for PTT  -->
  <DTRPTT>false</DTRPTT>
<!-- true:  set RTS signal line to +12V -->
  <RTSPLUS>false</RTSPLUS>
<!-- true:  set DTR signal line to +12V -->
  <DTRPLUS>false</DTRPLUS>
<!-- true:  enable PTT CI-V-CAT-command -->
  <CMDPTT>true</CMDPTT>
<!-- true:  The TRX CI-V-Interface echoes all chars -->
  <ECHO>true</ECHO>


<!-- Assumes USB connection, using USB Audio Class Driver and SI USB to Serial 
     device, resulting in only LSB, USB, AM, CW and RTTY modes.         -->
<!-- Please note: Mode 06 is not defined by the IC-7300 architecture    -->
<!-- My DSP Filters are set to 1.8KHz (flt1), 2.4 KHz (flt2) and
     3.0 KHz (flt3). Hence, I use Filter 3 for digi modes on all bands  -->

  <MODES>
    <ELEMENT> <SYMBOL>USB</SYMBOL>    <BYTES>00 01</BYTES> </ELEMENT>
    <ELEMENT> <SYMBOL>LSB</SYMBOL>    <BYTES>00 00</BYTES> </ELEMENT>  
    <ELEMENT> <SYMBOL>AM</SYMBOL>     <BYTES>00 02</BYTES> </ELEMENT>
    <ELEMENT> <SYMBOL>CW</SYMBOL>     <BYTES>00 03</BYTES> </ELEMENT>
    <ELEMENT> <SYMBOL>RTTY</SYMBOL>   <BYTES>00 04</BYTES> </ELEMENT>
  </MODES>

<!-- lsb mode strings should match those given in the modes id specifier.
     Note that the IC-F8101 does not offer reversed modes as the LMR service 
     is biased towards using only upper side-band based modes.          -->
  <LSBMODES>
    <STRING>LSB</STRING>
  </LSBMODES>

<!--
    CI-V-Command results: fldigi can parse and decode message returned
    from the transceiver that define 4 aspects of the transceiver operation:
    .   OK data accepted by the transceiver
    .   BAD (NG - no good) data rejected by the transceiver
    .   MODE current operating mode of the transceiver
    .   BW current bandwidth setting of the transceiver
    .   FREQ frequency of the active VFO (might be either A or B)
-->

<!--  OK data accepted by the transceiver
      Six bytes command response
-->
  <REPLY><SYMBOL>OK</SYMBOL><SIZE>6</SIZE>
    <BYTES>FE FE E0 8A FB FD</BYTES>
  </REPLY>

<!--  BAD (NG - no good) data rejected by the transceiver
      Six bytes command response
-->
  <REPLY><SYMBOL>BAD</SYMBOL><SIZE>6</SIZE>
    <BYTES>FE FE E0 8A FA FD</BYTES>
  </REPLY>

<!--  MODE current operating mode of the transceiver, two bytes command
      response
      Prefix + CI-V-Command code 1A 34 (current VFO)
      Two byte binary data is returned corresponding to the MODE
      definitions above followed by one byte trailer
      Response:	00 00	LSB
                00 01	USB
                00 02	AM
                00 03	CW
                00 04	RTTY
-->
  <REPLY><SYMBOL>MODE</SYMBOL><SIZE>10</SIZE>
    <BYTES>FE FE E0 8A 1A 34</BYTES>
    <DATA><DTYPE>BINARY</DTYPE><SIZE>2</SIZE></DATA>
    <BYTE>FD</BYTE>
  </REPLY>

<!--  FREQ frequency of the active VFO (might be either A or B)
      Eleven bytes command response
      5 bytes (ten BCD-Digits) frequency data returned
      One byte trailer
-->
  <REPLY><SYMBOL>FREQ</SYMBOL><SIZE>11</SIZE>
    <BYTES>FE FE E0 8A 03</BYTES>
    <DATA>
      <DTYPE>BCD</DTYPE>
      <SIZE>10</SIZE>
      <MAX>74800000</MAX>
      <MIN>30000</MIN>
      <RESOL>1</RESOL>
      <REV>true</REV>
    </DATA>
    <BYTE>FD</BYTE>
  </REPLY>

<!--
    CI-V-Commands:
-->

<!--  Set operating frequency of current VFO, eleven bytes command length
      Prefix + CI-V-Command code 05
      One byte trailer
      Result (command response) may be OK or BAD (Not Good)
      5 bytes (ten BCD-Digits) frequency data
-->
  <COMMAND><SYMBOL>SETFREQ</SYMBOL><SIZE>11</SIZE>
    <BYTES>FE FE 8A E0 05</BYTES>
    <DATA>
      <DTYPE>BCD</DTYPE>
      <SIZE>10</SIZE>
      <MAX>29999900</MAX>
      <MIN>500000</MIN>
      <RESOL>1</RESOL>
      <REV>true</REV>
    </DATA>
    <BYTE>FD</BYTE>
      <OK>OK</OK> <BAD>BAD</BAD>
  </COMMAND>

<!--  Read operating frequency of curren VFO, six bytes command length
      Prefix + CI-V-Command code 03 + trailer
      Result (command response) is FREQ ... or BAD
-->
  <COMMAND><SYMBOL>GETFREQ</SYMBOL><SIZE>6</SIZE>
    <BYTES>FE FE 8A E0 03 FD</BYTES>
    <INFO>FREQ</INFO>
  </COMMAND>

<!-- SETMODE and GETMODE usually use the CI-V-Commands 01 and 04. Both
     are changed with the IC-7300 concept and are not working as I like it.
     To set the DATA Mode (because of the IC-7300 internal sound card)
     AND the Filter on the current VFO (here case VFO 0) ... and there
     is one command only available.
     Hence, the CI-V-Command 26. This makes life easier, does it really?
-->

<!-- Operating mode selection for transceive
     Prefix + CI-V-Command code 1A 34 (current VFO)
     Prefix + CI-V-Command code 26 00 (current VFO 0)
     Three byte binary MODE data as declared above followed by one byte
     trailer
     Result may be OK or BAD (Not Good)
-->
  <COMMAND><SYMBOL>SETMODE</SYMBOL><SIZE>10</SIZE>
    <BYTES>FE FE 8A E0 1A 34</BYTES>
    <DATA><DTYPE>BYTES</DTYPE><SIZE>2</SIZE></DATA>
    <BYTE>FD</BYTE>
    <OK>OK</OK> <BAD>BAD</BAD>
  </COMMAND>

<!-- Read operating mode
     Prefix + CI-V-Command code 26 00 + (current VFO 0) trailer
     Result (command response) is MODE ... or BAD
-->
  <COMMAND><SYMBOL>GETMODE</SYMBOL><SIZE>5</SIZE>
    <BYTES>FE FE 8A E0 1A 34 FD</BYTES>
    <INFO>MODE</INFO>
  </COMMAND>


<!-- Use PTT Commands via CI-V and switch off RTS and DTR control. There 
     are good reasons.
       . This ensures CI-V is working
       . The signal lines RTS, DTR, CTS etc. may be used for serial flow 
         control on very high speed USB links
       . Using a serial terminal programm to debug the CI-V interface 
         RTS and DTR signals do not confuse the TRX (eg. switch on Tx 
         attached to an untuned antenna)
       . The TRX is not confused by the USB testing process during computer
         startup
       . Keep the PTTON definitions at the end of the file. If there are 
         unrecoverable errors before theese definitions, PTT just does 
         not work :-)
    -->

<!-- Set transceiver status RX == PTT off    
     Prefix + CI-V-Command code 1C 00 00 + trailer   
     Result may be OK or BAD (Not Good)  
-->
  <COMMAND><SYMBOL>PTTOFF</SYMBOL><SIZE>8</SIZE>
    <BYTES>FE FE 8A E0 1A 37 00 00 FD</BYTES>
    <OK>OK</OK> <BAD>BAD</BAD>
  </COMMAND>

<!-- Set transceiver status TX == PTT on 
     Prefix + CI-V-Command code 1C 00 01 + trailer   
     Result may be OK or BAD (Not Good)  
     F8101:  Use the command to change the TX mode to use the 
     ACC connector to activate USB audio to the transmitter.  NOTE 
     that when in an ALE LINK, this command fails to key the transmitter 
     (where the standard 1C command fails to route audio).  Seems like 
     a bug in the F8101 firmware.
-->
  <COMMAND><SYMBOL>PTTON</SYMBOL><SIZE>8</SIZE>
    <BYTES>FE FE 8A E0 1A 37 00 02 FD</BYTES>
    <OK>OK</OK> <BAD>BAD</BAD>
  </COMMAND>

<!-- smeter scale mapping -->
<SMETER> 0,0; 51, 1; 102, 2; 153, 3; 204, 4; 255,5 </SMETER>

<REPLY>
  <SYMBOL>SMETER</SYMBOL>
  <SIZE>9</SIZE>
	<BYTES>FE FE E0 8A 15 02</BYTES>
	<DATA>
		<DTYPE>BCD</DTYPE>
		<SIZE>2</SIZE>
		<MAX>255</MAX>
		<MIN>0</MIN>
		<RESOL>1</RESOL>
		<REV>false</REV>
	 </DATA>
	<BYTE>FD</BYTE>
</REPLY>

<COMMAND>
  <SYMBOL>GET_SMETER</SYMBOL>
  <SIZE>7</SIZE>
  <BYTES>FE FE 8A E0 15 02 FD</BYTES>
  <INFO>SMETER</INFO>
</COMMAND>

</RIGDEF>

<!--    That's all folks !!!    -->
