機能
ファンクションコード Read Input Registers (コード04) を用いてinput register領域のレジスタ情報を複数取得します。
書式
ret = modbus_read_input_registers( ctx , addr , nb , dest )
引数
ctx [ C: modbus_t * ] [ Python: ctypes.POINTER(modbus_t) ]
libmodbus構造体へのポインタを指定下さい。
addr [ C: int ] [ Python: ctypes.c_int ]
readする先頭アドレスを指定下さい。
nb [ C: int ] [ Python: ctypes.c_int ]
読みだすレジスタ数を指定下さい。
dest [ C: uint16_t * ] [ Python: ctypes.POINTER(ctypes.c_uint16) ]
readしたデータを格納する配列のポインタを指定下さい。
戻り値
ret [ C: int ] [ Python: ctypes.c_int ]
成功時には読み取りに成功したレジスタ点数が入ります。
失敗時には-1が入り、以下の errno が設定されます。
定義 |
意味 |
EMBMDATA |
要求データ数が多すぎます。 |
説明
ファンクションコード Read Input Registers (コード04) を用いてinput register領域のレジスタ情報を複数取得します。
使用例
スタートアドレス0から8点分のデータを取得します。
C |
int ret; modbus_t *ctx; uint16_t dest[8]; ret = modbus_read_input_registers( ctx, 0, 8 , dest );
|
Python |
ret = ctypes.c_int ctx = ctypes.POINTER(modbus_t) uint16_buff_type = ctypes.c_uint16 * 8 dest = uint16_buff_type() ret = modbus.modbus_read_input_registers(ctx, 0, 8, dest)
|