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

USB_PIPE_INFO

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

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

フィールド

フィールドサイズx64x86説明
EndpointDescriptorUSB_ENDPOINT_DESCRIPTOR7+0+0このパイプに対応するエンドポイントディスクリプタを格納する。
ScheduleOffsetDWORD4+7+7転送スケジュール内のオフセットを示す。

各言語での定義

#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)

// USB_PIPE_INFO  (x64 11 / x86 11 バイト)
#pragma pack(push, 1)
typedef struct USB_PIPE_INFO {
    USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
    DWORD ScheduleOffset;
} USB_PIPE_INFO;
#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;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_PIPE_INFO
{
    public USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
    public uint ScheduleOffset;
}
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 Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_PIPE_INFO
    Public EndpointDescriptor As USB_ENDPOINT_DESCRIPTOR
    Public ScheduleOffset As UInteger
End Structure
import 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),
    ]

class USB_PIPE_INFO(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("EndpointDescriptor", USB_ENDPOINT_DESCRIPTOR),
        ("ScheduleOffset", wintypes.DWORD),
    ]
#[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,
}

#[repr(C, packed(1))]
pub struct USB_PIPE_INFO {
    pub EndpointDescriptor: USB_ENDPOINT_DESCRIPTOR,
    pub ScheduleOffset: u32,
}
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_PIPE_INFO struct {
	EndpointDescriptor USB_ENDPOINT_DESCRIPTOR
	ScheduleOffset uint32
}
type
  USB_ENDPOINT_DESCRIPTOR = packed record
    bLength: Byte;
    bDescriptorType: Byte;
    bEndpointAddress: Byte;
    bmAttributes: Byte;
    wMaxPacketSize: Word;
    bInterval: Byte;
  end;

  USB_PIPE_INFO = packed record
    EndpointDescriptor: USB_ENDPOINT_DESCRIPTOR;
    ScheduleOffset: DWORD;
  end;
const USB_ENDPOINT_DESCRIPTOR = extern struct {
    bLength: u8,
    bDescriptorType: u8,
    bEndpointAddress: u8,
    bmAttributes: u8,
    wMaxPacketSize: u16,
    bInterval: u8,
};

const USB_PIPE_INFO = extern struct {
    EndpointDescriptor: USB_ENDPOINT_DESCRIPTOR,
    ScheduleOffset: u32,
};
type
  USB_ENDPOINT_DESCRIPTOR {.packed.} = object
    bLength: uint8
    bDescriptorType: uint8
    bEndpointAddress: uint8
    bmAttributes: uint8
    wMaxPacketSize: uint16
    bInterval: uint8

  USB_PIPE_INFO {.packed.} = object
    EndpointDescriptor: USB_ENDPOINT_DESCRIPTOR
    ScheduleOffset: uint32
align(1)
struct USB_ENDPOINT_DESCRIPTOR
{
    ubyte bLength;
    ubyte bDescriptorType;
    ubyte bEndpointAddress;
    ubyte bmAttributes;
    ushort wMaxPacketSize;
    ubyte bInterval;
}

align(1)
struct USB_PIPE_INFO
{
    USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
    uint ScheduleOffset;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_PIPE_INFO サイズ: 11 バイト(x64)
dim st, 3    ; 4byte整数×3(構造体サイズ 11 / 4 切り上げ)
; EndpointDescriptor : USB_ENDPOINT_DESCRIPTOR (+0, 7byte)  varptr(st)+0 を基点に操作(7byte:入れ子/配列)
; ScheduleOffset : DWORD (+7, 4byte)  lpoke st,7,値  /  値 = lpeek(st,7)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#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

#defstruct global USB_PIPE_INFO, pack=1
    #field USB_ENDPOINT_DESCRIPTOR EndpointDescriptor
    #field int ScheduleOffset
#endstruct

stdim st, USB_PIPE_INFO        ; NSTRUCT 変数を確保
st->ScheduleOffset = 100
mes "ScheduleOffset=" + st->ScheduleOffset