ホーム › Devices.SerialCommunication › SERIAL_STATUS
SERIAL_STATUS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Errors | DWORD | 4 | +0 | +0 | 発生中の通信エラー要因を示すフラグの組み合わせ。 |
| HoldReasons | DWORD | 4 | +4 | +4 | 送信が保留されている理由を示すフラグの組み合わせ。 |
| AmountInInQueue | DWORD | 4 | +8 | +8 | 受信キューに残っているバイト数を表す。 |
| AmountInOutQueue | DWORD | 4 | +12 | +12 | 送信キューに残っているバイト数を表す。 |
| EofReceived | BOOLEAN | 1 | +16 | +16 | EOF文字を受信したか否かを示す。 |
| WaitForImmediate | BOOLEAN | 1 | +17 | +17 | 即時送信文字の送出待機中か否かを示す。 |
各言語での定義
#include <windows.h>
// SERIAL_STATUS (x64 20 / x86 20 バイト)
typedef struct SERIAL_STATUS {
DWORD Errors;
DWORD HoldReasons;
DWORD AmountInInQueue;
DWORD AmountInOutQueue;
BOOLEAN EofReceived;
BOOLEAN WaitForImmediate;
} SERIAL_STATUS;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERIAL_STATUS
{
public uint Errors;
public uint HoldReasons;
public uint AmountInInQueue;
public uint AmountInOutQueue;
[MarshalAs(UnmanagedType.U1)] public bool EofReceived;
[MarshalAs(UnmanagedType.U1)] public bool WaitForImmediate;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERIAL_STATUS
Public Errors As UInteger
Public HoldReasons As UInteger
Public AmountInInQueue As UInteger
Public AmountInOutQueue As UInteger
<MarshalAs(UnmanagedType.U1)> Public EofReceived As Boolean
<MarshalAs(UnmanagedType.U1)> Public WaitForImmediate As Boolean
End Structureimport ctypes
from ctypes import wintypes
class SERIAL_STATUS(ctypes.Structure):
_fields_ = [
("Errors", wintypes.DWORD),
("HoldReasons", wintypes.DWORD),
("AmountInInQueue", wintypes.DWORD),
("AmountInOutQueue", wintypes.DWORD),
("EofReceived", ctypes.c_byte),
("WaitForImmediate", ctypes.c_byte),
]#[repr(C)]
pub struct SERIAL_STATUS {
pub Errors: u32,
pub HoldReasons: u32,
pub AmountInInQueue: u32,
pub AmountInOutQueue: u32,
pub EofReceived: u8,
pub WaitForImmediate: u8,
}import "golang.org/x/sys/windows"
type SERIAL_STATUS struct {
Errors uint32
HoldReasons uint32
AmountInInQueue uint32
AmountInOutQueue uint32
EofReceived byte
WaitForImmediate byte
}type
SERIAL_STATUS = record
Errors: DWORD;
HoldReasons: DWORD;
AmountInInQueue: DWORD;
AmountInOutQueue: DWORD;
EofReceived: ByteBool;
WaitForImmediate: ByteBool;
end;const SERIAL_STATUS = extern struct {
Errors: u32,
HoldReasons: u32,
AmountInInQueue: u32,
AmountInOutQueue: u32,
EofReceived: u8,
WaitForImmediate: u8,
};type
SERIAL_STATUS {.bycopy.} = object
Errors: uint32
HoldReasons: uint32
AmountInInQueue: uint32
AmountInOutQueue: uint32
EofReceived: uint8
WaitForImmediate: uint8struct SERIAL_STATUS
{
uint Errors;
uint HoldReasons;
uint AmountInInQueue;
uint AmountInOutQueue;
ubyte EofReceived;
ubyte WaitForImmediate;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SERIAL_STATUS サイズ: 20 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; Errors : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; HoldReasons : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; AmountInInQueue : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; AmountInOutQueue : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; EofReceived : BOOLEAN (+16, 1byte) poke st,16,値 / 値 = peek(st,16)
; WaitForImmediate : BOOLEAN (+17, 1byte) poke st,17,値 / 値 = peek(st,17)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SERIAL_STATUS
#field int Errors
#field int HoldReasons
#field int AmountInInQueue
#field int AmountInOutQueue
#field bool1 EofReceived
#field bool1 WaitForImmediate
#endstruct
stdim st, SERIAL_STATUS ; NSTRUCT 変数を確保
st->Errors = 100
mes "Errors=" + st->Errors