String to float conversion - different behaviour on different installations


I’m playing with a silly sensor from Bosch, the XDK110, from with I managed to extract data as a TCP stream, imported in Ignition with the TCP Driver.

I have two Ignition Maker installations: one in a VM for testing on a Debian 10, one online on a CentOS 7.

The TCP stream look like this:


At the 5th position there is the temperature reading (20.84), and in my project I’ve converted that value from string to float.

On my local VM (Debian 10) that value is interpreted and converted the right way, on the online server (CentOS 7) the decimal point is lost and that value become 2084 (or, in case of someting like 20.7, it became 207, so even linear scaling does not work).

Ignition is the same version, installed from the same installation file. The project has been developed on the local VM, then exported to the online server. The TCP stream is byte exact on both the installation. Both server shows the same locale configuration (a mix of en_US and it_IT, but mixed the same way).

CentOS has MariaDB 5.x, whereas Debian has MariaDB 10.x, could be that of relevance?

Where else should I seek for incongruence?

A lot depends on what part of the system is really responsible for the conversion. What you describe would be expected if the Italian locale was being applied somewhere. If you are converting in a jython script and passing the data to MariaDB via a prepared statement (? in a “Prep” query, or a value-type named param in a Named Query), then only java’s locale would matter. If you are passing the value to the DB for it to convert (constructing the entire update query as a string, perhaps–don’t do that!), then the DB’s locale would matter.

Some points:

  • Show your code when asking questions here. Use the pre-formatted text button on the pasted code so it doesn’t lose indentation. (This one: </>.) Then we don’t have to speculate.

  • The version of MariaDB probably doesn’t matter in this case.

  • Mixing locales is just asking for trouble. Pick one and apply it evenly. It’s ok to have additional locales present on the server for translation purposes, but the default should be uniform. Since IA is based in the US, your odds of wierd bugs is somewhat lower if you pick an English locale. /:

  • Consider isolating your DB from your Ignition gateway, perhaps with Docker. Both DBs and Java are hungry for RAM and CPU. Don’t let them fight over it. (Unlikely to be an immediate issue with Maker, but it’s good to nip bad habits in the bud.)

Side note: Are you sure you want to impersonate a Dread Lord? They are notorious for lack of a sense of humor and lack of forgiveness for transgressions. Unless you are the Dread Lord, in which case I apologize… /me runs…

1 Like