First time on StackExchange as a questioner! Hope I get this right. Apols if this is TLDR.
For thoes of you familiar with the TinyG SPJS you will know my context. For others: There is a program created by "somebody" called the SPJS(Serial Port Json Server) here It has a websocket interface. Among other things it primarially manages 2 things
- The Serial port traffic to and from the TinyG CNC controller. It manages integrity (no loss of data) and the buffering of commands to ensure a constant supply of G Code commands to the TinyG to ensure smooth cnc motion control.
- Multiple pc CAM clients in the form of pub sub websocket interface.
My Problem is 2 fold:
Does anyone knows where to find the SPJS protocol I would really appreciate it?
I want to use Python to write my own client. However I run into an issue at the connect:
import asyncio import websockets as ws async def WebsocSPJSConnection(): uri = "ws://localhost:8989" async with ws.connect(uri) as webs: print(webs.recv())
if name == "main": asyncio.run(WebsocSPJSConnection())
I know the server sees the connection attempt and a failure on the SPJS side, however the client just times out:
2022/10/25 12:07:48 cayenn.go:438: TCP Received GET / HTTP/1.1
Host: localhost:8988
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: Q3SDgBW/JHBXDE6ctEdC/g==
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
User-Agent: Python/3.9 websockets/10.3
from [::1]:60677
Checking if from me [::1]<>10.71.193.1412022/10/25 12:07:48 cayenn.go:475: Err unmarshalling TCP inbound message from device. err: <nil>
Wireshark shows: Wireshark Trace
It seems the SPJS is getting an unmarshalled message from my client. However this is a connect command, I send nothing to the SPJS other than a connect command above and . Any ideas what is going on here?
Note The Javascript server in another client seems to connect correctly. And if I make a dummy python server on port 8988 it all works fine.
As promised. Here for my penance is code which connects to TinyG SPJS and opens com4 on SPJS to connect to the TinyG board. Forgive, this is a snippet of a bigger code but is standalone.
The .kv file:
And the python file:
To Run you will need to create an images file in ./images for the buttons. Here are the button files:
emergencystop_released.png emergencystop_pressed.png