Function
Converts bit information to byte information.
Format
ret = modbus_get_byte_from_bits( src , index , nb_bits )
Parameters
src [ VB.NET: Byte() ] [ C, C++: uint8_t * ] [ C#: byte[] ] [ Python: ctypes.POINTER(ctypes.c_uint8) ]
Specify the start address of the array that has stored the bit data which is to be converted to bytes.
index [ VB.NET: Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]
Specify the position to start byte conversion in the src array.
nb [ VB.NET: UInteger ] [ C, C++: uint ] [ C#: uint ] [ Python: ctypes.c_uint ]
Specify the number of bits to convert.
Return values
ret [ VB.NET: Byte ] [ C, C++: uint8_t ] [ C#: byte ] [ Python: ctypes.c_uint8 ]
If the function succeeds, the byte conversion result is returned.
Remarks
Converts the given bit information to byte information.
Example
Converts the bit array [0, 1, 0, 1] to byte information (10).
VB.NET |
Dim ret As Byte Dim src() As Byte = { 0, 1, 0, 1 } ret = modbus_get_byte_from_bits(src, 0, 4)
|
C, C++ |
uint8_t ret; uint8_t src[] = { 0, 1, 0, 1 }; ret = modbus_get_byte_from_bits( src, 0, 4 );
|
C# |
byte ret; byte[] src = { 0, 1, 0, 1 }; ret = modbus.GetByteFromBits(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)
|