siemens / meta-iot2050

SIMATIC IOT2050 Isar/Debian Board Support Package
MIT License
130 stars 79 forks source link

Reading digital input with node-red-intel-gpio #315

Closed wjomo closed 1 year ago

wjomo commented 2 years ago

Hello, I am using a IOT2050 with the Example Image V1.2.2. On this system I am using node red and the Siemens IO Shield for reading some digital inputs. The digital input node reads the status of the signal, if its changing the node will send a message. Thank works fine. I have checked the option Send initial message with level of pin, because I would like to read the digital input when the box is starting or node red is restarting. But at startup there is no message sent from the node, only when I deploy my flow there is a message sent. I thinks it is very important to read the status at startup or restart the flow, otherwise there will be a undefined status.

I am thinking about two useful features for that node:

  1. Send the status of the pin at startup or restart the flow.
  2. Reading the input periodically with a scaleable cycle-time.

But I have no idea if that features are possible to implement.

I would be happy if that were possible.

Thanks for your help an have an nice day.

fr0st61te commented 2 years ago
  1. Once you'll deploy the flow, you'll see that will be started at startup or after Node-Red restart.
  2. Probably you need 'inject' functions from Node-Red nodes, as example https://theautomationplace.com/2019/10/30/time-based-automations-with-node-red/
wjomo commented 2 years ago

Hi, thanks for your answer. I am using the pre installed nodes on the Example Image V1.2.2 for reading the digital inputs with node red. At my use-case I tested the behaviour of the digital input nodes with checking the checkbox Send initial message with level of pin and without checking these option. With checking that option the node only send an status of the pin when I deploy the flow. At startup or restart Node-Red nothing happens.

I can t work with inject nodes, becuase there is no possibility to connect the digital input node with an inject node.

It would be great, if there is a way to adjust a time for a cyclic reading the input as it works with the analog input node. There is an option for adjusting the cycle time for reading the value.

I don t know what could I do to solve that problem.

Thanks for your help.

fr0st61te commented 2 years ago

@wjomo I'll double check what's happening with DIN on V1.2.2, maybe some regression, did you get any same problems with older releases?

I can t work with inject nodes, becuase there is no possibility to connect the digital input node with an inject node.

Ah, yes. Maybe that's correct to add some possibility with timers like for inject nodes.

wjomo commented 2 years ago

Hi, thanks for your answer.

I have only tested with V1.2.2, because I have only one controller which is in a productiv enviroment.

Ah, yes. Maybe that's correct to add some possibility with timers like for inject nodes.

Your suggestion to add a timer to the digital input node so that the pins can be read cyclically sounds very good.

Perhaps it would also be a possibility to provide the digital input node with a trigger input so that it can be controlled with an inject node.

I don t know, which solution is easier to solve.

If there is anything I can contribute to this please let me know.

Thanks

wjomo commented 2 years ago

@fr0st61te Hi Ivan, do you have some further information for me about my issue?

Thank you an have an nice day.

fr0st61te commented 2 years ago

@fr0st61te Hi Ivan, do you have some further information for me about my issue?

@wjomo as you stated there is issue about messages on startup from DIN node, trying to figure out how to solve it.

wjomo commented 2 years ago

Hi Ivan, thanks for your quick answer. If I understand correctly, you are trying to find a solution for that problem? Please let me know, if I can support you.

Thanks

fr0st61te commented 2 years ago

Hi Ivan, thanks for your quick answer. If I understand correctly, you are trying to find a solution for that problem? Please let me know, if I can support you.

Thanks

I'm testing the solution, I hope I'll get back with it at end of the week.

fr0st61te commented 2 years ago

@wjomo could you please check on your side If I provide you js/html file for DIN node?

wjomo commented 2 years ago

Hi Ivan, I would like to test it on my iot-controller if you provide the new file to me. Can you give me a little instruction how I have to use new js/html file for DIN node (in which file do I have to replace or change the js/html file?)

Thanks for your help.

👍

fr0st61te commented 2 years ago

Hi Ivan, I would like to test it on my iot-controller if you provide the new file to me. Can you give me a little instruction how I have to use new js/html file for DIN node (in which file do I have to replace or change the js/html file?)

  1. make the backup of mraa-gpio-din.js and mraa-gpio-din.html at /usr/lib/node_modules/node-red/node_modules/node-red-node-intel-gpio.
  2. change on these files: https://pastebin.com/VAAR1E3b - mraa-gpio-din.js https://pastebin.com/UEbK7JWe - mraa-gpio-din.html
  3. systemctl restart node-red, now there is input connection for DIN node, you can connect inject node with DIN and control when you want to report about DIN status.
wjomo commented 2 years ago

HI Ivan, thanks for your discription.

Now I have tested the new version of the DIN node on my controller with example Image V1.2.2.. The node work as expected. You did a great job. 👍

I have wired an inject node at the new DIN input. That inject node send a message at startup. The DIN node send a message everytime when it is triggered by the inject node. It works at start/stop node red service and by deploying the nodes.

Without triggering the DIN node it send a message by changing the input state.

Will that change of the DIN node be available at the example image V1.2.2 in future?

Thanks a lot for your help and enjoy the weekend.

Best regards.

fr0st61te commented 2 years ago

@wjomo PR under review @jan-kiszka what about fix for v1.2.2 image?

jan-kiszka commented 2 years ago

I'm not aware of any plans for a 1.2.3, so the fix should become available with the next major release.

wjomo commented 2 years ago

@fr0st61te Hi Ivan, please excuse my newbie question, what does "PR under review" mean?

Thanks

fr0st61te commented 2 years ago

pull request.

jan-kiszka commented 1 year ago

Fixed via upstream mraa - IIRC.