ホーム › Devices.Usb › USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR
USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| bLength | BYTE | 1 | +0 | +0 | このディスクリプタのサイズをバイト単位で示す。 |
| bDescriptorType | BYTE | 1 | +1 | +1 | ディスクリプタ種別。デバイス能力ディスクリプタ。 |
| bDevCapabilityType | BYTE | 1 | +2 | +2 | 能力種別。Power Delivery能力を示す。 |
| bReserved | BYTE | 1 | +3 | +3 | 予約フィールド。0でなければならない。 |
| bmAttributes | _bmAttributes_e__Union | 8/4 | +4 | +4 | 電力供給に関する属性ビットを保持する無名共用体。 |
| bmProviderPorts | WORD | 2 | +12 | +8 | 電力供給可能なポートをビットマスクで示す。 |
| bmConsumerPorts | WORD | 2 | +14 | +10 | 電力消費可能なポートをビットマスクで示す。 |
| bcdBCVersion | WORD | 2 | +16 | +12 | Battery Charging仕様のバージョンをBCDで示す。 |
| bcdPDVersion | WORD | 2 | +18 | +14 | Power Delivery仕様のバージョンをBCDで示す。 |
| bcdUSBTypeCVersion | WORD | 2 | +20 | +16 | USB Type-C仕様のバージョンをBCDで示す。 |
共用体: _bmAttributes_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| AsUlong | DWORD | 4 | +0 | +0 |
| Anonymous | _Anonymous_e__Struct | 8/4 | +0 | +0 |
各言語での定義
#include <windows.h>
// USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR (x64 22 / x86 18 バイト)
#pragma pack(push, 1)
typedef struct USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR {
BYTE bLength;
BYTE bDescriptorType;
BYTE bDevCapabilityType;
BYTE bReserved;
_bmAttributes_e__Union bmAttributes;
WORD bmProviderPorts;
WORD bmConsumerPorts;
WORD bcdBCVersion;
WORD bcdPDVersion;
WORD bcdUSBTypeCVersion;
} USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR
{
public byte bLength;
public byte bDescriptorType;
public byte bDevCapabilityType;
public byte bReserved;
public _bmAttributes_e__Union bmAttributes;
public ushort bmProviderPorts;
public ushort bmConsumerPorts;
public ushort bcdBCVersion;
public ushort bcdPDVersion;
public ushort bcdUSBTypeCVersion;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR
Public bLength As Byte
Public bDescriptorType As Byte
Public bDevCapabilityType As Byte
Public bReserved As Byte
Public bmAttributes As _bmAttributes_e__Union
Public bmProviderPorts As UShort
Public bmConsumerPorts As UShort
Public bcdBCVersion As UShort
Public bcdPDVersion As UShort
Public bcdUSBTypeCVersion As UShort
End Structureimport ctypes
from ctypes import wintypes
class USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR(ctypes.Structure):
_pack_ = 1
_fields_ = [
("bLength", ctypes.c_ubyte),
("bDescriptorType", ctypes.c_ubyte),
("bDevCapabilityType", ctypes.c_ubyte),
("bReserved", ctypes.c_ubyte),
("bmAttributes", _bmAttributes_e__Union),
("bmProviderPorts", ctypes.c_ushort),
("bmConsumerPorts", ctypes.c_ushort),
("bcdBCVersion", ctypes.c_ushort),
("bcdPDVersion", ctypes.c_ushort),
("bcdUSBTypeCVersion", ctypes.c_ushort),
]#[repr(C, packed(1))]
pub struct USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR {
pub bLength: u8,
pub bDescriptorType: u8,
pub bDevCapabilityType: u8,
pub bReserved: u8,
pub bmAttributes: _bmAttributes_e__Union,
pub bmProviderPorts: u16,
pub bmConsumerPorts: u16,
pub bcdBCVersion: u16,
pub bcdPDVersion: u16,
pub bcdUSBTypeCVersion: u16,
}import "golang.org/x/sys/windows"
type USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR struct {
bLength byte
bDescriptorType byte
bDevCapabilityType byte
bReserved byte
bmAttributes _bmAttributes_e__Union
bmProviderPorts uint16
bmConsumerPorts uint16
bcdBCVersion uint16
bcdPDVersion uint16
bcdUSBTypeCVersion uint16
}type
USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR = packed record
bLength: Byte;
bDescriptorType: Byte;
bDevCapabilityType: Byte;
bReserved: Byte;
bmAttributes: _bmAttributes_e__Union;
bmProviderPorts: Word;
bmConsumerPorts: Word;
bcdBCVersion: Word;
bcdPDVersion: Word;
bcdUSBTypeCVersion: Word;
end;const USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR = extern struct {
bLength: u8,
bDescriptorType: u8,
bDevCapabilityType: u8,
bReserved: u8,
bmAttributes: _bmAttributes_e__Union,
bmProviderPorts: u16,
bmConsumerPorts: u16,
bcdBCVersion: u16,
bcdPDVersion: u16,
bcdUSBTypeCVersion: u16,
};type
USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR {.packed.} = object
bLength: uint8
bDescriptorType: uint8
bDevCapabilityType: uint8
bReserved: uint8
bmAttributes: _bmAttributes_e__Union
bmProviderPorts: uint16
bmConsumerPorts: uint16
bcdBCVersion: uint16
bcdPDVersion: uint16
bcdUSBTypeCVersion: uint16align(1)
struct USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR
{
ubyte bLength;
ubyte bDescriptorType;
ubyte bDevCapabilityType;
ubyte bReserved;
_bmAttributes_e__Union bmAttributes;
ushort bmProviderPorts;
ushort bmConsumerPorts;
ushort bcdBCVersion;
ushort bcdPDVersion;
ushort bcdUSBTypeCVersion;
}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_POWER_DELIVERY_DESCRIPTOR サイズ: 18 バイト(x86)
dim st, 5 ; 4byte整数×5(構造体サイズ 18 / 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)
; bmAttributes : _bmAttributes_e__Union (+4, 4byte) varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; bmProviderPorts : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; bmConsumerPorts : WORD (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; bcdBCVersion : WORD (+12, 2byte) wpoke st,12,値 / 値 = wpeek(st,12)
; bcdPDVersion : WORD (+14, 2byte) wpoke st,14,値 / 値 = wpeek(st,14)
; bcdUSBTypeCVersion : WORD (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR サイズ: 22 バイト(x64)
dim st, 6 ; 4byte整数×6(構造体サイズ 22 / 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)
; bmAttributes : _bmAttributes_e__Union (+4, 8byte) varptr(st)+4 を基点に操作(8byte:入れ子/配列)
; bmProviderPorts : WORD (+12, 2byte) wpoke st,12,値 / 値 = wpeek(st,12)
; bmConsumerPorts : WORD (+14, 2byte) wpoke st,14,値 / 値 = wpeek(st,14)
; bcdBCVersion : WORD (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; bcdPDVersion : WORD (+18, 2byte) wpoke st,18,値 / 値 = wpeek(st,18)
; bcdUSBTypeCVersion : WORD (+20, 2byte) wpoke st,20,値 / 値 = wpeek(st,20)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR, pack=1
#field byte bLength
#field byte bDescriptorType
#field byte bDevCapabilityType
#field byte bReserved
#field byte bmAttributes 8
#field short bmProviderPorts
#field short bmConsumerPorts
#field short bcdBCVersion
#field short bcdPDVersion
#field short bcdUSBTypeCVersion
#endstruct
stdim st, USB_DEVICE_CAPABILITY_POWER_DELIVERY_DESCRIPTOR ; NSTRUCT 変数を確保
st->bLength = 100
mes "bLength=" + st->bLength
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。