TypeError: Cannot read properties of undefined (reading 'address')"

Hello friends,
I am receiving modbus responses from a flex node and to distinguish responses, I filter the memory address with a simple instruction.
Why am I getting typeError?


image
image
image

Could you help me?
Thank you so much

Please copy/paste code rather than screenshots, where possible. It saves us re-typing stuff.
The error in SUN11 is because you are testing msg.modbusRequest.address, but msg.modbusRequest does not exist. Add a debug node showing what is coming from the getter node. Set the debug node to Output Complete Message.

I don't know what the cause of the modbus error might be.

All the reason. Excuse me.

[{"id":"adaf4e02b12b67b6","type":"modbus-flex-getter","z":"19d7da1865ba7247","name":"","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"850a4d8b64093d2c","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":true,"keepMsgProperties":true,"x":450,"y":160,"wires":[["c1b3b43dba36195e","0d0618ae79bd160e","38e24bda8c328792","9a87ad5cd07189d7","08fc23dec162139a","ddf53747fcc12f52","1d574a216e3a9770"],[]]},{"id":"8cce77250759e302","type":"function","z":"19d7da1865ba7247","name":"SUN1","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32000,\n    'quantity': 11\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":180,"wires":[["adaf4e02b12b67b6"]]},{"id":"f1b9d124ecea0d6c","type":"inject","z":"19d7da1865ba7247","name":"begin","props":[{"p":"payload"},{"p":"queueUnitId","v":"0","vt":"num"}],"repeat":"5","crontab":"","once":true,"onceDelay":"10","topic":"","payload":"","payloadType":"str","x":90,"y":180,"wires":[["8cce77250759e302","4e43b362a79f929e","feac34b959ec9029","b64af8db63911209","d41dcda1e53b8446","dffd5dab3b60704e","ec3fb003c91163a4"]]},{"id":"4e43b362a79f929e","type":"function","z":"19d7da1865ba7247","name":"SUN2","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32089,\n    'quantity': 1\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":220,"wires":[["adaf4e02b12b67b6"]]},{"id":"feac34b959ec9029","type":"function","z":"19d7da1865ba7247","name":"SUN3","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 37113,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":260,"wires":[["adaf4e02b12b67b6"]]},{"id":"b64af8db63911209","type":"function","z":"19d7da1865ba7247","name":"SUN4","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32064,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":300,"wires":[["adaf4e02b12b67b6"]]},{"id":"d41dcda1e53b8446","type":"function","z":"19d7da1865ba7247","name":"SUN5","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32080,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":340,"wires":[["adaf4e02b12b67b6"]]},{"id":"dffd5dab3b60704e","type":"function","z":"19d7da1865ba7247","name":"SUN6","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 37760,\n    'quantity': 3\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":380,"wires":[["adaf4e02b12b67b6"]]},{"id":"c1b3b43dba36195e","type":"function","z":"19d7da1865ba7247","name":"SUN11","func":"if (msg.modbusRequest.address == 32000) {\n    var msg1 = {};\n    var msg2 = {};\n    var msg3 = {};\n    var msg4 = {};\n    msg1.payload = msg.payload[0];\n    msg2.payload = msg.payload[8];\n    msg3.payload = msg.payload[9];\n    msg4.payload = msg.payload[10];\n    return ([msg1, msg2, msg3, msg4]);\n}","outputs":4,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":100,"wires":[["46af2379249c7e4c"],["b658c74c3d05158e"],["5fdae1ae25389094"],["6e2e71c9cdabb296"]]},{"id":"0d0618ae79bd160e","type":"function","z":"19d7da1865ba7247","name":"SUN22","func":"if (msg.modbusRequest.address == 32089) {\n    var msg1 = {};\n    msg1.payload = msg.payload[0];\n    return msg1;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":180,"wires":[["b8adf41e7cbb07ad"]]},{"id":"38e24bda8c328792","type":"function","z":"19d7da1865ba7247","name":"SUN33","func":"if (msg.modbusRequest.address == 37113) {\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":220,"wires":[["1e33bb66ac0034d6"]]},{"id":"9a87ad5cd07189d7","type":"function","z":"19d7da1865ba7247","name":"SUN44","func":"if (msg.modbusRequest.address == 32064) {\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":657,"y":263,"wires":[["021495af20dde36a"]]},{"id":"08fc23dec162139a","type":"function","z":"19d7da1865ba7247","name":"SUN55","func":"if (msg.modbusRequest.address == 32080) {\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":300,"wires":[["c1967cdd6dbff898"]]},{"id":"ddf53747fcc12f52","type":"function","z":"19d7da1865ba7247","name":"SUN66","func":"if (msg.modbusRequest.address == 37760) {\n    var msg1 = {};\n    var msg2 = {};\n    msg1.payload = (msg.payload[0]/10);\n    msg2.payload = msg.payload[2];\n    return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":340,"wires":[["6977dfa3fb079bfa"],["c897b94156655071"]]},{"id":"ec3fb003c91163a4","type":"function","z":"19d7da1865ba7247","name":"SUN7","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 37765,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":420,"wires":[["adaf4e02b12b67b6"]]},{"id":"1d574a216e3a9770","type":"function","z":"19d7da1865ba7247","name":"SUN77","func":"if (msg.modbusRequest.address == 37765) {\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":380,"wires":[["47272f752251e256"]]},{"id":"850a4d8b64093d2c","type":"modbus-client","name":"Huawei Sun 2000","clienttype":"tcp","bufferCommands":false,"stateLogEnabled":false,"queueLogEnabled":true,"failureLogEnabled":false,"tcpHost":"192.168.20.99","tcpPort":"6607","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"0","commandDelay":"800","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

Thank you so much

You have not included the debug nodes in the export, so we cannot see what output it is showing.

Not explaining the problem, but it would be much more efficient to use a Switch node with seven outputs, testing the address and sending the message on to the appropriate SUNxx nodes.

[{"id":"adaf4e02b12b67b6","type":"modbus-flex-getter","z":"19d7da1865ba7247","name":"","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"850a4d8b64093d2c","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":true,"keepMsgProperties":true,"x":450,"y":160,"wires":[["c1b3b43dba36195e","0d0618ae79bd160e","38e24bda8c328792","9a87ad5cd07189d7","08fc23dec162139a","ddf53747fcc12f52","1d574a216e3a9770","03aa3f51ddf15c27"],[]]},{"id":"8cce77250759e302","type":"function","z":"19d7da1865ba7247","name":"SUN1","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32000,\n    'quantity': 11\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":180,"wires":[["adaf4e02b12b67b6","12efbaaaf96460a4"]]},{"id":"4e43b362a79f929e","type":"function","z":"19d7da1865ba7247","name":"SUN2","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32089,\n    'quantity': 1\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":220,"wires":[["adaf4e02b12b67b6"]]},{"id":"feac34b959ec9029","type":"function","z":"19d7da1865ba7247","name":"SUN3","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 37113,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":260,"wires":[["adaf4e02b12b67b6"]]},{"id":"b64af8db63911209","type":"function","z":"19d7da1865ba7247","name":"SUN4","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32064,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":300,"wires":[["adaf4e02b12b67b6"]]},{"id":"d41dcda1e53b8446","type":"function","z":"19d7da1865ba7247","name":"SUN5","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32080,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":340,"wires":[["adaf4e02b12b67b6"]]},{"id":"dffd5dab3b60704e","type":"function","z":"19d7da1865ba7247","name":"SUN6","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 37760,\n    'quantity': 3\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":380,"wires":[["adaf4e02b12b67b6"]]},{"id":"c1b3b43dba36195e","type":"function","z":"19d7da1865ba7247","name":"SUN11","func":"if (msg.modbusRequest.address == 32000) {\n    var msg1 = {};\n    var msg2 = {};\n    var msg3 = {};\n    var msg4 = {};\n    msg1.payload = msg.payload[0];\n    msg2.payload = msg.payload[8];\n    msg3.payload = msg.payload[9];\n    msg4.payload = msg.payload[10];\n    return ([msg1, msg2, msg3, msg4]);\n}","outputs":4,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":100,"wires":[["46af2379249c7e4c"],["b658c74c3d05158e"],["5fdae1ae25389094"],["6e2e71c9cdabb296"]]},{"id":"0d0618ae79bd160e","type":"function","z":"19d7da1865ba7247","name":"SUN22","func":"if (msg.modbusRequest.address == 32089) {\n    var msg1 = {};\n    msg1.payload = msg.payload[0];\n    return msg1;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":180,"wires":[["b8adf41e7cbb07ad"]]},{"id":"38e24bda8c328792","type":"function","z":"19d7da1865ba7247","name":"SUN33","func":"if (msg.modbusRequest.address == 37113) {\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":220,"wires":[["1e33bb66ac0034d6"]]},{"id":"9a87ad5cd07189d7","type":"function","z":"19d7da1865ba7247","name":"SUN44","func":"if (msg.modbusRequest.address == 32064) {\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":657,"y":263,"wires":[["021495af20dde36a"]]},{"id":"08fc23dec162139a","type":"function","z":"19d7da1865ba7247","name":"SUN55","func":"if (msg.modbusRequest.address == 32080) {\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":300,"wires":[["c1967cdd6dbff898"]]},{"id":"ddf53747fcc12f52","type":"function","z":"19d7da1865ba7247","name":"SUN66","func":"if (msg.modbusRequest.address == 37760) {\n    var msg1 = {};\n    var msg2 = {};\n    msg1.payload = (msg.payload[0]/10);\n    msg2.payload = msg.payload[2];\n    return ([msg1, msg2]);\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":340,"wires":[["6977dfa3fb079bfa"],["c897b94156655071"]]},{"id":"ec3fb003c91163a4","type":"function","z":"19d7da1865ba7247","name":"SUN7","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 37765,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":420,"wires":[["adaf4e02b12b67b6"]]},{"id":"1d574a216e3a9770","type":"function","z":"19d7da1865ba7247","name":"SUN77","func":"if (msg.modbusRequest.address == 37765) {\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":380,"wires":[["47272f752251e256","1d2787d3fb1bc796"]]},{"id":"03aa3f51ddf15c27","type":"debug","z":"19d7da1865ba7247","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":420,"y":80,"wires":[]},{"id":"12efbaaaf96460a4","type":"debug","z":"19d7da1865ba7247","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":240,"y":80,"wires":[]},{"id":"1d2787d3fb1bc796","type":"debug","z":"19d7da1865ba7247","name":"debug 7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":640,"y":480,"wires":[]},{"id":"f1b9d124ecea0d6c","type":"inject","z":"19d7da1865ba7247","name":"begin","props":[{"p":"payload"},{"p":"queueUnitId","v":"0","vt":"num"}],"repeat":"5","crontab":"","once":true,"onceDelay":"10","topic":"","payload":"","payloadType":"str","x":90,"y":180,"wires":[["8cce77250759e302","4e43b362a79f929e","feac34b959ec9029","b64af8db63911209","d41dcda1e53b8446","dffd5dab3b60704e","ec3fb003c91163a4"]]},{"id":"850a4d8b64093d2c","type":"modbus-client","name":"Huawei Sun 2000","clienttype":"tcp","bufferCommands":false,"stateLogEnabled":false,"queueLogEnabled":true,"failureLogEnabled":false,"tcpHost":"192.168.20.99","tcpPort":"6607","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"0","commandDelay":"800","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

Hello, the problem is that Error messages constantly appear:
TypeError: Cannot read properties of undefined (reading ‘address’)

Can you show us a screenshot of the debug 5 output immediately followed by the error output please.

In your first post, the second message in the debug is:
7/8/2023. 10:00:07 node: adafe02b12b67b6 "Error: Modus exception 1: Illegal function (device does not support
this read/write function)'

The following following error messages come from each of the function nodes because you are testing for something in the msg that does not exist
if (msg.modbusRequest.address == 32000) {

If you add a catch node attached to a debug node it should catch the error from the Mobus node and it would not be passed onto the various function` nodes.


image



image

Hello, does it say so?

image

The errors are constant:


I have just realised that you are sending seven messages to the getter node at virtually the same time. I don't know whether it copes with that. I suggest you try inserting a Delay node in Rate Limit mode (that is important) to limit the rate that they are sent to the getter. Set the rate so that it should have time to complete the previous one before it starts the next. Note that all the debug 5 outputs have the same time, so it may be that the getter node is trying to do them in parallel rather than in series.

In fact for testing it might be best to disconnect all but one of the input SUN nodes and make sure that works reliably.

Not one more mistake! Bus collapse?

[{"id":"adaf4e02b12b67b6","type":"modbus-flex-getter","z":"19d7da1865ba7247","name":"","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"850a4d8b64093d2c","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":true,"keepMsgProperties":true,"x":510,"y":160,"wires":[["c1b3b43dba36195e","0d0618ae79bd160e","38e24bda8c328792","9a87ad5cd07189d7","08fc23dec162139a","ddf53747fcc12f52","1d574a216e3a9770","03aa3f51ddf15c27"],[]]},{"id":"8cce77250759e302","type":"function","z":"19d7da1865ba7247","name":"SUN1","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32000,\n    'quantity': 11\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":180,"wires":[["4ab6d7344b0636f4"]]},{"id":"f1b9d124ecea0d6c","type":"inject","z":"19d7da1865ba7247","name":"begin","props":[{"p":"payload"},{"p":"queueUnitId","v":"0","vt":"num"}],"repeat":"7","crontab":"","once":true,"onceDelay":"10","topic":"","payload":"","payloadType":"str","x":90,"y":180,"wires":[["8cce77250759e302","4e43b362a79f929e","feac34b959ec9029","b64af8db63911209","d41dcda1e53b8446","dffd5dab3b60704e","ec3fb003c91163a4"]]},{"id":"4e43b362a79f929e","type":"function","z":"19d7da1865ba7247","name":"SUN2","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32089,\n    'quantity': 1\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":220,"wires":[["4ab6d7344b0636f4"]]},{"id":"feac34b959ec9029","type":"function","z":"19d7da1865ba7247","name":"SUN3","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 37113,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":260,"wires":[["4ab6d7344b0636f4"]]},{"id":"b64af8db63911209","type":"function","z":"19d7da1865ba7247","name":"SUN4","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32064,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":300,"wires":[["4ab6d7344b0636f4"]]},{"id":"d41dcda1e53b8446","type":"function","z":"19d7da1865ba7247","name":"SUN5","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 32080,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":340,"wires":[["4ab6d7344b0636f4"]]},{"id":"dffd5dab3b60704e","type":"function","z":"19d7da1865ba7247","name":"SUN6","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 37760,\n    'quantity': 3\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":380,"wires":[["4ab6d7344b0636f4"]]},{"id":"ec3fb003c91163a4","type":"function","z":"19d7da1865ba7247","name":"SUN7","func":"msg.payload = {\n    'fc': 3,\n    'unitid': 0,\n    'address': 37765,\n    'quantity': 2\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":250,"y":420,"wires":[["4ab6d7344b0636f4"]]},{"id":"03aa3f51ddf15c27","type":"debug","z":"19d7da1865ba7247","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":560,"wires":[]},{"id":"4ab6d7344b0636f4","type":"delay","z":"19d7da1865ba7247","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":450,"y":240,"wires":[["adaf4e02b12b67b6"]]},{"id":"850a4d8b64093d2c","type":"modbus-client","name":"Huawei Sun 2000","clienttype":"tcp","bufferCommands":false,"stateLogEnabled":false,"queueLogEnabled":true,"failureLogEnabled":false,"tcpHost":"192.168.20.99","tcpPort":"6607","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"0","commandDelay":"800","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":false}]

Possibly overloading the Huawei device.

Perfect, thank you very much for the help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.