modbus_write_bit


機能

 

ファンクションコード Write Coil (コード05)を用いてCoil領域へ1ビット分書き込みます。

 

書式

 

ret =  modbus_write_bit( ctx , addr , status )

 

引数

 

ctx [ VB.NET: IntPtr ] [ C, C++: modbus_t * ] [ C#: IntPtr ] [ Python: ctypes.POINTER(modbus_t) ]

libmodbus構造体へのポインタを指定下さい。

 

addr[ VB.NET: Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]

writeする先頭アドレスを指定下さい。

 

status[ VB.NET: Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]

書き込むデータを0か1で指定下さい。

 

戻り値

 

ret [ VB.NET:Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]

 

成功時には1が入ります。

失敗時には-1が入ります。

 

説明

 

ファンクションコード Write Coil (コード05)を用いてCoil領域へ1ビット分書き込みます。

 

使用例

 

アドレス0のビットに1を書き込みます。

 

VB.NET

Dim ret As Integer

Dim ctx As IntPtr

ret = modbus_write_bit(ctx, 0, 1)

 

C, C++

int ret;

modbus_t *ctx;

ret = modbus_write_bit( ctx, 0, 1 );

 

C#
 

int ret;

IntPtr ctx;

ret = modbus.WriteBit(ctx, 0, 1);

 

Python

ret = ctypes.c_int

ctx = ctypes.POINTER(modbus_t)

ret = modbus.modbus_write_bit(ctx, 0, 1)