Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Feb 2014 16:03:54 +0900 (JST)
From:      Kohji Okuno <okuno.kohji@jp.panasonic.com>
To:        jmg@funkthat.com
Cc:        freebsd-current@freebsd.org, okuno.kohji@jp.panasonic.com
Subject:   Re: kqueue for usb_dev
Message-ID:  <20140227.160354.2283977188535912888.okuno.kohji@jp.panasonic.com>
In-Reply-To: <20140227062118.GC47921@funkthat.com>
References:  <20140227.142615.924807465819500067.okuno.kohji@jp.panasonic.com> <20140227062118.GC47921@funkthat.com>

next in thread | previous in thread | raw e-mail | index | archive | help
----Next_Part(Thu_Feb_27_16_03_54_2014_940)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi John-Mark,

I tested the attached sample source with USB mouse.

Thanks,
 Kohji Okuno

From: John-Mark Gurney <jmg@funkthat.com>
> Kohji Okuno wrote this message on Thu, Feb 27, 2014 at 14:26 +0900:
>> I tried add kqueue I/F to usb_dev.c. I attached my patch.
>> What do you think about my patch?
> 
> Do you have test cases for these patches?
> 
> -- 
>   John-Mark Gurney				Voice: +1 415 225 5579
> 
>      "All that I will do, has been done, All that I have, has not."

----Next_Part(Thu_Feb_27_16_03_54_2014_940)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="ums.c"

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/event.h>
#include <sys/select.h>
#include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>

#define	DEV	"/dev/ums0"

#if 0
int
main()
{
	int i;
	ssize_t ret;
	uint8_t buf[128];
	int fd = open(DEV, O_RDONLY);
	fd_set readfds;

	for (i = 0; i < 10; i++) {
		FD_ZERO(&readfds);
		FD_SET(fd, &readfds);
		ret = select(fd+1, &readfds, NULL, NULL, NULL);
		printf("select=%d\n", ret);

		ret = read(fd, buf, sizeof(buf));
		printf("%d:%02x %02x %02x\n", ret, buf[0], buf[1], buf[2]);
	}

	close(fd);
	exit(0);
}
#else
int
main()
{
	int i;
	int err;
	ssize_t ret;
	uint8_t buf[128];
	int fd = open(DEV, O_RDONLY);
	int kqfd = kqueue();
	struct kevent evlist[1];

	EV_SET(&evlist[0], fd, EVFILT_READ, EV_ADD, 0, 0, 0);
	err = kevent(kqfd, evlist, 1, 0, 0, 0);
	if (err) {
		perror("kevent");
		close(fd);
		close(kqfd);
		exit(1);
	}

	for (i = 0; i < 10; i++) {
		ret = kevent(kqfd, 0, 0, evlist, 1, 0);
		printf("kev=%d\n", ret);

		ret = read(fd, buf, sizeof(buf));
		printf("%d:%02x %02x %02x\n", ret, buf[0], buf[1], buf[2]);
	}

	close(fd);
	exit(0);
}
#endif

----Next_Part(Thu_Feb_27_16_03_54_2014_940)----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140227.160354.2283977188535912888.okuno.kohji>