Modbus Server with node-red Docker - Port forwarding required?

Modbus TCP garbage was single-number arrays getting broadcast to modbus rather than just numbers, e.g.

{"value": 0: 12345,"register":"holding","address":8,"disableMsgOutput":0}

rather than the desired

{"value": 12345,"register":"holding","address":8,"disableMsgOutput":0}

I picked out the values from those weird little arrays via:

var temp1 = msg.payload[0]

msg.payload = {
   'value': temp1,
   'register': 'holding',
   'address': 2,
   'disableMsgOutput': 0
};

return msg;

My colleague is still getting dynamic byte swapping, but I at least am reading back expected numbers now.

Lesson: beware of single-number arrays.

2 Likes