Example #1
0
        public static bool Start()
        {
            bool retval = false;
            int  rc;

            phase_buf_l = new float[2048];
            phase_buf_r = new float[2048];
            Console c = Console.getConsole();

            rc = NetworkIO.initRadio();

            if (rc != 0)
            {
                if (rc == -101) // firmware version error;
                {
                    string fw_err = NetworkIO.getFWVersionErrorMsg();
                    if (fw_err == null)
                    {
                        fw_err = "Bad Firmware levels";
                    }
                    MessageBox.Show(fw_err, "Firmware Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return(false);
                }
                else
                {
                    MessageBox.Show("Error starting SDR hardware, is it connected and powered?", "Network Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return(false);
                }
            }

            // add setup calls that are needed to change between P1 & P2 before startup
            if (NetworkIO.CurrentRadioProtocol == RadioProtocol.USB)
            {
                console.SampleRateTX = 48000; // set tx audio sampling rate
                WDSP.SetTXACFIRRun(cmaster.chid(cmaster.inid(1, 0), 0), false);
                puresignal.SetPSHWPeak(cmaster.chid(cmaster.inid(1, 0), 0), 0.4072);
                console.psform.PSdefpeak = "0.4072";
            }
            else
            {
                console.SampleRateTX = 192000;
                WDSP.SetTXACFIRRun(cmaster.chid(cmaster.inid(1, 0), 0), true);
                puresignal.SetPSHWPeak(cmaster.chid(cmaster.inid(1, 0), 0), 0.2899);
                console.psform.PSdefpeak = "0.2899";
            }

            c.SetupForm.InitAudioTab();
            c.SetupForm.ForceReset = true;
            cmaster.PSLoopback     = cmaster.PSLoopback;

            int result = NetworkIO.StartAudioNative();

            if (result == 0)
            {
                retval = true;
            }

            return(retval);
        }
Example #2
0
        public static void CMCreateCMaster()
        {
            // set radio structure
            int[] cmSPC = new int[1] {
                2
            };
            int[] cmInboundSize = new int[8] {
                240, 240, 240, 240, 240, 720, 240, 240
            };

            fixed(int *pcmSPC = cmSPC, pcmIbSize = cmInboundSize)
            cmaster.SetRadioStructure(8, cmRCVR, 1, cmSubRCVR, 1, pcmSPC, pcmIbSize, 1536000, 48000, 384000);

            // send function pointers
            cmaster.SendCallbacks();

            // set default rates
            int[] xcm_inrates = new int[8] {
                192000, 192000, 192000, 192000, 192000, 48000, 192000, 192000
            };
            int aud_outrate = 48000;

            int[] rcvr_ch_outrates = new int[5] {
                48000, 48000, 48000, 48000, 48000
            };
            int[] xmtr_ch_outrates = new int[1] {
                192000
            };

            fixed(int *p1 = xcm_inrates, p2 = rcvr_ch_outrates, p3 = xmtr_ch_outrates)
            cmaster.SetCMDefaultRates(p1, aud_outrate, p2, p3);

            // create receivers, transmitters, specials, and buffers
            cmaster.CreateRadio();

            // get transmitter idenifiers
            int txinid = cmaster.inid(1, 0);        // stream id
            int txch   = cmaster.chid(txinid, 0);   // wdsp channel

            // setup transmitter input sample rate here since it is fixed
            cmaster.SetXcmInrate(txinid, 48000);

            // setup CFIR to run; it will always be ON with new protocol firmware
            WDSP.SetTXACFIRRun(txch, true);

            // set PureSignal basic parameters
            // note:  if future models have different settings, these calls could be moved to
            //      CMLoadRouterAll() which is called each time the receiver model changes.
            SetPSRxIdx(0, 0);   // txid = 0, all current models use Stream0 for RX feedback
            SetPSTxIdx(0, 1);   // txid = 0, all current models use Stream1 for TX feedback
            puresignal.SetPSFeedbackRate(txch, 192000);
            puresignal.SetPSHWPeak(txch, 0.2899);

            // setup transmitter display
            WDSP.TXASetSipMode(txch, 1);            // 1=>call the appropriate 'analyzer'
            WDSP.TXASetSipDisplay(txch, txinid);    // disp = txinid = tx stream

            NetworkIO.CreateRNet();
            cmaster.create_rxa();

            // create_wb();
        }
Example #3
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)
                    {
                        NetworkIO.SetCWX(Convert.ToInt32(commPort.DsrHolding));
                    }
                    break;

                case SerialPinChange.CtsChanged:

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

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

                case SerialPinChange.CtsChanged:
                    NetworkIO.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;
                }
            }
        }
Example #4
0
 private void udRXAFreq_ValueChanged(object sender, EventArgs e)
 {
     NetworkIO.SetVFOfreq(fwid, NetworkIO.Freq2PW((int)(1000000.0 * (double)udRXAFreq.Value)), 0); // sending phaseword to firmware
     panDisplay.VFOHz = RXFreq;
 }
Example #5
0
File: Alex.cs Project: VK6VW/Thetis
        public void UpdateAlexAntSelection(Band band, bool tx, bool alex_enabled, bool xvtr)
        {
            if (!alex_enabled)
            {
                NetworkIO.SetAntBits(0, 0, 0, false);
                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;
            //    NetworkIO.SetAlexAntBits(rx_only_ant, trx_ant, xrx_out);
            //    init_update = false;
            //    Thread.Sleep(10);
            //}
            NetworkIO.SetAntBits(rx_only_ant, trx_ant, rx_out, tx);
            System.Console.WriteLine("Ant Rx Only {0} , Tx Ant {1}, Rx Out {2}", rx_only_ant.ToString(), trx_ant.ToString(), rx_out.ToString());

            // 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;
        }