Пример #1
0
        private static byte ReceiveBit(HW hw)
        {
            int count = 0;

            // take X2-5 high
            hw.X2 |= 1 << 4;

            // wait for pin 12 to go high
            while ((hw.StatusPort() & (byte)StatusPin.PIN_12) == 0)
            {
                if (count++ > TIME_OUT_COUNT)
                {
                    MessageBox.Show("Error receiving bit from UCB.",
                                    "UCB Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return(2);
                }
                Thread.Sleep(1);
            }

            // set X2-5 low
            hw.X2 &= 0xEF;
            Thread.Sleep(new TimeSpan(receive_bit_delay1));

            byte retval = 0;

            if ((hw.StatusPort() & (byte)StatusPin.PIN_12) != 0)
            {
                retval = 1;
            }

            Thread.Sleep(receive_bit_delay2);
            return(retval);
        }
Пример #2
0
        /// <summary>
        /// Sends a single bit to the UCB
        /// </summary>
        /// <param name="hw">A hardware control object.</param>
        /// <param name="val">An integer representing a 0 or a 1.
        /// (Anything other than 0 is considered a 1)</param>
        private static bool SendBit(HW hw, int val)
        {
            int count = 0;

            // take X2-5 high
            hw.X2 |= 0x10;

            // wait for pin 12 to go high
            while ((hw.StatusPort() & (byte)StatusPin.PIN_12) == 0)
            {
                if (count++ > TIME_OUT_COUNT)
                {
                    MessageBox.Show("Error sending bit to UCB (1).",
                                    "UCB Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return(false);
                }
                Thread.Sleep(1);
            }

            // set X2-5 for data bit
            if (val == 0)
            {
                hw.X2 &= 0xEF;
            }
            count = 0;
            if ((hw.StatusPort() & (byte)StatusPin.PIN_12) == 0)
            {
                MessageBox.Show("Error sending bit to UCB (2).",
                                "UCB Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return(false);
            }

            // wait until pin 12 goes back low
            count = 0;
            while ((hw.StatusPort() & (byte)StatusPin.PIN_12) != 0)
            {
                if (count++ > TIME_OUT_COUNT)
                {
                    MessageBox.Show("Error sending bit to UCB (3).",
                                    "UCB Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return(false);
                }
                Thread.Sleep(1);
            }
            //Thread.Sleep(new TimeSpan(send_bit_delay1));

            // set X2-5 back low
            hw.X2 &= 0xEF;

            Thread.Sleep(new TimeSpan(send_bit_delay2));
            return(true);
        }
Пример #3
0
		private static byte ReceiveBit(HW hw)
		{
			int count = 0;

			// take X2-5 high
			hw.X2 |= 1<<4;

			// wait for pin 12 to go high
			while((hw.StatusPort() & (byte)StatusPin.PIN_12) == 0)
			{
				if(count++ > TIME_OUT_COUNT)
				{
					MessageBox.Show("Error receiving bit from UCB.",
						"UCB Error",
						MessageBoxButtons.OK,
						MessageBoxIcon.Error);
					return 2;
				}
				Thread.Sleep(1);
			}

			// set X2-5 low
			hw.X2 &= 0xEF;
			Thread.Sleep(new TimeSpan(receive_bit_delay1));

			byte retval = 0;
			if((hw.StatusPort() & (byte)StatusPin.PIN_12) != 0)
				retval = 1;

			Thread.Sleep(receive_bit_delay2);
			return retval;
		}
Пример #4
0
		/// <summary>
		/// Sends a single bit to the UCB
		/// </summary>
		/// <param name="hw">A hardware control object.</param>
		/// <param name="val">An integer representing a 0 or a 1.
		/// (Anything other than 0 is considered a 1)</param>
		private static bool SendBit(HW hw, int val)
		{
			int count = 0;

			// take X2-5 high
			hw.X2 |= 0x10;
	
			// wait for pin 12 to go high
			while((hw.StatusPort() & (byte)StatusPin.PIN_12) == 0)
			{
				if(count++ > TIME_OUT_COUNT)
				{
					MessageBox.Show("Error sending bit to UCB (1).",
						"UCB Error",
						MessageBoxButtons.OK,
						MessageBoxIcon.Error);
					return false;
				}
				Thread.Sleep(1);				
			}

			// set X2-5 for data bit
			if(val == 0) hw.X2 &= 0xEF;
			count = 0;
			if((hw.StatusPort() & (byte)StatusPin.PIN_12) == 0)
			{
				MessageBox.Show("Error sending bit to UCB (2).",
					"UCB Error",
					MessageBoxButtons.OK,
					MessageBoxIcon.Error);
				return false;
			}

			// wait until pin 12 goes back low
			count = 0;
			while((hw.StatusPort() & (byte)StatusPin.PIN_12) != 0)
			{
				if(count++ > TIME_OUT_COUNT)
				{
					MessageBox.Show("Error sending bit to UCB (3).",
						"UCB Error",
						MessageBoxButtons.OK,
						MessageBoxIcon.Error);
					return false;
				}
				Thread.Sleep(1);
			}
			//Thread.Sleep(new TimeSpan(send_bit_delay1));

			// set X2-5 back low
			hw.X2 &= 0xEF;

			Thread.Sleep(new TimeSpan(send_bit_delay2));
			return true;
		}
Пример #5
0
        public void KeyThread()
        {
            //SetThreadAffinity(1);
            bool extkey_dash, extkey_dot, keyprog;

            do
            {
                DttSP.KeyerStartedWait();
                for (; DttSP.KeyerRunning();)
                {
                    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 "Radio":
                        extkey_dot  = fwc_dot;
                        extkey_dash = fwc_dash;
                        break;

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

                    // handle CWX
                    if (!extkey_dash && !extkey_dot)
                    {
                        if (memoryptt)
                        {
                            //console ptt on
                            keyprog    = true;
                            extkey_dot = extkey_dash = memorykey;
                        }
                        else
                        {
                            //console ptt off
                            keyprog = false;
                        }
                    }

                    if (!extkey_dash && !extkey_dot)                     // don't override primary
                    {
                        switch (secondary_conn_port)
                        {
                        case "None":
                            break;

                        case "CAT":
                            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);
                            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
                            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;
                            }

                            break;
                        }
                        if (extkey_dash || extkey_dot)
                        {
                            keyprog = true;
                        }
                        else
                        {
                            keyprog = false;
                        }
                        //Debug.WriteLine("keyprog: "+keyprog);
                    }
                    timer.Stop();
                    msdel = (float)timer.DurationMsec;
                    //Debug.WriteLine("Dash: "+extkey_dash+" Dot: "+extkey_dot);
                    DttSP.KeyValue(msdel, extkey_dash, extkey_dot, keyprog);
                }
            } while(threads_running);
        }
Пример #6
0
        public void KeyThread()
        {
            byte extkey_dash, extkey_dot;

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

                    default:                             // COM port
                        extkey_dash = System.Convert.ToByte(sp.CtsHolding);
                        extkey_dot  = System.Convert.ToByte(sp.DsrHolding);
                        break;
                    }

                    // [patch_16
                    // M0PUB : also allow keying via USB-connected AVR processor, running DG8SAQ firmware
                    if ((extkey_dash == 0) && (extkey_dot == 0))                     // don't override primary
                    {
                        extkey_dot = extkey_dash = Console.GetDG8SAQkeyStatus();
                    }
                    // patch_16]

                    if (memoryptt)
                    {
                        //console ptt on
                        keyprog    = 1;
                        extkey_dot = extkey_dash = System.Convert.ToByte(memorykey);
                    }
                    else
                    {
                        keyprog = 0;
                        //console ptt off
                    }
                    switch (secondary_conn_port)
                    {
                    case "None":
                        break;

                    case "CAT":
                        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(siolisten.SIO.isDSR());
                                }
                                else
                                {
                                    extkey_dot = System.Convert.ToByte(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 = System.Convert.ToByte(siolisten.SIO.isDSR());
                                }
                                else
                                {
                                    extkey_dot = System.Convert.ToByte(siolisten.SIO.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(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 = System.Convert.ToByte(siolisten.SIO.isCTS());
                                break;
                            }

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

                        break;

                    default:                                         // comm port
                        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(sp2.DsrHolding);
                                }
                                else
                                {
                                    extkey_dot = System.Convert.ToByte(sp2.CtsHolding);
                                }
                                break;

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                keyerptt = sp2.DsrHolding;
//										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 = sp2.CtsHolding;
//										extkey_dash  = System.Convert.ToByte(sp2.DsrHolding);
                                break;
                            }

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

                            case KeyerLine.DTR:                                             // look at DSR since we are on the other side of the null modem cable
                                extkey_dot = System.Convert.ToByte(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 = System.Convert.ToByte(sp2.CtsHolding);
                                break;
                            }

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

                        break;
                    }
                    timer.Stop();
                    msdel = (float)timer.DurationMsec;
                    DttSP.KeyValue(msdel, extkey_dash, extkey_dot, keyprog);
                }
            } while(true);
        }