So to further my notes and need for help as I continue to refine the string extraction, I have discovered an issue getting the data out of Node-Red .
Something is getting corrupted somewhere with the string I'm extracting from a Modbus buffer and transmitting to InfluxDB. The string looks right everywhere I debug it with message windows, but it's clear from InfluxDB queries that there is an issue with the string it records.
Here's my function as it sends to the db:
gwSerialString = "GTYA002018";
gwSerial = msg.responseBuffer.buffer.toString('utf8',0,16);
gwPower = msg.responseBuffer.buffer.readInt32BE(28)/10;
msg.payload = [
timestamp: new Date()
Which appears in the debug window to return the same string as follows:
However, the InfluxDB does not see them the same way because trying to use the hard coded string works fine but using the one passed from the buffer.toString gives the following error when used in queries:
found GTYA002018, expected identifier, string, number, bool
Which interestingly when pasted into some text windows and previewed I have witnessed an an extra diamond shaped character I haven't seen before preceding the expected string. This may be the clue as to where the issue is coming from although it's not appearing in this window.
I don't think anything is wrong with the batch uploader, but I cannot figure out where this string is getting messed up or how to "cleanse" it appropriately.