bool RTCANSubscriber::notify_unsafe(Message &msg, const Time &timestamp) {
	RTCANTransport * transportp = static_cast<RTCANTransport *>(get_transport());
	(void) timestamp;

	if (transportp->send(&msg, this)) return true;

	return false;
}
Ejemplo n.º 2
0
static int
lua_dfui_connection_new(lua_State *L)
{
	const char *transport_string, *rendezvous;
	int transport;
	struct dfui_connection *c;

	transport_string = luaL_checkstring(L, 1);
	rendezvous = luaL_checkstring(L, 2);
	if (! (transport = get_transport(transport_string)) > 0) {
		lua_pushnil(L);
		return(1);
	}
	c = dfui_connection_new(transport, rendezvous);
	lua_push_dfui_connection(L, c);
	return(1);
}
Ejemplo n.º 3
0
int main(void)
{
	IOHIDManagerRef mgr;
	int i;

	mgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
	IOHIDManagerSetDeviceMatching(mgr, NULL);
	IOHIDManagerOpen(mgr, kIOHIDOptionsTypeNone);

	CFSetRef device_set = IOHIDManagerCopyDevices(mgr);
    if (device_set==NULL) {
        return 0;
    }

	CFIndex num_devices = CFSetGetCount(device_set);
	IOHIDDeviceRef *device_array = calloc(num_devices, sizeof(IOHIDDeviceRef));
	CFSetGetValues(device_set, (const void **) device_array);

	for (i = 0; i < num_devices; i++) {
		IOHIDDeviceRef dev = device_array[i];
		printf("Device: %p\n", dev);
		printf("  %04hx %04hx\n", get_vendor_id(dev), get_product_id(dev));

		wchar_t serial[256], buf[256];
		char cbuf[256];
		get_serial_number(dev, serial, 256);


		printf("  Serial: %ls\n", serial);
		printf("  Loc: %ld\n", get_location_id(dev));
		get_transport(dev, buf, 256);
		printf("  Trans: %ls\n", buf);
		make_path(dev, cbuf, 256);
		printf("  Path: %s\n", cbuf);

	}

	return 0;
}
//probe书中有教
static int our_probe(struct usb_interface *intf,
			 const struct usb_device_id *id){
struct us_data *us;
int result;
//device
struct device *dev;
//scsihost
struct Scsi_Host *host;
//检测id是否符合 和intf
struct us_unusual_dev *unusual_dev;

unusual_dev=(id - usb_storage_usb_ids) + us_unusual_dev_list;
if(usb_usual_check_type(id,USB_US_TYPE_STOR) || usb_usual_ignore_device(intf))
return -ENXIO;

printk(KERN_ALERT "probe usb   usb  detected!\n");
//分配个host

host = scsi_host_alloc(&usb_stor_host_template,sizeof(*us));
if(!host){
dev_warn(&intf->dev,"fail to allocate the scsi host\n");
return -ENOMEM;
}
//host中的一些初始化
host->max_cmd_len = 16;
host-> sg_tablesize = usb_stor_sg_tablesize(intf);
us= host_to_us(host);//us 作为host中 的us
//分内存?
memset(us,0,sizeof(struct us_data));
mutex_init(&(us->dev_mutex));
init_completion(&us->cmnd_ready);
init_completion(&(us->notify));
init_waitqueue_head(&us->delay_wait);
INIT_DELAYED_WORK(&us->scan_dwork,usb_stor_scan_dwork);

result = associate_dev(us,intf);
if(result)
         goto Bad;
result = get_device_info(us,id,unusual_dev);
if(result)
         goto Bad;
//transport protocol
get_transport(us);
get_protocol(us);

if(!us->transport ||!us->proto_handler){
result=-ENXIO;
goto Bad;
}
printk(KERN_ALERT"Transport: %s\n",us->transport_name);
printk(KERN_ALERT"Protocol: %s\n",us->transport_name);
dev = &us->pusb_intf->dev;
//设置max lun
if(us->fflags & US_FL_SINGLE_LUN)
us->max_lun =0;

//endpoint get pipe
result = get_pipes(us);
if(result)
goto Bad;
//如果u盘前十个指令错误,重置
if (us->fflags & US_FL_INITIAL_READ10)
		set_bit(US_FLIDX_REDO_READ10, &us->dflags);
//申请子资源,添加进host
result=usb_stor_acquire_sesources(us);
if(result)
goto Bad;
snprintf(us->scsi_name,sizeof(us->scsi_name),"our-usb-storage%s",dev_name(&us->pusb_intf->dev));
result= scsi_add_host(us_to_host(us),dev);
if(result){
printk(KERN_ALERT"UNable to add the host\n");
goto Bad;
}
//scsi设备延时探测
usb_autopm_get_interface_no_resume(us->pusb_intf);
set_bit(US_FLIDX_SCAN_PENDING,&us->dflags);
if(delay_use>0)
          dev_dbg(dev,"waiting for device before scanning\n");
queue_delayed_work(system_freezable_wq,&us->scan_dwork,delay_use * HZ);


return 0;
Bad:

 printk(KERN_ALERT "probe false!\n");
release_everything(us);
return result;
   }
Ejemplo n.º 5
0
    int ObChunkServer::initialize()
    {
      int ret = OB_SUCCESS;
      // do not handle batch packet.
      // process packet one by one.
      set_batch_process(false);

      // read configure item value from configure file.
      // this step is the very first thing.
      ret = param_.load_from_config();

      // set listen port
      if (OB_SUCCESS == ret) 
      {
        ret = set_listen_port(param_.get_chunk_server_port());
      }

      if (OB_SUCCESS == ret)
      {
        ret = set_dev_name(param_.get_dev_name());
        if (OB_SUCCESS == ret)
        {
          ret = set_self(param_.get_dev_name(), 
              param_.get_chunk_server_port());
        }
      }

      // task queue and work thread count
      if (OB_SUCCESS == ret)
      {
        ret = set_default_queue_size(param_.get_task_queue_size());
      }

      if (OB_SUCCESS == ret)
      {
        ret = set_thread_count(param_.get_task_thread_count());
      }

      if (OB_SUCCESS == ret)
      {
        ret = set_min_left_time(param_.get_task_left_time());
      }

      // set packet factory object.
      if (OB_SUCCESS == ret)
      {
        ret = set_packet_factory(&packet_factory_);
      }

      // initialize client_manager_ for server remote procedure call.
      if (OB_SUCCESS == ret)
      {
        ret = client_manager_.initialize(get_transport(), get_packet_streamer());
      }

      if (OB_SUCCESS == ret)
      {
        ret = rs_rpc_stub_.init( param_.get_root_server(), &client_manager_);
      }

      if (OB_SUCCESS == ret)
      {
        ret = tablet_manager_.init(&param_);
      }

      // server initialize, including start transport, 
      // listen port, accept socket data from client
      if (OB_SUCCESS == ret)
      {
        ret = ObSingleServer::initialize();
      }

      if (OB_SUCCESS == ret)
      {
        ret = service_.initialize(this);
      }

      return ret;
    }