I am working with a piece of equipment which requires me to send some UDP commands and then enable TCP communications after all the UDP commands are sent. The problem I am running into is that I am just waiting a specific delay before sending the TCP commands instead of waiting for a confirmation response to the UDP commands as I should. I am unable to get any type of response back from the UDP commands using the UPD In Node and Debug Node
. (I am not having any luck with the TCP In
Node either, but that is not the focus of my question for now.) My flow works as far as sending the UDP commands and then initiating the TCP commands, but it gets out of sequence now and again because I don't wait for a confirmation. Any help on setting up the UDP In
would be appreciated.
Partial SubFlow:
[{“id”:“cfaafe56.9e7118”,“type”:“inject”,“z”:“232afa27.9b8b12”,“name”:"",“topic”:"",“payload”:“blah”,“payloadType”:“str”,“repeat”:"",“crontab”:"",“once”:false,“x”:256,“y”:138.22999572753906,“wires”:[[“796d20e2.36e8a”]]},{“id”:“796d20e2.36e8a”,“type”:“debug”,“z”:“232afa27.9b8b12”,“name”:"",“active”:true,“console”:“false”,“complete”:“false”,“x”:454,“y”:113.47000122070312,“wires”:[]},{“id”:“5490f5e7.16ffbc”,“type”:“udp in”,“z”:“232afa27.9b8b12”,“name”:"",“iface”:"",“port”:“1234”,“ipv”:“udp4”,“multicast”:“false”,“group”:"",“datatype”:“buffer”,“x”:248,“y”:93.22999572753906,“wires”:[[“796d20e2.36e8a”]]}]
Full SubFlow:
[{"id":"e3b4f37e.511c2","type":"function","z":"dd199d89.e8788","name":"Enable TCP Notifications","func":"var ip = flow.get('ip');\nmsg.payload = new Buffer([0x80,ip[0],ip[1],ip[2],ip[3],0x01,0x17,0x01]);\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"x":430,"y":240,"wires":[["da2ce5a6.2a5ca8","38b31be0.83ba84"]]},{"id":"ed5e94ec.6c4ff8","type":"udp out","z":"dd199d89.e8788","name":"","addr":"","iface":"","port":"","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":910,"y":260,"wires":[]},{"id":"4dc15f79.ac34d","type":"function","z":"dd199d89.e8788","name":"Low Level API","func":"var ip = flow.get('ip');\nmsg.payload = new Buffer([0x80,ip[0],ip[1],ip[2],ip[3],0x00,0x0C]);\nreturn msg;\n\n\n\n\n","outputs":1,"noerr":0,"x":460,"y":160,"wires":[["8c1d416d.7747b","da2ce5a6.2a5ca8"]]},{"id":"df430505.2d3ca8","type":"function","z":"dd199d89.e8788","name":"buffer to hexString","func":"var rfid = msg.payload;\npktVer = rfid[0];\ncrcFlag = rfid[1]&0b00000001;\nif (crcFlag === 0 && (pktVer === 0X02 || pktVer === 0X01)){\nepcLength = (rfid[20] >> 3) *2;\nmsg = {};\nmsg.payload = rfid;\n\n// Wide band RSSI is in byte 12 and narrow band RSSI is in byte 13\nmsg.wbRSSIdB = rfid[12] * 0.8;\nmsg.nbRSSIdB = rfid[13] * 0.8;\n\nvar epc = new Buffer(rfid, 'utf8').toString('hex',22,22+epcLength);\nmsg.epc = epc.toString();\nvar ip = flow.get('ip');\nmsg.ip = \"\"+ip[0]+\".\"+ip[1]+\".\"+ip[2]+\".\"+ip[3]+\"\";\n\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":1030,"y":640,"wires":[["e04cb822.84d3a8"]]},{"id":"982d780a.89eb38","type":"function","z":"dd199d89.e8788","name":"Start Inventory","func":"\nmsg.payload = new Buffer([0x70,0x01,0x00,0xf0,0x0f,0x00,0x00,0x00]);\n\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"x":400,"y":660,"wires":[["d1f4ee09.90bd1"]]},{"id":"7d54347f.7a4a9c","type":"function","z":"dd199d89.e8788","name":"Continuous Mode","func":"\nmsg.payload = new Buffer([0x70,0x01,0x00,0x07,0xff,0xff,0x00,0x00]);\n\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"x":390,"y":600,"wires":[["d1f4ee09.90bd1","aa7cbd6.f6e134"]]},{"id":"89f4834b.de829","type":"function","z":"dd199d89.e8788","name":"ABORT","func":"\nmsg.payload = new Buffer([0x40,0x03,0x00,0x00,0x00,0x00,0x00,0x00]);\n\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"x":380,"y":720,"wires":[["d1f4ee09.90bd1","8fbd2151.970db"]]},{"id":"19ca020a.1337de","type":"tcp request","z":"dd199d89.e8788","server":"","port":"","out":"sit","splitc":" ","name":"","x":850,"y":620,"wires":[["df430505.2d3ca8"]]},{"id":"dfa72d98.c078d","type":"function","z":"dd199d89.e8788","name":"Disable TCP Notifications","func":"var ip = flow.get('ip');\nmsg.payload = new Buffer([0x80,ip[0],ip[1],ip[2],ip[3],0x01,0x17,0x00]);\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"x":430,"y":300,"wires":[["da2ce5a6.2a5ca8","2a1c6448.88a95c"]]},{"id":"8c1d416d.7747b","type":"delay","z":"dd199d89.e8788","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":200,"y":240,"wires":[["e3b4f37e.511c2"]]},{"id":"7f111220.0e832c","type":"catch","z":"dd199d89.e8788","name":"","scope":null,"x":1040,"y":580,"wires":[["a7207db3.ad696","dfa72d98.c078d"]]},{"id":"aa7cbd6.f6e134","type":"delay","z":"dd199d89.e8788","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":200,"y":660,"wires":[["982d780a.89eb38"]]},{"id":"da2ce5a6.2a5ca8","type":"function","z":"dd199d89.e8788","name":"msg.ip","func":"var ip = flow.get('ip');\nmsg.ip = \"\"+ip[0]+\".\"+ip[1]+\".\"+ip[2]+\".\"+ip[3]+\"\";\nmsg.port = 3041;\nreturn msg;","outputs":1,"noerr":0,"x":770,"y":260,"wires":[["ed5e94ec.6c4ff8"]]},{"id":"d1f4ee09.90bd1","type":"function","z":"dd199d89.e8788","name":"msg.host","func":"var ip = flow.get('ip');\nmsg.host = \"\"+ip[0]+\".\"+ip[1]+\".\"+ip[2]+\".\"+ip[3]+\"\";\nmsg.port = 1515;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":660,"wires":[["19ca020a.1337de"]]},{"id":"a1b95379.35b17","type":"function","z":"dd199d89.e8788","name":"msg.start","func":"if(msg.start){\nreturn msg;\n}","outputs":1,"noerr":0,"x":180,"y":160,"wires":[["4dc15f79.ac34d","f931137e.1bab8"]]},{"id":"8989e98e.7681b8","type":"function","z":"dd199d89.e8788","name":"!msg.start","func":"if(!msg.start){\nreturn msg;\n}","outputs":1,"noerr":0,"x":180,"y":720,"wires":[["89f4834b.de829"]]},{"id":"8fbd2151.970db","type":"delay","z":"dd199d89.e8788","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":600,"y":720,"wires":[["dfa72d98.c078d"]]},{"id":"2a1c6448.88a95c","type":"delay","z":"dd199d89.e8788","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"20","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1100,"y":320,"wires":[["b93db03d.37a2f"]]},{"id":"b93db03d.37a2f","type":"function","z":"dd199d89.e8788","name":"","func":"msg.start = flow.get('start');\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":200,"wires":[["a1b95379.35b17"]]},{"id":"e5c122a4.51d85","type":"delay","z":"dd199d89.e8788","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":200,"y":600,"wires":[["7d54347f.7a4a9c"]]},{"id":"b7f4ff06.7318d","type":"change","z":"dd199d89.e8788","name":"","rules":[{"t":"set","p":"start","pt":"flow","to":"start","tot":"msg"},{"t":"set","p":"ip","pt":"flow","to":"ip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":80,"wires":[["a1b95379.35b17","8989e98e.7681b8"]]},{"id":"a7207db3.ad696","type":"debug","z":"dd199d89.e8788","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1310,"y":580,"wires":[]},{"id":"e04cb822.84d3a8","type":"trigger","z":"dd199d89.e8788","op1":"","op2":"true","op1type":"nul","op2type":"bool","duration":"5","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":1060,"y":740,"wires":[["dfa72d98.c078d"]]},{"id":"f931137e.1bab8","type":"delay","z":"dd199d89.e8788","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":880,"y":740,"wires":[["e04cb822.84d3a8"]]},{"id":"e370bc8d.dc161","type":"function","z":"dd199d89.e8788","name":"Ant_Port_Power","func":"\nmsg.payload = new Buffer([0x70,0x01,0x06,0x07,0xfa,0x00,0x00,0x00]);\n\nreturn msg;\n\n\n\n","outputs":1,"noerr":0,"x":380,"y":540,"wires":[["e5c122a4.51d85","d1f4ee09.90bd1"]]},{"id":"38b31be0.83ba84","type":"delay","z":"dd199d89.e8788","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":200,"y":540,"wires":[["e370bc8d.dc161"]]},{"id":"a421158d.ada978","type":"udp in","z":"dd199d89.e8788","name":"","iface":"","port":"3041","ipv":"udp4","multicast":"false","group":"","datatype":"utf8","x":1330,"y":380,"wires":[[]]},{"id":"573a06ae.225918","type":"tcp in","z":"dd199d89.e8788","name":"","server":"server","host":"","port":"1515","datamode":"stream","datatype":"buffer","newline":"","topic":"","base64":false,"x":1320,"y":460,"wires":[[]]}]