예제 #1
1
void vrpn_HidInterface::update()
{
	if (!_working) {
		//fprintf(stderr,"vrpn_HidInterface::update(): Interface not currently working\n");
		return;
	}

        // Maximum packet size for USB is 512 characters.
	vrpn_uint8 inbuf[512];
	if (inbuf == NULL) {
		fprintf(stderr,"vrpn_HidInterface::update(): Out of memory\n");
		return;
	}

        int ret = hid_read(_device, inbuf, sizeof(inbuf));
        if (ret < 0) {
		fprintf(stderr,"vrpn_HidInterface::update(): Read error\n");
		return;
        }

        // Handle any data we got.  This can include fewer bytes than we
        // asked for.
        if (ret > 0) {
          vrpn_uint8 *data = static_cast<vrpn_uint8 *>(static_cast<void*>(inbuf));
          on_data_received(ret, data);
        }
}
예제 #2
0
void vrpn_HidInterface::update()
{
	if (!_working) {
		//fprintf(stderr,"vrpn_HidInterface::update(): Interface not currently working\n");
		return;
	}

        // Maximum packet size for USB is 512 characters.
	vrpn_uint8 inbuf[512];
	if (inbuf == NULL) {
		fprintf(stderr,"vrpn_HidInterface::update(): Out of memory\n");
		return;
	}

        int ret = hid_read(_device, inbuf, sizeof(inbuf));
        if (ret < 0) {
		fprintf(stderr,"vrpn_HidInterface::update(): Read error\n");
		fprintf(stderr,"  (On one version of Red Hat Linux, this was from not having libusb-devel installed when configuring in CMake.)\n");
		return;
        }

        // Handle any data we got.  This can include fewer bytes than we
        // asked for.
        if (ret > 0) {
          vrpn_uint8 *data = static_cast<vrpn_uint8 *>(static_cast<void*>(inbuf));
          on_data_received(ret, data);
        }
}
예제 #3
0
void MainWindow::on_Conectar_clicked()
{
    this->c = new Client(ui->HostInput->currentText(), ui->PortaInput->text().toInt());

    connect(c, SIGNAL(connectionSuccessful()), this, SLOT(on_connection_successful()));
    connect(c, SIGNAL(hasReadData()), this, SLOT(on_data_received()));

    //ui->HostInput->setEnabled(false);
    //ui->PortaInput->setEnabled(false);
}
예제 #4
0
void CyH4TransportDriver::on_controller_irq()
{
	assert_bt_dev_wake();

	while (uart.readable()) {
        uint8_t char_received = uart.getc();
        on_data_received(&char_received, 1);
    }

	deassert_bt_dev_wake();
}
예제 #5
0
파일: network_thread.c 프로젝트: remij/c
int32_t select_loop(int32_t sockfd, shared_threads_t *shared) {

  int32_t rc;
  
  nt_frame_t oframe;  
  memset(&oframe, 0, sizeof(oframe));
  
  uint8_t buff[BUFF_SIZE];

  while (shared->running) {
  
    /* Set up a 5 second select timeout */
    struct timeval timeout;
    timeout.tv_sec = 5;
    timeout.tv_usec = 0;

    fd_set read_fd;
    FD_ZERO(&read_fd);

    /* Just monitor our client socket */
    FD_SET(sockfd, &read_fd);

    /* Let's call select */
    rc = select(sockfd + 1, &read_fd, NULL, NULL, &timeout);

    /* An error occured */
    if (rc < 0) {
      fprintf(stderr, "[Error] select failed\n");
      shared->running = false;
    }
    /* Select timeout */
    else if (rc == 0) {
      fprintf(stdout, "[Debug] select timeout\n");
    }
    else {
      /* The socket is readable */
      if (FD_ISSET(sockfd, &read_fd)) {

	uint32_t read_bytes;

	/* Leave the select loop if an error occured */
	if ((read_bytes = read_socket(sockfd, buff)) <= 0) {
	  shared->running = false;
	}
	else {
	  on_data_received(shared->input_fifo, &oframe, buff, read_bytes);
	}
      }
    }
  }
  
  fprintf(stdout, "[Debug] leaving select loop\n");
  return (rc);
}
예제 #6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    serialPort = new QSerialPort(this);
    settings = new SettingsDialog;

    connect(serialPort, SIGNAL(readyRead()), this, SLOT(on_data_received()));

    ui->setupUi(this);
    grabKeyboard();
}
예제 #7
0
DecoderStack::DecoderStack(pv::SigSession &session,
	const srd_decoder *const dec) :
	_session(session),
	_sample_count(0),
	_frame_complete(false),
	_samples_decoded(0)
{
	connect(&_session, SIGNAL(frame_began()),
		this, SLOT(on_new_frame()));
	connect(&_session, SIGNAL(data_received()),
		this, SLOT(on_data_received()));
	connect(&_session, SIGNAL(frame_ended()),
		this, SLOT(on_frame_ended()));

	_stack.push_back(shared_ptr<decode::Decoder>(
		new decode::Decoder(dec)));
}
예제 #8
0
DecoderStack::DecoderStack(pv::Session &session,
	const srd_decoder *const dec) :
	session_(session),
	start_time_(0),
	samplerate_(0),
	sample_count_(0),
	frame_complete_(false),
	samples_decoded_(0)
{
	connect(&session_, SIGNAL(frame_began()),
		this, SLOT(on_new_frame()));
	connect(&session_, SIGNAL(data_received()),
		this, SLOT(on_data_received()));
	connect(&session_, SIGNAL(frame_ended()),
		this, SLOT(on_frame_ended()));

	stack_.push_back(shared_ptr<decode::Decoder>(
		new decode::Decoder(dec)));
}
예제 #9
0
	void netstream_threaded::operator()()
	{	binary_data tmp_data;

		// Post disconnect once the disconnect
		sem_disconnect.post();

		while(1)
		{
			// Wait for new socket
			sem_newsocket.wait();

			// On zombie-mode exit thread
			if (b_zombie)
				return;

			// We must be connected
			b_connected = true;
			on_connected();
			sem_connect.post();

			try{

				while(1)
				{
					tmp_data = netstream::receive(1024);
					on_data_received(tmp_data);
				}
			}
			catch(std::exception){}

			// We got disconnected
			b_connected = false;
			netstream::disconnect();	// Disconnect for sure
			on_disconnected();

			// Post event
			sem_disconnect.post();
		}
	}