Write negative Number to Drive with C++ interface

I want to write a negative value to a paramter on the CtrlX Drive. Via Drive Engineering a decimal number can be written to the parameter which can be negative. This is not possible via the C++ interface, because there the number to write is a vector of byte, which holds no information about the number being positive or negative. Is it possible to write negative number via the C++ interface on the CtrlX and if yes how?

In my particular case it is the paramter "S-0-0052, Reference distance of encoder 1". This parameter can be positive and negative. 

Its format is DEC_MV(Signed decimal number). But in the C++ interface the data to send is a vector of uint8_t so a vector of unsigned numbers. Is there a logical conversion to a negative number? I have tried to set the first bit to 1, representing the minus bit for a signed, but this does not work.

 

auto data__ = data ? _fbb.CreateVector<uint8_t>(*data)

 

source: sdk/include/comm.ethercat.master/comm/ethercat/master/fbs/parameter_generated.h
 
Also the decimal place in the documentation is emtpy, which implies for me it is 0. After testing I found out it is actually 4.
Best reply by CodeShepherd

Changing only the first bit could be not enough depending on the data size. Here an example simply made with the calculator:

 

View original
1 reply