Libraries or Command to manage DIO/DO/DI with node.js

Topics about the Software of Revolution Pi
Post Reply
edoardo_bosio
Posts: 7
Joined: 21 Feb 2018, 10:46

Libraries or Command to manage DIO/DO/DI with node.js

Post by edoardo_bosio »

Good morning,
I am developing a Node.js app that I want to deploy on the RevPi, to do so I need to know which libraries are required or command are used in order to change input status and so on. Is it also possible to change settings of pictory from my app? Like the name of variables and so on?

I look forward to your reply.
Edoardo
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41

Re: Libraries or Command to manage DIO/DO/DI with node.js

Post by volker »

sounds interesting...
Actually there is nothing "out of the shelf" which is really nice and smart. When we use Node.Red to access the process image (and thus the Di/DO/DIO values) we are usung a "system" node to listen to the answer of a shell command which reads the process image. The shell command could be the test software which is on every device. Just enter the command piTest -r 1,x (x being the name of the input) and you will get the state of this input. This then would be the payload of the node's output. But we are on the way to develop a more consistent and smoother method to retrieve data from the process image and get it into the data flow. Please also refer to the linux man page for the piTest command options.
In Detail: yes, there is a simple way you can retrieve data from the central process image (or write data to it). The Linux driver is called picontrol and it uses simple standard file mechanisms like usual in Linux: You get an instance of the driver object, call the open method and then a seek method to the offset in the process image memory. Then you use the read method to retrieve N bytes starting from this offset. Writing works similar. there are also several IOCTL methods you can call which do offer additional functionality. please refer to the tutorial on how to exchange data with the IOs (Python and C do use the same procedure).
For your second question I fear there is no simple way to build a second shell over the PiCtory. if you want to replace piCtory by your own GUI you need to write the JSON output file of PiCtory because this is the input for the runtime system (picontrol). You software could possibly manipulate this JSON file ("-config.json") by exchanging just the names of IOs. But you need to understand its complex format.
Unser RevPi Motto: Don't just claim it - make it!
edoardo_bosio
Posts: 7
Joined: 21 Feb 2018, 10:46

Re: Libraries or Command to manage DIO/DO/DI with node.js

Post by edoardo_bosio »

Thank you for your reply.
But I still don't get how I am supposed to use DIO and so on. With node red? My aim was to make automation app and with the raspberry pi I was able to do that. I try RevPi for this reason, and because I am working to develop an application to make it works like a PLC.
Can I ask you which is the connection between DIO-DI-DO and the rasberry GPIO? Becasue if there is a Connection i could try to use node.js library for GPIO I can try to use it.
Edoardo
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41

Re: Libraries or Command to manage DIO/DO/DI with node.js

Post by volker »

no the Di DiO and DO terminals have absolutely nothing to do with GPIOs of a raspi. these GPIOs can't be used for industrial purposes and neither for a modular system like the RevPi. please study the complete blog from the first article on to understand the concept of a central process image and the way to configure it using PiCtory and using piControl to set or retrieve bytes in the central process image. You can also read the tutorials related to DIO (there are some "hands on" tutorials). There are complete ready to use PLC programs for the RevPy which are not expensive and which will work out of the box. One of them (logi.CAD) is pre-installed and can be used in the trial version without paying anything. The editor is a PC software which is free. But when you want to use Node.JS why not going for Node.Red??? You could also control with it and use the central process image data as In- and Outputs for Nodes.
But I think it would be really wise to first get the basics by reading or watching the tutorials and the blog. If you have any specific questions about things which are not clear from these material then please come back and ask.
Unser RevPi Motto: Don't just claim it - make it!
edoardo_bosio
Posts: 7
Joined: 21 Feb 2018, 10:46

Re: Libraries or Command to manage DIO/DO/DI with node.js

Post by edoardo_bosio »

I am looking for the documentation you are talking about, thank you. Any way using Node RED how I am supposed to use the I/O?? WIth additional libraries? Same question but about python. If I use Python I have the possibility to control DIO by a certain library?
Thanks for all the clarifying reply are you sending to me.

Best,
Edoardo
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41

Re: Libraries or Command to manage DIO/DO/DI with node.js

Post by volker »

How about watching these tutorials:
https://revolution.kunbus.com/tutorials ... tutorials/
Number 12 to 16 do also show how to programm th IOs including a Python example. You find the source code of these examples in the download section.
Please also do play around with piTest command on the command line (there is a man page for the command). Then simply use this command to exchange data with any Node.Red flow using "system" nodes. I can't repeat whole tutorials here in the forum. If you have watched them and still have specific questions you are welcome to come back. In short: no you do not need a library as there is a kernel driver with standard linux file based functions io to write and read IOs (open seek read write close).
Unser RevPi Motto: Don't just claim it - make it!
User avatar
RevPiModIO
KUNBUS
Posts: 327
Joined: 20 Jan 2017, 08:44
Contact:

Re: Libraries or Command to manage DIO/DO/DI with node.js

Post by RevPiModIO »

For Python3 you can use the RevPiModIO library to access the IOs in a very simple way. You also has direct access to the names, the user is given in piCtory.

https://revpimodio.org/en/homepage

Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
Post Reply