Comments (5)
The websocket port number is 1 more than the http port, so if the http port is at its default value of 80, you will need to connect on port 81 for the websocket.
After that you can send Grbl commands like over a serial connection.
from fluidnc.
Thanks for the info.
I tried and I was able to establish a connection. But I am still not able to get the steppers move.
Here is my new attempt:
import websocket
import _thread
import time
def on_message(ws, message):
print('in message ', message)
def on_error(ws, error):
print('error: ', error)
def on_close(ws, close_status_code, close_msg):
print("### closed ###")
def on_open(ws):
def run(*args):
ws.send('$HX\n')
time.sleep(1)
ws.close()
print("thread terminating...")
_thread.start_new_thread(run, ())
if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp("ws://10.88.111.15:81",
on_open=on_open,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.run_forever()
And here is the log:
--- request header ---
GET / HTTP/1.1
Upgrade: websocket
Host: 10.88.111.15:81
Origin: http://10.88.111.15:81
Sec-WebSocket-Key: UOnb7DZkNEkQVYO6FMqXVQ==
Sec-WebSocket-Version: 13
Connection: Upgrade
-----------------------
--- response header ---
HTTP/1.1 101 Switching Protocols
Server: arduino-WebSocketsServer
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
Sec-WebSocket-Accept: Uwdjp+mfNTLrZjyYd6gwT9WJwFM=
-----------------------
++Rcv raw: b'\x89\x00'
++Rcv decoded: fin=1 opcode=9 data=b''
++Sent raw: b'\x81\x84,\xad1&\x08\xe5i,'
++Sent decoded: fin=1 opcode=1 data=b'$HX\n'
++Sent raw: b'\x8a\x80pF(\xd6'
++Sent decoded: fin=1 opcode=10 data=b''
++Rcv raw: b'\x81\x0cCURRENT_ID:0'
++Rcv decoded: fin=1 opcode=1 data=b'CURRENT_ID:0'
in message CURRENT_ID:0
++Rcv raw: b'\x81\x0bACTIVE_ID:0'
++Rcv decoded: fin=1 opcode=1 data=b'ACTIVE_ID:0'
in message ACTIVE_ID:0
++Sent raw: b"\x88\x82'\x10\xd8\xf4$\xf8"
++Sent decoded: fin=1 opcode=8 data=b'\x03\xe8'
### closed ###
from fluidnc.
I found a bug in the websocket handling. The bug is now fixed in the WebSockets branch.
Here is simple test showing it basically working.
PS C:\Users\wmb\Documents\GitHub\fluidterm> python
Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import websocket
>>> ws = websocket.WebSocket()
>>> ws.connect("ws://192.168.2.150:81")
>>> ws.send("$\n")
8
>>> print(ws.recv())
CURRENT_ID:0
>>> print(ws.recv())
ACTIVE_ID:0
>>> print(ws.recv())
PING:0
>>> print(ws.recv())
PING:0
>>> print(ws.recv())
b'[HLP:$$ $+ $# $S $L $G $I $N $x=val $Nx=line $J=line $SLP $C $X $H $F $E=err ~ ! ? ctrl-x]\nok\n'
>>>
from fluidnc.
Thanks for the fix. I confirm that it solved the issue for Linux as well.
from fluidnc.
Fixed by #142
from fluidnc.
Related Issues (20)
- Problem: HOT 1
- PWM and RS485 issues HOT 3
- Error Message: Ignored key SingleArmScara HOT 1
- upload any file via web and X move 1mm HOT 13
- Problem: ESP32, WIFI on causes consumption jump from 0.07A to 0.13A and overhearts HOT 30
- controllare un motore nidec a 6 fili mediante mks dlc32 HOT 25
- Problem: Can't use SYNRAD CO2 RF laser HOT 1
- Problem: Stepper motors not moving HOT 43
- Steering gear configuration file consult HOT 1
- Problem: Unable to clear "X Axis tmc_2209 homing current not in config: Using run current" error HOT 6
- Brownout detector was triggered when wifi wants to begin HOT 1
- Problem: when config value contains a colon the $config/dump returns invalid JSON
- Problem: yaml file. HOT 13
- Resetování ESP32 po instalaci FluidNC HOT 8
- Problem: config. yaml file HOT 12
- Problem: DM320T/ DM332T no movement HOT 2
- Problem: Laser firing on G0 moves HOT 5
- RS485 error: Skipping key uart1 indent 1 this indent 0 HOT 17
- Bluetooth not working, HOT 1
- Problem: Low memory error while running G-code HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluidnc.