How can CRC16 XModem accept Hex Input

Here is a demo using easy-crc node package

Example...
chrome_d6AT7LUCMp

Demo flow...

[{"id":"e2beeb574d982801","type":"inject","z":"cba04618014a760c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"type","v":"hex","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"calculate","payload":"8500A9000002005202","payloadType":"str","x":1950,"y":80,"wires":[["4bf21b40a1445e15"]]},{"id":"4bf21b40a1445e15","type":"function","z":"cba04618014a760c","name":"xmodem crc16 (easy-crc)","func":"//See https://www.npmjs.com/package/easy-crc?activeTab=readme for list of supported algorithms\nconst { crc16 } = easyCrc;\nconst data = Buffer.from(msg.payload, 'hex');\nmsg.payload = crc16('XMODEM', data);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"easyCrc","module":"easy-crc"}],"x":1890,"y":140,"wires":[["25cd665db5eaa0d9"]]},{"id":"25cd665db5eaa0d9","type":"debug","z":"cba04618014a760c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2110,"y":140,"wires":[]}]
2 Likes