コード例 #1
0
ファイル: hardware_usb.py プロジェクト: IW0HDV/quisk
 def run(self):
     while not self.doQuit.isSet():
         try:  # Test key up/down state
             ret = self.usb_dev.ctrl_transfer(IN, 0x51, 0, 0, 1)
         except usb.core.USBError:
             key_down = None
             if DEBUG: traceback.print_exc()
         else:
             # bit 0x20 is the tip, bit 0x02 is the ring (ring not used)
             if ret[0] & 0x20 == 0:  # Tip: key is down
                 key_down = True
             else:  # key is up
                 key_down = False
         if self.is_cw:
             if self.spot_level >= 0 or key_down:  # key is down
                 QS.set_key_down(1)
                 self.key_transmit = 1
                 self.key_timer = time.time()
             else:  # key is up
                 QS.set_key_down(0)
                 if self.key_transmit and time.time(
                 ) - self.key_timer > self.key_hang_time:
                     self.key_transmit = 0
             if self.key_transmit != self.currently_in_tx:
                 try:
                     self.usb_dev.ctrl_transfer(IN, 0x50, self.key_transmit,
                                                0, 3)
                 except usb.core.USBError:
                     if DEBUG: traceback.print_exc()
                 else:
                     self.currently_in_tx = self.key_transmit  # success
                     QS.set_transmit_mode(self.key_transmit)
                     if DEBUG:
                         print("Change CW currently_in_tx",
                               self.currently_in_tx)
         else:
             if key_down or self.ptt_button:
                 self.key_transmit = 1
             else:
                 self.key_transmit = 0
             if self.key_transmit != self.currently_in_tx:
                 QS.set_key_down(self.key_transmit)
                 try:
                     self.usb_dev.ctrl_transfer(IN, 0x50, self.key_transmit,
                                                0, 3)
                 except usb.core.USBError:
                     if DEBUG: traceback.print_exc()
                 else:
                     self.currently_in_tx = self.key_transmit  # success
                     if DEBUG:
                         print("Change currently_in_tx",
                               self.currently_in_tx)
         time.sleep(self.poll_secs)
コード例 #2
0
 def run(self):
   while not self.doQuit.isSet():
     try:		# Test key up/down state
       ret = self.usb_dev.ctrl_transfer(IN, 0x51, 0, 0, 1)
     except usb.core.USBError:
       key_down = None
       if DEBUG: traceback.print_exc()
     else:
       # bit 0x20 is the tip, bit 0x02 is the ring (ring not used)
       if ret[0] & 0x20 == 0:		# Tip: key is down
         key_down = True
       else:			# key is up
         key_down = False
     if self.is_cw:
       if self.spot_level >= 0 or key_down:		# key is down
         QS.set_key_down(1)
         self.key_transmit = 1
         self.key_timer = time.time()
       else:			# key is up
         QS.set_key_down(0)
         if self.key_transmit and time.time() - self.key_timer > self.key_hang_time:
           self.key_transmit = 0
       if self.key_transmit != self.currently_in_tx:
         try:
           self.usb_dev.ctrl_transfer(IN, 0x50, self.key_transmit, 0, 3)
         except usb.core.USBError:
           if DEBUG: traceback.print_exc()
         else:
           self.currently_in_tx = self.key_transmit	# success
           QS.set_transmit_mode(self.key_transmit)
           if DEBUG: print ("Change CW currently_in_tx", self.currently_in_tx)
     else:
       if key_down or self.ptt_button:
         self.key_transmit = 1
       else:
         self.key_transmit = 0
       if self.key_transmit != self.currently_in_tx:
         QS.set_key_down(self.key_transmit)
         try:
           self.usb_dev.ctrl_transfer(IN, 0x50, self.key_transmit, 0, 3)
         except usb.core.USBError:
           if DEBUG: traceback.print_exc()
         else:
           self.currently_in_tx = self.key_transmit	# success
           if DEBUG: print ("Change currently_in_tx", self.currently_in_tx)
     time.sleep(self.poll_secs)
コード例 #3
0
 def OnButtonPTT(self, event=None):
   if event:
     if event.GetEventObject().GetValue():
       self.ptt_button = 1
     else:
       self.ptt_button = 0
   if self.key_thread:
     self.key_thread.OnPTT(self.ptt_button)
   elif self.usb_dev:
     if self.is_cw:
       QS.set_key_down(0)
       QS.set_transmit_mode(self.ptt_button)
     else:
       QS.set_key_down(self.ptt_button)
     try:
       self.usb_dev.ctrl_transfer(IN, 0x50, self.ptt_button, 0, 3)
     except usb.core.USBError:
       if DEBUG: traceback.print_exc()
       try:
         self.usb_dev.ctrl_transfer(IN, 0x50, self.ptt_button, 0, 3)
       except usb.core.USBError:
         if DEBUG: traceback.print_exc()
コード例 #4
0
ファイル: hardware_usb.py プロジェクト: IW0HDV/quisk
 def OnButtonPTT(self, event=None):
     if event:
         if event.GetEventObject().GetValue():
             self.ptt_button = 1
         else:
             self.ptt_button = 0
     if self.key_thread:
         self.key_thread.OnPTT(self.ptt_button)
     elif self.usb_dev:
         if self.is_cw:
             QS.set_key_down(0)
             QS.set_transmit_mode(self.ptt_button)
         else:
             QS.set_key_down(self.ptt_button)
         try:
             self.usb_dev.ctrl_transfer(IN, 0x50, self.ptt_button, 0, 3)
         except usb.core.USBError:
             if DEBUG: traceback.print_exc()
             try:
                 self.usb_dev.ctrl_transfer(IN, 0x50, self.ptt_button, 0, 3)
             except usb.core.USBError:
                 if DEBUG: traceback.print_exc()
コード例 #5
0
ファイル: quisk_hardware.py プロジェクト: jmharvey1/SdrCwXcvr
    def run(self):
        while not self.doQuit.isSet():
            if DEBUG:
                if not self.text == "":
                    print("DeBug: self.text: %s" % self.text)
                    self.text = ""

            try:  # Test key up/down state
                #ret = self.usb_dev.ctrl_transfer(IN, 0x51, 0, 0, 1)
                if self.serial:  ##JMH 20190909 ADDED to support keying SSMicro via external key
                    chars = self.serial.read(1024)
                    if chars:
                        if (self.HrdwrTalk): print("SSMicro: %s" % chars)
                        if (chars[0:6] == "KEYDWN"):
                            self.key_down = True
                            self.stateChng = True
                            self.stateChng1 = True
                        if (chars[0:5] == "KEYUP"):
                            self.key_down = False
                            self.stateChng = True
                            self.stateChng1 = True

            except usb.core.USBError:
                if DEBUG: traceback.print_exc()
            if self.is_cw:
                if self.stateChng:
                    if self.spot_level >= 0 or self.key_down:  # key is down
                        QS.set_key_down(1)
                        self.key_transmit = 1
                        #self.key_timer = time.time()
                    else:  # key is up
                        QS.set_key_down(0)
##            if self.key_transmit and time.time() - self.key_timer > self.key_hang_time:
##              self.key_transmit = 0
                    self.stateChng = False
                if self.spot_level >= 0 or self.key_down:  # key is down
                    self.key_timer = time.time()
                else:
                    if self.key_transmit and time.time(
                    ) - self.key_timer > self.key_hang_time:
                        self.key_transmit = 0

                if self.key_transmit != self.currently_in_tx:
                    QS.set_transmit_mode(self.key_transmit)
                    #wx.CallAfter(self.application.OnButtonPTT(None))
                    #self.application.pttButton.SetValue(0, self.key_transmit)
                    #self.ptt_button = self.key_transmit
                    self.currently_in_tx = self.key_transmit  # success


##          try:
##            #self.usb_dev.ctrl_transfer(IN, 0x50, self.key_transmit, 0, 3)
##            print("key_transmit state %d" %self.key_transmit)
##          except usb.core.USBError:
##            if DEBUG: traceback.print_exc()
##          else:
##            self.currently_in_tx = self.key_transmit	# success
##            QS.set_transmit_mode(self.key_transmit)
##            if DEBUG: print ("Change CW currently_in_tx", self.currently_in_tx)
##      else:  #weare not in the CW mode
##        if self.key_down or self.ptt_button:
##          self.key_transmit = 1
##        else:
##          self.key_transmit = 0
##        if self.key_transmit != self.currently_in_tx:
##          QS.set_key_down(self.key_transmit)
##          try:
##            #self.usb_dev.ctrl_transfer(IN, 0x50, self.key_transmit, 0, 3)
##            print("key_transmit state %d" %self.key_transmit)
##          except usb.core.USBError:
##            if DEBUG: traceback.print_exc()
##          else:
##            self.currently_in_tx = self.key_transmit	# success
##            if DEBUG: print ("Change currently_in_tx", self.currently_in_tx)
            time.sleep(self.poll_secs)