From 17be59886612e1ab28b35d84c1548587555c1ea3 Mon Sep 17 00:00:00 2001 From: Stéphane Raimbault Date: Wed, 11 Mar 2015 09:32:09 +0100 Subject: [PATCH] Documentation of modbus get float functions --- doc/modbus_get_float.txt | 6 +++--- doc/modbus_get_float_abcd.txt | 39 +++++++++++++++++++++++++++++++++++++++ doc/modbus_get_float_badc.txt | 40 ++++++++++++++++++++++++++++++++++++++++ doc/modbus_get_float_cdab.txt | 39 +++++++++++++++++++++++++++++++++++++++ doc/modbus_get_float_dcba.txt | 9 ++++++--- src/modbus-data.c | 6 +++--- 6 files changed, 130 insertions(+), 9 deletions(-) create mode 100644 doc/modbus_get_float_abcd.txt create mode 100644 doc/modbus_get_float_badc.txt create mode 100644 doc/modbus_get_float_cdab.txt diff --git a/doc/modbus_get_float.txt b/doc/modbus_get_float.txt index cb4bdbc..023c0bb 100644 --- a/doc/modbus_get_float.txt +++ b/doc/modbus_get_float.txt @@ -17,9 +17,9 @@ replaced by *modbus_get_float_dcba()*. DESCRIPTION ----------- The *modbus_get_float()* function shall get a float from 4 bytes in Modbus -format (ABCD order). The _src_ array must be pointer on two 16 bits values, for -example, if the first word is set to 0x4465 and the second to 0x229a, the float -value will be 916.540649. +format (DCBA byte order). The _src_ array must be a pointer on two 16 bits +values, for example, if the first word is set to 0x4465 and the second to +0x229a, the float value will be 916.540649. RETURN VALUE diff --git a/doc/modbus_get_float_abcd.txt b/doc/modbus_get_float_abcd.txt new file mode 100644 index 0000000..b715a9c --- /dev/null +++ b/doc/modbus_get_float_abcd.txt @@ -0,0 +1,39 @@ +modbus_get_float_abcd(3) +======================== + + +NAME +---- +modbus_get_float_abcd - get a float value from 2 registers in ABCD byte order + + +SYNOPSIS +-------- +*float modbus_get_float_abcd(const uint16_t *'src');* + + +DESCRIPTION +----------- +The *modbus_get_float_abcd()* function shall get a float from 4 bytes in usual +Modbus format. The _src_ array must be a pointer on two 16 bits values, for +example, if the first word is set to 0x0020 and the second to 0xF147, the float +value will be read as 123456.0. + + +RETURN VALUE +------------ +The function shall return a float. + + +SEE ALSO +-------- +linkmb:modbus_set_float_abcd[3] +linkmb:modbus_get_float_dcba[3] +linkmb:modbus_get_float_badc[3] +linkmb:modbus_get_float_cdab[3] + + +AUTHORS +------- +The libmodbus documentation was written by Stéphane Raimbault + diff --git a/doc/modbus_get_float_badc.txt b/doc/modbus_get_float_badc.txt new file mode 100644 index 0000000..525f945 --- /dev/null +++ b/doc/modbus_get_float_badc.txt @@ -0,0 +1,40 @@ +modbus_get_float_badc(3) +======================== + + +NAME +---- +modbus_get_float_badc - get a float value from 2 registers in BADC byte order + + +SYNOPSIS +-------- +*float modbus_get_float_badc(const uint16_t *'src');* + + +DESCRIPTION +----------- + +The *modbus_get_float_badc()* function shall get a float from 4 bytes with +swapped bytes (BADC instead of ABCD). The _src_ array must be a pointer on two +16 bits values, for example, if the first word is set to 0x2000 and the second +to 0x47F1, the float value will be read as 123456.0. + + +RETURN VALUE +------------ +The function shall return a float. + + +SEE ALSO +-------- +linkmb:modbus_set_float_badc[3] +linkmb:modbus_get_float_abcd[3] +linkmb:modbus_get_float_dcba[3] +linkmb:modbus_get_float_cdab[3] + + +AUTHORS +------- +The libmodbus documentation was written by Stéphane Raimbault + diff --git a/doc/modbus_get_float_cdab.txt b/doc/modbus_get_float_cdab.txt new file mode 100644 index 0000000..dc57183 --- /dev/null +++ b/doc/modbus_get_float_cdab.txt @@ -0,0 +1,39 @@ +modbus_get_float_cdab(3) +======================== + + +NAME +---- +modbus_get_float_cdab - get a float value from 2 registers in CDAB byte order + + +SYNOPSIS +-------- +*float modbus_get_float_cdab(const uint16_t *'src');* + + +DESCRIPTION +----------- +The *modbus_get_float_cdab()* function shall get a float from 4 bytes with +swapped words (CDAB order instead of ABCD). The _src_ array must be a pointer on +two 16 bits values, for example, if the first word is set to F147 and the second +to 0x0020, the float value will be read as 123456.0. + + +RETURN VALUE +------------ +The function shall return a float. + + +SEE ALSO +-------- +linkmb:modbus_set_float_cdab[3] +linkmb:modbus_get_float_abcd[3] +linkmb:modbus_get_float_dcba[3] +linkmb:modbus_get_float_badc[3] + + +AUTHORS +------- +The libmodbus documentation was written by Stéphane Raimbault + diff --git a/doc/modbus_get_float_dcba.txt b/doc/modbus_get_float_dcba.txt index 9e7a8c3..cd98a04 100644 --- a/doc/modbus_get_float_dcba.txt +++ b/doc/modbus_get_float_dcba.txt @@ -15,9 +15,9 @@ SYNOPSIS DESCRIPTION ----------- The *modbus_get_float_dcba()* function shall get a float from 4 bytes in -inversed Modbus format (DCBA order instead of ABCD). The _src_ array must be -pointer on two 16 bits values, for example, if the first word is set to 0x9a22 -and the second to 0x6544, the float value read will be 916.540649. +inversed Modbus format (DCBA order instead of ABCD). The _src_ array must be a +pointer on two 16 bits values, for example, if the first word is set to 0x47F1 +and the second to 0x2000, the float value will be read as 123456.0. RETURN VALUE @@ -28,6 +28,9 @@ The function shall return a float. SEE ALSO -------- linkmb:modbus_set_float_dcba[3] +linkmb:modbus_get_float_abcd[3] +linkmb:modbus_get_float_badc[3] +linkmb:modbus_get_float_cdab[3] AUTHORS diff --git a/src/modbus-data.c b/src/modbus-data.c index ec5e262..7e4fb10 100644 --- a/src/modbus-data.c +++ b/src/modbus-data.c @@ -114,7 +114,7 @@ float modbus_get_float_abcd(const uint16_t *src) return f; } -/* Get a float from 4 bytes (Modbus) with byte and word swap conversion (DCBA) */ +/* Get a float from 4 bytes (Modbus) in inversed format (DCBA) */ float modbus_get_float_dcba(const uint16_t *src) { float f; @@ -126,7 +126,7 @@ float modbus_get_float_dcba(const uint16_t *src) return f; } -/* Get a float from 4 bytes (Modbus) with byte swap conversion (BADC) */ +/* Get a float from 4 bytes (Modbus) with swapped bytes (BADC) */ float modbus_get_float_badc(const uint16_t *src) { float f; @@ -138,7 +138,7 @@ float modbus_get_float_badc(const uint16_t *src) return f; } -/* Get a float from 4 bytes (Modbus) in the format CDAB */ +/* Get a float from 4 bytes (Modbus) with swapped words (CDAB) */ float modbus_get_float_cdab(const uint16_t *src) { float f; -- libgit2 0.21.4