Linux bluetooth development
 help / color / mirror / Atom feed
From: Alexander Holler <holler@ahsoftware.de>
To: BlueZ Mailing List <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] hid2hci and Logitech Hub
Date: Fri, 26 Dec 2003 05:26:20 +0100	[thread overview]
Message-ID: <27150000.1072412780@[192.168.207.2]> (raw)
In-Reply-To: <1072406653.2876.98.camel@pegasus>

Hi Marcel,

--On Freitag, Dezember 26, 2003 03:44:13 +0100 Marcel Holtmann 
<marcel@holtmann.org> wrote:

>> As the report info for 0x10 shows 1 field and the maxusage from that
>> field  is 1, it seems there is no way sending 6 bytes (usages?) with one
>> report  0x10 using hiddev (if I have understood that part of hiddev
>> correct ;) ).
>
> I can't tell you how it is with hiddev, but the report ID 16 has six
> bytes and the report ID 17 has 19 bytes. Count for yourself.
>
> 	Usage Page (Undefined)
> 	Usage (0x01)
> 	Collection (Application)
> 	  Report ID (16)
> 	  Report Size (8)
> 	  Report Count (6)
> 	  Logical Minimum (0)
> 	  Logical Maximum (65535)
> 	  Usage (0x01)
> 	  Input (0x0000)
> 	  Usage (0x01)
> 	  Output (0x0000)
> 	End Collection
>
> 	Usage Page (Undefined)
> 	Usage (0x02)
> 	Collection (Application)
> 	  Report ID (17)
> 	  Report Size (8)
> 	  Report Count (19)
> 	  Logical Minimum (0)
> 	  Logical Maximum (65535)
> 	  Usage (0x02)
> 	  Input (0x0000)
> 	  Usage (0x02)
> 	  Output (0x0000)
> 	End Collection

Hmm, such an report I've searched. How to do you got this?

I've used the HIDIOCGREPORTINFO and HIDIOCGFIELDINFO ioctl from hiddev. 
There is an example ( 
http://www.frogmouth.net/hid-doco/examples/hiddev-misc/dump-events.c ) 
which output prints the same as my findings:

  Report id: 16 (1 fields)
  Field: 0: app: ff000001 phys 0000 flags 0 (1 usages) unit 0 exp 0
  Usage: ff000001 val 255 idx 0

>> I've tried sending 6 reports (0x10) with the values 0xff ... 0x00. That
>> hasn't worked (allways remember, I've just started collecting some
>> knowledge of usb, bluetooth and hid ;) ).
>
> With what kind of code?

Looking at hiddev.c and the documentation I've found, normally it should 
work with that code:

--------------------------
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <asm/types.h>
#include <linux/hiddev.h>

int main(void)
{
  char switch_sequence[] = {
    0xff, 0x81, 0x80, 0x00, 0x00, 0x00
  };
  struct hiddev_report_info rinfo;
  struct hiddev_usage_ref uref;
  struct hiddev_field_info finfo;
  int fd;
  if ((fd = open("/dev/usb/hid/hiddev0", O_RDONLY)) <= 0) { // I have only 
one hiddev
    printf("error opening device\n");
    return 1;
  }
  int rc=ioctl(fd, HIDIOCINITREPORT,0);
  printf("rc: %d\n", rc);
  if(rc)
    perror(NULL);
  memset( &rinfo, 0, sizeof(rinfo) );
  rinfo.report_type = HID_REPORT_TYPE_OUTPUT;
  rinfo.report_id = 0x10;
  rc=ioctl(fd, HIDIOCGREPORTINFO, &rinfo);
  printf("rc: %d\n", rc);
  if(rc)
    perror(NULL);
  printf("rinfo.num_fields: %u\n", rinfo.num_fields);
  memset( &finfo, 0, sizeof(finfo) );
  finfo.report_type=HID_REPORT_TYPE_OUTPUT;
  finfo.report_id=0x10;
  finfo.field_index=0;
  rc=ioctl(fd, HIDIOCGFIELDINFO, &finfo);
  printf("rc: %d\n", rc);
  if(rc)
    perror(NULL);
  printf("finfo.maxusage: %u\n", finfo.maxusage);
  int i;
  for(i=0; i< 6; ++i ) {
    memset( &uref, 0, sizeof(uref) );
    uref.report_type = HID_REPORT_TYPE_OUTPUT;
    uref.report_id = 0x10;
    uref.field_index = i;
    uref.usage_index = 0;
    uref.usage_code = 0 ;
    uref.value = switch_sequence[i];
    rc=ioctl(fd, HIDIOCSUSAGE, &uref);
    printf("rc: %d\n", rc);
    if(rc)
      perror(NULL);
  }
  memset( &rinfo, 0, sizeof(rinfo) );
  rinfo.report_type = HID_REPORT_TYPE_OUTPUT;
  rinfo.report_id = 0x10;
  rinfo.num_fields = 6;
  rc=ioctl(fd, HIDIOCSREPORT, &rinfo);
  printf("rc: %d\n", rc);
  if(rc)
    perror(NULL);
  close(fd);
  return 0;
}
--------------------------

The above doesn't work. I've also tried to increment usage_index, which 
doesn't work too (as the code in hiddev.c shows too).

But reading other messages on the usb-ml it seems I'm not the only one 
having problems sending multiples bytes with hiddev.

The next thing I will try, is using usbfs, but first I have to read how. ;)


>> Just remove or comment out the release of the isoc_iface. The release
>> isn't  needed and that avoids the oops. ;)
>
> Trust me that it is better to check it in detail. You always have to
> know why you are doing some things this way and I don't know it right
> now.

Surely, but the comment to usb_driver_release_interface clearly says the 
call of that function in hci_usb.c is not needed:

-------------
 * When the USB subsystem disconnect()s a driver from some interface,
 * it automatically invokes this method for that interface.  That
 * means that even drivers that used usb_driver_claim_interface()
 * usually won't need to call this.
-----------------

So removing it, isn't wrong and it avoids the oops. ;)

I think that maybe something is released twice. I've digged somewhat deeper 
into the usb code, but haven't find something. So I will this left 'as an 
excercise for the reader'. Choke, I will report it to the usb-ml. ;)

Regards,

Alexander




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

  reply	other threads:[~2003-12-26  4:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-25 12:48 [Bluez-devel] hid2hci and Logitech Hub Alexander Holler
2003-12-25 14:37 ` Marcel Holtmann
     [not found]   ` <30700000.1072366993@[192.168.207.2]>
2003-12-25 16:28     ` Marcel Holtmann
2003-12-26  2:02       ` Alexander Holler
2003-12-26  2:44         ` Marcel Holtmann
2003-12-26  4:26           ` Alexander Holler [this message]
2003-12-26 15:06             ` Marcel Holtmann
2003-12-26 16:49               ` Alexander Holler
2003-12-26 19:15                 ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='27150000.1072412780@[192.168.207.2]' \
    --to=holler@ahsoftware.de \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox