-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflows_mcu_serial-in-out_experiment.json
1 lines (1 loc) · 5.1 KB
/
flows_mcu_serial-in-out_experiment.json
1
[{"id":"c282fba1467c87c2","type":"tab","label":"mcu serial with Function node","disabled":false,"info":"","env":[],"_mcu":{"mcu":true}},{"id":"a8e47427141baace","type":"debug","z":"c282fba1467c87c2","name":"debug MCU","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","_mcu":{"mcu":true},"x":290,"y":160,"wires":[]},{"id":"da41a8a1469ce748","type":"function","z":"c282fba1467c87c2","name":"mcu serial in","func":"// code or port settings are written in 'On Start' tab.\n// please ignore red triangle on this node.\n\n// コードやポート設定は「初期化処理(On Start)」にあります。\n// ノードに赤い三角マークがつきますが無視してください。","outputs":1,"timeout":0,"noerr":4,"initialize":"// Code added here will be run once\n// whenever the node is started.\n\nlet serial = new device.io.Serial({\n ...device.Serial.default,\n baud: 115200,\n port: 2,\n receive: 16,\n transmit: 17,\n format: \"buffer\",\n onReadable: function (count) {\n let msg = {};\n msg.payload = String.fromArrayBuffer(this.read());\n msg.payload = msg.payload.trimEnd();\n node.send(msg);\n },\n});\nflow.set('serial', serial); // provide 'serial' for 'mcu serial out' node.\n","finalize":"","libs":[],"_mcu":{"mcu":true},"x":110,"y":100,"wires":[["a8e47427141baace","c2dbd3f2ece37dfc"]]},{"id":"f0d8c610fb2f86fd","type":"mcu_digital_out","z":"c282fba1467c87c2","name":"LED port 18","pin":"18","mode":"Output","initial":"1","invert":false,"moddable_manifest":{"include":"$(NODEREDMCU)/nodes/mcu/digital/manifest.json"},"_mcu":{"mcu":true},"x":610,"y":160,"wires":[]},{"id":"c2dbd3f2ece37dfc","type":"switch","z":"c282fba1467c87c2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"18true","vt":"str"},{"t":"eq","v":"18false","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"_mcu":{"mcu":true},"x":270,"y":100,"wires":[["d19a137b4b6a8fa2"],["8b67afdf33241e3c"]]},{"id":"8b67afdf33241e3c","type":"change","z":"c282fba1467c87c2","name":"on","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"_mcu":{"mcu":true},"x":410,"y":120,"wires":[["f0d8c610fb2f86fd","ac4b3cf62b8391be"]]},{"id":"d19a137b4b6a8fa2","type":"change","z":"c282fba1467c87c2","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"_mcu":{"mcu":true},"x":410,"y":80,"wires":[["f0d8c610fb2f86fd","f893710bfa423276"]]},{"id":"ac4b3cf62b8391be","type":"change","z":"c282fba1467c87c2","name":"turned on","rules":[{"t":"set","p":"payload","pt":"msg","to":"18 turned on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"_mcu":{"mcu":true},"x":600,"y":120,"wires":[["e3607e845916aeaf"]]},{"id":"f893710bfa423276","type":"change","z":"c282fba1467c87c2","name":"turned off","rules":[{"t":"set","p":"payload","pt":"msg","to":"18 turned off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"_mcu":{"mcu":true},"x":600,"y":80,"wires":[["e3607e845916aeaf"]]},{"id":"e3607e845916aeaf","type":"function","z":"c282fba1467c87c2","name":"mcu serial out","func":"let serial = flow.get('serial'); // get 'serial' from 'mcu serial in'\n\nif (msg.payload != null){\n serial.write(ArrayBuffer.fromString(msg.payload + \"\\n\"));\n}\n","outputs":0,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"_mcu":{"mcu":true},"x":800,"y":100,"wires":[]},{"id":"87e3f7bb716419fa","type":"tab","label":"serial receive on PC","disabled":false,"info":"","env":[],"_mcu":{"mcu":false}},{"id":"8c2d5d6701d4737a","type":"serial in","z":"87e3f7bb716419fa","name":"","serial":"4aa9498a.4e4888","_mcu":{"mcu":false},"x":170,"y":180,"wires":[["9f526124cade8f26"]]},{"id":"9f526124cade8f26","type":"debug","z":"87e3f7bb716419fa","name":"debug PC receive","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","_mcu":{"mcu":false},"x":430,"y":180,"wires":[]},{"id":"cc57de5fda827960","type":"serial out","z":"87e3f7bb716419fa","name":"","serial":"4aa9498a.4e4888","_mcu":{"mcu":false},"x":390,"y":100,"wires":[]},{"id":"6e7b2e32fcc0270e","type":"inject","z":"87e3f7bb716419fa","name":"18 OFF","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"18true","payloadType":"str","_mcu":{"mcu":false},"x":190,"y":120,"wires":[["cc57de5fda827960"]]},{"id":"7a87b6f6eb8e7941","type":"inject","z":"87e3f7bb716419fa","name":"18 ON","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"18false","payloadType":"str","_mcu":{"mcu":false},"x":190,"y":80,"wires":[["cc57de5fda827960"]]},{"id":"4aa9498a.4e4888","type":"serial-port","serialport":"COM7","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"\\n","responsetimeout":"10000"}]