Exemplo n.º 1
0
static void cb_parse_object(struct libusb_transfer *transfer)
{
	struct aura_node *node = transfer->user_data;
	struct usb_dev_info *inf = aura_get_transportdata(node);
	char is_method;
	char *name, *afmt, *rfmt;

	check_control(transfer);
	name = (char *) libusb_control_transfer_get_data(transfer);

	is_method = *name++;
	afmt = next(name);
	rfmt = next(afmt);

	slog(4, SLOG_DEBUG, "usb: got %s %s / '%s' '%s'", 
	     is_method ? "method" : "event",
	     name, afmt, rfmt);

	aura_etable_add(inf->etbl, name, 
			is_method ? afmt : NULL, 
			rfmt);

	if (inf->current_object == inf->num_objects) { 
		slog(4, SLOG_DEBUG, "etable becomes active");
		aura_etable_activate(inf->etbl);
		aura_set_status(node, AURA_STATUS_ONLINE);
		inf->state = AUSB_DEVICE_OPERATIONAL;
		itransfer_enable(node, true);
		return;
	}

	slog(4, SLOG_DEBUG, "Requesting info about obj %d", inf->current_object);
	/* Resubmit the transfer for the next round */
	request_object(node, inf->current_object++);
}
Exemplo n.º 2
0
static int l_etable_activate(lua_State *L)
{
	struct aura_export_table *tbl;

	TRACE();
	aura_check_args(L, 1);

	if (!lua_islightuserdata(L, 1))
		aura_typeerror(L, 1, "ludata");

	tbl = lua_touserdata(L, 1);
	aura_etable_activate(tbl);
	return 0;
}
Exemplo n.º 3
0
static int gpio_open(struct aura_node *node, const char *opts)
{
	slog(0, SLOG_INFO, "Opening sysfs/gpio transport");
	struct aura_export_table *etbl = aura_etable_create(node, 16);
	if (!etbl)
		BUG(node, "Failed to create etable");
	aura_etable_add(etbl, "write", "33", "");
	aura_etable_add(etbl, "read", "3", "3");
	aura_etable_add(etbl, "out", "3", "");
	aura_etable_add(etbl, "in", "3", "");
	aura_etable_add(etbl, "export", "3", "3");
	aura_etable_add(etbl, "watch", "3", "");
	//Change notification
	aura_etable_add(etbl, "gpio_changed", NULL, "333");
	aura_etable_activate(etbl);
	aura_set_status(node, AURA_STATUS_ONLINE);
	slog(0, SLOG_INFO, "Opened sysfs/gpio transport");
	return 0;
}
Exemplo n.º 4
0
static void susb_handle_event(struct aura_node *node, enum node_event evt, const struct aura_pollfds *fd)
{
	struct aura_buffer *buf;
	struct usb_dev_info *inf = aura_get_transportdata(node);

	ncusb_handle_events_nonblock_once(node, inf->ctx, inf->timer);

	if (inf->cbusy)
		return;

	if (evt == NODE_EVENT_STARTED) {
		aura_etable_activate(inf->etbl);
		/* Activate our export table
		 * Hack: Since libusb tends to send and receive data in one buffer,
		 * we need to adjust argument buffer to fit in return values as well.
		 * It helps us to avoid needless copying.
		 */
		int i;
		for (i = 0; i < inf->etbl->next; i++) {
			struct aura_object *tmp;
			tmp = &inf->etbl->objects[i];
			tmp->arglen += tmp->retlen;
		}
		inf->etbl = NULL;
		ncusb_watch_for_device(inf->ctx, &inf->dev_descr);
		ncusb_start_descriptor_watching(node, inf->ctx);
		slog(1, SLOG_INFO, "usb: Now looking for a device %x:%x %s/%s/%s",
		     inf->dev_descr.vid, inf->dev_descr.pid,
		     inf->dev_descr.vendor, inf->dev_descr.product, inf->dev_descr.serial);
	} else if (inf->state == SUSB_DEVICE_RESTART) {
		susb_offline_transport(inf);
	} else if (inf->state == SUSB_DEVICE_OPERATIONAL) {
		buf = aura_peek_buffer(&node->outbound_buffers);
		if (buf)
			susb_issue_call(node, buf);
	}
}