-
Notifications
You must be signed in to change notification settings - Fork 0
/
confirmHardwareIdentity.json
1 lines (1 loc) · 3.58 KB
/
confirmHardwareIdentity.json
1
[{"id":"a7d743e3.5828c","type":"subflow","name":"Confirm Hardware Identity HMC5883L","info":"This subflow asks the I2C bus hardware at the\nfixed I2C address for the HMC5883L ID register\ncontents.\n\nThe ID register (A,B,C) contents returned are compared to the hardwired (immutable) value assigned to the HMC5883L in the datasheet. (p.15, Table 18, 19, 20)\n\nQ and Q' outputs as true/false outputs.","category":"","in":[{"x":40,"y":80,"wires":[{"id":"6127f0b7.9ed81"}]}],"out":[{"x":1400,"y":80,"wires":[{"id":"f7a2b90a.085d48","port":0}]},{"x":1400,"y":160,"wires":[{"id":"f7a2b90a.085d48","port":1}]}],"env":[],"color":"#E9967A","inputLabels":["msg triggered (1-shot)"],"outputLabels":["Confirmed (true/false)","Disconfirmed (true/false)"],"icon":"node-red/watch.svg"},{"id":"6127f0b7.9ed81","type":"function","z":"a7d743e3.5828c","name":"read ID command","func":"return [{command:\"10\"},{command:\"11\"},{command:\"12\"}];","outputs":3,"noerr":0,"x":200,"y":80,"wires":[["a57b1d62.5a84e"],["a57b1d62.5a84e"],["a57b1d62.5a84e"]],"outputLabels":["get ID1","get ID2","get ID3"]},{"id":"a57b1d62.5a84e","type":"i2c in","z":"a7d743e3.5828c","name":"HMC5883L command","address":"30","command":"","count":"1","x":490,"y":80,"wires":[["471e0bef.b8e1f4"]]},{"id":"471e0bef.b8e1f4","type":"join","z":"a7d743e3.5828c","name":"join msgs","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":710,"y":80,"wires":[["3f7a3672.c085ca"]]},{"id":"3f7a3672.c085ca","type":"function","z":"a7d743e3.5828c","name":"calc ID","func":"msg.ID=\"0x\"+((msg.payload[0]<<16)+(msg.payload[1]<<8)+(msg.payload[2])).toString(16);\n\nmsg.topic = \"Identification Register\";\nnode.status({text:\"ID: 0x\"+parseInt(msg.ID).toString(16)});//flow coding -readable version\n \nreturn msg;","outputs":1,"noerr":2,"x":880,"y":80,"wires":[["f7a2b90a.085d48"]]},{"id":"f7a2b90a.085d48","type":"function","z":"a7d743e3.5828c","name":"Confirm HMC5883L identity","func":"if (null===msg.payload) return [{payload:false},{payload:false}];\nvar idvalue = (msg.payload[0]<<16) +(msg.payload[1]<<8) +(msg.payload[2]);\nif (0x483433 == idvalue) return [{payload:true,topic:\"Confirmed HMC5883L Identity\"},\n {payload:false, topic:\"Disconfirmed HMC5883L Identity\"}];\nelse return [{payload:false,topic:\"Confirmed HMC5883L Identity\"},\n {payload:true, topic:\"Disconfirmed HMC5883L Identity\"}];","outputs":2,"noerr":2,"x":1190,"y":80,"wires":[[],[]],"inputLabels":["3-byte identity"],"outputLabels":["Confirmed Identity","Dis-Confirmed Identity"],"info":"Checks the 3-byte input value against the HMC5883L\nID number (hard-wired register).\n\nInputs:\n3-byte msg.payload\n\nOutputs:\nConfirmed Identity: true/false\nDis-Confirmed Identity: true/false\n\nOutputs are only true when their named condition is true."},{"id":"54815778.ab7ea8","type":"inject","z":"a7d743e3.5828c","name":"wrong id test","topic":"","payload":"[1,2,3]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":890,"y":360,"wires":[["f7a2b90a.085d48"]]},{"id":"bb58d86.f44a728","type":"inject","z":"a7d743e3.5828c","name":"right id test","topic":"","payload":"[72,52,51]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":870,"y":200,"wires":[["f7a2b90a.085d48"]]},{"id":"540dbba6.abf244","type":"comment","z":"a7d743e3.5828c","name":"Send ID Request on I2C, check against Hard-wired ID","info":"","x":330,"y":180,"wires":[]}]