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

SERIAL_LINE_CONTROL

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

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

フィールド

フィールドサイズx64x86説明
StopBitsBYTE1+0+0ストップビット数の設定値を示す(1/1.5/2)。
ParityBYTE1+1+1パリティ方式(なし/奇数/偶数/マーク/スペース)を示す。
WordLengthBYTE1+2+21キャラクタあたりのデータビット長を示す(5~8)。

各言語での定義

#include <windows.h>

// SERIAL_LINE_CONTROL  (x64 3 / x86 3 バイト)
typedef struct SERIAL_LINE_CONTROL {
    BYTE StopBits;
    BYTE Parity;
    BYTE WordLength;
} SERIAL_LINE_CONTROL;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERIAL_LINE_CONTROL
{
    public byte StopBits;
    public byte Parity;
    public byte WordLength;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERIAL_LINE_CONTROL
    Public StopBits As Byte
    Public Parity As Byte
    Public WordLength As Byte
End Structure
import ctypes
from ctypes import wintypes

class SERIAL_LINE_CONTROL(ctypes.Structure):
    _fields_ = [
        ("StopBits", ctypes.c_ubyte),
        ("Parity", ctypes.c_ubyte),
        ("WordLength", ctypes.c_ubyte),
    ]
#[repr(C)]
pub struct SERIAL_LINE_CONTROL {
    pub StopBits: u8,
    pub Parity: u8,
    pub WordLength: u8,
}
import "golang.org/x/sys/windows"

type SERIAL_LINE_CONTROL struct {
	StopBits byte
	Parity byte
	WordLength byte
}
type
  SERIAL_LINE_CONTROL = record
    StopBits: Byte;
    Parity: Byte;
    WordLength: Byte;
  end;
const SERIAL_LINE_CONTROL = extern struct {
    StopBits: u8,
    Parity: u8,
    WordLength: u8,
};
type
  SERIAL_LINE_CONTROL {.bycopy.} = object
    StopBits: uint8
    Parity: uint8
    WordLength: uint8
struct SERIAL_LINE_CONTROL
{
    ubyte StopBits;
    ubyte Parity;
    ubyte WordLength;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SERIAL_LINE_CONTROL サイズ: 3 バイト(x64)
dim st, 1    ; 4byte整数×1(構造体サイズ 3 / 4 切り上げ)
; StopBits : BYTE (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; Parity : BYTE (+1, 1byte)  poke st,1,値  /  値 = peek(st,1)
; WordLength : BYTE (+2, 1byte)  poke st,2,値  /  値 = peek(st,2)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SERIAL_LINE_CONTROL
    #field byte StopBits
    #field byte Parity
    #field byte WordLength
#endstruct

stdim st, SERIAL_LINE_CONTROL        ; NSTRUCT 変数を確保
st->StopBits = 100
mes "StopBits=" + st->StopBits