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

HCD_STAT_INFORMATION_1

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

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

フィールド

フィールドサイズx64x86説明
Reserved1DWORD4+0+0予約フィールド。未使用。
Reserved2DWORD4+4+4予約フィールド。未使用。
ResetCountersDWORD4+8+8非0を設定するとカウンタをリセットする要求フラグ。
TimeReadLONGLONG8+12+12統計を読み出した時刻(QPCティック等)。
CountersHCD_STAT_COUNTERS24+20+20ホストコントローラの各種統計カウンタ。

各言語での定義

#include <windows.h>

// HCD_STAT_COUNTERS  (x64 24 / x86 24 バイト)
#pragma pack(push, 1)
typedef struct HCD_STAT_COUNTERS {
    DWORD BytesTransferred;
    WORD IsoMissedCount;
    WORD DataOverrunErrorCount;
    WORD CrcErrorCount;
    WORD ScheduleOverrunCount;
    WORD TimeoutErrorCount;
    WORD InternalHcErrorCount;
    WORD BufferOverrunErrorCount;
    WORD SWErrorCount;
    WORD StallPidCount;
    WORD PortDisableCount;
} HCD_STAT_COUNTERS;
#pragma pack(pop)

// HCD_STAT_INFORMATION_1  (x64 44 / x86 44 バイト)
#pragma pack(push, 1)
typedef struct HCD_STAT_INFORMATION_1 {
    DWORD Reserved1;
    DWORD Reserved2;
    DWORD ResetCounters;
    LONGLONG TimeRead;
    HCD_STAT_COUNTERS Counters;
} HCD_STAT_INFORMATION_1;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct HCD_STAT_COUNTERS
{
    public uint BytesTransferred;
    public ushort IsoMissedCount;
    public ushort DataOverrunErrorCount;
    public ushort CrcErrorCount;
    public ushort ScheduleOverrunCount;
    public ushort TimeoutErrorCount;
    public ushort InternalHcErrorCount;
    public ushort BufferOverrunErrorCount;
    public ushort SWErrorCount;
    public ushort StallPidCount;
    public ushort PortDisableCount;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct HCD_STAT_INFORMATION_1
{
    public uint Reserved1;
    public uint Reserved2;
    public uint ResetCounters;
    public long TimeRead;
    public HCD_STAT_COUNTERS Counters;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure HCD_STAT_COUNTERS
    Public BytesTransferred As UInteger
    Public IsoMissedCount As UShort
    Public DataOverrunErrorCount As UShort
    Public CrcErrorCount As UShort
    Public ScheduleOverrunCount As UShort
    Public TimeoutErrorCount As UShort
    Public InternalHcErrorCount As UShort
    Public BufferOverrunErrorCount As UShort
    Public SWErrorCount As UShort
    Public StallPidCount As UShort
    Public PortDisableCount As UShort
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure HCD_STAT_INFORMATION_1
    Public Reserved1 As UInteger
    Public Reserved2 As UInteger
    Public ResetCounters As UInteger
    Public TimeRead As Long
    Public Counters As HCD_STAT_COUNTERS
End Structure
import ctypes
from ctypes import wintypes

class HCD_STAT_COUNTERS(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("BytesTransferred", wintypes.DWORD),
        ("IsoMissedCount", ctypes.c_ushort),
        ("DataOverrunErrorCount", ctypes.c_ushort),
        ("CrcErrorCount", ctypes.c_ushort),
        ("ScheduleOverrunCount", ctypes.c_ushort),
        ("TimeoutErrorCount", ctypes.c_ushort),
        ("InternalHcErrorCount", ctypes.c_ushort),
        ("BufferOverrunErrorCount", ctypes.c_ushort),
        ("SWErrorCount", ctypes.c_ushort),
        ("StallPidCount", ctypes.c_ushort),
        ("PortDisableCount", ctypes.c_ushort),
    ]

class HCD_STAT_INFORMATION_1(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("Reserved1", wintypes.DWORD),
        ("Reserved2", wintypes.DWORD),
        ("ResetCounters", wintypes.DWORD),
        ("TimeRead", ctypes.c_longlong),
        ("Counters", HCD_STAT_COUNTERS),
    ]
#[repr(C, packed(1))]
pub struct HCD_STAT_COUNTERS {
    pub BytesTransferred: u32,
    pub IsoMissedCount: u16,
    pub DataOverrunErrorCount: u16,
    pub CrcErrorCount: u16,
    pub ScheduleOverrunCount: u16,
    pub TimeoutErrorCount: u16,
    pub InternalHcErrorCount: u16,
    pub BufferOverrunErrorCount: u16,
    pub SWErrorCount: u16,
    pub StallPidCount: u16,
    pub PortDisableCount: u16,
}

#[repr(C, packed(1))]
pub struct HCD_STAT_INFORMATION_1 {
    pub Reserved1: u32,
    pub Reserved2: u32,
    pub ResetCounters: u32,
    pub TimeRead: i64,
    pub Counters: HCD_STAT_COUNTERS,
}
import "golang.org/x/sys/windows"

type HCD_STAT_COUNTERS struct {
	BytesTransferred uint32
	IsoMissedCount uint16
	DataOverrunErrorCount uint16
	CrcErrorCount uint16
	ScheduleOverrunCount uint16
	TimeoutErrorCount uint16
	InternalHcErrorCount uint16
	BufferOverrunErrorCount uint16
	SWErrorCount uint16
	StallPidCount uint16
	PortDisableCount uint16
}

type HCD_STAT_INFORMATION_1 struct {
	Reserved1 uint32
	Reserved2 uint32
	ResetCounters uint32
	TimeRead int64
	Counters HCD_STAT_COUNTERS
}
type
  HCD_STAT_COUNTERS = packed record
    BytesTransferred: DWORD;
    IsoMissedCount: Word;
    DataOverrunErrorCount: Word;
    CrcErrorCount: Word;
    ScheduleOverrunCount: Word;
    TimeoutErrorCount: Word;
    InternalHcErrorCount: Word;
    BufferOverrunErrorCount: Word;
    SWErrorCount: Word;
    StallPidCount: Word;
    PortDisableCount: Word;
  end;

  HCD_STAT_INFORMATION_1 = packed record
    Reserved1: DWORD;
    Reserved2: DWORD;
    ResetCounters: DWORD;
    TimeRead: Int64;
    Counters: HCD_STAT_COUNTERS;
  end;
const HCD_STAT_COUNTERS = extern struct {
    BytesTransferred: u32,
    IsoMissedCount: u16,
    DataOverrunErrorCount: u16,
    CrcErrorCount: u16,
    ScheduleOverrunCount: u16,
    TimeoutErrorCount: u16,
    InternalHcErrorCount: u16,
    BufferOverrunErrorCount: u16,
    SWErrorCount: u16,
    StallPidCount: u16,
    PortDisableCount: u16,
};

const HCD_STAT_INFORMATION_1 = extern struct {
    Reserved1: u32,
    Reserved2: u32,
    ResetCounters: u32,
    TimeRead: i64,
    Counters: HCD_STAT_COUNTERS,
};
type
  HCD_STAT_COUNTERS {.packed.} = object
    BytesTransferred: uint32
    IsoMissedCount: uint16
    DataOverrunErrorCount: uint16
    CrcErrorCount: uint16
    ScheduleOverrunCount: uint16
    TimeoutErrorCount: uint16
    InternalHcErrorCount: uint16
    BufferOverrunErrorCount: uint16
    SWErrorCount: uint16
    StallPidCount: uint16
    PortDisableCount: uint16

  HCD_STAT_INFORMATION_1 {.packed.} = object
    Reserved1: uint32
    Reserved2: uint32
    ResetCounters: uint32
    TimeRead: int64
    Counters: HCD_STAT_COUNTERS
align(1)
struct HCD_STAT_COUNTERS
{
    uint BytesTransferred;
    ushort IsoMissedCount;
    ushort DataOverrunErrorCount;
    ushort CrcErrorCount;
    ushort ScheduleOverrunCount;
    ushort TimeoutErrorCount;
    ushort InternalHcErrorCount;
    ushort BufferOverrunErrorCount;
    ushort SWErrorCount;
    ushort StallPidCount;
    ushort PortDisableCount;
}

align(1)
struct HCD_STAT_INFORMATION_1
{
    uint Reserved1;
    uint Reserved2;
    uint ResetCounters;
    long TimeRead;
    HCD_STAT_COUNTERS Counters;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; HCD_STAT_INFORMATION_1 サイズ: 44 バイト(x64)
dim st, 11    ; 4byte整数×11(構造体サイズ 44 / 4 切り上げ)
; Reserved1 : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Reserved2 : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ResetCounters : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; TimeRead : LONGLONG (+12, 8byte)  qpoke st,12,値 / qpeek(st,12)  ※IronHSPのみ。3.7/3.8は lpoke st,12,下位 : lpoke st,16,上位
; Counters : HCD_STAT_COUNTERS (+20, 24byte)  varptr(st)+20 を基点に操作(24byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global HCD_STAT_COUNTERS, pack=1
    #field int BytesTransferred
    #field short IsoMissedCount
    #field short DataOverrunErrorCount
    #field short CrcErrorCount
    #field short ScheduleOverrunCount
    #field short TimeoutErrorCount
    #field short InternalHcErrorCount
    #field short BufferOverrunErrorCount
    #field short SWErrorCount
    #field short StallPidCount
    #field short PortDisableCount
#endstruct

#defstruct global HCD_STAT_INFORMATION_1, pack=1
    #field int Reserved1
    #field int Reserved2
    #field int ResetCounters
    #field int64 TimeRead
    #field HCD_STAT_COUNTERS Counters
#endstruct

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