for (i = address; i < address + nb; i++) {rsp[rsp_length++] = mb_mapping->tab_registers[i] >> 8;rsp[rsp_length++] = mb_mapping->tab_registers[i] & 0xFF;
memcpy(&i, &f, sizeof(uint32_t));dest[0] = (uint16_t)i;dest[1] = (uint16_t)(i >> 16);
memcpy(&i, &f, sizeof(uint32_t));dest[0] = (uint16_t)(i >> 16);dest[1] = (uint16_t)i;
Its not libmodbus, it’s the slave device. Another type of slave device may send 32 bit values differently.
There are many variations in the MODBUS protocol.
Chuck Watson BS, CEM,
CMVP
Direct USA
724-799-1529
www.EnergyChaser.com
--
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+...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.
My understanding of the ABCD 32 bit byte ordering is this (this might be where I am getting it wrong?!?)
I have a 32 bit value (float), lets say it is presented in 32 bit as 0xAABBCCDD
If it is sent in the ABCD format the byte order sent (on the network) should be 0xAA 0xBB 0xCC 0xDD, is this correct?
/* Set a float to 4 bytes in Modbus format (ABCD) */void modbus_set_float(float f, uint16_t *dest){uint32_t i;
memcpy(&i, &f, sizeof(uint32_t));dest[0] = (uint16_t)i;dest[1] = (uint16_t)(i >> 16);}