Win32 API 日本語リファレンス
ホームDevices.Usb › USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR

USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR

構造体
サイズx64: 30 バイト / x86: 26 バイトパッキング1

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
bLengthBYTE1+0+0このディスクリプタのサイズをバイト単位で示す。
bDescriptorTypeBYTE1+1+1ディスクリプタ種別。デバイス能力ディスクリプタ。
bDevCapabilityTypeBYTE1+2+2能力種別。PD消費ポート能力を示す。
bReservedBYTE1+3+3予約フィールド。0でなければならない。
bmCapabilities_bmCapabilities_e__Union8/4+4+4消費ポートの能力ビットを保持する無名共用体。
wMinVoltageWORD2+12+8受電可能な最小電圧を50mV単位で示す。
wMaxVoltageWORD2+14+10受電可能な最大電圧を50mV単位で示す。
wReservedWORD2+16+12予約フィールド。0でなければならない。
dwMaxOperatingPowerDWORD4+18+14通常動作時の最大消費電力を示す。
dwMaxPeakPowerDWORD4+22+18ピーク時の最大消費電力を示す。
dwMaxPeakPowerTimeDWORD4+26+22ピーク電力を維持できる最大時間を示す。

共用体: _bmCapabilities_e__Union x64 8B / x86 4B

フィールドサイズx64x86
AsUshortWORD2+0+0
Anonymous_Anonymous_e__Struct8/4+0+0

各言語での定義

#include <windows.h>

// USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR  (x64 30 / x86 26 バイト)
#pragma pack(push, 1)
typedef struct USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR {
    BYTE bLength;
    BYTE bDescriptorType;
    BYTE bDevCapabilityType;
    BYTE bReserved;
    _bmCapabilities_e__Union bmCapabilities;
    WORD wMinVoltage;
    WORD wMaxVoltage;
    WORD wReserved;
    DWORD dwMaxOperatingPower;
    DWORD dwMaxPeakPower;
    DWORD dwMaxPeakPowerTime;
} USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR
{
    public byte bLength;
    public byte bDescriptorType;
    public byte bDevCapabilityType;
    public byte bReserved;
    public _bmCapabilities_e__Union bmCapabilities;
    public ushort wMinVoltage;
    public ushort wMaxVoltage;
    public ushort wReserved;
    public uint dwMaxOperatingPower;
    public uint dwMaxPeakPower;
    public uint dwMaxPeakPowerTime;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR
    Public bLength As Byte
    Public bDescriptorType As Byte
    Public bDevCapabilityType As Byte
    Public bReserved As Byte
    Public bmCapabilities As _bmCapabilities_e__Union
    Public wMinVoltage As UShort
    Public wMaxVoltage As UShort
    Public wReserved As UShort
    Public dwMaxOperatingPower As UInteger
    Public dwMaxPeakPower As UInteger
    Public dwMaxPeakPowerTime As UInteger
End Structure
import ctypes
from ctypes import wintypes

class USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("bLength", ctypes.c_ubyte),
        ("bDescriptorType", ctypes.c_ubyte),
        ("bDevCapabilityType", ctypes.c_ubyte),
        ("bReserved", ctypes.c_ubyte),
        ("bmCapabilities", _bmCapabilities_e__Union),
        ("wMinVoltage", ctypes.c_ushort),
        ("wMaxVoltage", ctypes.c_ushort),
        ("wReserved", ctypes.c_ushort),
        ("dwMaxOperatingPower", wintypes.DWORD),
        ("dwMaxPeakPower", wintypes.DWORD),
        ("dwMaxPeakPowerTime", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR {
    pub bLength: u8,
    pub bDescriptorType: u8,
    pub bDevCapabilityType: u8,
    pub bReserved: u8,
    pub bmCapabilities: _bmCapabilities_e__Union,
    pub wMinVoltage: u16,
    pub wMaxVoltage: u16,
    pub wReserved: u16,
    pub dwMaxOperatingPower: u32,
    pub dwMaxPeakPower: u32,
    pub dwMaxPeakPowerTime: u32,
}
import "golang.org/x/sys/windows"

type USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR struct {
	bLength byte
	bDescriptorType byte
	bDevCapabilityType byte
	bReserved byte
	bmCapabilities _bmCapabilities_e__Union
	wMinVoltage uint16
	wMaxVoltage uint16
	wReserved uint16
	dwMaxOperatingPower uint32
	dwMaxPeakPower uint32
	dwMaxPeakPowerTime uint32
}
type
  USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR = packed record
    bLength: Byte;
    bDescriptorType: Byte;
    bDevCapabilityType: Byte;
    bReserved: Byte;
    bmCapabilities: _bmCapabilities_e__Union;
    wMinVoltage: Word;
    wMaxVoltage: Word;
    wReserved: Word;
    dwMaxOperatingPower: DWORD;
    dwMaxPeakPower: DWORD;
    dwMaxPeakPowerTime: DWORD;
  end;
const USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR = extern struct {
    bLength: u8,
    bDescriptorType: u8,
    bDevCapabilityType: u8,
    bReserved: u8,
    bmCapabilities: _bmCapabilities_e__Union,
    wMinVoltage: u16,
    wMaxVoltage: u16,
    wReserved: u16,
    dwMaxOperatingPower: u32,
    dwMaxPeakPower: u32,
    dwMaxPeakPowerTime: u32,
};
type
  USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR {.packed.} = object
    bLength: uint8
    bDescriptorType: uint8
    bDevCapabilityType: uint8
    bReserved: uint8
    bmCapabilities: _bmCapabilities_e__Union
    wMinVoltage: uint16
    wMaxVoltage: uint16
    wReserved: uint16
    dwMaxOperatingPower: uint32
    dwMaxPeakPower: uint32
    dwMaxPeakPowerTime: uint32
align(1)
struct USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR
{
    ubyte bLength;
    ubyte bDescriptorType;
    ubyte bDevCapabilityType;
    ubyte bReserved;
    _bmCapabilities_e__Union bmCapabilities;
    ushort wMinVoltage;
    ushort wMaxVoltage;
    ushort wReserved;
    uint dwMaxOperatingPower;
    uint dwMaxPeakPower;
    uint dwMaxPeakPowerTime;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR サイズ: 26 バイト(x86)
dim st, 7    ; 4byte整数×7(構造体サイズ 26 / 4 切り上げ)
; bLength : BYTE (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; bDescriptorType : BYTE (+1, 1byte)  poke st,1,値  /  値 = peek(st,1)
; bDevCapabilityType : BYTE (+2, 1byte)  poke st,2,値  /  値 = peek(st,2)
; bReserved : BYTE (+3, 1byte)  poke st,3,値  /  値 = peek(st,3)
; bmCapabilities : _bmCapabilities_e__Union (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; wMinVoltage : WORD (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; wMaxVoltage : WORD (+10, 2byte)  wpoke st,10,値  /  値 = wpeek(st,10)
; wReserved : WORD (+12, 2byte)  wpoke st,12,値  /  値 = wpeek(st,12)
; dwMaxOperatingPower : DWORD (+14, 4byte)  lpoke st,14,値  /  値 = lpeek(st,14)
; dwMaxPeakPower : DWORD (+18, 4byte)  lpoke st,18,値  /  値 = lpeek(st,18)
; dwMaxPeakPowerTime : DWORD (+22, 4byte)  lpoke st,22,値  /  値 = lpeek(st,22)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR サイズ: 30 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 30 / 4 切り上げ)
; bLength : BYTE (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; bDescriptorType : BYTE (+1, 1byte)  poke st,1,値  /  値 = peek(st,1)
; bDevCapabilityType : BYTE (+2, 1byte)  poke st,2,値  /  値 = peek(st,2)
; bReserved : BYTE (+3, 1byte)  poke st,3,値  /  値 = peek(st,3)
; bmCapabilities : _bmCapabilities_e__Union (+4, 8byte)  varptr(st)+4 を基点に操作(8byte:入れ子/配列)
; wMinVoltage : WORD (+12, 2byte)  wpoke st,12,値  /  値 = wpeek(st,12)
; wMaxVoltage : WORD (+14, 2byte)  wpoke st,14,値  /  値 = wpeek(st,14)
; wReserved : WORD (+16, 2byte)  wpoke st,16,値  /  値 = wpeek(st,16)
; dwMaxOperatingPower : DWORD (+18, 4byte)  lpoke st,18,値  /  値 = lpeek(st,18)
; dwMaxPeakPower : DWORD (+22, 4byte)  lpoke st,22,値  /  値 = lpeek(st,22)
; dwMaxPeakPowerTime : DWORD (+26, 4byte)  lpoke st,26,値  /  値 = lpeek(st,26)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR, pack=1
    #field byte bLength
    #field byte bDescriptorType
    #field byte bDevCapabilityType
    #field byte bReserved
    #field byte bmCapabilities 8
    #field short wMinVoltage
    #field short wMaxVoltage
    #field short wReserved
    #field int dwMaxOperatingPower
    #field int dwMaxPeakPower
    #field int dwMaxPeakPowerTime
#endstruct

stdim st, USB_DEVICE_CAPABILITY_PD_CONSUMER_PORT_DESCRIPTOR        ; NSTRUCT 変数を確保
st->bLength = 100
mes "bLength=" + st->bLength
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。