ホーム › Devices.Usb › USB_ENDPOINT_DESCRIPTOR
USB_ENDPOINT_DESCRIPTOR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| bLength | BYTE | 1 | +0 | +0 | このディスクリプタのサイズをバイト単位で示す。通常7。 |
| bDescriptorType | BYTE | 1 | +1 | +1 | ディスクリプタ種別。エンドポイントは0x05。 |
| bEndpointAddress | BYTE | 1 | +2 | +2 | エンドポイントのアドレスと方向(最上位ビットがIN/OUT)を示す。 |
| bmAttributes | BYTE | 1 | +3 | +3 | 転送タイプ(制御/アイソクロナス/バルク/割込)等を示す属性。 |
| wMaxPacketSize | WORD | 2 | +4 | +4 | このエンドポイントの最大パケットサイズをバイト単位で示す。 |
| bInterval | BYTE | 1 | +6 | +6 | ポーリング間隔をフレーム/マイクロフレーム単位で示す。 |
各言語での定義
#include <windows.h>
// USB_ENDPOINT_DESCRIPTOR (x64 7 / x86 7 バイト)
#pragma pack(push, 1)
typedef struct USB_ENDPOINT_DESCRIPTOR {
BYTE bLength;
BYTE bDescriptorType;
BYTE bEndpointAddress;
BYTE bmAttributes;
WORD wMaxPacketSize;
BYTE bInterval;
} USB_ENDPOINT_DESCRIPTOR;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_ENDPOINT_DESCRIPTOR
{
public byte bLength;
public byte bDescriptorType;
public byte bEndpointAddress;
public byte bmAttributes;
public ushort wMaxPacketSize;
public byte bInterval;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_ENDPOINT_DESCRIPTOR
Public bLength As Byte
Public bDescriptorType As Byte
Public bEndpointAddress As Byte
Public bmAttributes As Byte
Public wMaxPacketSize As UShort
Public bInterval As Byte
End Structureimport ctypes
from ctypes import wintypes
class USB_ENDPOINT_DESCRIPTOR(ctypes.Structure):
_pack_ = 1
_fields_ = [
("bLength", ctypes.c_ubyte),
("bDescriptorType", ctypes.c_ubyte),
("bEndpointAddress", ctypes.c_ubyte),
("bmAttributes", ctypes.c_ubyte),
("wMaxPacketSize", ctypes.c_ushort),
("bInterval", ctypes.c_ubyte),
]#[repr(C, packed(1))]
pub struct USB_ENDPOINT_DESCRIPTOR {
pub bLength: u8,
pub bDescriptorType: u8,
pub bEndpointAddress: u8,
pub bmAttributes: u8,
pub wMaxPacketSize: u16,
pub bInterval: u8,
}import "golang.org/x/sys/windows"
type USB_ENDPOINT_DESCRIPTOR struct {
bLength byte
bDescriptorType byte
bEndpointAddress byte
bmAttributes byte
wMaxPacketSize uint16
bInterval byte
}type
USB_ENDPOINT_DESCRIPTOR = packed record
bLength: Byte;
bDescriptorType: Byte;
bEndpointAddress: Byte;
bmAttributes: Byte;
wMaxPacketSize: Word;
bInterval: Byte;
end;const USB_ENDPOINT_DESCRIPTOR = extern struct {
bLength: u8,
bDescriptorType: u8,
bEndpointAddress: u8,
bmAttributes: u8,
wMaxPacketSize: u16,
bInterval: u8,
};type
USB_ENDPOINT_DESCRIPTOR {.packed.} = object
bLength: uint8
bDescriptorType: uint8
bEndpointAddress: uint8
bmAttributes: uint8
wMaxPacketSize: uint16
bInterval: uint8align(1)
struct USB_ENDPOINT_DESCRIPTOR
{
ubyte bLength;
ubyte bDescriptorType;
ubyte bEndpointAddress;
ubyte bmAttributes;
ushort wMaxPacketSize;
ubyte bInterval;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_ENDPOINT_DESCRIPTOR サイズ: 7 バイト(x64)
dim st, 2 ; 4byte整数×2(構造体サイズ 7 / 4 切り上げ)
; bLength : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; bDescriptorType : BYTE (+1, 1byte) poke st,1,値 / 値 = peek(st,1)
; bEndpointAddress : BYTE (+2, 1byte) poke st,2,値 / 値 = peek(st,2)
; bmAttributes : BYTE (+3, 1byte) poke st,3,値 / 値 = peek(st,3)
; wMaxPacketSize : WORD (+4, 2byte) wpoke st,4,値 / 値 = wpeek(st,4)
; bInterval : BYTE (+6, 1byte) poke st,6,値 / 値 = peek(st,6)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_ENDPOINT_DESCRIPTOR, pack=1
#field byte bLength
#field byte bDescriptorType
#field byte bEndpointAddress
#field byte bmAttributes
#field short wMaxPacketSize
#field byte bInterval
#endstruct
stdim st, USB_ENDPOINT_DESCRIPTOR ; NSTRUCT 変数を確保
st->bLength = 100
mes "bLength=" + st->bLength