Headless/No HMI w/Python module, can stream data or only poll?
- kyleh
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 1
04 Dec 2023 18:35 - 04 Dec 2023 18:35 #287210
by kyleh
Headless/No HMI w/Python module, can stream data or only poll? was created by kyleh
I'd like to remotely control and stream data from LinuxCNC preferably with Python. Seems like I could run an API (e.g. Flask/FastAPI) on the LinuxCNC comp that creates access to the LinuxCNC python control features and streams the "outs" via WebSockets, allowing a remote HMI set up however I want. Glancing through the docs however it looks like the python module is set up for polling things like machine position, sensor states, etc.
Is there some interface where I can access/subscribe to a stream of the machine's outputs as they are updated, or a place where I can see how PyVCP and similar access this data?
Is there some interface where I can access/subscribe to a stream of the machine's outputs as they are updated, or a place where I can see how PyVCP and similar access this data?
Last edit: 04 Dec 2023 18:35 by kyleh.
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19460
- Thank you received: 6529
04 Dec 2023 22:43 #287224
by tommylight
Replied by tommylight on topic Headless/No HMI w/Python module, can stream data or only poll?
Please Log in or Create an account to join the conversation.
- kyleh
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 1
05 Dec 2023 13:55 - 05 Dec 2023 14:10 #287274
by kyleh
It looks like from the source and examples the <halpin> XML tag can receive this data, so I'll review the docs on HAL pins and see if I can get it.
EDIT: Oops, I wouldnt need 4+ polling, just one locally that then pushes it however often I want.
It looks like the HAL pin states are what I want, so I'll dig into the HAL docs and try to learn some more fundamentals there. Appreciate the reply.
Replied by kyleh on topic Headless/No HMI w/Python module, can stream data or only poll?
Thanks, this looks focused on headless communication but still seems to be primarily "poll" based requiring Get <emc command> rather than a stream of sensor/position data. I could certainly poll every N ms, but it seems better to understand how the VCPs get their stream of data (i.e. do they also constantly poll?) then push that data where it needs to go every 100ms rather than handle potential 4+ clients all making 50ms polls.linuxcnc.org/docs/html/man/man1/linuxcncrsh.1.html
It looks like from the source and examples the <halpin> XML tag can receive this data, so I'll review the docs on HAL pins and see if I can get it.
EDIT: Oops, I wouldnt need 4+ polling, just one locally that then pushes it however often I want.
It looks like the HAL pin states are what I want, so I'll dig into the HAL docs and try to learn some more fundamentals there. Appreciate the reply.
Last edit: 05 Dec 2023 14:10 by kyleh.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
- JacobRush
- Offline
- Junior Member
Less
More
- Posts: 20
- Thank you received: 1
05 Dec 2023 14:29 #287276
by JacobRush
Replied by JacobRush on topic Headless/No HMI w/Python module, can stream data or only poll?
I've never written anything of substance in python but trolling through the linuxcnc github it looks like this might be a place to start?
github.com/LinuxCNC/linuxcnc/blob/master...ython/linux_event.py
Also you could try reading through the source code of various interfaces (axis, gmoccapy etc) to see how they implement reading the machine state and updating their interfaces. I think you'll find at some level its polling the state periodically.
github.com/LinuxCNC/linuxcnc/blob/master...ython/linux_event.py
Also you could try reading through the source code of various interfaces (axis, gmoccapy etc) to see how they implement reading the machine state and updating their interfaces. I think you'll find at some level its polling the state periodically.
Please Log in or Create an account to join the conversation.
- Aciera
- Away
- Administrator
Less
More
- Posts: 4001
- Thank you received: 1728
05 Dec 2023 14:31 #287277
by Aciera
Replied by Aciera on topic Headless/No HMI w/Python module, can stream data or only poll?
Not sure but maybe this could be of interest:
forum.linuxcnc.org/38-general-linuxcnc-q...c-ua?start=20#286396
forum.linuxcnc.org/38-general-linuxcnc-q...c-ua?start=20#286396
Please Log in or Create an account to join the conversation.
- rodw
- Online
- Platinum Member
Less
More
- Posts: 10780
- Thank you received: 3550
05 Dec 2023 20:44 #287308
by rodw
Replied by rodw on topic Headless/No HMI w/Python module, can stream data or only poll?
Also with 2.9.1 there is a MQTT publisher component
linuxcnc.org/docs/stable/html/man/man1/mqtt-publisher.1.html
linuxcnc.org/docs/stable/html/man/man1/mqtt-publisher.1.html
Please Log in or Create an account to join the conversation.
- TheRoslyak
- Offline
- Elite Member
Less
More
- Posts: 238
- Thank you received: 37
06 Dec 2023 11:06 #287346
by TheRoslyak
Replied by TheRoslyak on topic Headless/No HMI w/Python module, can stream data or only poll?
OPC UA fully accomplishes all tasks. It's even possible, without creating a database, to make a variable that will remember readings over time. (Say, 10,000 points per hour). There is also a library for working with Python. You can use it to create your own client.
Please Log in or Create an account to join the conversation.
- TheRoslyak
- Offline
- Elite Member
Less
More
- Posts: 238
- Thank you received: 37
06 Dec 2023 11:43 - 06 Dec 2023 11:43 #287348
by TheRoslyak
Replied by TheRoslyak on topic Headless/No HMI w/Python module, can stream data or only poll?
If you need to create buttons for local use, you need to scan the HAL environment using the rtapi_mutex_get() function. Then, by name or other parameters, find the address of the pin, signal, or parameter you need. This address can be used for a button, for recording in a database, or for displaying on a graph. Perhaps OPC UA history can record data faster than 50 milliseconds, but I haven't tried it.
Last edit: 06 Dec 2023 11:43 by TheRoslyak.
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19460
- Thank you received: 6529
21 Dec 2023 13:34 #288757
by tommylight
Replied by tommylight on topic Headless/No HMI w/Python module, can stream data or only poll?
Spammer left...
Please Log in or Create an account to join the conversation.
Time to create page: 0.070 seconds