コード例 #1
0
/**
 * Handle a INFO message
 */
void RobeWidgetDetector::HandleInfoMessage(DispatchingRobeWidget *widget,
                                           const uint8_t *data,
                                           unsigned int length) {
  struct {
    uint8_t hardware_version;
    uint8_t software_version;
    uint8_t eeprom_version;
    uint8_t empty;
    uint8_t empty2;
  } info_response;

  WidgetStateMap::iterator iter = m_widgets.find(widget);
  if (iter == m_widgets.end())
    return;

  if (length != sizeof(info_response)) {
    OLA_WARN << "Info response size " << length << " != " <<
      sizeof(info_response);
    return;
  } else {
    memcpy(reinterpret_cast<uint8_t*>(&info_response),
           data,
           sizeof(info_response));
    iter->second.information.hardware_version = info_response.hardware_version;
    iter->second.information.software_version = info_response.software_version;
    iter->second.information.eeprom_version = info_response.eeprom_version;
  }

  RemoveTimeout(&iter->second);
  SetupTimeout(widget, &iter->second);
  widget->SendMessage(BaseRobeWidget::UID_REQUEST, NULL, 0);
}
コード例 #2
0
/*
 * Start the discovery process for a widget
 * @param widget, the RobeWidget to run discovery on.
 * @return true if the process started ok, false otherwise.
 */
bool RobeWidgetDetector::Discover(
    ola::io::ConnectedDescriptor *descriptor) {
  DispatchingRobeWidget *widget = new DispatchingRobeWidget(descriptor);
  widget->SetHandler(
    NewCallback(this, &RobeWidgetDetector::HandleMessage, widget));

  if (!widget->SendMessage(BaseRobeWidget::INFO_REQUEST, NULL, 0)) {
    delete widget;
    return false;
  }

  // Set the onclose handler so we can mark this as failed.
  descriptor->SetOnClose(NewSingleCallback(this,
                         &RobeWidgetDetector::WidgetRemoved,
                         widget));

  // Register a timeout for this widget
  SetupTimeout(widget, &m_widgets[widget]);
  return true;
}
コード例 #3
0
ファイル: SerialAdapter.cpp プロジェクト: kodack64/touchsynth
bool SerialAdapter::Init()
{
	f_init=true;
	f_loop=false;
	f_start=false;

	Logger::Println("[SerialPort]	Initialize");

	string mySection="Serial";
	string str = ApplicationProperty::ReadSetupString(mySection.c_str(),"ComName","COM3");
	int fps = ApplicationProperty::ReadSetupInt(mySection.c_str(),"Fps",60);
	strcpy_s(comName,"COM3");
	ncomcfg=sizeof(comcfg);

	hPort = CreateFile(
		comName,
		GENERIC_READ,
		0,
		NULL,
		OPEN_EXISTING,
		FILE_ATTRIBUTE_NORMAL,
		NULL
		);

	if(hPort == INVALID_HANDLE_VALUE){
		Logger::Println("[SerialPort]	Error : CreateFile Fail");
		goto error;
	}

	if(!SetupComm(hPort,1024,1024)){
		Logger::Println("[SerialPort]	Error : SetupComm Fail");
		goto error;
	}

	if(!PurgeComm(hPort,PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR)){
		Logger::Println("[SerialPort]	Error : PurgeComm Fail");
		goto error;
	}

	GetCommConfig(hPort,&comcfg,&ncomcfg);
	if(!SetCommConfig(hPort, &comcfg,ncomcfg))
	{
		Logger::Println("[SerialPort]	Error : SetCommState Fail");
		goto error;
	}
	
	COMMTIMEOUTS timeout;
	SetupTimeout(&timeout);
	if(!SetCommTimeouts(hPort, &timeout)){
		Logger::Println("[SerialPort]	Error : SetCommTimeouts Fail");
		goto error;
	}

	unsigned int id;
	myHandle=(HANDLE)_beginthreadex(NULL,0,SerialAdapter::Launch,this,0,&id);
	if(myHandle==NULL){
		Logger::Println("[SerialPort]	Error : Thread Error");
		goto error;
	}
	return true;

error:
	f_init=false;
	return false;
}
コード例 #4
0
void NoopIdleCommand::RunImpl()
{
	SetupTimeout();
}