modbus_set_slave


機能

 

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

 

書式

 

ret = modbus_set_slave( ctx , slave )

 

引数

 

ctx [ C: modbus_t * ] [ Python: ctypes.POINTER(modbus_t) ]

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

 

slave [ C: int ]  [ Python: ctypes.c_int ]

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

 

戻り値

 

ret [ C: int ]  [ Python: ctypes.c_int ]

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

 

定義

意味

EINVAL

スレーブIDが不正です。

 

説明

 

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

 

使用例

 

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

 

C

int ret;

modbus_t *ctx;

ret = modbus_set_slave(ctx,1);

 

Python

ret = ctypes.c_int

ctx = ctypes.POINTER(modbus_t)

ret = modbus.modbus_set_slave(ctx, 1)