I need modbus double value conversion function

19 views
Skip to first unread message

Ali BAŞEL

unread,
Mar 6, 2018, 5:26:31 PM3/6/18
to libmodbus
Hello,

I started to use siemens sentron pac3200 energy analyser with this library.

For the address 801 a double value returns like below:

<29><E8><00><00><00><0B><FF><03><08><41><E5><61><A9><ED><DE><6E><39>
And this the value part 8 bytes - 4 words: <41><E5><61><A9><ED><DE><6E><39>

I need a similar conversion function like for the float values but for double values
float modbus_get_float_dcba(const uint16_t *src)

double modbus_get_double_dcba(const uint16_t *src)

Can anyone convert this function to double?

/* Get a float from 4 bytes (Modbus) in inversed format (DCBA) */
float modbus_get_float_dcba(const uint16_t *src)
{
    float f;
    uint32_t i;

    i = ntohl(bswap_32((((uint32_t)src[0]) << 16) + src[1]));
    memcpy(&f, &i, sizeof(float));

    return f;
}


Regards,
Ali




Stéphane Raimbault

unread,
Mar 26, 2018, 5:00:46 PM3/26/18
to libm...@googlegroups.com
No answers so you need to write it!
I'll do my best to merge it.

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+unsubscribe@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

Patrick Boettcher

unread,
Mar 27, 2018, 2:57:44 AM3/27/18
to Stéphane Raimbault, libm...@googlegroups.com
On Mon, 26 Mar 2018 23:00:23 +0200
Stéphane Raimbault <stephane....@gmail.com> wrote:

> No answers so you need to write it!
> I'll do my best to merge it.

This same issue has been discussed here:

https://github.com/stephane/libmodbus/issues/423

best regards,
--
Patrick.
Reply all
Reply to author
Forward
0 new messages