2012-10-01 4 views
6

키보드 에뮬레이션에 Arduino Leonardo을 사용하려고합니다. 그 이유는 이것이 광고 기능 중 하나이기 때문입니다. 저는 Leonardo와 놀았으며 Blink 예제를 기반으로 한 아주 간단한 스케치를 작성했습니다.Arduino Leonardo를 사용하는 일반 키보드 에뮬레이션

// Pin 13 has an LED connected on most Arduino boards. 
int led = 13; 

// The setup routine runs once when you press reset: 
void setup() 
{ 
    // Initialize the digital pin as an output. 
    pinMode(led, OUTPUT); 
} 

// The loop routine runs over and over again forever: 
void loop() 
{ 
    delay(5000);    // Wait for five seconds 
    digitalWrite(led, HIGH); // Turn the LED on (HIGH is the voltage level) 
    delay(100);    // Wait for a secondA 
    digitalWrite(led, LOW); // Turn the LED off by making the voltage LOW 
    Keyboard.write('A');  // Write an A using keyboard emulator 
} 

이제이 예제는 내 Windows XP 컴퓨터에서 잘 작동합니다. 일반 HID 키보드로 인식되며 5 초마다 'A'가 입력됩니다.

대상 환경에서 DOS를 실행하고 있으므로이 컴퓨터의 BIOS에서 Arduino Leonardo를 인식해야합니다.이 시스템은 BIOS가 아니며 DOS에 'A'를 입력하지 않습니다.

나는 Leonardo의 USB 장치 설명자를 수정하여 가능한 한 Dell L100과 일치하도록 만들었습니다. 필자가 만든 수정은 도움이되지 않았고, 레오나르도가 직렬 통신, 키보드 에뮬레이션 및 마우스 에뮬레이션을 동일한 USB 포트에서 제공하는 복합 장치이기 때문에 이것이 문제가 아닐 수 있습니다. 의 USB 기술자/구성에 대한 소스 코드를 편집 할 수 있습니다 및 다음 위치에 있습니다

  • Arduino_Installation의 \ 하드웨어 \ 아두 이노 \ 코어 \ 아두 이노 \ HID.cpp
  • Arduino_Installation의 \ 하드웨어 \ 아두 이노 \ 코어 \ 아두 이노 \ USBDesc.h
  • Arduino_Installation의 \ 하드웨어 \ 아두 이노 \ 코어 \ 아두 이노 \ USBCore.h
  • Arduino_Installation의 \ 하드웨어 \ 아두 이노 \ 코어 \ 아두 이노 \ USBCore.cpp

USB 장치에서 덤프입니다 다음레오나르도를위한 뷰어 :

[Port3] : USB Composite Device 

      ---===>Device Information<===--- 
English product name: "Arduino Leonardo" 

ConnectionStatus: 
Current Config Value:    0x01 -> Device Bus Speed: Full 
Device Address:     0x03 
Open Pipes:       4 

      ===>Endpoint Descriptor<=== 
bLength:       0x07 
bDescriptorType:     0x05 
bEndpointAddress:     0x81 -> Direction: IN - EndpointID: 1 
bmAttributes:      0x03 -> Interrupt Transfer Type 
wMaxPacketSize:     0x0010 = 0x10 bytes 
bInterval:       0x40 

      ===>Endpoint Descriptor<=== 
bLength:       0x07 
bDescriptorType:     0x05 
bEndpointAddress:     0x02 -> Direction: OUT - EndpointID: 2 
bmAttributes:      0x02 -> Bulk Transfer Type 
wMaxPacketSize:     0x0040 = 0x40 bytes 
bInterval:       0x00 

      ===>Endpoint Descriptor<=== 
bLength:       0x07 
bDescriptorType:     0x05 
bEndpointAddress:     0x83 -> Direction: IN - EndpointID: 3 
bmAttributes:      0x02 -> Bulk Transfer Type 
wMaxPacketSize:     0x0040 = 0x40 bytes 
bInterval:       0x00 

      ===>Endpoint Descriptor<=== 
bLength:       0x07 
bDescriptorType:     0x05 
bEndpointAddress:     0x84 -> Direction: IN - EndpointID: 4 
bmAttributes:      0x03 -> Interrupt Transfer Type 
wMaxPacketSize:     0x0040 = 0x40 bytes 
bInterval:       0x01 

      ===>Device Descriptor<=== 
bLength:       0x12 
bDescriptorType:     0x01 
bcdUSB:       0x0110 
bDeviceClass:      0x00 
*!*ERROR: device class should be Multi-interface Function 0xEF 
      When IAD descriptor is used 
bDeviceSubClass:     0x00 
*!*ERROR: device SubClass should be USB Common Sub Class 2 
      When IAD descriptor is used 
bDeviceProtocol:     0x00 
*!*ERROR: device Protocol should be USB IAD Protocol 1 
      When IAD descriptor is used 
bMaxPacketSize0:     0x40 = (64) Bytes 
idVendor:      0x2341 = Vendor ID not listed with USB.org as of 03-19-2008 
idProduct:      0x8036 
bcdDevice:      0x0100 
iManufacturer:      0x01 
    English (United States) "Arduino LLC" 
iProduct:       0x02 
    English (United States) "Arduino Leonardo" 
iSerialNumber:      0x00 
bNumConfigurations:    0x01 

      ===>Configuration Descriptor<=== 
bLength:       0x09 
bDescriptorType:     0x02 
wTotalLength:     0x0064 -> Validated 
bNumInterfaces:     0x03 
bConfigurationValue:    0x01 
iConfiguration:     0x00 
bmAttributes:      0x80 -> Bus Powered 
MaxPower:       0xFA = 500 mA 

      ===>IAD Descriptor<=== 
bLength:       0x08 
bDescriptorType:     0x0B 
bFirstInterface:     0x00 
bInterfaceCount:     0x02 
bFunctionClass:     0x02 -> This is Communications (CDC Control) USB Device Interface Class 
bFunctionSubClass:     0x01 
bFunctionProtocol:     0x01 
iFunction:       0x00 

      ===>Interface Descriptor<=== 
bLength:       0x09 
bDescriptorType:     0x04 
bInterfaceNumber:     0x00 
bAlternateSetting:     0x00 
bNumEndpoints:      0x01 
bInterfaceClass:     0x02 -> This is Communications (CDC Control) USB Device Interface Class 
bInterfaceSubClass:    0x01 
bInterfaceProtocol:    0x00 
CAUTION: This may be an invalid bInterfaceProtocol 
iInterface:      0x00 
    -> This is a Communications (CDC Control) USB Device Interface Class 

      ===>Descriptor Hex Dump<=== 
bLength:       0x05 
bDescriptorType:     0x24 
05 24 00 10 01 
    -> This is a Communications (CDC Control) USB Device Interface Class 

      ===>Descriptor Hex Dump<=== 
bLength:       0x05 
bDescriptorType:     0x24 
05 24 01 01 01 
    -> This is a Communications (CDC Control) USB Device Interface Class 

      ===>Descriptor Hex Dump<=== 
bLength:       0x04 
bDescriptorType:     0x24 
04 24 02 06 
    -> This is a Communications (CDC Control) USB Device Interface Class 

      ===>Descriptor Hex Dump<=== 
bLength:       0x05 
bDescriptorType:     0x24 
05 24 06 00 01 

      ===>Endpoint Descriptor<=== 
bLength:       0x07 
bDescriptorType:     0x05 
bEndpointAddress:     0x81 -> Direction: IN - EndpointID: 1 
bmAttributes:      0x03 -> Interrupt Transfer Type 
wMaxPacketSize:     0x0010 = 0x10 bytes 
bInterval:       0x40 

      ===>Interface Descriptor<=== 
bLength:       0x09 
bDescriptorType:     0x04 
bInterfaceNumber:     0x01 
bAlternateSetting:     0x00 
bNumEndpoints:      0x02 
bInterfaceClass:     0x0A -> This is a CDC Data USB Device Interface Class 
bInterfaceSubClass:    0x01 
bInterfaceProtocol:    0x00 
CAUTION: This may be an invalid bInterfaceProtocol 
iInterface:      0x00 

      ===>Endpoint Descriptor<=== 
bLength:       0x07 
bDescriptorType:     0x05 
bEndpointAddress:     0x02 -> Direction: OUT - EndpointID: 2 
bmAttributes:      0x02 -> Bulk Transfer Type 
wMaxPacketSize:     0x0040 = 0x40 bytes 
bInterval:       0x00 

      ===>Endpoint Descriptor<=== 
bLength:       0x07 
bDescriptorType:     0x05 
bEndpointAddress:     0x83 -> Direction: IN - EndpointID: 3 
bmAttributes:      0x02 -> Bulk Transfer Type 
wMaxPacketSize:     0x0040 = 0x40 bytes 
bInterval:       0x00 

      ===>Interface Descriptor<=== 
bLength:       0x09 
bDescriptorType:     0x04 
bInterfaceNumber:     0x02 
bAlternateSetting:     0x00 
bNumEndpoints:      0x01 
bInterfaceClass:     0x03 -> HID Interface Class 
bInterfaceSubClass:    0x01 
bInterfaceProtocol:    0x00 
CAUTION: This may be an invalid bInterfaceProtocol 
iInterface:      0x00 

      ===>HID Descriptor<=== 
bLength:       0x09 
bDescriptorType:     0x21 
bcdHID:       0x0101 
bCountryCode:      0x00 
bNumDescriptors:     0x01 
bDescriptorType:     0x22 
wDescriptorLength:    0x0065 

      ===>Endpoint Descriptor<=== 
bLength:       0x07 
bDescriptorType:     0x05 
bEndpointAddress:     0x84 -> Direction: IN - EndpointID: 4 
bmAttributes:      0x03 -> Interrupt Transfer Type 
wMaxPacketSize:     0x0040 = 0x40 bytes 
bInterval:       0x01 

BIOS로 레오나르도를 일반 키보드로 어떻게 인식시킬 수 있습니까?

+0

해결책이 있습니까? 나는 같은 문제를 가지고있다. – Delta

+0

나는 그렇지 않습니다. 내가 darBis가 제공 한 솔루션을 시도했지만 PC가이를 인식하도록 관리하지 못했습니다. –

답변

2

Arduino는 부팅 프로토콜을 지원하지 않습니다. 나는 Teensy (Arduino 호환)을 사용하기 시작했으며, 꽤 잘 작동한다.

+1

부팅 프로토콜을 살펴본 후에도 이것이 문제라고 생각합니다. 어떻게 구현할 수 있는지 설명하는 문서 [USB.ORG] (http://www.usb.org/developers/devclass_docs/HID1_11.pdf)를 발견했습니다. –

+0

@wirecat : 작동 시키려면 HID 소스 코드를 수정할 수 있었습니까? – Force

+0

@Force 아니 었어. 나는 그 후 다른 해결책을 사용했고이 문제로 다시 돌아갈 시간이 없었습니다. –

1

내가 잘못 생각할 수도 있지만 부팅하는 동안 devide를 인식하려면 bInterfaceSubClass이 0x01 (부팅 장치 하위 클래스)이어야합니다. 당신이 지적한 소스 파일에는 0x00으로 설정된 모든 곳의 하위 클래스가 있습니다.

D_INTERFACE 매크로의 모든 용도에서 USBCore.h에서 0x01로 서브 클래스를 설정할 수 있습니다.

저는 Arduino 사용자가 아니기 때문에 AVR에서 V-USB을 사용하여 HID 키보드 에뮬레이션을 한 번만 사용했습니다. 설명서에서 USB.org에 USB 디스크립터에 대한 자세한 정보를 찾으려고 할 수 있습니다. 하지만 읽을 거리가 상당히 많습니다.

가 여기 내 키보드의 일부 외경 HID 설명 덤프입니다, 인터페이스 설명자에 통보 값 : 리눅스에서 루트로 "lsusb -v"를 사용하여

Bus 005 Device 002: ID 046d:c30e Logitech, Inc. UltraX Keyboard (Y-BL49) 
Device Descriptor: 
    bLength    18 
    bDescriptorType   1 
    bcdUSB    1.10 
    bDeviceClass   0 (Defined at Interface level) 
    bDeviceSubClass   0 
    bDeviceProtocol   0 
    bMaxPacketSize0   8 
    idVendor   0x046d Logitech, Inc. 
    idProduct   0xc30e UltraX Keyboard (Y-BL49) 
    bcdDevice   1.80 
    iManufacturer   1 Logitech 
    iProduct    2 HID compliant keyboard 
    iSerial     0 
    bNumConfigurations  1 
    Configuration Descriptor: 
    bLength     9 
    bDescriptorType   2 
    wTotalLength   59 
    bNumInterfaces   2 
    bConfigurationValue  1 
    iConfiguration   0 
    bmAttributes   0xa0 
     (Bus Powered) 
     Remote Wakeup 
    MaxPower    100mA 
    Interface Descriptor: 
     bLength     9 
     bDescriptorType   4 
     bInterfaceNumber  0 
     bAlternateSetting  0 
     bNumEndpoints   1 
     bInterfaceClass   3 Human Interface Device 
     bInterfaceSubClass  1 Boot Interface Subclass 
     bInterfaceProtocol  1 Keyboard 
     iInterface    0 
     HID Device Descriptor: 
      bLength     9 
      bDescriptorType  33 
      bcdHID    1.10 
      bCountryCode   0 Not supported 
      bNumDescriptors   1 
      bDescriptorType  34 Report 
      wDescriptorLength  62 

덤프되었다.

+1

권장 솔루션을 사용해 보았지만 불행히도 Leonardo는 여전히 BIOS에서 인식되지 않습니다.내 질문에 USB Device Viewer에서 덤프를 추가하여 Leonardo의 현재 설명자를 보여줍니다. –

관련 문제