code: def _handle_invalid_read_response(self, res, expected_len):
          
          if not res:
              reset(self.stick)
              raise pyhsm.exception.YHSM_Error('YubiHSM did not respond to command %s' \
                                                   % (pyhsm.defines.cmd2str(self.command)) )
          # try to check if it is a YubiHSM in configuration mode
          self.stick.write('\r\r\r', '(mode test)')
          res2 = self.stick.read(50) # expect a timeout
          lines = res2.split('\n')
          for this in lines:
              if re.match('^(NO_CFG|WSAPI|HSM).*> .*', this):
                  raise pyhsm.exception.YHSM_Error('YubiHSM is in configuration mode')
          raise pyhsm.exception.YHSM_Error('Unknown response from serial device %s : "%s"' \
                                               % (self.stick.device, res.encode('hex')))
docs: This function is called when we do not get the expected frame header in
          response to a command. Probable reason is that we are not talking to a
          YubiHSM in HSM mode (might be a modem, or a YubiHSM in configuration mode).
  
          Throws a hopefully helpful exception.