modbus_set_float_cdab


 

Function

 

Converts the specified float value to 4-byte data. The byte order is in CDAB order.

 

Format

 

modbus_set_float_cdab( value , dest )

 

Parameters

 

value [ C : float ] [ Python : ctypes.c_float ]

Specify the conversion data.

 

dest [ C : uint16_t * ] [ Python : ctypes.POINTER(ctypes.c_uint16) ]

Specify the pointer of the array that stores the float conversion result.

The premise is that the number of elements in the array is two, and each contains 16-bit data.

 

Return values

 

None

 

Remarks

 

Converts the specified float value to 4-byte data. The byte order is in CDAB order.

The premise is that the dest array has two elements and each has a 16-bit value.

 

Example

 

Gets 4-byte data from the float value.

 

C

uint16_t dest[2];

modbus_set_float_cdab( 123456.0, dest );

 

Python

uint16_buff_type = ctypes.c_uint16 * 2

dest = uint16_buff_type()

value = modbus_set_float_cdab( 123456.0, dest )