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

More
2 years 10 months ago - 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? 
Last edit: 2 years 10 months ago by kyleh.

Please Log in or Create an account to join the conversation.

More
More
2 years 10 months ago - 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. 
Last edit: 2 years 10 months ago by kyleh.
The following user(s) said Thank You: tommylight

Please Log in or Create an account 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 or Create an account to join the conversation.

More
2 years 10 months ago #287277 by Aciera

Please Log in or Create an account to join the conversation.

More
2 years 10 months ago #287308 by rodw

Please Log in or Create an account to join the conversation.

Time to create page: 0.265 seconds
Powered by Kunena Forum