Hi team,
I am trying to decode a constant stream of data that is being transmitted via RS485. Following is an example snippet of the data string.
7e 16 10 bf 14 01 04 05 11 28 00 00 00 00 00 00 00 00 00 00 00 00 5e 7e 7e 05 10 bf 06 5c 7e 7e 07 10 bf 11 00 00 3e 7e
There are no breaks to this string of data it is constantly being transmitted from the device with occasional waits between messages to allow for NodeRed to send requests or to update parameters.
If you look at the data, the hex value 0x7e is repeated, which, according to the protocol description, is the message delimiter.
What I need to do is break this data down into chunks first between delimiters, so if you take the above message, it would be broken up as follows.
7e 16 10 bf 14 01 04 05 11 28 00 00 00 00 00 00 00 00 00 00 00 00 5e 7e
7e 05 10 bf 06 5c 7e
7e 07 10 bf 11 00 00 3e 7e
But I am struggling to work out how to do that. I could write some Java to do the job, but I thought I would see if anyone out there might know how to do this.
Once each message sentence is broken down, I then need to break it down further to individual hex values and use that information to populate values on a web dashboard.
The breaking down of the hex word is easy using the split and the join nodes. But the problem I am having is that there is no way of splitting up each sentence; the flow is only able to process the first message it receives and nothing else.
So is there a way I can do this with the split node? If you think about it another way, I need a way to flow control the message to add a break between two occurrences of 0x7e to give Node Red a fighting chance to process the data.
Below is the flow I am building, so you can see the bit that’s working.
[{"id":"6a470816a4d22f2f","type":"switch","z":"a8124655.e780f8","name":"","property":"payload[4]","propertyType":"msg","rules":[{"t":"eq","v":"00","vt":"str"},{"t":"eq","v":"01","vt":"str"},{"t":"eq","v":"02","vt":"str"},{"t":"eq","v":"03","vt":"str"},{"t":"eq","v":"04","vt":"str"},{"t":"eq","v":"05","vt":"str"},{"t":"eq","v":"06","vt":"str"},{"t":"eq","v":"07","vt":"str"},{"t":"eq","v":"11","vt":"str"},{"t":"eq","v":"12","vt":"str"},{"t":"eq","v":"13","vt":"str"},{"t":"eq","v":"14","vt":"str"},{"t":"eq","v":"20","vt":"str"},{"t":"eq","v":"21","vt":"str"},{"t":"eq","v":"22","vt":"str"},{"t":"eq","v":"23","vt":"str"},{"t":"eq","v":"24","vt":"str"},{"t":"eq","v":"25","vt":"str"},{"t":"eq","v":"26","vt":"str"},{"t":"eq","v":"27","vt":"str"},{"t":"eq","v":"28","vt":"str"},{"t":"eq","v":"29","vt":"str"},{"t":"eq","v":"2A","vt":"str"},{"t":"eq","v":"2B","vt":"str"},{"t":"eq","v":"2D","vt":"str"},{"t":"eq","v":"2E","vt":"str"},{"t":"eq","v":"48","vt":"str"},{"t":"eq","v":"82","vt":"str"},{"t":"eq","v":"92","vt":"str"},{"t":"eq","v":"94","vt":"str"},{"t":"eq","v":"96","vt":"str"},{"t":"eq","v":"E0","vt":"str"},{"t":"eq","v":"E1","vt":"str"},{"t":"eq","v":"F1","vt":"str"}],"checkall":"true","repair":false,"outputs":34,"x":691.5312538146973,"y":948.7500152587891,"wires":[["cb639753c49f3e99"],["43347568a09581fd"],["9d70398da64dbb6c"],["72b4ac64eeb39761"],["344cbf1bfd99e5ac"],["9bf7ec59624242fb"],["25b12e2039556fb9"],["ad4006c33bb44b68"],["fddda866c92357f8"],["42b19ccc93dcb675"],["f1ffa5717633aa76"],["ed0b1884a865639c"],["8198c9e23869e888"],["06465237468bc274"],["f9bfb41fe72f1395"],["7d8baaded881fd4f"],["db3cc0a8d8d02ed6"],["9ef9495326d3fe5e"],["ec8a3eb855b6e92a"],["d458c64953b7f9f8"],["f3b2f3673d7e6600"],["ab84c0e532e2c738"],["549c6ba58518d11b"],["3dde2753f497991b"],["263719596c98d8cd"],["88bfc45136b9af36"],["e1f8316e551c2af7"],["3b7e22149ff009dd"],["9744a9e4c88d5948"],["d186ee577f44bb08"],["7c1586a0fc445b34"],["ead93070d34c89f3"],["091dad95d0d5abcc"],["d600e209674a79ce"]]},{"id":"cb639753c49f3e99","type":"change","z":"a8124655.e780f8","name":"00 New Client Clear to Send","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"New Client Clear to Send","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":951.5313529968262,"y":463.74999713897705,"wires":[["f5923ce8df1d450d"]]},{"id":"72b4ac64eeb39761","type":"change","z":"a8124655.e780f8","name":"03 Channel Assignment Acknowledgement","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Channel Assignment Acknowledgement","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":999.5313110351562,"y":560.749936580658,"wires":[["f5923ce8df1d450d"]]},{"id":"344cbf1bfd99e5ac","type":"change","z":"a8124655.e780f8","name":"04 Existing Client Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Existing Client Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":949.5313262939453,"y":593.7499327659607,"wires":[["f5923ce8df1d450d"]]},{"id":"9bf7ec59624242fb","type":"change","z":"a8124655.e780f8","name":"05 Existing Client Response","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Existing Client Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":949.5313339233398,"y":626.7499432563782,"wires":[["f5923ce8df1d450d"]]},{"id":"25b12e2039556fb9","type":"change","z":"a8124655.e780f8","name":"06 Clear to Send","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"\tClear to Send","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920.5313262939453,"y":659.7499585151672,"wires":[["f5923ce8df1d450d"]]},{"id":"43347568a09581fd","type":"change","z":"a8124655.e780f8","name":"01 Channel Assignment Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Channel Assignment Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":970.5313186645508,"y":496.7499713897705,"wires":[["f5923ce8df1d450d"]]},{"id":"8f528a80f148c6be","type":"join","z":"a8124655.e780f8","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":533.2656154632568,"y":606.9394731521606,"wires":[["6a470816a4d22f2f"]]},{"id":"ad4006c33bb44b68","type":"change","z":"a8124655.e780f8","name":"07 Nothing to Send","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Nothing to Send","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920.53125,"y":692.7499489784241,"wires":[["f5923ce8df1d450d"]]},{"id":"fddda866c92357f8","type":"change","z":"a8124655.e780f8","name":"11 Toggle Item Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Toggle Item Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":940.5312404632568,"y":725.749945640564,"wires":[["f5923ce8df1d450d"]]},{"id":"f1ffa5717633aa76","type":"change","z":"a8124655.e780f8","name":"13 Status Update","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Status Update","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":918.5311985015869,"y":792.7499170303345,"wires":[["f5923ce8df1d450d"]]},{"id":"ed0b1884a865639c","type":"change","z":"a8124655.e780f8","name":"14 ?? 2","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"?? 2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":888.531213760376,"y":825.7499132156372,"wires":[["f5923ce8df1d450d"]]},{"id":"8198c9e23869e888","type":"change","z":"a8124655.e780f8","name":"20 Set Temperature Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Set Temperature Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":948.5312213897705,"y":858.7499237060547,"wires":[["f5923ce8df1d450d"]]},{"id":"06465237468bc274","type":"change","z":"a8124655.e780f8","name":"21 Set Time Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Set Time Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":929.531213760376,"y":891.7499389648438,"wires":[["f5923ce8df1d450d"]]},{"id":"42b19ccc93dcb675","type":"change","z":"a8124655.e780f8","name":"12 ?? 1","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"?? 1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":889.5312061309814,"y":758.7499198913574,"wires":[["f5923ce8df1d450d"]]},{"id":"f9bfb41fe72f1395","type":"change","z":"a8124655.e780f8","name":"22 Settings Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Settings Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":928.765625,"y":924.7499680519104,"wires":[["f5923ce8df1d450d"]]},{"id":"7d8baaded881fd4f","type":"change","z":"a8124655.e780f8","name":"23 Filter Cycles Message","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Filter Cycles Message","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":938.7656154632568,"y":957.7499647140503,"wires":[["f5923ce8df1d450d"]]},{"id":"9ef9495326d3fe5e","type":"change","z":"a8124655.e780f8","name":"25 ?Settings 0x04 Response?","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"\t?Settings 0x04 Response?","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":957.7656555175781,"y":1024.7499766349792,"wires":[["f5923ce8df1d450d"]]},{"id":"ec8a3eb855b6e92a","type":"change","z":"a8124655.e780f8","name":"26 Preferences Response","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Preferences Response","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":936.7656669616699,"y":1055.7500228881836,"wires":[["f5923ce8df1d450d"]]},{"id":"d458c64953b7f9f8","type":"change","z":"a8124655.e780f8","name":"27 Set Preference Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Set Preference Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":945.765697479248,"y":1086.7500371932983,"wires":[["f5923ce8df1d450d"]]},{"id":"f3b2f3673d7e6600","type":"change","z":"a8124655.e780f8","name":"28 Fault Log Response","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Fault Log Response","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":934.765739440918,"y":1116.7500228881836,"wires":[["f5923ce8df1d450d"]]},{"id":"db3cc0a8d8d02ed6","type":"change","z":"a8124655.e780f8","name":"24 Information Response","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Information Response","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":937.7655811309814,"y":990.7499389648438,"wires":[["f5923ce8df1d450d"]]},{"id":"ab84c0e532e2c738","type":"change","z":"a8124655.e780f8","name":"29 ?Settings 0x04 Response?","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"\t?Settings 0x04 Response?","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":954.7657623291016,"y":1147.7499923706055,"wires":[["f5923ce8df1d450d"]]},{"id":"549c6ba58518d11b","type":"change","z":"a8124655.e780f8","name":"2A Change Setup Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Change Setup Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":944.765739440918,"y":1179.7499923706055,"wires":[["f5923ce8df1d450d"]]},{"id":"3dde2753f497991b","type":"change","z":"a8124655.e780f8","name":"2B GFCI Test Response","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"GFCI Test Response","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":934.765754699707,"y":1210.7500534057617,"wires":[["f5923ce8df1d450d"]]},{"id":"263719596c98d8cd","type":"change","z":"a8124655.e780f8","name":"2D Lock Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Lock Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":914.7657699584961,"y":1242.750099182129,"wires":[["f5923ce8df1d450d"]]},{"id":"88bfc45136b9af36","type":"change","z":"a8124655.e780f8","name":"2E Configuration Response","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Configuration Response","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":943.7658233642578,"y":1272.7501602172852,"wires":[["f5923ce8df1d450d"]]},{"id":"e1f8316e551c2af7","type":"change","z":"a8124655.e780f8","name":"48 ??3","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"?? 3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":872.7657661437988,"y":1302.7502822875977,"wires":[["f5923ce8df1d450d"]]},{"id":"3b7e22149ff009dd","type":"change","z":"a8124655.e780f8","name":"82 ??4","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"??4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":871.7657432556152,"y":1332.7502517700195,"wires":[["f5923ce8df1d450d"]]},{"id":"9744a9e4c88d5948","type":"change","z":"a8124655.e780f8","name":"92 Set WiFi Settings Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Set WiFi Settings Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":941.7657585144043,"y":1364.7503128051758,"wires":[["f5923ce8df1d450d"]]},{"id":"d186ee577f44bb08","type":"change","z":"a8124655.e780f8","name":"94 WiFi Module Configuration Response","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"WiFi Module Configuration Response","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":981.7658271789551,"y":1396.7500381469727,"wires":[["f5923ce8df1d450d"]]},{"id":"ead93070d34c89f3","type":"change","z":"a8124655.e780f8","name":"E0 Toggle Test Setting Request","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Toggle Test Setting Request","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":949.8566627502441,"y":1460.4773111343384,"wires":[["f5923ce8df1d450d"]]},{"id":"091dad95d0d5abcc","type":"change","z":"a8124655.e780f8","name":"E1 ?Error? 1","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"?Error? 1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":888.8566207885742,"y":1492.4776163101196,"wires":[["f5923ce8df1d450d"]]},{"id":"d600e209674a79ce","type":"change","z":"a8124655.e780f8","name":"F0 ?Error? 2","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"?Error? 2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":889.8566055297852,"y":1527.4772500991821,"wires":[["f5923ce8df1d450d"]]},{"id":"9d70398da64dbb6c","type":"change","z":"a8124655.e780f8","name":"02 Channel Assignment Response","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Channel Assignment Response","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":968.765625,"y":528.75,"wires":[["f5923ce8df1d450d"]]},{"id":"7c1586a0fc445b34","type":"change","z":"a8124655.e780f8","name":"96 Spa Craft Wifi Model","rules":[{"t":"set","p":"messagetype","pt":"msg","to":"Spa Craft Wifi Model","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":929.4717216491699,"y":1426.9836864471436,"wires":[["f5923ce8df1d450d"]]},{"id":"b3c81f5b59e2c4d9","type":"inject","z":"a8124655.e780f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"7e 16 10 bf 14 01 04 05 11 28 00 00 00 00 00 00 00 00 00 00 00 00 5e 7e ","payloadType":"str","x":239.76562881469727,"y":627.7500348091125,"wires":[["0215a32efaf38ab0"]]},{"id":"f5923ce8df1d450d","type":"debug","z":"a8124655.e780f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1384.7655944824219,"y":1172.7501249313354,"wires":[]},{"id":"0215a32efaf38ab0","type":"split","z":"a8124655.e780f8","name":"","splt":" ","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"key","x":388.765625,"y":626.75,"wires":[["8f528a80f148c6be"]]}]