ホーム › Devices.Usb › USB_30_HUB_DESCRIPTOR
USB_30_HUB_DESCRIPTOR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| bLength | BYTE | 1 | +0 | +0 | このディスクリプタのサイズをバイト単位で示す。 |
| bDescriptorType | BYTE | 1 | +1 | +1 | ディスクリプタ種別。USB3.0ハブは0x2A。 |
| bNumberOfPorts | BYTE | 1 | +2 | +2 | ハブが持つダウンストリームポート数を示す。 |
| wHubCharacteristics | WORD | 2 | +3 | +3 | 電源管理・過電流保護等のハブ特性ビットフラグを示す。 |
| bPowerOnToPowerGood | BYTE | 1 | +5 | +5 | ポート電源投入から安定までの時間を2ms単位で示す。 |
| bHubControlCurrent | BYTE | 1 | +6 | +6 | ハブコントローラの最大消費電流をmA単位で示す。 |
| bHubHdrDecLat | BYTE | 1 | +7 | +7 | ハブパケットヘッダのデコード遅延を示す。 |
| wHubDelay | WORD | 2 | +8 | +8 | ハブの遅延をナノ秒単位で示す。 |
| DeviceRemovable | WORD | 2 | +10 | +10 | 各ポートのデバイス着脱可否を表すビットマスク。 |
各言語での定義
#include <windows.h>
// USB_30_HUB_DESCRIPTOR (x64 12 / x86 12 バイト)
#pragma pack(push, 1)
typedef struct USB_30_HUB_DESCRIPTOR {
BYTE bLength;
BYTE bDescriptorType;
BYTE bNumberOfPorts;
WORD wHubCharacteristics;
BYTE bPowerOnToPowerGood;
BYTE bHubControlCurrent;
BYTE bHubHdrDecLat;
WORD wHubDelay;
WORD DeviceRemovable;
} USB_30_HUB_DESCRIPTOR;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_30_HUB_DESCRIPTOR
{
public byte bLength;
public byte bDescriptorType;
public byte bNumberOfPorts;
public ushort wHubCharacteristics;
public byte bPowerOnToPowerGood;
public byte bHubControlCurrent;
public byte bHubHdrDecLat;
public ushort wHubDelay;
public ushort DeviceRemovable;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_30_HUB_DESCRIPTOR
Public bLength As Byte
Public bDescriptorType As Byte
Public bNumberOfPorts As Byte
Public wHubCharacteristics As UShort
Public bPowerOnToPowerGood As Byte
Public bHubControlCurrent As Byte
Public bHubHdrDecLat As Byte
Public wHubDelay As UShort
Public DeviceRemovable As UShort
End Structureimport ctypes
from ctypes import wintypes
class USB_30_HUB_DESCRIPTOR(ctypes.Structure):
_pack_ = 1
_fields_ = [
("bLength", ctypes.c_ubyte),
("bDescriptorType", ctypes.c_ubyte),
("bNumberOfPorts", ctypes.c_ubyte),
("wHubCharacteristics", ctypes.c_ushort),
("bPowerOnToPowerGood", ctypes.c_ubyte),
("bHubControlCurrent", ctypes.c_ubyte),
("bHubHdrDecLat", ctypes.c_ubyte),
("wHubDelay", ctypes.c_ushort),
("DeviceRemovable", ctypes.c_ushort),
]#[repr(C, packed(1))]
pub struct USB_30_HUB_DESCRIPTOR {
pub bLength: u8,
pub bDescriptorType: u8,
pub bNumberOfPorts: u8,
pub wHubCharacteristics: u16,
pub bPowerOnToPowerGood: u8,
pub bHubControlCurrent: u8,
pub bHubHdrDecLat: u8,
pub wHubDelay: u16,
pub DeviceRemovable: u16,
}import "golang.org/x/sys/windows"
type USB_30_HUB_DESCRIPTOR struct {
bLength byte
bDescriptorType byte
bNumberOfPorts byte
wHubCharacteristics uint16
bPowerOnToPowerGood byte
bHubControlCurrent byte
bHubHdrDecLat byte
wHubDelay uint16
DeviceRemovable uint16
}type
USB_30_HUB_DESCRIPTOR = packed record
bLength: Byte;
bDescriptorType: Byte;
bNumberOfPorts: Byte;
wHubCharacteristics: Word;
bPowerOnToPowerGood: Byte;
bHubControlCurrent: Byte;
bHubHdrDecLat: Byte;
wHubDelay: Word;
DeviceRemovable: Word;
end;const USB_30_HUB_DESCRIPTOR = extern struct {
bLength: u8,
bDescriptorType: u8,
bNumberOfPorts: u8,
wHubCharacteristics: u16,
bPowerOnToPowerGood: u8,
bHubControlCurrent: u8,
bHubHdrDecLat: u8,
wHubDelay: u16,
DeviceRemovable: u16,
};type
USB_30_HUB_DESCRIPTOR {.packed.} = object
bLength: uint8
bDescriptorType: uint8
bNumberOfPorts: uint8
wHubCharacteristics: uint16
bPowerOnToPowerGood: uint8
bHubControlCurrent: uint8
bHubHdrDecLat: uint8
wHubDelay: uint16
DeviceRemovable: uint16align(1)
struct USB_30_HUB_DESCRIPTOR
{
ubyte bLength;
ubyte bDescriptorType;
ubyte bNumberOfPorts;
ushort wHubCharacteristics;
ubyte bPowerOnToPowerGood;
ubyte bHubControlCurrent;
ubyte bHubHdrDecLat;
ushort wHubDelay;
ushort DeviceRemovable;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_30_HUB_DESCRIPTOR サイズ: 12 バイト(x64)
dim st, 3 ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; bLength : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; bDescriptorType : BYTE (+1, 1byte) poke st,1,値 / 値 = peek(st,1)
; bNumberOfPorts : BYTE (+2, 1byte) poke st,2,値 / 値 = peek(st,2)
; wHubCharacteristics : WORD (+3, 2byte) wpoke st,3,値 / 値 = wpeek(st,3)
; bPowerOnToPowerGood : BYTE (+5, 1byte) poke st,5,値 / 値 = peek(st,5)
; bHubControlCurrent : BYTE (+6, 1byte) poke st,6,値 / 値 = peek(st,6)
; bHubHdrDecLat : BYTE (+7, 1byte) poke st,7,値 / 値 = peek(st,7)
; wHubDelay : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; DeviceRemovable : WORD (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_30_HUB_DESCRIPTOR, pack=1
#field byte bLength
#field byte bDescriptorType
#field byte bNumberOfPorts
#field short wHubCharacteristics
#field byte bPowerOnToPowerGood
#field byte bHubControlCurrent
#field byte bHubHdrDecLat
#field short wHubDelay
#field short DeviceRemovable
#endstruct
stdim st, USB_30_HUB_DESCRIPTOR ; NSTRUCT 変数を確保
st->bLength = 100
mes "bLength=" + st->bLength