Exemple #1
0
static int32_t Azbox_Reset(struct s_reader *reader, ATR *atr)
{
  int32_t status;
  unsigned char tmp[512];

  memset(tmp, 0, sizeof(tmp));
  tmp[0] = 3;
  tmp[1] = 1;

  ioctl(reader->handle, SCARD_IOC_WARMRESET, &tmp);

  cs_sleepms(500);

  while ((status = _GetStatus(reader, NULL)) != 3)
    cs_sleepms(50);

  tmp[0] = 0x02;
  tmp[1] = sc_mode;
  status = ioctl(reader->handle, SCARD_IOC_CHECKCARD, &tmp);

  memset(tmp, 0, sizeof(tmp));
  tmp[0] = 1;

  int32_t atr_len = ioctl(reader->handle, SCARD_IOC_CHECKCARD, &tmp);
  if (ATR_InitFromArray(atr, tmp, atr_len) == ERROR)
    return 0;

   cs_sleepms(500);

   return OK;
}
Exemple #2
0
void RimeWithWeaselHandler::_UpdateUI(UINT session_id)
{
	weasel::Status weasel_status;
	weasel::Context weasel_context;

	bool is_tsf = _IsSessionTSF(session_id);

	if (session_id == 0)
		weasel_status.disabled = m_disabled;

	_GetStatus(weasel_status, session_id);

	if (!is_tsf) {
		_GetContext(weasel_context, session_id);
	}

	if (!m_ui) return;
	if (RimeGetOption(session_id, "inline_preedit"))
		m_ui->style().client_caps |= weasel::INLINE_PREEDIT_CAPABLE;
	else
		m_ui->style().client_caps &= ~weasel::INLINE_PREEDIT_CAPABLE;


	if (weasel_status.composing)
	{
		m_ui->Update(weasel_context, weasel_status);
		if (!is_tsf) m_ui->Show();
	}
	else if (!_ShowMessage(weasel_context, weasel_status))
	{
		m_ui->Hide();
		m_ui->Update(weasel_context, weasel_status);
	}
	
	// Dangerous, don't touch
	static char app_name[50];
	RimeGetProperty(session_id, "client_app", app_name, sizeof(app_name) - 1);
	if (utf8towcs(app_name) == std::wstring(L"explorer.exe") && m_vista_greater) {
		boost::thread th([=]() {
			::Sleep(100);
			if (_UpdateUICallback) _UpdateUICallback();
		});
	}
	else {
		if (_UpdateUICallback) _UpdateUICallback();
	}

	m_message_type.clear();
	m_message_value.clear();
}
Exemple #3
0
static int32_t Azbox_GetStatus(struct s_reader *reader, int32_t *in)
{
  unsigned char tmp[512];
  memset (tmp, 0, sizeof(tmp));

  int32_t status = _GetStatus(reader, in);

  if (in) {
    if (status != 1 && status != 3)
      *in = 0;
    else
      *in = 1;

    //rdr_debug_mask(reader, D_DEVICE, "openxcas sc: get status = %d", *in);
  }

  return OK;
}
/**
 * Call this function periodically outside the interrupt context to process commands
 */
void Command_Task()
{
	if(CommandStatus != CommandStateFinishedReceiving)
		return;

	LED_GREEN_ClrVal();

	CommandStatus = CommandStateExecuting;

	uint32 intendedAddress = 0; // this is the address the packet is intended for
//	uint32 intendedAddress = ( (uint32)ReceiveBuffer[1] << 24 ) | ( (uint32)ReceiveBuffer[2] << 16 ) | ( (uint32)ReceiveBuffer[3] << 8 ) | (uint32)ReceiveBuffer[4];
//	intendedAddress = (intendedAddress << 8) + ReceiveBuffer[4];
//	intendedAddress = (intendedAddress << 8) + ReceiveBuffer[3];
//	intendedAddress = (intendedAddress << 8) + ReceiveBuffer[2];
//	intendedAddress = (intendedAddress << 8) + ReceiveBuffer[1];
	intendedAddress |= ReceiveBuffer[4] & 0xFF;
	intendedAddress <<= 8;
	intendedAddress |= ReceiveBuffer[3] & 0xFF;
	intendedAddress <<= 8;
	intendedAddress |= ReceiveBuffer[2] & 0xFF;
	intendedAddress <<= 8;
	intendedAddress |= ReceiveBuffer[1] & 0xFF;

	if(intendedAddress == MyAddress || intendedAddress == 0) // 0 = broadcast
	{
		switch(ReceiveBuffer[5])
		{
		case CommandPing:
			_Ping();
			break;
		case CommandConfigure:
			_Configure(&ReceiveBuffer[6]);
			break;
		case CommandHomeUp:
			//_HomeUp();
			break;
		case CommandHomeDown:
			//_HomeDown();
			break;
		case CommandMoveTo:
			_MoveTo(&ReceiveBuffer[6]);
			break;
		case CommandGetStatus:
			_GetStatus();
			break;
		case CommandAssociate:
			_Associate();
			break;
		case CommandIdentifyLed:
			_IdentifyLed(ReceiveBuffer[6]);
			break;
		case CommandJog:
			_Jog(&ReceiveBuffer[6]);
			break;
		case CommandResetCounters:
			_ResetCounter(ReceiveBuffer[6], ReceiveBuffer[7]);
			break;
		case CommandDoubleMoveTo:
			_DoubleMoveTo(&ReceiveBuffer[6]);
			break;
		case CommandSetPosGetData:
			_SetPosGetData(&ReceiveBuffer[6]);
			break;
		case CommandGetHallPos:
			_GetHallPos();
			break;
		case CommandGetPots:
			_GetPots();
			break;
		case CommandGetCurremt:
			_GetCurrent();
			break;
		}
	}
	CommandStatus = CommandStateWaiting;
	LED_GREEN_SetVal();
}
void _SetPosGetData(char* buffer)
{
	_DoubleMoveTo(buffer);
	_GetStatus();
}