modbus_set_bits_from_bytes


 

Function

 

Retrieves bit information from multiple byte information.

 

Format

 

modbus_set_bits_from_bytes( dest , index , nb_bits , tab_byte )

 

Parameters

 

dest [ C : uint8_t * ] [ Python : ctypes.POINTER(ctypes.c_int) ]

Specify the start address of the array that stores the converted bit information.

 

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

Specify the start position to set the converted bit information in the dest array.

 

nb [ C : uint ] [ Python : ctypes.c_uint ]

Specify the number of bits to convert.

 

tab_byte [ C : uint8_t * ] [ Python : ctypes.POINTER(ctypes.c_uint8) ]

Specify the start address of the array that has stored the data to be converted to bit information.

 

Return values

 

None

 

Remarks

 

Converts from byte array to bit information. Gets byte information from the beginning of the array and converts it to bit information.

 

The converted bit information is stored in the array dest. It is possible to store from the position specified by index.

 

Example

 

Retrieves the bit array [0, 1, 0, 1] from the byte information array [10, 0, 10, 0].

 

C

uint8_t dest[4];

uint8_t tab_byte[] = {10, 0, 10, 0};

modbus_set_bits_from_bytes( dest, 0, 4, tab_byte );

 

Python

uint8_buff_type = ctypes.c_uint8 * 4

dest = uint8_buff_type()

tab_byte = uint8_buff_type()

tab_byte[0], tab_byte[1], tab_byte[2], srtab_byte[3] = (10, 0, 10, 0)

modbus.modbus.set_bits_from_bytes(dest, 0, 4, tab_byte)