Beispiel #1
0
        public void UpdateExtCtrl(Band band, bool tx)
        {
            if (!tx)                // if !tx ignore given band and round off to nearest band based on freq
            {
                band = Alex.AntBandFromFreq();
            }

            int idx = (int)band - (int)Band.B160M;
            int bits;

            if (idx < 0 || idx > 11)
            {
                bits = 0;
            }
            else
            {
                if (tx)
                {
                    bits = TXBitMasks[idx];
                }
                else
                {
                    bits = RXBitMasks[idx];
                }
            }
            System.Console.WriteLine("Bits: " + bits + " Band: " + (int)band);
            JanusAudio.SetPennyOCBits(bits);
        }
Beispiel #2
0
        /*private void setConsole()
         * {
         *  //
         *   // This version of code assumes that the TX samples are being returned on receiver 2 and
         *   // that receiver 1 is being used to receive the OUTPUT of the amplifier to be corrected.
         *   // VFO-A + RIT is assumed to hold the desired frequency and VFO-B will be forced to this same
         *   // frequency during transmissions so that RX2 can capture and return the transmit sample
         *   // stream.  XIT is not allowed as receive and transmit frequencies must match.
         * //
         *  if ((lincor.auto == 1) || tt_cal)
         *  {
         *      console.RX2Enabled = true;
         *      vfoA_oldfreq = console.VFOAFreq;
         *      vfoB_oldfreq = console.VFOBFreq;
         *      vfoA_tx = console.VFOATX;
         *      vfoB_tx = console.VFOBTX;
         *      rit = console.RITValue;
         *      xit = console.XITValue;
         *      riton = console.RITOn;
         *      xiton = console.XITOn;
         *
         *      console.VFOBFreq = vfoA_oldfreq;
         *      if (riton) console.VFOBFreq += 0.000001 * rit;
         *      console.XITOn = false;
         *      console.VFOATX = false;
         *      console.VFOBTX = true;
         *      console_set = true;
         *  }
         * }*/

        private void setConsole()
        {
            //Version assuming TX samples come back in rx5.  rx5 will be set to VFOA freq.
            //Duplex must be used to get RX samples back in rx1 while transmitting on VFOA.
            if ((lincor.auto == 1) || tt_cal)
            {
                if (console.VFOATX)
                {
                    JanusAudio.SetVFOfreqRX5(console.VFOAFreq);
                }
                if (console.VFOBTX)
                {
                    if (console.RX2Enabled == true)
                    {
                        JanusAudio.SetVFOfreqRX5(console.VFOBFreq);
                    }
                    else
                    {
                        console.VFOBTX = false;
                        console.VFOATX = true;
                    }
                }
                rit   = console.RITValue;
                xit   = console.XITValue;
                riton = console.RITOn;
                xiton = console.XITOn;

                if (riton)
                {
                    console.XITValue = (int)rit;
                }

                console_set = true;
            }
        }
        private bool init(bool rfe, bool pa)
        {
            hasRFE = rfe;
            hasPA  = pa;

            JanusAudio.initOzy();

            IntPtr OzyHandle = JanusAudio.OzyOpen();

            if (OzyHandle != (IntPtr)0)
            {
                usbDevHandle = JanusAudio.OzyHandleToRealHandle(OzyHandle);
            }
            else
            {
                usbDevHandle = IntPtr.Zero;
            }

            if (usbDevHandle.Equals(IntPtr.Zero))
            {
                System.Console.WriteLine("Ozy init fails");
                return(false);
            }
            /* else */
            // System.Console.WriteLine("Ozy init succeeds");
            return(true);
        }
Beispiel #4
0
 private void PTTODelay()
 {
     // HiPerfTimer t1 = new HiPerfTimer();
     //   t1.Start();
     //  t1.Stop();
     //  while (t1.DurationMsec < ptt_out_delay) t1.Stop();
     Thread.Sleep(ptt_out_delay);
     JanusAudio.SetXmitBit(0);
 }
Beispiel #5
0
 public void ExtCtrlEnable(bool enable, Band band, bool tx)
 {
     if (!enable)
     {
         JanusAudio.SetPennyOCBits(0);
     }
     else
     {
         UpdateExtCtrl(band, tx);
     }
 }
Beispiel #6
0
        //
        // compute fwd power from Penny based on count returned
        // this conversion is a linear interpolation of values measured on an
        // actual penny board
        //
        public static float computeFwdPower()
        {
            int    power_int = JanusAudio.getFwdPower();
            double power_f   = (double)power_int;
            double result;


            if (power_int <= 2095)
            {
                if (power_int <= 874)
                {
                    if (power_int <= 113)
                    {
                        result = 0.0;
                    }
                    else                      // > 113
                    {
                        result = (power_f - 113.0) * 0.065703;
                    }
                }
                else                  // > 874
                {
                    if (power_int <= 1380)
                    {
                        result = 50.0 + ((power_f - 874.0) * 0.098814);
                    }
                    else                      // > 1380
                    {
                        result = 100.0 + ((power_f - 1380.0) * 0.13986);
                    }
                }
            }
            else              // > 2095
            {
                if (power_int <= 3038)
                {
                    if (power_int <= 2615)
                    {
                        result = 200.0 + ((power_f - 2095.0) * 0.192308);
                    }
                    else                      // > 2615, <3038
                    {
                        result = 300.0 + ((power_f - 2615.0) * 0.236407);
                    }
                }
                else                  // > 3038
                {
                    result = 400.0 + ((power_f - 3038.0) * 0.243902);
                }
            }

            result = result / 1000;            //convert to watts
            return((float)result);
        }
Beispiel #7
0
        // checks if the firmware versions are consistent - returns false if they are not
        // and set fwVersionmsg to point to an appropriate message
        private static bool fwVersionsGood()
        {
            bool result  = true;
            int  ozy_ver = getOzyFWVersion();

            if (ozy_ver <= 15)
            {
                legacyDotDashPTT = true;
                JanusAudio.SetLegacyDotDashPTT(1);
            }

            int     merc_ver           = getMercuryFWVersion();
            int     penny_ver          = getPenelopeFWVersion();
            string  fx2_version_string = getFX2FirmwareVersionString();
            Console c = Console.getConsole();

            System.Console.WriteLine("fx2: " + fx2_version_string);
            System.Console.WriteLine("ozy: " + ozy_ver);
            System.Console.WriteLine("merc: " + merc_ver);
            System.Console.WriteLine("penny: " + penny_ver);
            if (forceFWGood == true)
            {
                System.Console.WriteLine("Firmware ver check forced good!");
                return(true);
            }

            if (fx2_version_string.CompareTo("20090524") >= 0)
            {
                if ((ozy_ver < 13) ||
                    (c != null && c.MercuryPresent && (merc_ver < 27)) ||
                    (c != null && c.PennyPresent && (penny_ver < 12))
                    )
                {
                    result       = false;
                    fwVersionMsg = "Invalid Firmware Level.  Ozy >= 16, Penelope >= 12 and Mercury >= 27 required\n";
                }
            }
            else
            {
                if ((ozy_ver > 12) ||
                    (c != null && c.MercuryPresent && (merc_ver > 26)) ||
                    (c != null && c.PennyPresent && (penny_ver > 11))
                    )
                {
                    result       = false;
                    fwVersionMsg = "Invalid Firmware Level.  Ozy < 13, Penelope < 12 and Mercury < 27 required\n";
                }
            }
            return(result);
        }
Beispiel #8
0
        private int dds_reset()
        {
            int rc = JanusAudio.WriteControlMsg(usbDevHandle,
                                                VRT_VENDOR_OUT,
                                                VRQ_SDR1K_CTL,
                                                SDR1KCTRL_DDS_RESET,
                                                0,
                                                null,
                                                0,
                                                1000);

            // Thread.Sleep(10);
            // System.Console.WriteLine("dds_reset: rc: " + rc);
            return(rc);
        }
Beispiel #9
0
        private int latch(byte latchid, byte data)
        {
            int rc = 0; JanusAudio.WriteControlMsg(usbDevHandle,
                                                   VRT_VENDOR_OUT,
                                                   VRQ_SDR1K_CTL,
                                                   SDR1KCTRL_LATCH,
                                                   (latchid << 8) | data,
                                                   null,
                                                   0,
                                                   1000);

            // Thread.Sleep(10);
            // System.Console.WriteLine("latch: latchid: " + latchid + " data: " + data + " rc: " + rc);
            return(rc);
        }
Beispiel #10
0
        private int sr_load(byte reg, byte data)
        {
            int rc = JanusAudio.WriteControlMsg(usbDevHandle,
                                                VRT_VENDOR_OUT,
                                                VRQ_SDR1K_CTL,
                                                SDR1KCTRL_SR_LOAD,
                                                (reg << 8) | data,
                                                null,
                                                0,
                                                1000);

            // Thread.Sleep(10);
            // System.Console.WriteLine("sr_load: reg:" + reg + " data: " + data + " rc: " + rc);
            return(rc);
        }
Beispiel #11
0
        private int dds_write(byte addr, byte data)
        {
            int rc = JanusAudio.WriteControlMsg(usbDevHandle,
                                                VRT_VENDOR_OUT,
                                                VRQ_SDR1K_CTL,
                                                SDR1KCTRL_DDS_WRITE,
                                                (addr << 8) | data,
                                                null,
                                                0,
                                                1000);

            // Thread.Sleep(10);
            // System.Console.WriteLine("dds_write: addr:" + addr + " data: " + data + " rc: " + rc);
            return(rc);
        }
Beispiel #12
0
        private int get_status_port()
        {
            byte[] buf = new byte[1];

            int rc = JanusAudio.WriteControlMsg(usbDevHandle,
                                                VRT_VENDOR_IN,
                                                VRQ_SDR1K_CTL,
                                                SDR1KCTRL_READ_STATUS,
                                                0,
                                                buf,
                                                buf.Length,
                                                1000);

            if (rc == buf.Length)
            {
                rc = (int)((uint)(buf[0]));
                rc = swizzleStatusBits(rc);
#if false
                ++read_ok_count;
#endif
            }
            else
            {
                rc = -1;
#if false
                ++read_notok_count;
#endif
            }
            // Thread.Sleep(10);
#if false
            if (dbgGate == 100)
            {
                System.Console.WriteLine("get_status: data: 0x" + rc.ToString("X") + " read_ok: " + read_ok_count + " read_not_ok: " + read_notok_count);
            }
            ++dbgGate;
            if (dbgGate >= 101)
            {
                dbgGate          = 0;
                read_ok_count    = 0;
                read_notok_count = 0;
            }
#endif
            return(rc);
        }
Beispiel #13
0
        // get ozy firmware version string - 8 bytes.  returns
        // null for error
        private static string getOzyFirmwareString()
        {
            IntPtr oz_h = OzyOpen();

            if (oz_h == (IntPtr)0)
            {
                return(null);
            }
            IntPtr usb_h = JanusAudio.OzyHandleToRealHandle(oz_h);

            if (usb_h == (IntPtr)0)
            {
                JanusAudio.OzyClose(oz_h);
                return(null);
            }

            byte[] buf = new byte[8];
            // int rc = WriteControlMsg(usb_h,
            //OzySDR1kControl.VRT_VENDOR_IN, //0xC0
            // OzySDR1kControl.VRQ_SDR1K_CTL, //0x0d
            // OzySDR1kControl.SDR1KCTRL_READ_VERSION, // 0x7
            // 0, buf, buf.Length, 1000);

            int rc = GetOzyID(usb_h, buf, buf.Length);

            // System.Console.WriteLine("read version rc: " + rc);

            string result = null;

            if (rc == 8)    // got length we expected
            {
                char[] cbuf = new char[8];
                for (int i = 0; i < 8; i++)
                {
                    cbuf[i] = (char)(buf[i]);
                }
                result = new string(cbuf);
                System.Console.WriteLine("version: >" + result + "<");
            }
            JanusAudio.OzyClose(oz_h);
            return(result);
        }
Beispiel #14
0
        public void UpdateExtCtrl(Band band, bool tx)
        {
            int idx = (int)band - (int)Band.B160M;
            int bits;

            if (idx < 0 || idx > 11)
            {
                bits = 0;
            }
            else
            {
                if (tx)
                {
                    bits = TXBitMasks[idx];
                }
                else
                {
                    bits = RXBitMasks[idx];
                }
            }
            System.Console.WriteLine("Bits: " + bits + " Band: " + (int)band);
            JanusAudio.SetPennyOCBits(bits);
        }
Beispiel #15
0
        public void UpdateAlexAntSelection(Band band, bool tx, bool alex_enabled, bool xvtr)
        {
            if (!alex_enabled)
            {
                JanusAudio.SetAlexAntBits(0, 0, 0);
                return;
            }


            int rx_only_ant;
            int trx_ant;
            int rx_out;
            int xrx_out;

            int idx = (int)band - (int)Band.B160M;

            if (idx < 0 || idx > 11)
            {
                band = AntBandFromFreq();
                idx  = (int)band - (int)Band.B160M;
                if (idx < 0 || idx > 11)
                {
                    System.Console.WriteLine("No good ant!");
                    return;
                }
            }
            System.Console.WriteLine("Ant idx: " + idx);


            if (tx)
            {
                if (Ext2OutOnTx)
                {
                    rx_only_ant = 1;
                }
                else if (Ext1OutOnTx)
                {
                    rx_only_ant = 2;
                }
                else
                {
                    rx_only_ant = 0;
                }

                rx_out  = RxOutOnTx || Ext1OutOnTx || Ext2OutOnTx ? 1 : 0;
                trx_ant = TxAnt[idx];
            }
            else
            {
                rx_only_ant = RxOnlyAnt[idx];
                if (xvtr)
                {
                    if (rx_only_ant >= 3)
                    {
                        rx_only_ant = 3;
                    }
                    else
                    {
                        rx_only_ant = 0;
                    }
                }
                else
                {
                    if (rx_only_ant >= 3)
                    {
                        rx_only_ant -= 3;                   // do not use XVTR ant port if not using transverter
                    }
                }

                rx_out = rx_only_ant != 0 ? 1 : 0;
                if (TRxAnt)
                {
                    trx_ant = TxAnt[idx];
                }
                else
                {
                    trx_ant = RxAnt[idx];
                }
                if (RxAnt[idx] != TxAnt[idx])
                {
                    trx_ant_not_same = true;
                }
                else
                {
                    trx_ant_not_same = false;
                }
            }

            if (rx_out_override && rx_out == 1)
            {
                if (!tx)
                {
                    trx_ant = 4;
                }
                // rx_out = 0; // disable Rx_Bypass_Out relay
                if (tx) // override override
                {
                    rx_out = RxOutOnTx || Ext1OutOnTx || Ext2OutOnTx ? 1 : 0;
                }
                else
                {
                    rx_out = 0;  // disable Rx_Bypass_Out relay
                }
            }

            if (init_update)
            {
                if (rx_out == 0)
                {
                    xrx_out = 1;              // workaround for Hermes
                }
                else
                {
                    xrx_out = 0;
                }
                JanusAudio.SetAlexAntBits(rx_only_ant, trx_ant, xrx_out);
                init_update = false;
                Thread.Sleep(10);
            }
            JanusAudio.SetAlexAntBits(rx_only_ant, trx_ant, rx_out);

            // don't allow changing antenna selections when mox is activated

            /*	if ( tx )
             *      {
             *              AlexEnableSavedState = Console.getConsole().SetupForm.SetAlexAntEnabled(false);
             *              AlexEnableIsStateSaved = true;
             *      }
             *      else if ( AlexEnableIsStateSaved )
             *      {
             *              Console.getConsole().SetupForm.SetAlexAntEnabled(AlexEnableSavedState);
             *              AlexEnableIsStateSaved = false;
             *      } */

            // Console.getConsole().SetupForm.txtRXAnt.Text = rx_ant.ToString();
            //  Console.getConsole().SetupForm.txtRXOut.Text = rx_out.ToString();
            //  Console.getConsole().SetupForm.txtTXAnt.Text = tx_ant.ToString();
            // Console.getConsole().SetupForm.txtAlexBand.Text = band.ToString();
            //  Console.getConsole().SetupForm.txtAlexEnabled.Text = alex_enabled.ToString();
            //  Console.getConsole().SetupForm.txtAlexBits.Text = Convert.ToString(rc, 2);

            return;
        }
Beispiel #16
0
        void SerialPinChanged(object source, SerialPinChangedEventArgs e)
        {
            if (!use_for_keyptt && !use_for_paddles && !use_for_cat_ptt)
            {
                return;
            }

            if (use_for_keyptt)
            {
                switch (e.EventType)
                {
                case SerialPinChange.DsrChanged:

                    if (ptt_on_dtr)
                    {
                        CWInput.KeyerPTT = commPort.DsrHolding;
                    }

                    if (key_on_dtr)
                    {
                        JanusAudio.SetCWX(Convert.ToInt32(commPort.DsrHolding));
                    }
                    break;

                case SerialPinChange.CtsChanged:

                    if (ptt_on_rts)
                    {
                        CWInput.KeyerPTT = commPort.CtsHolding;
                    }

                    if (key_on_rts)
                    {
                        JanusAudio.SetCWX(Convert.ToInt32(commPort.CtsHolding));
                    }
                    break;
                }
            }
            else if (use_for_paddles)
            {
                switch (e.EventType)
                {
                case SerialPinChange.DsrChanged:
                    JanusAudio.SetCWDot(Convert.ToInt32(commPort.DsrHolding));
                    break;

                case SerialPinChange.CtsChanged:
                    JanusAudio.SetCWDash(Convert.ToInt32(commPort.CtsHolding));
                    break;
                }
            }

            if (use_for_cat_ptt)
            {
                switch (e.EventType)
                {
                case SerialPinChange.DsrChanged:

                    if (ptt_on_dtr)
                    {
                        CWInput.CATPTT = commPort.DsrHolding;
                    }
                    break;

                case SerialPinChange.CtsChanged:

                    if (ptt_on_rts)
                    {
                        CWInput.CATPTT = commPort.CtsHolding;
                    }
                    break;
                }
            }
        }
Beispiel #17
0
        public void UpdateAlexAntSelection(Band band, bool tx, bool alex_enabled)
        {
            if (!alex_enabled)
            {
                JanusAudio.SetAlexAntBits(0, 0, 0);
                return;
            }
            int rx_ant;
            int tx_ant;
            int rx_out;

            int idx = (int)band - (int)Band.B160M;

            if (idx < 0 || idx > 11)
            {
                band = AntBandFromFreq();
                idx  = (int)band - (int)Band.B160M;
                if (idx < 0 || idx > 11)
                {
                    System.Console.WriteLine("No good ant!");
                    return;
                }
            }
            System.Console.WriteLine("Ant idx: " + idx);


            if (tx)
            {
                rx_ant = 0;
                rx_out = 0;
                tx_ant = TxAnt[idx];
            }
            else
            {
                rx_ant = RxOnlyAnt[idx];
                if (rx_ant != 0)
                {
                    rx_out = 1;
                }
                else
                {
                    rx_out = 0;
                }
                tx_ant = RxAnt[idx];
            }
            JanusAudio.SetAlexAntBits(rx_ant, tx_ant, rx_out);

            // don't allow changing antenna selections when nox is activated
            if (tx)
            {
                AlexEnableSavedState   = Console.getConsole().SetupForm.SetAlexAntEnabled(false);
                AlexEnableIsStateSaved = true;
            }
            else if (AlexEnableIsStateSaved)
            {
                Console.getConsole().SetupForm.SetAlexAntEnabled(AlexEnableSavedState);
                AlexEnableIsStateSaved = false;
            }

            return;
        }
Beispiel #18
0
        public void UpdateAlexAntSelection(Band band, bool tx, bool alex_enabled)
        {
            if (!alex_enabled)
            {
                JanusAudio.SetAlexAntBits(0, 0, 0);
                return;
            }
            int rx_ant;
            int tx_ant;
            int rx_out;

            int idx = (int)band - (int)Band.B160M;

            if (idx < 0 || idx > 11)
            {
                band = AntBandFromFreq();
                idx  = (int)band - (int)Band.B160M;
                if (idx < 0 || idx > 11)
                {
                    System.Console.WriteLine("No good ant!");
                    return;
                }
            }
            System.Console.WriteLine("Ant idx: " + idx);


            if (tx)
            {
                rx_ant = 0;
                rx_out = RxOutOnTx ? 1 : 0;
                tx_ant = TxAnt[idx];
            }
            else
            {
                rx_ant = RxOnlyAnt[idx];
                rx_out = rx_ant != 0 ? 1 : 0;
                tx_ant = RxAnt[idx];
            }
            //  int rc = JanusAudio.SetAlexAntBits(rx_ant, tx_ant, 1);
            JanusAudio.SetAlexAntBits(rx_ant, tx_ant, rx_out);

            // don't allow changing antenna selections when mox is activated

            /*	if ( tx )
             *      {
             *              AlexEnableSavedState = Console.getConsole().SetupForm.SetAlexAntEnabled(false);
             *              AlexEnableIsStateSaved = true;
             *      }
             *      else if ( AlexEnableIsStateSaved )
             *      {
             *              Console.getConsole().SetupForm.SetAlexAntEnabled(AlexEnableSavedState);
             *              AlexEnableIsStateSaved = false;
             *      } */

            // Console.getConsole().SetupForm.txtRXAnt.Text = rx_ant.ToString();
            //  Console.getConsole().SetupForm.txtRXOut.Text = rx_out.ToString();
            //  Console.getConsole().SetupForm.txtTXAnt.Text = tx_ant.ToString();
            // Console.getConsole().SetupForm.txtAlexBand.Text = band.ToString();
            //  Console.getConsole().SetupForm.txtAlexEnabled.Text = alex_enabled.ToString();
            //  Console.getConsole().SetupForm.txtAlexBits.Text = Convert.ToString(rc, 2);

            return;
        }
Beispiel #19
0
        public void UpdateAlexAntSelection(Band band, bool tx, bool alex_enabled)
        {
            Console c = Console.getConsole();   //Vk4xv Need c.TXXVTRIndex & RXXVTRIndex

            if (c == null)
            {
                System.Console.WriteLine("no console");
                //return Band.LAST;
            }

            if (!alex_enabled)
            {
                JanusAudio.SetAlexAntBits(0, 0, 0);
                return;
            }
            int rx_ant;
            int tx_ant;
            int rx_out;

            int idx = (int)band - (int)Band.B160M;

            if (idx < 0 || idx > 11)
            {
                band = AntBandFromFreq();   // Sort Transv IF Freq
                if (idx == 12 || idx == -1) //WWV = 12 GEN = -1 Vk4xv
                {
                    idx = (int)band - (int)Band.B160M;
                }
                if (idx < 0 || idx > 26)
                {
                    System.Console.WriteLine("No good ant!");
                    return;
                }
            }
            System.Console.WriteLine("Ant idx: " + idx);


            if (tx)
            {
                if (c.TXXVTRIndex >= 0)      // VHF Bands so force Xvtr out on Tx Vk4xv
                {
                    rx_ant = 0;
                    rx_out = RxOutOnTx ? 1 : 0;
                    tx_ant = 0;
                }
                else
                {
                    rx_ant = 0;
                    rx_out = RxOutOnTx ? 1 : 0;
                    tx_ant = TxAnt[idx];
                }
            }
            else
            {
                if (c.RX1XVTRIndex >= 0)     // VHF Bands so force Xvtr on Rx Vk4xv
                {
                    rx_ant = 3;
                    rx_out = RxOutOnTx ? 1 : 0;
                    tx_ant = 0;
                }
                else
                {
                    rx_ant = RxOnlyAnt[idx];
                    rx_out = rx_ant != 0 ? 1 : 0;
                    tx_ant = RxAnt[idx];
                }
            }
            //  int rc = JanusAudio.SetAlexAntBits(rx_ant, tx_ant, 1);
            JanusAudio.SetAlexAntBits(rx_ant, tx_ant, rx_out);

            // don't allow changing antenna selections when mox is activated
            if (tx)
            {
                AlexEnableSavedState   = Console.getConsole().SetupForm.SetAlexAntEnabled(false);
                AlexEnableIsStateSaved = true;
            }
            else if (AlexEnableIsStateSaved)
            {
                Console.getConsole().SetupForm.SetAlexAntEnabled(AlexEnableSavedState);
                AlexEnableIsStateSaved = false;
            }

            // Console.getConsole().SetupForm.txtRXAnt.Text = rx_ant.ToString();
            //  Console.getConsole().SetupForm.txtRXOut.Text = rx_out.ToString();
            //  Console.getConsole().SetupForm.txtTXAnt.Text = tx_ant.ToString();
            // Console.getConsole().SetupForm.txtAlexBand.Text = band.ToString();
            //  Console.getConsole().SetupForm.txtAlexEnabled.Text = alex_enabled.ToString();
            //  Console.getConsole().SetupForm.txtAlexBits.Text = Convert.ToString(rc, 2);

            return;
        }
Beispiel #20
0
        public static string setC1Opts(string opt)
        {
            int bits;
            int off_mask = 0xff;
            int on_mask  = 0;

            string result = null;

            switch (opt)
            {
            case "--Atlas10MHz":
                off_mask = 0xf3;      // 11110011
                on_mask  = 0;         // 10 meg atlas == 00xx
                result   = "Atlas10";
                break;

            case "--Penny10MHz":
                off_mask = 0xf3;      // 11110011
                on_mask  = 0x4;       // 10 meg penny == 01xx
                result   = "Penny10";
                break;

            case "--Mercury10Mhz":
                off_mask = 0xf3;      // 11110011
                on_mask  = 0x8;       // 10 meg merc == 10xx
                result   = "Merc10";
                break;

            case "--Mercury125MHz":
                off_mask = 0xef;         // 11101111
                on_mask  = 0x10;
                result   = "Merc125";
                break;

            case "--CfgPenny":
                off_mask = 0x9f;         // 10011111
                on_mask  = 0x20;
                result   = "CfgPenny";
                break;

            case "--CfgMercury":
                off_mask = 0x9f;         // 10011111
                on_mask  = 0x40;
                result   = "CfgMerc";
                break;

            case "--CfgBoth":
                off_mask = 0x9f;         // 10011111
                on_mask  = 0x60;
                result   = "CfgBoth";
                break;

            case "--PennyMic":
                off_mask = 0x7f;         // 01111111
                on_mask  = 0x80;
                result   = "PennyMic";
                break;
            }

            bits  = JanusAudio.GetC1Bits();
            bits &= off_mask;
            bits |= on_mask;
            JanusAudio.SetC1Bits(bits);
            return(result);
        }
Beispiel #21
0
        public void KeyThread()
        {
            //SetThreadAffinity(1);
            bool extkey_dash, extkey_dot;

            do
            {
                DttSP.KeyerStartedWait();
                for (; DttSP.KeyerRunning();)
                {
                    bool keyprog = false;
                    timer.Start();
                    DttSP.PollTimerWait();
                    switch (primary_conn_port)
                    {
                    case "SDR":
                        byte b = hw.StatusPort();
                        extkey_dash = ((b & (byte)StatusPin.Dash) != 0);
                        extkey_dot  = ((b & (byte)StatusPin.Dot) != 0);
                        break;

                    case "5000":
                        extkey_dot  = fwc_dot;
                        extkey_dash = fwc_dash;
                        break;

                    case "Ozy":
                        int tmp = JanusAudio.GetDotDash();
                        // System.Console.WriteLine("dd: " + tmp);
                        extkey_dot  = ((tmp & 0x1) != 0);
                        extkey_dash = ((tmp & 0x2) != 0);
                        break;

                    default:                             // COM port
                        extkey_dash = sp.CtsHolding;
                        extkey_dot  = sp.DsrHolding;
                        break;
                    }

                    // handle CWX
                    if (!extkey_dash && !extkey_dot && console.USBtoI2CPresent)
                    {
                        extkey_dot  = ((Console.GetDG8SAQkeyStatus() & 2) == 0);
                        extkey_dash = ((Console.GetDG8SAQkeyStatus() & 32) == 0);
                    }
                    if (!extkey_dash && !extkey_dot)
                    {
                        if (memoryptt)
                        {
                            //console ptt on
                            keyprog    = true;
                            extkey_dot = extkey_dash = memorykey;
                        }
                        else
                        {
                            //console ptt off
                            keyprog = false;
                        }
                    }

                    switch (secondary_conn_port)
                    {
                    case "None":
                        break;

                    case "CAT":
                        if (!extkey_dash && !extkey_dot)                                 // don't override primary
                        {
                            switch (secondary_ptt_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = siolisten.SIO.isDSR();
                                }
                                else
                                {
                                    extkey_dot = siolisten.SIO.isCTS();
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                keyerptt = siolisten.SIO.isDSR();
                                //										extkey_dot = System.Convert.ToByte(sp2.CtsHolding);
                                break;

                            case KeyerLine.RTS:                                             // look at CTS since we are on the other side of the null modem cable
                                keyerptt = siolisten.SIO.isCTS();
                                //										extkey_dash  = System.Convert.ToByte(sp2.DsrHolding);
                                break;
                            }

                            switch (secondary_key_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = siolisten.SIO.isDSR();
                                }
                                else
                                {
                                    extkey_dot = siolisten.SIO.isCTS();
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                extkey_dot = siolisten.SIO.isDSR();
                                //										Debug.WriteLine("extkey_dot: "+extkey_dot);
                                break;

                            case KeyerLine.RTS:                                             // look at CTS since we are on the other side of the null modem cable
                                extkey_dash = siolisten.SIO.isCTS();
                                break;
                            }

                            if (!extkey_dash || !extkey_dot)
                            {
                                keyprog = true;
                            }
                            else
                            {
                                keyprog = false;
                            }
                            //								Debug.WriteLine("keyprog: "+keyprog);
                        }
                        //else keyprog = false;

                        break;

#if false
                    // wjtFIXME!! - merged from KD5TFD's HPSDR 1.6.3 tree - sr xmit
                    case "BB-PTT":
                        Console c = Console.getConsole();


                        if ((extkey_dash == 0) && (extkey_dot == 0))                               // don't override primary
                        {
                            switch (secondary_ptt_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = System.Convert.ToByte(c.serialPTT.isDSR());
                                }
                                else
                                {
                                    extkey_dot = System.Convert.ToByte(c.serialPTT.isCTS());
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                keyerptt = c.serialPTT.isDSR();
                                //										extkey_dot = System.Convert.ToByte(sp2.CtsHolding);
                                break;

                            case KeyerLine.RTS:                                             // look at CTS since we are on the other side of the null modem cable
                                keyerptt = c.serialPTT.isCTS();
                                //										extkey_dash  = System.Convert.ToByte(sp2.DsrHolding);
                                break;
                            }

                            switch (secondary_key_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = System.Convert.ToByte(c.serialPTT.isDSR());
                                }
                                else
                                {
                                    extkey_dot = System.Convert.ToByte(c.serialPTT.isCTS());
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                extkey_dot = System.Convert.ToByte(c.serialPTT.isDSR());
                                //										Debug.WriteLine("extkey_dot: "+extkey_dot);
                                break;

                            case KeyerLine.RTS:                                             // look at CTS since we are on the other side of the null modem cable
                                extkey_dash = System.Convert.ToByte(c.serialPTT.isCTS());
                                break;
                            }

                            if ((extkey_dash + extkey_dot) != 0)
                            {
                                keyprog = 1;
                            }
                            else
                            {
                                keyprog = 0;
                            }
                            //								Debug.WriteLine("keyprog: "+keyprog);
                        }
                        else
                        {
                            keyprog = 0;
                        }
                        break;
#endif


                    default:                             // comm port
                        if (!extkey_dash && !extkey_dot) // don't override primary
                        {
                            switch (secondary_ptt_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = sp2.DsrHolding;
                                }
                                else
                                {
                                    extkey_dot = sp2.CtsHolding;
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                keyerptt = sp2.DsrHolding;
                                break;

                            case KeyerLine.RTS:                                             // look at CTS since we are on the other side of the null modem cable
                                keyerptt = sp2.CtsHolding;
                                break;
                            }

                            switch (secondary_key_line)
                            {
                            case KeyerLine.NONE:
                                if (sp2dotkey)
                                {
                                    extkey_dash = sp2.DsrHolding;
                                }
                                else
                                {
                                    extkey_dot = sp2.CtsHolding;
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                extkey_dot = sp2.DsrHolding;
//										Debug.WriteLine("extkey_dot: "+extkey_dot);
                                break;

                            case KeyerLine.RTS:                                             // look at CTS since we are on the other side of the null modem cable
                                extkey_dash = sp2.CtsHolding;
                                break;
                            }

                            if (extkey_dash || extkey_dot)
                            {
                                keyprog = true;
                            }
                            else
                            {
                                keyprog = false;
                            }
                            Debug.WriteLine("keyprog: " + keyprog);
                        }                                 //else keyprog = false;

                        break;
                    }
                    timer.Stop();
                    msdel = (float)timer.DurationMsec;
                    //Debug.WriteLine("Dash: "+extkey_dash+" Dot: "+extkey_dot);
                    DttSP.KeyValue(msdel, extkey_dash, extkey_dot, keyprog);
                }
            } while(true);
        }