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

SERIAL_COMMPROP

構造体
サイズx64: 64 バイト / x86: 64 バイト

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

フィールド

フィールドサイズx64x86説明
PacketLengthWORD2+0+0このプロパティパケット全体の長さをバイトで表す。
PacketVersionWORD2+2+2プロパティパケットのバージョン番号を表す。
ServiceMaskDWORD4+4+4プロバイダが提供するサービスを示すビットマスク。
Reserved1DWORD4+8+8予約フィールド。
MaxTxQueueDWORD4+12+12送信キューの最大サイズをバイトで表す。0で制限なし。
MaxRxQueueDWORD4+16+16受信キューの最大サイズをバイトで表す。0で制限なし。
MaxBaudDWORD4+20+20サポートする最大ボーレートを示すフラグ。
ProvSubTypeDWORD4+24+24通信プロバイダのサブタイプ(RS232等)を示す値。
ProvCapabilitiesDWORD4+28+28プロバイダが備える機能を示すフラグの組み合わせ。
SettableParamsDWORD4+32+32設定変更可能なパラメータを示すフラグ。
SettableBaudDWORD4+36+36設定可能なボーレートを示すフラグの組み合わせ。
SettableDataWORD2+40+40設定可能なデータビット長を示すフラグ。
SettableStopParityWORD2+42+42設定可能なストップビット/パリティを示すフラグ。
CurrentTxQueueDWORD4+44+44現在の送信キューサイズをバイトで表す。0で不明。
CurrentRxQueueDWORD4+48+48現在の受信キューサイズをバイトで表す。0で不明。
ProvSpec1DWORD4+52+52プロバイダ固有のデータ領域1。
ProvSpec2DWORD4+56+56プロバイダ固有のデータ領域2。
ProvCharWCHAR2+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 Structure
import 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