Пример #1
0
void LibDevice::leave(AppId parent_id, const void *obj, lh_device *dev )
{
    Q_UNUSED(obj);
    Q_ASSERT(dev && dev->devid);

    if(dev && dev->devid)
    {
        LibDevicePointer *ldp = 0;
        QString device_id(QString::fromLatin1(dev->devid).replace('/', '-'));
        if(LibLibrary *parent_lib = static_cast<LibLibrary *>(parent_id.lock()))
        {
            ldp = parent_lib->findChild<LibDevicePointer *>(device_id);
            if(ldp)
                ldp->clear();
            parent_id.unlock();
            if(ldp)
                parent_id.postAppEvent(new EventDestroyAppDevice(dev->devid), Qt::HighEventPriority+1);
        }
        else
            qCritical("LibDevice::leave(%s): parent_id.lock() failed (%d)%s",
                      dev->devid, parent_id.toInt(), parent_id.hasLibObject() ? "" : " (no LibObject)");
    }

    return;
}
Пример #2
0
/*-------------------------------------------------------------------------
 * Function : API_DeviceId
 *            get the device identification (ID) for the current device.
 * Input    : *pars_p, *result_sym_p
 * Output   :
 * Return   : TRUE if ok, else FALSE
 * ----------------------------------------------------------------------*/
static BOOL API_DeviceId( STTST_Parse_t *pars_p, char *result_sym_p )
{
    BOOL RetErr = FALSE;
#ifdef ST_OS20
    device_id_t devid;
#endif /* ST_OS20 */
    UNUSED_PARAMETER(pars_p);
    UNUSED_PARAMETER(result_sym_p);

#ifdef ST_OSLINUX
    sprintf(API_Msg, "Device Id not available\n\n");
#else
#ifdef ST_OS20
    devid = device_id();
    sprintf(API_Msg, "Device 0x%x (%s)\n\n", devid.id, device_name(devid));
#endif /* ST_OS20 */

#ifdef ST_OS21
    sprintf(API_Msg, "Device (%s)\n\n", kernel_chip());
#endif /* ST_OS21 */

#endif
    STTBX_Print(( API_Msg ));
    return ( API_EnableError ? RetErr : FALSE );
} /* end of API_DeviceId */
Пример #3
0
void LibDevice::arrive(AppId parent_id, const void *obj, lh_device* dev)
{
    Q_UNUSED(obj);
    Q_ASSERT(dev && dev->devid);

    if(dev && dev->devid)
    {
        LibDevicePointer *ldp = 0;
        QString device_id(QString::fromLatin1(dev->devid).replace('/', '-'));
        if(LibLibrary *parent_lib = static_cast<LibLibrary *>(parent_id.lock()))
        {
            ldp = parent_lib->findChild<LibDevicePointer *>(device_id);
            if(ldp == 0)
                new LibDevicePointer(dev, device_id, parent_lib);
            parent_id.unlock();
            if(ldp == 0)
            {
                parent_id.postAppEvent(new EventCreateAppDevice(
                                           QByteArray(dev->devid),
                                           QString::fromUtf8(dev->name),
                                           QSize(dev->width, dev->height),
                                           dev->depth,
                                           !dev->noauto
                                           ), Qt::HighEventPriority+1);
            }
        }
        else
            qCritical("LibDevice::arrive(%s): parent_id.lock() failed (%d)%s",
                      dev->devid, parent_id.toInt(), parent_id.hasLibObject() ? "" : " (no LibObject)");
    }

    return;
}
Пример #4
0
	inline StorageDevice *storage_device()
	{
		StorageDevice *sd = new StorageDevice();
		
		sd->device_id = device_id();
		sd->node_id = node_id();
		sd->model_name = randr_string(5, "sd-model-");
		sd->local_address = randr_string(5, "sd-address-");
		
		return sd;
	}
Пример #5
0
  static entry make_from_json(const nlohmann::json& json) {
    entry result(device_id(0),
                 event_time_stamp(absolute_time_point(0)),
                 event(),
                 event_type::key_down,
                 event());

    if (json.is_object()) {
      if (auto v = pqrs::json::find<uint32_t>(json, "device_id")) {
        result.device_id_ = device_id(*v);
      }

      if (auto v = pqrs::json::find_json(json, "event_time_stamp")) {
        result.event_time_stamp_ = event_time_stamp::make_from_json(v->value());
      }

      if (auto v = pqrs::json::find<bool>(json, "valid")) {
        result.valid_ = *v;
      }

      if (auto v = pqrs::json::find<bool>(json, "lazy")) {
        result.lazy_ = *v;
      }

      if (auto v = pqrs::json::find_json(json, "event")) {
        result.event_ = event::make_from_json(v->value());
      }

      if (auto v = pqrs::json::find_json(json, "event_type")) {
        result.event_type_ = v->value().get<event_type>();
      }

      if (auto v = pqrs::json::find_json(json, "original_event")) {
        result.original_event_ = event::make_from_json(v->value());
      }
    }

    return result;
  }
Пример #6
0
int main()
{
	std::string device_id ("");
	pcl::OpenNIGrabber::Mode image_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;

	pcl::OpenNIGrabber grabber (device_id, pcl::OpenNIGrabber::OpenNI_Default_Mode, image_mode);

//	grabber.start();

	image_viewer v(grabber);

	v.run();

	while (1)
	{
	}
	
	return 0;
}
Пример #7
0
/*
 * If hotplug isn't supported, this is called periodically to checked for
 * USB devices that have been added or removed.
 *
 * This is run within the main thread, since the libusb thread only runs if at
 * least one USB device is used.
 */
bool AsyncPluginImpl::ScanUSBDevices() {
  OLA_INFO << "Scanning USB devices....";
  std::set<USBDeviceID> current_device_ids;

  libusb_device **device_list;
  size_t device_count = libusb_get_device_list(m_context, &device_list);

  OLA_INFO << "Got " << device_count << " devices";
  for (unsigned int i = 0; i < device_count; i++) {
    libusb_device *usb_device = device_list[i];

    USBDeviceID device_id(libusb_get_bus_number(usb_device),
                          libusb_get_device_address(usb_device));

    current_device_ids.insert(device_id);

    if (!STLContains(m_seen_usb_devices, device_id)) {
      OLA_INFO << "  " << usb_device;
      bool claimed = USBDeviceAdded(usb_device);
      STLReplace(&m_seen_usb_devices, device_id, claimed ? usb_device : NULL);
    }
  }
  libusb_free_device_list(device_list, 1);  // unref devices

  USBDeviceIDs::iterator iter = m_seen_usb_devices.begin();
  while (iter != m_seen_usb_devices.end()) {
    if (!STLContains(current_device_ids, iter->first)) {
      if (iter->second) {
        USBDeviceRemoved(iter->second);
      }
      m_seen_usb_devices.erase(iter++);
    } else {
      iter++;
    }
  }
  return true;
}
Пример #8
0
int jvs_device::handle_message(const UINT8 *send_buffer, UINT32 send_size, UINT8 *&recv_buffer)
{
	UINT32 old_reset_counter = jvs_reset_counter;
	jvs_reset_counter = 0;

	switch(send_buffer[0]) {
	case 0xf0:
		if(send_size < 2 || send_buffer[1] != 0xd9)
			return 0;

		// Reset, must be sent twice
		jvs_reset_counter = old_reset_counter+1;
		if(jvs_reset_counter == 2)
			device_reset();
		return 2;

	case 0x10: {
		const char *id = device_id();
		int len = strlen(id)+1;
		*recv_buffer++ = 0x01;
		memcpy(recv_buffer, id, len);
		recv_buffer += len;
		return 1;
	}

	case 0x11:
		*recv_buffer++ = 0x01;
		*recv_buffer++ = command_format_version();
		return 1;

	case 0x12:
		*recv_buffer++ = 0x01;
		*recv_buffer++ = jvs_standard_version();
		return 1;

	case 0x13:
		*recv_buffer++ = 0x01;
		*recv_buffer++ = comm_method_version();
		return 1;

	case 0x14:
		*recv_buffer++ = 0x01;
		function_list(recv_buffer);
		*recv_buffer++ = 0x00;
		return 1;

	case 0x20:
		if(send_size < 3)
			return 0;
		*recv_buffer++ = 0x01;
		return switches(recv_buffer, send_buffer[1], send_buffer[2]) ? 3 : 0;

	case 0x21:
		if(send_size < 2)
			return 0;
		*recv_buffer++ = 0x01;
		return coin_counters(recv_buffer, send_buffer[1]) ? 2 : 0;

	case 0x22:
		if(send_size < 2)
			return 0;
		*recv_buffer++ = 0x01;
		return analogs(recv_buffer, send_buffer[1]) ? 2 : 0;

	case 0x30:
		if(send_size < 4)
			return 0;
		*recv_buffer++ = 0x01;
		return coin_add(send_buffer[1], -((send_buffer[2] << 8) | send_buffer[3])) ? 4 : 0;

	case 0x31:
		if(send_size < 4)
			return 0;
		*recv_buffer++ = 0x01;
		return coin_add(send_buffer[1],  ((send_buffer[2] << 8) | send_buffer[3])) ? 4 : 0;

	case 0x32:
		if(send_size < 2 || send_size < 2+send_buffer[1])
			return 0;
		*recv_buffer++ = 0x01;
		return swoutputs(send_buffer[1], send_buffer+2) ? 2+send_buffer[1] : 0;

	case 0x38:
		if(send_size < 3)
			return 0;
		*recv_buffer++ = 0x01;
		return swoutputs(send_buffer[1], send_buffer[2]) ? 3 : 0;

	default:
		logerror("JVSDEV: unhandled command %02x\n", send_buffer[0]);
		return 0;
	}

	return -1;
}
Пример #9
0
bool benchmark::write_test_data_csv(
	const char * file_name,
	const base::stats_data & stats,
	const float time,
	const int nframes,
	bool is_dummy)
{
	FILE * pFile;
	pFile = fopen(file_name, "r+");

	if (pFile == NULL){
		pFile = fopen(file_name, "w");
		if (pFile == NULL){
			return false;
		}

		fputs(
			"test_name,"
			"gpu_gl_name,"
			"use_vbo,"
			"tex_freq,"
			"tex_mode,"
			"mesh_size,"
			"one_mesh,"
			"frames,"
			"render_time,"
			"cpu_render_time (ms),"
			"gpu_render_time (ms),"
			"dc,"
			"ntri (Mtri),"
			"nverts (Mvtx),"
			"buf_mem (MB),"
			"tex_mem (MB),"
			"gpu_vendor,"
			"gpu_drv_ver,"
			"gpu_vendor_id,"
			"gpu_device_id,"
			"gpu_rev_id,"
			"test_status",
			pFile);
	}
	else{
		fseek(pFile, 0, SEEK_END);
	}

	if (!is_dummy){
	std::ostringstream oss;
	std::string vendor_id("");
	std::string device_id("");
	std::string rev_id("");

	oss << std::hex << _renderer->get_vendor_id();
	vendor_id = oss.str();
	oss.str("");

	oss << std::hex << _renderer->get_device_id();
	device_id = oss.str();
	oss.str("");

	oss << std::hex << _renderer->get_rev_id();
	rev_id = oss.str();
	oss.str("");

	fprintf(
		pFile,
		"\n%s,%s,%s,%i,%u,%i,%s,%u,%f,%f,%f,%u,%llu,%llu,%u,%u,%s,%s,%s,%s,%s,OK",
		this->get_test_name(),
		_renderer->get_gpu_str(),
		base::cfg().use_vbo ? "true" : "false",
		base::cfg().tex_freq,
		base::cfg().tex_mode,
		base::cfg().mesh_size*16,
		base::cfg().one_mesh ? "true" : "false",
		nframes,
		time,
		stats._cpu_time,
		stats._gpu_time,
		stats._ndrawcalls,
		stats._ntriangles,
		stats._nvertices,
		stats._buffer_mem >> 20,
		stats._texture_mem >> 20,
		_renderer->get_gpu_vendor_str(),
		_renderer->get_gpu_driver_str(),
		vendor_id.c_str(),
		device_id.c_str(),
		rev_id.c_str());
	}
Пример #10
0
void Driver::setup()
{
  double hz(DEFAULT_RATE);
  int32_t device_id(0);
  std::string frame_id("camera");
  std::string file_path("");

  private_node_.getParam("device_id", device_id);
  private_node_.getParam("frame_id", frame_id);
  private_node_.getParam("rate", hz);

  int32_t image_width(640);
  int32_t image_height(480);

  camera_.reset(new Capture(camera_node_,
                            "image_raw",
                            PUBLISHER_BUFFER_SIZE,
                            frame_id));
  if (private_node_.getParam("file", file_path) &&
      file_path != "")
  {
    camera_->openFile(file_path);
  }
  else
  {
    camera_->open(device_id);
  }
  if (private_node_.getParam("image_width", image_width))
  {
    if (!camera_->setWidth(image_width))
    {
      ROS_WARN("fail to set image_width");
    }
  }
  if (private_node_.getParam("image_height", image_height))
  {
    if (!camera_->setHeight(image_height))
    {
      ROS_WARN("fail to set image_height");
    }
  }

  camera_->setPropertyFromParam(CV_CAP_PROP_POS_MSEC, "cv_cap_prop_pos_msec");
  camera_->setPropertyFromParam(CV_CAP_PROP_POS_AVI_RATIO, "cv_cap_prop_pos_avi_ratio");
  camera_->setPropertyFromParam(CV_CAP_PROP_FRAME_WIDTH, "cv_cap_prop_frame_width");
  camera_->setPropertyFromParam(CV_CAP_PROP_FRAME_HEIGHT, "cv_cap_prop_frame_height");
  camera_->setPropertyFromParam(CV_CAP_PROP_FPS, "cv_cap_prop_fps");
  camera_->setPropertyFromParam(CV_CAP_PROP_FOURCC, "cv_cap_prop_fourcc");
  camera_->setPropertyFromParam(CV_CAP_PROP_FRAME_COUNT, "cv_cap_prop_frame_count");
  camera_->setPropertyFromParam(CV_CAP_PROP_FORMAT, "cv_cap_prop_format");
  camera_->setPropertyFromParam(CV_CAP_PROP_MODE, "cv_cap_prop_mode");
  camera_->setPropertyFromParam(CV_CAP_PROP_BRIGHTNESS, "cv_cap_prop_brightness");
  camera_->setPropertyFromParam(CV_CAP_PROP_CONTRAST, "cv_cap_prop_contrast");
  camera_->setPropertyFromParam(CV_CAP_PROP_SATURATION, "cv_cap_prop_saturation");
  camera_->setPropertyFromParam(CV_CAP_PROP_HUE, "cv_cap_prop_hue");
  camera_->setPropertyFromParam(CV_CAP_PROP_GAIN, "cv_cap_prop_gain");
  camera_->setPropertyFromParam(CV_CAP_PROP_EXPOSURE, "cv_cap_prop_exposure");
  camera_->setPropertyFromParam(CV_CAP_PROP_CONVERT_RGB, "cv_cap_prop_convert_rgb");

  camera_->setPropertyFromParam(CV_CAP_PROP_RECTIFICATION, "cv_cap_prop_rectification");
  camera_->setPropertyFromParam(CV_CAP_PROP_ISO_SPEED, "cv_cap_prop_iso_speed");
#ifdef CV_CAP_PROP_WHITE_BALANCE_U
  camera_->setPropertyFromParam(CV_CAP_PROP_WHITE_BALANCE_U, "cv_cap_prop_white_balance_u");
#endif  // CV_CAP_PROP_WHITE_BALANCE_U
#ifdef CV_CAP_PROP_WHITE_BALANCE_V
  camera_->setPropertyFromParam(CV_CAP_PROP_WHITE_BALANCE_V, "cv_cap_prop_white_balance_v");
#endif  // CV_CAP_PROP_WHITE_BALANCE_V
#ifdef CV_CAP_PROP_BUFFERSIZE
  camera_->setPropertyFromParam(CV_CAP_PROP_BUFFERSIZE, "cv_cap_prop_buffersize");
#endif  // CV_CAP_PROP_BUFFERSIZE

  rate_.reset(new ros::Rate(hz));
}
Пример #11
0
 __host__ __device__
 constexpr explicit basic_grid_executor(device_id device = device_id(0))
   : device_(device)
 {}
Пример #12
0
int
main(int argc, char ** argv)
{
  std::string device_id ("");
  pcl::OpenNIGrabber::Mode image_mode = pcl::OpenNIGrabber::OpenNI_Default_Mode;
  
  if (argc >= 2)
  {
    device_id = argv[1];
    if (device_id == "--help" || device_id == "-h")
    {
      usage(argv);
      return 0;
    }
    else if (device_id == "-l")
    {
      if (argc >= 3)
      {
        pcl::OpenNIGrabber grabber (argv[2]);
        boost::shared_ptr<openni_wrapper::OpenNIDevice> device = grabber.getDevice ();
        std::vector<std::pair<int, XnMapOutputMode> > modes;

        if (device->hasImageStream ())
        {
          cout << endl << "Supported image modes for device: " << device->getVendorName () << " , " << device->getProductName () << endl;
          modes = grabber.getAvailableImageModes ();
          for (std::vector<std::pair<int, XnMapOutputMode> >::const_iterator it = modes.begin (); it != modes.end (); ++it)
          {
            cout << it->first << " = " << it->second.nXRes << " x " << it->second.nYRes << " @ " << it->second.nFPS << endl;
          }
        }
      }
      else
      {
        openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
        if (driver.getNumberDevices () > 0)
        {
          for (unsigned deviceIdx = 0; deviceIdx < driver.getNumberDevices (); ++deviceIdx)
          {
            cout << "Device: " << deviceIdx + 1 << ", vendor: " << driver.getVendorName (deviceIdx) << ", product: " << driver.getProductName (deviceIdx)
              << ", connected: " << driver.getBus (deviceIdx) << " @ " << driver.getAddress (deviceIdx) << ", serial number: \'" << driver.getSerialNumber (deviceIdx) << "\'" << endl;
          }

        }
        else
          cout << "No devices connected." << endl;
        
        cout <<"Virtual Devices available: ONI player" << endl;
      }
      return (0);
    }
  }
  else
  {
    openni_wrapper::OpenNIDriver& driver = openni_wrapper::OpenNIDriver::getInstance ();
    if (driver.getNumberDevices () > 0)
      cout << "Device Id not set, using first device." << endl;
  }
  
  unsigned mode;
  if (pcl::console::parse (argc, argv, "-imagemode", mode) != -1)
    image_mode = pcl::OpenNIGrabber::Mode (mode);
  
  pcl::OpenNIGrabber grabber (device_id, pcl::OpenNIGrabber::OpenNI_Default_Mode, image_mode);
  SimpleOpenNIViewer v (grabber);
  v.run ();

  return (0);
}
Пример #13
0
ldc_info_t * info (int log) {
	hd_data_t * hd_data = new_hd_data_t();
	hd_t *hd;

	hd = hd_list(hd_data, hw_sound, 1, NULL);

	ldc_info_t * head = NULL;
	ldc_info_t * tail = NULL;

	for(; hd; hd = hd->next) {
		if (! head) {
			head = new_ldc_info_t("sound");
			tail = head;
		} else {
			tail->next = new_ldc_info_t("sound");
			tail = tail->next;
		}

		//vendor
		if (hd->vendor.name){
			set_vendor (tail, "vendor", hd->vendor.name, hd->vendor.id, "Vendor");
		} else {
			set_vendor (tail, "vendor", "Unknown", -1, "Vendor");
		}

		//device
		if (hd->device.name){
			set_model (tail, "device", hd->device.name, hd->device.id, "Device");
		} else {
			set_model (tail, "device", "Unknown", -1, "Device");
		}

		//model
		if (hd->model){
			add_info_tuple(tail, "model", hd->model, -1, "Model");
		} else {
			add_info_tuple(tail, "model", "Unknown", -1, "Model");
		}

		//driver modules; driver active; device id
		if (hd->driver_info){
			driver_info_t *di;
			for(di = hd->driver_info; di; di = di->next) {
				if (di->any.type == di_module) {
					str_list_t * mod_list = di->module.names;
					add_info_tuple(tail, "driver_active", NULL, di->module.active, "Driver Active");

					for (; mod_list; mod_list = mod_list->next){
						add_info_tuple(tail, "driver_modules", mod_list->str, -1, "Driver Modules");
						device_id(tail, mod_list->str);
					}
				}
			}
		} else {
			add_info_tuple(tail, "driver_modules", "Unknown", -1, "Driver Modules");
			add_info_tuple(tail, "driver_active", NULL, -1, "Driver Active");
		}

		tail->return_status = 1;
	}

	free_hd_structs (hd_data, hd);

	if (log){
		insert_info_log(head);
	}

	return head;
}