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