Skip to content

API (for client communication)

Claudio Prezzi edited this page May 26, 2017 · 18 revisions

The client (webpage) communicates with lw.comm-server through websockets.
Multiple clients can connect to the same server at the same time, but the server can only connect one machine at a time via USB, Serial, Telnet or WebSocket (ESP8266).

Websocket communication is asynchonous, which means a client sends a command to server and gets the response (if any) back via websocket event.

Right after websocket connection, the client gets a bunch of response events like:

  • List of supported interfaces
  • List of available serial ports
  • Actual port or IP (if connected)
  • Actual firmware (if connected)
  • Actual connect status (if connected)

Commands (client -> server)

  • firstLoad - Get initial config data
  • getInterfaces - Get list of supported interfaces
  • getPorts - Get list of available serial ports
  • getConnectStatus - Get the actual interface status (status & serial port+baudrate or ip:port)
  • getFirmware - Get connected firmware and version
  • getFeatureList - Get a list of firmware supported features (not yet implemented)
  • connectTo - Connect to the machine via the given params
  • runJob - Send gcode file to server and then run the code
  • runCommand - Send one line of gcode to execute
  • feedOverride - Increase/decrease actual feed
  • spindleOverride - Increase/decrease actual spindle speed / laser power
  • laserTest - Switch laser on (permanent or for given time)
  • jog - Execute jog move
  • setZero - Zero given axis (x, y, z or all)
  • gotoZero - Fast move axis to zero (x, y, z or all)
  • pause - Pause running job
  • unpause - Resume from pause
  • stop- Stop running job/command immediately
  • clearAlarm - Clear controller alarm
  • closePort - Close machine connection

Events (server -> client)

  • serverConfig - Config file from server
  • interfaces - List of supported interfaces
  • activeInterface - The active interface
  • ports - List of available USB/Serial ports
  • activePort - The active serial port
  • activeBaudRate - The active BaudRate
  • activeIP - The active IP (incl. :port)
  • connectStatus - Actual connection status
  • error - Error reported from server
  • firmware - Firmware and version of the connected machine
  • data - Data response from machine controller (ex: position data, query responses...)
  • wpos - Position in work coordinates
  • mpos - Position in machine coordinates
  • feedOverride - Actual feed override value
  • spindleOverride - Actual spindle / laser override value
  • laserTest - Laser Test status (power)
  • runStatus - Actual running status (run, hold, idle)
  • qCount - Actual lines in queue (on the server)

More details will follow.

Clone this wiki locally