ホーム › Devices.SerialCommunication › SERIAL_CHARS
SERIAL_CHARS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| EofChar | BYTE | 1 | +0 | +0 | ファイル終端を示す特殊文字。 |
| ErrorChar | BYTE | 1 | +1 | +1 | 受信エラー文字を置換する文字。 |
| BreakChar | BYTE | 1 | +2 | +2 | ブレーク状態を示す特殊文字。 |
| EventChar | BYTE | 1 | +3 | +3 | イベント発生を通知する文字。 |
| XonChar | BYTE | 1 | +4 | +4 | 送信再開を要求するXON文字。 |
| XoffChar | BYTE | 1 | +5 | +5 | 送信停止を要求するXOFF文字。 |
各言語での定義
#include <windows.h>
// SERIAL_CHARS (x64 6 / x86 6 バイト)
typedef struct SERIAL_CHARS {
BYTE EofChar;
BYTE ErrorChar;
BYTE BreakChar;
BYTE EventChar;
BYTE XonChar;
BYTE XoffChar;
} SERIAL_CHARS;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERIAL_CHARS
{
public byte EofChar;
public byte ErrorChar;
public byte BreakChar;
public byte EventChar;
public byte XonChar;
public byte XoffChar;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERIAL_CHARS
Public EofChar As Byte
Public ErrorChar As Byte
Public BreakChar As Byte
Public EventChar As Byte
Public XonChar As Byte
Public XoffChar As Byte
End Structureimport ctypes
from ctypes import wintypes
class SERIAL_CHARS(ctypes.Structure):
_fields_ = [
("EofChar", ctypes.c_ubyte),
("ErrorChar", ctypes.c_ubyte),
("BreakChar", ctypes.c_ubyte),
("EventChar", ctypes.c_ubyte),
("XonChar", ctypes.c_ubyte),
("XoffChar", ctypes.c_ubyte),
]#[repr(C)]
pub struct SERIAL_CHARS {
pub EofChar: u8,
pub ErrorChar: u8,
pub BreakChar: u8,
pub EventChar: u8,
pub XonChar: u8,
pub XoffChar: u8,
}import "golang.org/x/sys/windows"
type SERIAL_CHARS struct {
EofChar byte
ErrorChar byte
BreakChar byte
EventChar byte
XonChar byte
XoffChar byte
}type
SERIAL_CHARS = record
EofChar: Byte;
ErrorChar: Byte;
BreakChar: Byte;
EventChar: Byte;
XonChar: Byte;
XoffChar: Byte;
end;const SERIAL_CHARS = extern struct {
EofChar: u8,
ErrorChar: u8,
BreakChar: u8,
EventChar: u8,
XonChar: u8,
XoffChar: u8,
};type
SERIAL_CHARS {.bycopy.} = object
EofChar: uint8
ErrorChar: uint8
BreakChar: uint8
EventChar: uint8
XonChar: uint8
XoffChar: uint8struct SERIAL_CHARS
{
ubyte EofChar;
ubyte ErrorChar;
ubyte BreakChar;
ubyte EventChar;
ubyte XonChar;
ubyte XoffChar;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SERIAL_CHARS サイズ: 6 バイト(x64)
dim st, 2 ; 4byte整数×2(構造体サイズ 6 / 4 切り上げ)
; EofChar : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; ErrorChar : BYTE (+1, 1byte) poke st,1,値 / 値 = peek(st,1)
; BreakChar : BYTE (+2, 1byte) poke st,2,値 / 値 = peek(st,2)
; EventChar : BYTE (+3, 1byte) poke st,3,値 / 値 = peek(st,3)
; XonChar : BYTE (+4, 1byte) poke st,4,値 / 値 = peek(st,4)
; XoffChar : BYTE (+5, 1byte) poke st,5,値 / 値 = peek(st,5)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SERIAL_CHARS
#field byte EofChar
#field byte ErrorChar
#field byte BreakChar
#field byte EventChar
#field byte XonChar
#field byte XoffChar
#endstruct
stdim st, SERIAL_CHARS ; NSTRUCT 変数を確保
st->EofChar = 100
mes "EofChar=" + st->EofChar