機能
ビット情報をバイト情報に変換します。
書式
ret = modbus_get_byte_from_bits( src , index , nb_bits )
引数
src [ C: uint8_t * ] [ Python: ctypes.POINTER(ctypes.c_uint8) ]
バイトに変換するビットデータを格納した配列の先頭アドレスを指定下さい。
index [ C: int ] [ Python: ctypes.c_int ]
src配列において、バイト変換を開始する位置を指定下さい。
nb [ C: uint ] [ Python: ctypes.c_uint ]
変換するbit数を指定下さい。
戻り値
ret [ C: uint8_t ] [ Python: ctypes.c_uint8 ]
成功時はバイト変換結果を返します。
説明
与えられたビット情報をバイト情報に変換します。
使用例
ビット配列[ 0, 1, 0, 1]をバイト情報(10)に変換します。
C |
uint8_t ret; uint8_t src[] = { 0, 1, 0, 1 }; ret = modbus_get_byte_from_bits( src, 0, 4 );
|
Python |
ret = ctypes.c_uint8 uint8_buff_type = ctypes.c_uint8 * 4 src = uint8_buff_type() src[0], src[1], src[2], src[3] = (0, 1, 0, 1) ret = modbus.modbus_get_byte_from_bits(src, 0, 4)
|