機能
ファンクションコード Read Coils (コード01)を用いてCoil領域のビット情報を複数取得します。
書式
ret = modbus_read_bits( ctx , addr , nb , dest )
引数
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 ]
readする先頭アドレスを指定下さい。
nb[ VB.NET: Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]
読みだすbit数を指定下さい。
dest [ VB.NET:Byte() ] [ C, C++: uint8_t * ] [ C#: byte[] ] [ Python: ctypes.POINTER(ctypes.c_uint8) ]
readしたデータを格納する配列のポインタを指定下さい。
戻り値
ret [ VB.NET:Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]
成功時には読み取りに成功したビット点数が入ります。
失敗時には-1が入り、以下の errno が設定されます。
定義 |
意味 |
EMBMDATA |
要求データ数が多すぎます。 |
説明
ファンクションコード Read Coils (コード01)を用いてCoil領域のビット情報を複数取得します。
使用例
スタートアドレス0から8点分のデータを取得します。
VB.NET |
Dim ret As Integer Dim ctx As IntPtr Dim dest(8) As Byte ret = modbus_read_bits(ctx, 0, 8, dest)
|
C, C++ |
int ret; modbus_t *ctx; uint8_t dest[8]; ret = modbus_read_bits( ctx, 0, 8 , dest );
|
C# |
int ret; IntPtr ctx; byte[] dest = new byte[8]; ret = modbus.ReadBits(ctx, 0, 8, dest);
|
Python |
ret = ctypes.c_int ctx = ctypes.POINTER(modbus_t) uint8_buff_type = ctypes.c_uint8 * 8 dest = uint8_buff_type() ret = modbus.modbus_read_bits(ctx, 0, 8, dest)
|