ホーム › Devices.SerialCommunication › SERENUM_PORT_PARAMETERS
SERENUM_PORT_PARAMETERS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Size | DWORD | 4 | +0 | +0 | このパラメータ構造体のサイズをバイトで表す。 |
| ReadAccessor | PSERENUM_READPORT | 8/4 | +8 | +4 | ポート読み取り用アクセサ関数へのポインタ。 |
| WriteAccessor | PSERENUM_WRITEPORT | 8/4 | +16 | +8 | ポート書き込み用アクセサ関数へのポインタ。 |
| SerPortAddress | void* | 8/4 | +24 | +12 | シリアルポートのアドレスを指すポインタ。 |
| HardwareHandle | void* | 8/4 | +32 | +16 | ハードウェアアクセス用のハンドルを指すポインタ。 |
| Portion | SERENUM_PORTION | 4 | +40 | +20 | アクセス対象のポート部分を示すSERENUM_PORTION値。 |
| NumberAxis | WORD | 2 | +44 | +24 | デバイスの軸(チャネル)数を表す。 |
| Reserved | WORD | 6 | +46 | +26 | 予約フィールド。0を設定する。 |
各言語での定義
#include <windows.h>
// SERENUM_PORT_PARAMETERS (x64 56 / x86 32 バイト)
typedef struct SERENUM_PORT_PARAMETERS {
DWORD Size;
PSERENUM_READPORT ReadAccessor;
PSERENUM_WRITEPORT WriteAccessor;
void* SerPortAddress;
void* HardwareHandle;
SERENUM_PORTION Portion;
WORD NumberAxis;
WORD Reserved[3];
} SERENUM_PORT_PARAMETERS;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERENUM_PORT_PARAMETERS
{
public uint Size;
public IntPtr ReadAccessor;
public IntPtr WriteAccessor;
public IntPtr SerPortAddress;
public IntPtr HardwareHandle;
public int Portion;
public ushort NumberAxis;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public ushort[] Reserved;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERENUM_PORT_PARAMETERS
Public Size As UInteger
Public ReadAccessor As IntPtr
Public WriteAccessor As IntPtr
Public SerPortAddress As IntPtr
Public HardwareHandle As IntPtr
Public Portion As Integer
Public NumberAxis As UShort
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public Reserved() As UShort
End Structureimport ctypes
from ctypes import wintypes
class SERENUM_PORT_PARAMETERS(ctypes.Structure):
_fields_ = [
("Size", wintypes.DWORD),
("ReadAccessor", ctypes.c_void_p),
("WriteAccessor", ctypes.c_void_p),
("SerPortAddress", ctypes.c_void_p),
("HardwareHandle", ctypes.c_void_p),
("Portion", ctypes.c_int),
("NumberAxis", ctypes.c_ushort),
("Reserved", ctypes.c_ushort * 3),
]#[repr(C)]
pub struct SERENUM_PORT_PARAMETERS {
pub Size: u32,
pub ReadAccessor: *mut core::ffi::c_void,
pub WriteAccessor: *mut core::ffi::c_void,
pub SerPortAddress: *mut core::ffi::c_void,
pub HardwareHandle: *mut core::ffi::c_void,
pub Portion: i32,
pub NumberAxis: u16,
pub Reserved: [u16; 3],
}import "golang.org/x/sys/windows"
type SERENUM_PORT_PARAMETERS struct {
Size uint32
ReadAccessor uintptr
WriteAccessor uintptr
SerPortAddress uintptr
HardwareHandle uintptr
Portion int32
NumberAxis uint16
Reserved [3]uint16
}type
SERENUM_PORT_PARAMETERS = record
Size: DWORD;
ReadAccessor: Pointer;
WriteAccessor: Pointer;
SerPortAddress: Pointer;
HardwareHandle: Pointer;
Portion: Integer;
NumberAxis: Word;
Reserved: array[0..2] of Word;
end;const SERENUM_PORT_PARAMETERS = extern struct {
Size: u32,
ReadAccessor: ?*anyopaque,
WriteAccessor: ?*anyopaque,
SerPortAddress: ?*anyopaque,
HardwareHandle: ?*anyopaque,
Portion: i32,
NumberAxis: u16,
Reserved: [3]u16,
};type
SERENUM_PORT_PARAMETERS {.bycopy.} = object
Size: uint32
ReadAccessor: pointer
WriteAccessor: pointer
SerPortAddress: pointer
HardwareHandle: pointer
Portion: int32
NumberAxis: uint16
Reserved: array[3, uint16]struct SERENUM_PORT_PARAMETERS
{
uint Size;
void* ReadAccessor;
void* WriteAccessor;
void* SerPortAddress;
void* HardwareHandle;
int Portion;
ushort NumberAxis;
ushort[3] Reserved;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SERENUM_PORT_PARAMETERS サイズ: 32 バイト(x86)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; Size : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; ReadAccessor : PSERENUM_READPORT (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; WriteAccessor : PSERENUM_WRITEPORT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; SerPortAddress : void* (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; HardwareHandle : void* (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; Portion : SERENUM_PORTION (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; NumberAxis : WORD (+24, 2byte) wpoke st,24,値 / 値 = wpeek(st,24)
; Reserved : WORD (+26, 6byte) varptr(st)+26 を基点に操作(6byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SERENUM_PORT_PARAMETERS サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; Size : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; ReadAccessor : PSERENUM_READPORT (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; WriteAccessor : PSERENUM_WRITEPORT (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; SerPortAddress : void* (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; HardwareHandle : void* (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; Portion : SERENUM_PORTION (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; NumberAxis : WORD (+44, 2byte) wpoke st,44,値 / 値 = wpeek(st,44)
; Reserved : WORD (+46, 6byte) varptr(st)+46 を基点に操作(6byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SERENUM_PORT_PARAMETERS
#field int Size
#field intptr ReadAccessor
#field intptr WriteAccessor
#field intptr SerPortAddress
#field intptr HardwareHandle
#field int Portion
#field short NumberAxis
#field short Reserved 3
#endstruct
stdim st, SERENUM_PORT_PARAMETERS ; NSTRUCT 変数を確保
st->Size = 100
mes "Size=" + st->Size