Try the Linuxcnc docs Creating Userspace Python Components
I've never used Python to create components and write mine in C but for comms, Python is the way to go.
There should be some examples of comms you can borrow from the Linuxcnc git repo
This one that talks to a plasma cutter by RS485 comes to mind
https://github.com/LinuxCNC/linuxcnc...omps/pmx485.py