Community

Support float on ServiceChannel functions

On some of the Beckhoff devices they use a 32 bit float value for setting options (for instance the EL3356 load cell terminal). Currently the ServiceChannelWrite function only supports int32, so it requires some ugly coercing in C++ to hide the float in an int. Here is a simplified version of what my code looks like:

float command = 123.456;
rsi_int32* floatAsInt = reinterpret_cast<rsi_int32*>(&command);
_pDeviceNode->NetworkNode->ServiceChannelWrite(index, subindex, byteCount, *floatAsInt);

In C# it’s not quite so ugly:
Node.ServiceChannelWrite(index, subindex, byteCount, BitConverter.ToInt32(command, 0));

I think it should be fairly easy to add either an overload to ServiceChannelWrite that takes a float. This would make the previous C++ example look like:

float command = 123.456;
_pDeviceNode->NetworkNode->ServiceChannelWrite(index, subindex, byteCount, command);

Alternatively an additional function called ServiceChannelWriteFloat could be provided.

There would of course need to be matching Read commands, and the icing on the cake would be to allow the SDO Read/Write on RapidSetup to support floats as well (currently I have to use an online float converter to get the right hex value to use).

Hi @patrick. I’m going to discuss with the team tomorrow to see if we have a module to make changes to our C++ API. I will keep you posted.