Am 2014-08-05 15:37, schrieb Michael Wenz:
Hello,I am using Etherlab 1.5.2, Linux kernel 3.2.21, Xenomai-2.6.2.1 and I would like to download negative floating point values with the EtherLab command line tool to a slave: e.g. ./ethercat download -p0 0x2001 0x9 -10.3 It is no problem to download positive values, but negative values cannot be downloaded with the above call. The SDO entry has type 32 bit float.
Try downloading a hex value: -10.3 = 0xc124cccd See attached proggie (assumes little endian computer): # num2hex -10.3 -10.300000 = 0xC124CCCD
Do you have any advice, please? Kind regards Michael _______________________________________________ etherlab-users mailing list etherlab-users@etherlab.org http://lists.etherlab.org/mailman/listinfo/etherlab-users
num2hex
Description: Binary data
/***************************************************************************** * Convert as many singles to IEEE754 hexadecimal representation * NOTE: assumes Little Endianness * * (c) 2014 Richard Hacker * License: LGPL * * You may use this program as is. No guarantee for correctness! * *****************************************************************************/ #include <stdlib.h> #include <stdio.h> /*****************************************************************************/ int main(int argc, char **argv) { union { float f; unsigned char c[4]; } value; int i,j; if (argc == 1) { printf("Useage: %s <float>\n" "where: <float> are as many floats as you like\n", argv[0]); } while (--argc) { value.f = atof(*++argv); printf("%f = 0x", value.f); for (j = 3; j >= 0; j--) printf("%X", value.c[j]); printf("\n"); } } /*****************************************************************************/
_______________________________________________ etherlab-users mailing list etherlab-users@etherlab.org http://lists.etherlab.org/mailman/listinfo/etherlab-users