Headless/No HMI w/Python module, can stream data or only poll?

More
2 years 10 months ago #287210 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? 

Please Log in to join the conversation.

More
More
2 years 10 months ago #287274 by kyleh

linuxcnc.org/docs/html/man/man1/linuxcncrsh.1.html
 
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.

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. 

Please Log in to join the conversation.

More
2 years 10 months ago #287276 by JacobRush
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.

Please Log in to join the conversation.

More
2 years 10 months ago #287277 by Aciera

Please Log in to join the conversation.

More
2 years 10 months ago #287308 by rodw

Please Log in to join the conversation.

More
2 years 10 months ago #287346 by TheRoslyak
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 to join the conversation.

More
2 years 10 months ago #287348 by TheRoslyak
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.

Please Log in to join the conversation.

More
2 years 10 months ago #288757 by tommylight

Please Log in to join the conversation.

Time to create page: 0.248 seconds
Powered by Kunena Forum