ホーム › Devices.SerialCommunication › SERIAL_COMMPROP
SERIAL_COMMPROP
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| PacketLength | WORD | 2 | +0 | +0 | このプロパティパケット全体の長さをバイトで表す。 |
| PacketVersion | WORD | 2 | +2 | +2 | プロパティパケットのバージョン番号を表す。 |
| ServiceMask | DWORD | 4 | +4 | +4 | プロバイダが提供するサービスを示すビットマスク。 |
| Reserved1 | DWORD | 4 | +8 | +8 | 予約フィールド。 |
| MaxTxQueue | DWORD | 4 | +12 | +12 | 送信キューの最大サイズをバイトで表す。0で制限なし。 |
| MaxRxQueue | DWORD | 4 | +16 | +16 | 受信キューの最大サイズをバイトで表す。0で制限なし。 |
| MaxBaud | DWORD | 4 | +20 | +20 | サポートする最大ボーレートを示すフラグ。 |
| ProvSubType | DWORD | 4 | +24 | +24 | 通信プロバイダのサブタイプ(RS232等)を示す値。 |
| ProvCapabilities | DWORD | 4 | +28 | +28 | プロバイダが備える機能を示すフラグの組み合わせ。 |
| SettableParams | DWORD | 4 | +32 | +32 | 設定変更可能なパラメータを示すフラグ。 |
| SettableBaud | DWORD | 4 | +36 | +36 | 設定可能なボーレートを示すフラグの組み合わせ。 |
| SettableData | WORD | 2 | +40 | +40 | 設定可能なデータビット長を示すフラグ。 |
| SettableStopParity | WORD | 2 | +42 | +42 | 設定可能なストップビット/パリティを示すフラグ。 |
| CurrentTxQueue | DWORD | 4 | +44 | +44 | 現在の送信キューサイズをバイトで表す。0で不明。 |
| CurrentRxQueue | DWORD | 4 | +48 | +48 | 現在の受信キューサイズをバイトで表す。0で不明。 |
| ProvSpec1 | DWORD | 4 | +52 | +52 | プロバイダ固有のデータ領域1。 |
| ProvSpec2 | DWORD | 4 | +56 | +56 | プロバイダ固有のデータ領域2。 |
| ProvChar | WCHAR | 2 | +60 | +60 | プロバイダ固有データを格納するワイド文字配列の先頭。 |
各言語での定義
#include <windows.h>
// SERIAL_COMMPROP (x64 64 / x86 64 バイト)
typedef struct SERIAL_COMMPROP {
WORD PacketLength;
WORD PacketVersion;
DWORD ServiceMask;
DWORD Reserved1;
DWORD MaxTxQueue;
DWORD MaxRxQueue;
DWORD MaxBaud;
DWORD ProvSubType;
DWORD ProvCapabilities;
DWORD SettableParams;
DWORD SettableBaud;
WORD SettableData;
WORD SettableStopParity;
DWORD CurrentTxQueue;
DWORD CurrentRxQueue;
DWORD ProvSpec1;
DWORD ProvSpec2;
WCHAR ProvChar[1];
} SERIAL_COMMPROP;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERIAL_COMMPROP
{
public ushort PacketLength;
public ushort PacketVersion;
public uint ServiceMask;
public uint Reserved1;
public uint MaxTxQueue;
public uint MaxRxQueue;
public uint MaxBaud;
public uint ProvSubType;
public uint ProvCapabilities;
public uint SettableParams;
public uint SettableBaud;
public ushort SettableData;
public ushort SettableStopParity;
public uint CurrentTxQueue;
public uint CurrentRxQueue;
public uint ProvSpec1;
public uint ProvSpec2;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)] public string ProvChar;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERIAL_COMMPROP
Public PacketLength As UShort
Public PacketVersion As UShort
Public ServiceMask As UInteger
Public Reserved1 As UInteger
Public MaxTxQueue As UInteger
Public MaxRxQueue As UInteger
Public MaxBaud As UInteger
Public ProvSubType As UInteger
Public ProvCapabilities As UInteger
Public SettableParams As UInteger
Public SettableBaud As UInteger
Public SettableData As UShort
Public SettableStopParity As UShort
Public CurrentTxQueue As UInteger
Public CurrentRxQueue As UInteger
Public ProvSpec1 As UInteger
Public ProvSpec2 As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)> Public ProvChar As String
End Structureimport ctypes
from ctypes import wintypes
class SERIAL_COMMPROP(ctypes.Structure):
_fields_ = [
("PacketLength", ctypes.c_ushort),
("PacketVersion", ctypes.c_ushort),
("ServiceMask", wintypes.DWORD),
("Reserved1", wintypes.DWORD),
("MaxTxQueue", wintypes.DWORD),
("MaxRxQueue", wintypes.DWORD),
("MaxBaud", wintypes.DWORD),
("ProvSubType", wintypes.DWORD),
("ProvCapabilities", wintypes.DWORD),
("SettableParams", wintypes.DWORD),
("SettableBaud", wintypes.DWORD),
("SettableData", ctypes.c_ushort),
("SettableStopParity", ctypes.c_ushort),
("CurrentTxQueue", wintypes.DWORD),
("CurrentRxQueue", wintypes.DWORD),
("ProvSpec1", wintypes.DWORD),
("ProvSpec2", wintypes.DWORD),
("ProvChar", ctypes.c_wchar * 1),
]#[repr(C)]
pub struct SERIAL_COMMPROP {
pub PacketLength: u16,
pub PacketVersion: u16,
pub ServiceMask: u32,
pub Reserved1: u32,
pub MaxTxQueue: u32,
pub MaxRxQueue: u32,
pub MaxBaud: u32,
pub ProvSubType: u32,
pub ProvCapabilities: u32,
pub SettableParams: u32,
pub SettableBaud: u32,
pub SettableData: u16,
pub SettableStopParity: u16,
pub CurrentTxQueue: u32,
pub CurrentRxQueue: u32,
pub ProvSpec1: u32,
pub ProvSpec2: u32,
pub ProvChar: [u16; 1],
}import "golang.org/x/sys/windows"
type SERIAL_COMMPROP struct {
PacketLength uint16
PacketVersion uint16
ServiceMask uint32
Reserved1 uint32
MaxTxQueue uint32
MaxRxQueue uint32
MaxBaud uint32
ProvSubType uint32
ProvCapabilities uint32
SettableParams uint32
SettableBaud uint32
SettableData uint16
SettableStopParity uint16
CurrentTxQueue uint32
CurrentRxQueue uint32
ProvSpec1 uint32
ProvSpec2 uint32
ProvChar [1]uint16
}type
SERIAL_COMMPROP = record
PacketLength: Word;
PacketVersion: Word;
ServiceMask: DWORD;
Reserved1: DWORD;
MaxTxQueue: DWORD;
MaxRxQueue: DWORD;
MaxBaud: DWORD;
ProvSubType: DWORD;
ProvCapabilities: DWORD;
SettableParams: DWORD;
SettableBaud: DWORD;
SettableData: Word;
SettableStopParity: Word;
CurrentTxQueue: DWORD;
CurrentRxQueue: DWORD;
ProvSpec1: DWORD;
ProvSpec2: DWORD;
ProvChar: array[0..0] of WideChar;
end;const SERIAL_COMMPROP = extern struct {
PacketLength: u16,
PacketVersion: u16,
ServiceMask: u32,
Reserved1: u32,
MaxTxQueue: u32,
MaxRxQueue: u32,
MaxBaud: u32,
ProvSubType: u32,
ProvCapabilities: u32,
SettableParams: u32,
SettableBaud: u32,
SettableData: u16,
SettableStopParity: u16,
CurrentTxQueue: u32,
CurrentRxQueue: u32,
ProvSpec1: u32,
ProvSpec2: u32,
ProvChar: [1]u16,
};type
SERIAL_COMMPROP {.bycopy.} = object
PacketLength: uint16
PacketVersion: uint16
ServiceMask: uint32
Reserved1: uint32
MaxTxQueue: uint32
MaxRxQueue: uint32
MaxBaud: uint32
ProvSubType: uint32
ProvCapabilities: uint32
SettableParams: uint32
SettableBaud: uint32
SettableData: uint16
SettableStopParity: uint16
CurrentTxQueue: uint32
CurrentRxQueue: uint32
ProvSpec1: uint32
ProvSpec2: uint32
ProvChar: array[1, uint16]struct SERIAL_COMMPROP
{
ushort PacketLength;
ushort PacketVersion;
uint ServiceMask;
uint Reserved1;
uint MaxTxQueue;
uint MaxRxQueue;
uint MaxBaud;
uint ProvSubType;
uint ProvCapabilities;
uint SettableParams;
uint SettableBaud;
ushort SettableData;
ushort SettableStopParity;
uint CurrentTxQueue;
uint CurrentRxQueue;
uint ProvSpec1;
uint ProvSpec2;
wchar[1] ProvChar;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SERIAL_COMMPROP サイズ: 64 バイト(x64)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; PacketLength : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; PacketVersion : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; ServiceMask : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Reserved1 : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; MaxTxQueue : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; MaxRxQueue : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; MaxBaud : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; ProvSubType : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ProvCapabilities : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; SettableParams : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; SettableBaud : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; SettableData : WORD (+40, 2byte) wpoke st,40,値 / 値 = wpeek(st,40)
; SettableStopParity : WORD (+42, 2byte) wpoke st,42,値 / 値 = wpeek(st,42)
; CurrentTxQueue : DWORD (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; CurrentRxQueue : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; ProvSpec1 : DWORD (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; ProvSpec2 : DWORD (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; ProvChar : WCHAR (+60, 2byte) varptr(st)+60 を基点に操作(2byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SERIAL_COMMPROP
#field short PacketLength
#field short PacketVersion
#field int ServiceMask
#field int Reserved1
#field int MaxTxQueue
#field int MaxRxQueue
#field int MaxBaud
#field int ProvSubType
#field int ProvCapabilities
#field int SettableParams
#field int SettableBaud
#field short SettableData
#field short SettableStopParity
#field int CurrentTxQueue
#field int CurrentRxQueue
#field int ProvSpec1
#field int ProvSpec2
#field wchar ProvChar 1
#endstruct
stdim st, SERIAL_COMMPROP ; NSTRUCT 変数を確保
st->PacketLength = 100
mes "PacketLength=" + st->PacketLength