Hi,

I am not sure to be in the right place to post this message but if someone can
help me ...

Hi,

I want to code a tiny pogram to access to the "Hercules Dj console". It is an
mp3 mixer console with set of control to act as a double deck CD. It has an
internal sound card.
It's a HID device I want to access on it, I just want to know wath keys are
pressed and to light the leds.

My hercules DJ console is detected by my system and Alsa :

#tail -f /var/log/message

Aug 26 20:34:38 neuromancer kernel: usb 1-1: new full speed USB device using
ohci_hcd and address 4
Aug 26 20:34:38 neuromancer kernel: usb 1-1: Product: Hercules DJ Console
Aug 26 20:34:38 neuromancer kernel: usb 1-1: Manufacturer: Hercules
Aug 26 20:34:38 neuromancer kernel: input: USB HID v1.10 Joystick [Hercules
Hercules DJ Console] on usb-0000:00:02.0-1
Aug 26 20:34:38 neuromancer kernel: input: USB HID v1.10 Mouse [Hercules
Hercules DJ Console] on usb-0000:00:02.0-1
Aug 26 20:34:38 neuromancer kernel: input: USB HID v1.10 Keyboard [Hercules
Hercules DJ Console] on usb-0000:00:02.0-1

#lsusb

Bus 001 Device 004: ID 06f8:b000 Guillemot Corp. <-- Hercules Dj console
Bus 001 Device 003: ID 0461:4d03 Primax Electronics, Ltd Kensington
Mouse-in-a-box
Bus 001 Device 001: ID 0000:0000

#lsevent

Compiled with EV_VERSION 0x10000
Found 'AT Translated Set 2 keyboard' on '/dev/input/event0'
Found 'Targus USB Mouse' on '/dev/input/event1'
Found 'Hercules Hercules DJ Console' on '/dev/input/event2'
Found 'Hercules Hercules DJ Console' on '/dev/input/event3'
Found 'Hercules Hercules DJ Console' on '/dev/input/event4'
Nothing on /dev/input/event5.
Nothing on /dev/input/event6.
Nothing on /dev/input/event7.

Supported events:
Using 0 relative axes, 0 absolute axes, and 0 buttons.

My kernel is a 2.6.11 with a debian sarge.

I have use this program to detect the leds :

/************************BEGIN****************************/

#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <asm/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>

#include <linux/input.h>

/* this macro is used to tell if "bit" is set in "array"
 * it selects a byte from the array, and does a boolean AND
 * operation with a byte that only has the relevant bit set.
 * eg. to check for the 12th bit, we do (array[1] & 1<<4)
 */
#define test_bit(bit, array)    (array[bit/8] & (1<<(bit%8)))

int main (int argc, char **argv) {

  int fd = -1;
  uint8_t led_bitmask[LED_MAX/8 + 1];
  int yalv;

  /* ioctl() requires a file descriptor, so we check we got one, and then open
it */
  if (argc != 2) {
    fprintf(stderr, "usage: %s event-device - probably /dev/input/evdev0\n",
argv[0]);
    exit(1);
  }
  if ((fd = open(argv[1], O_RDONLY)) < 0) {
    perror("evdev open");
    exit(1);
  }

  memset(led_bitmask, 0, sizeof(led_bitmask));
  if (ioctl(fd, EVIOCGBIT(EV_LED, sizeof(led_bitmask)), led_bitmask) < 0) {
      perror("evdev ioctl");
  }

  printf("Supported LEDs:\n");

  for (yalv = 0; yalv < LED_MAX; yalv++) {
      if (test_bit(yalv, led_bitmask)) {
          /* this means that the bit is set in the LED list */
          printf("  LED type 0x%02x ", yalv);
          switch ( yalv)
              {
              case LED_NUML :
                  printf(" (Num Lock)\n");
                  break;
              case LED_CAPSL :
                  printf(" (Caps Lock)\n");
                  break;
              case LED_SCROLLL :
                  printf(" (Scroll Lock)\n");
                  break;
              case LED_COMPOSE :
                  printf(" (Compose)\n");
                  break;
              case LED_KANA :
                  printf(" (Kana)\n");
                  break;
              case LED_SLEEP :
                  printf(" (Sleep)\n");
                  break;
              case LED_SUSPEND :
                  printf(" (Suspend)\n");
                  break;
              case LED_MUTE :
                  printf(" (Mute)\n");
                  break;
              case LED_MISC :
                  printf(" (Miscellaneous)\n");
                  break;
              default:
                  printf(" (Unknown LED type: 0x%04hx)\n", yalv);
              }
      }
  }

  close(fd);

  exit(0);
}

/***********************************END***************************/

The leds of the Hercules Dj console are not detected by this piece of code,
but for my keyboard they are.

Guillaume postaire on the website "http://www.site2nous.com/postaire/"; has
worked a bit on this device, he used the same code has me and it seems to
work.

He has used this program to detect the led on the hercules dj console and he had
differents outputs than me :

Supported LEDs:
LED type 0x00  (Num Lock)
LED type 0x01  (Caps Lock)
LED type 0x02  (Scroll Lock)
LED type 0x03  (Compose)
LED type 0x04  (Kana)
LED type 0x05  (Sleep)
LED type 0x06  (Suspend)
LED type 0x07  (Mute)
LED type 0x08  (Miscellaneous)
LED type 0x09  (Unknown LED type: 0x0009)
LED type 0x0a  (Unknown LED type: 0x000a)
LED type 0x0b  (Unknown LED type: 0x000b)
LED type 0x0c  (Unknown LED type: 0x000c)
LED type 0x0d  (Unknown LED type: 0x000d)
LED type 0x0e  (Unknown LED type: 0x000e))


I have also tried this program to light a led :


#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
#include <linux/input.h>
#include <linux/string.h>

int main(int argc, char *argv[])
{
 int fd;
 int retval,  retvol;
 char devname[255];
 struct input_event ev;

 ev.type = EV_LED;
 ev.code = 3;     /*Code for a particular led*/
 ev.value = 1;    /*Led On*/
 fd=open(argv[1], O_RDWR | O_EXCL);

 if(fd>0)
 {
  retval = ioctl(fd, EVIOCGNAME(sizeof(devname)), devname);
   retvol = write(fd, &ev,sizeof(struct input_event));
  printf("Name : %s, Error : %s, %s\n",devname, strerror(retval),
  strerror(retvol));
  sleep(1);
 }
 else
  printf("Open Failed !\n");

 return 0;
}


And I have this ouput for the result of the write function :
"Device or ressource busy" and "Illegal Seek" for ioctl but I can
read the name of the Hercules DJ Console (for all events listed
by lsevent see above)

What's wrong ? Bad coding, bad kernel options or a default in the
configuration ?

Everything comes or is inspired by the website :

http://www.frogmouth.net/hid-doco/linux-hid.html

Thanks for your help


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users

Reply via email to