Function
Converts the specified 4-byte data to a float value. The byte order is in CDAB order.
Format
ret = modbus_get_float_cdab( src )
Parameters
src [ C : uint16_t * ] [ Python : ctypes.POINTER(ctypes.c_uint16) ]
Specify the pointer of the array that has stored the data for float conversion.
The premise is that the number of elements in the array is two, and each contains 16-bit data.
Return values
ret [ C : float] [ Python : ctypes.c_float ]
Returns the converted float value.
Remarks
Converts the specified 4-byte data to a float value. The byte order is in CDAB order.
The premise is that the src array has two elements and each has a 16-bit value.
For example, if the first word is set to 0xF147 and the second word is set to 0x0020, the converted float value will be 123456.0.
Example
Gets the float value 123456.0 from the array [0xF147, 0x0020].
C |
float value; uint16_t src = { 0xF147 , 0x0020 }; value = modbus_get_float_cdab( src );
|
Python |
value = ctypes.c_float uint16_buff_type = ctypes.c_uint16 * 2 src = uint16_buff_type() src[0], src[1] = ( 0xF147 , 0x0020 ) value = modbus_get_float_cdab( src )
|