modbus_get_float_dcba


 

Function

 

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

 

Format

 

ret = modbus_get_float_dcba( 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 DCBA 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 0x47F1 and the second word is set to 0x2000, the converted float value will be 123456.0.

 

Example

 

Gets the float value 123456.0 from the array [0x47F1, 0x2000].

 

C

float value;

uint16_t src = { 0x47F1 , 0x2000 };

value = modbus_get_float_dcba( src );

 

Python

value = ctypes.c_float

uint16_buff_type = ctypes.c_uint16 * 2

src = uint16_buff_type()

src[0], src[1] = ( 0x47F1 , 0x2000 )

value = modbus_get_float_dcba( src )