LoginSignup
2
1

More than 3 years have passed since last update.

USB切替機

Last updated at Posted at 2020-05-21

以前秋葉原で処分品を280円で買ってきた、ArvelのUSB切替機を調べてみました。

写真(2020-05-22 7.05).jpg

購入したものは2回路のもので2台のホスト間でデバイスを切り替えて使えるようにするものです。4回路の製品もあったようです。

中に使われているチップはUSBのDevice DescriptorからActionStarという台湾の会社の製品のようです。

スクリーンショット(2020-05-22 6.41.47).png

VID,PIDは0x2101,0x0201です。

接続されてるホストにはデバイスが見え、接続されてないホストには切替機が見える仕様になっています。接続されてない方からしかコントロールできません。

Windows 7に付属のソフトをインストールして切り替えをwiresharkでusbスヌープしてみました。切り替えはHIDのSET_REPORTを使っていました。

No.     Time           Source                Destination           Protocol Length Info
     15 5.803210       host                  1.2.0                 USBHID   38     SET_REPORT Request

Frame 15: 38 bytes on wire (304 bits), 38 bytes captured (304 bits) on interface wireshark_extcap1040, id 0
USB URB
    [Source: host]
    [Destination: 1.2.0]
    USBPcap pseudoheader length: 28
    IRP ID: 0xfffffa8007164010
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_CLASS_INTERFACE (0x001b)
    IRP information: 0x00, Direction: FDO -> PDO
    URB bus id: 1
    Device address: 2
    Endpoint: 0x00, Direction: OUT
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 10
    [Response in: 16]
    Control transfer stage: Setup (0)
    [bInterfaceClass: HID (0x03)]
Setup Data
    bmRequestType: 0x21
    bRequest: SET_REPORT (0x09)
    wValue: 0x0200
    wIndex: 0
    wLength: 2
    bRequest: 9
    wValue: 0x0200
    wIndex: 0 (0x0000)
    wLength: 2
    Data Fragment: 0200

No.     Time           Source                Destination           Protocol Length Info
     16 5.803210       1.2.0                 host                  USBHID   28     SET_REPORT Response

Frame 16: 28 bytes on wire (224 bits), 28 bytes captured (224 bits) on interface wireshark_extcap1040, id 0
USB URB
    [Source: 1.2.0]
    [Destination: host]
    USBPcap pseudoheader length: 28
    IRP ID: 0xfffffa8007164010
    IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
    URB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008)
    IRP information: 0x01, Direction: PDO -> FDO
    URB bus id: 1
    Device address: 2
    Endpoint: 0x00, Direction: OUT
    URB transfer type: URB_CONTROL (0x02)
    Packet Data Length: 0
    [Request in: 15]
    [Time from request: 0.000000000 seconds]
    Control transfer stage: Complete (3)
    [bInterfaceClass: HID (0x03)]

KLabさんのIRリモコン用のコードをVID/PIDを書き換えて、以下で切り替え出来ました。いつもお世話になります。(_o_)

        buf[0] = 0x00;
        buf[1] = 0x02;
        buf[2] = 0x00;
        WriteToDevice(refDevice, buf, DEVICE_BUFSIZE);

切り替えるとカチカチ音がするので、リレーが入ってるのかもしれません。

何か面白い使い方が思いついたら使ってみようと思います。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1