modbus_set_slave


機能

 

スレーブIDを設定します。

 

書式

 

ret = modbus_set_slave( ctx , slave )

 

引数

 

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

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

 

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

スレーブIDを指定下さい。

 

戻り値

 

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

成功時には0が入り、失敗時には-1が入り、errnoには以下が入ります。

 

定義

意味

EINVAL

スレーブIDが不正です。

 

説明

 

指定したModbus構造体にスレーブIDを設定します。

 

使用例

 

スレーブID 1を設定します。

 

VB.NET

Dim ret As Integer

Dim ctx As IntPtr

ret = modbus_set_slave(ctx, 1)

 

C, C++

int ret;

modbus_t *ctx;

ret = modbus_set_slave(ctx, 1);

 

C#
 

int ret;

IntPtr ctx;

ret = modbus.SetSlave(ctx , 1);
 

Python

ret = ctypes.c_int

ctx = ctypes.POINTER(modbus_t)

ret = modbus.modbus_set_slave(ctx, 1)