Hello, I have a ZD30 printer installed in IoT 2050 gateway using CUPS, I want to know if there is any way to send to print from node-RED?
Hi.
My colleague used the node-red-contrib-ipprint - npm node for that.
We're sending a Buffer containing a PDF there, has been working fine so far.
The CUPS printer must have the "Share" flag enabled, otherwise it won't work.
I hope this will help you to get started.
[{"id":"74ac8e787b168218","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"eeec9e7369b5ead6","type":"http request","z":"74ac8e787b168218","name":"","method":"PUT","ret":"bin","paytoqs":"ignore","url":"https://us-central1-faneamiento-app.cloudfunctions.net/animalsapp/animals","tls":"","persist":false,"proxy":"","authType":"","x":150,"y":120,"wires":[["426b2457e54e033b"]]},{"id":"426b2457e54e033b","type":"function","z":"74ac8e787b168218","name":"","func":"// Obtener el Binary Buffer de la imagen\nvar buffer = msg.payload;\n\n// Convertir el Binary Buffer a una URL de datos (data URL)\nvar dataUrl = 'data:image/jpeg;base64,' + buffer.toString('base64');\n\n// Enviar la URL de datos en el mensaje\nmsg.payload = dataUrl;\n\n// Devolver el mensaje para pasar al siguiente nodo\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":120,"wires":[["c7695bb55b6e5143"]]},{"id":"c7695bb55b6e5143","type":"ui_template","z":"74ac8e787b168218","group":"96f57673356c6885","name":"","order":1,"width":"6","height":"4","format":"<img src=\"{{msg.payload}}\" alt=\"Imagen\">","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":600,"y":120,"wires":[[]]},{"id":"96f57673356c6885","type":"ui_group","name":"Etiqueta","tab":"4cebec0ed5def0cf","order":3,"disp":true,"width":"6","collapse":false},{"id":"4cebec0ed5def0cf","type":"ui_tab","name":"Ganado Porcino","icon":"input","disabled":false,"hidden":false}]
This is my flow, I send certain characters and the http request node returns an image to me, I want to send this image to print to a printer configured in CUPS
Did you install the node (as was suggested) and try anything with it?
Yes, I installed it as it says in the manual, but the node does not appear in the manage palette
- What device are you running NR on and what OS?
- What version of NR and node.js? (you can find this in the NR startup log)
- When you did the install were you in the .node-red folder? If not, go to a terminal window and change folders so you are in the .node-red folder. Then run the
npm i node-red-contrib-ipprint
command. Once that is done, stop and restart NR. At that pointy should see it in the pallet and in the left menu.
I was finally able to install node.
At the end of all the code there is an "http request" node, which returns me an image and with the "function" node I present it in an html template.
Could you help me to print the image to a printer at a certain IP address?
[{"id":"e9c7705cf137b29e","type":"tab","label":"cerdos","disabled":false,"info":""},{"id":"f18df0fae51a6344","type":"ui_form","z":"e9c7705cf137b29e","name":"","label":"","group":"dff1b7f895ec7f67","order":1,"width":6,"height":2,"options":[{"label":"Peso Total","value":"pesoTotal","type":"number","required":true,"rows":null},{"label":"Tipo","value":"tipo","type":"text","required":true,"rows":null},{"label":"CĂłdigo","value":"id","type":"text","required":true,"rows":null}],"formValue":{"pesoTotal":"","tipo":"","id":""},"payload":"","submit":"Enviar","cancel":"Cancelar","topic":"topic","topicType":"msg","splitLayout":false,"x":510,"y":240,"wires":[["9dc07639a4695a6f"]]},{"id":"3d239101d1222b69","type":"change","z":"e9c7705cf137b29e","name":"","rules":[{"t":"set","p":"msg","pt":"flow","to":"msg.payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.tipo","pt":"msg","to":"msg","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":240,"wires":[["f18df0fae51a6344"]]},{"id":"30bb0e4a8065b75f","type":"inject","z":"e9c7705cf137b29e","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Porcino","payloadType":"str","x":60,"y":240,"wires":[["3d239101d1222b69"]]},{"id":"ab15538e30e120ae","type":"debug","z":"e9c7705cf137b29e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":300,"wires":[]},{"id":"9dc07639a4695a6f","type":"function","z":"e9c7705cf137b29e","name":"","func":"let id =msg.payload.id;\nlet txt=id.toString();\ntxt = txt.slice(0, 3) + \"-\" + txt.slice(3);\nmsg.payload.id=txt\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":240,"wires":[["85c390652dfed930"]]},{"id":"b616955816d6825a","type":"change","z":"e9c7705cf137b29e","name":"","rules":[{"t":"set","p":"msg","pt":"flow","to":"msg.payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.pesoDer","pt":"msg","to":"msg","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":300,"wires":[["85c390652dfed930"]]},{"id":"b291db183d83e82f","type":"inject","z":"e9c7705cf137b29e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"pesoDer","payload":"0","payloadType":"num","x":90,"y":300,"wires":[["b616955816d6825a"]]},{"id":"85c390652dfed930","type":"join","z":"e9c7705cf137b29e","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":630,"y":360,"wires":[["ba7195db95470a0a"]]},{"id":"ea0ead19afd87fc2","type":"serial in","z":"e9c7705cf137b29e","name":"","serial":"9d10fcb604e753dd","x":70,"y":80,"wires":[[]]},{"id":"5acb4b9787b0fc8e","type":"change","z":"e9c7705cf137b29e","name":"","rules":[{"t":"set","p":"msg","pt":"flow","to":"msg.payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.pesoTotal","pt":"msg","to":"msg","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":80,"wires":[["6aaa8e683e703fe8"]]},{"id":"6aaa8e683e703fe8","type":"function","z":"e9c7705cf137b29e","name":"","func":"let str2 =msg.payload.pesoTotal;\nlet txt2=parseFloat(str2);\n\nmsg.payload.pesoTotal=txt2\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":80,"wires":[["f18df0fae51a6344"]]},{"id":"15c0fc138073b9c4","type":"function","z":"e9c7705cf137b29e","name":"","func":"let izq=msg.payload;\nizq=izq.slice(12,17);\nmsg.payload=izq;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":80,"wires":[["5acb4b9787b0fc8e"]]},{"id":"ba7195db95470a0a","type":"http request","z":"e9c7705cf137b29e","name":"","method":"PUT","ret":"bin","paytoqs":"ignore","url":"https://us-central1-faneamiento-app.cloudfunctions.net/animalsapp/animals","tls":"","persist":false,"proxy":"","authType":"","x":790,"y":360,"wires":[["ab15538e30e120ae","1225cc7b776f5fdc"]]},{"id":"4ee3afbf562c5a35","type":"change","z":"e9c7705cf137b29e","name":"","rules":[{"t":"set","p":"msg","pt":"flow","to":"msg.payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.pesoIzq","pt":"msg","to":"msg","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":360,"wires":[["85c390652dfed930"]]},{"id":"0ee9ae452c1b51cd","type":"inject","z":"e9c7705cf137b29e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"pesoIzq","payload":"0","payloadType":"num","x":90,"y":360,"wires":[["4ee3afbf562c5a35"]]},{"id":"be474c3f4455ac47","type":"inject","z":"e9c7705cf137b29e","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"ST,NT,5 25 kg","payloadType":"str","x":80,"y":20,"wires":[[]]},{"id":"1225cc7b776f5fdc","type":"function","z":"e9c7705cf137b29e","name":"","func":"// Obtener el Binary Buffer de la imagen\nvar buffer = msg.payload;\n\n// Convertir el Binary Buffer a una URL de datos (data URL)\nvar dataUrl = 'data:image/jpeg;base64,' + buffer.toString('base64');\n\n// Enviar la URL de datos en el mensaje\nmsg.payload = dataUrl;\n\n// Devolver el mensaje para pasar al siguiente nodo\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":460,"wires":[["955771dfdfbeaa49","51e5fdb12980c809"]]},{"id":"955771dfdfbeaa49","type":"ui_template","z":"e9c7705cf137b29e","group":"96f57673356c6885","name":"","order":1,"width":"6","height":"4","format":"<img src=\"{{msg.payload}}\" alt=\"Imagen\">","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":1140,"y":460,"wires":[[]]},{"id":"51e5fdb12980c809","type":"IPPrint","z":"e9c7705cf137b29e","name":"Zebra","IP":"192.168.0.17","JOB_name":"","authuser":"","authpassword":"","authcheck":"","x":1110,"y":540,"wires":[[]]},{"id":"dff1b7f895ec7f67","type":"ui_group","name":"Registro de informaciĂłn","tab":"4cebec0ed5def0cf","order":1,"disp":true,"width":"6","collapse":false},{"id":"9d10fcb604e753dd","type":"serial-port","serialport":"/dev/ttyUSB0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"","responsetimeout":"1000"},{"id":"96f57673356c6885","type":"ui_group","name":"Etiqueta","tab":"4cebec0ed5def0cf","order":3,"disp":true,"width":"6","collapse":false},{"id":"4cebec0ed5def0cf","type":"ui_tab","name":"Ganado Porcino","icon":"input","disabled":false,"hidden":false}]
- What device are you running NR on and what OS?
- What version of NR and node.js? (you can find this in the NR startup log)
- Does yhe CUPS printer have the "Share" flag enabled?
- Gateway IoT 2050 use Debian
- Node-RED v2.0.6 node.js v12.225
- Yes
- Add a
debug
node (set to display the complete msg object) to the output of theIPPrint
node - Add a
catch
node connected to adebug
node (set to display the complete msg object)
Do you get anything when you try to send a print?
Also, please run NR from the command line and look at the log after you try to print then copy and paste the log in a reply.
Two things, I asked you to
-
- Add a
catch
node connected to adebug
node (set to display the complete msg object
)
- Add a
-
- run NR from the command line and look at the log after you try to print then copy and paste the log in a reply
In addition, please don't do screen prints, copy the debug information and paste it to a reply.
There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.
Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.
In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```
)
```
code goes here
```
You can edit and correct your post by clicking the pencil icon.
See this post for more details - How to share code or flow json
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.