Skip to content

API (for client communication)

Claudio Prezzi edited this page Sep 7, 2018 · 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
  • connectTo(interface, port, [baud]) - Connect to the machine via the given params (example JS)
  • runJob - Send gcode file to server and then run the code (example JS)
  • runCommand - Send one line of gcode to execute (example JS)
  • feedOverride - Increase/decrease actual feed (example JS)
  • spindleOverride - Increase/decrease actual spindle speed / laser power (example JS)
  • laserTest - Switch laser on (permanent or for given time) (example JS)
  • jog - Execute jog move (single axis) (example JS)
  • jogTo - Execute jog move (multiple axes together) (example JS)
  • home - Execute axis homing (x, y, z or all) (example JS)
  • setZero - Zero given axis (x, y, z or all) (example JS)
  • gotoZero - Fast move axis to zero (x, y, z or all) (example JS)
  • pause - Pause running job (example JS)
  • unpause - Resume from pause (example JS)
  • stop- Stop running job/command immediately (example JS)
  • resetMachine - Reset controler (example JS)
  • clearAlarm - Clear controller alarm (example JS)
  • closePort - Close machine connection (example JS)

not yet tested:

  • sd.ls - Get actual SD directory listing
  • sd.cd - Change active SD directory
  • sd.rm - Remove file from SD card
  • sd.mv - Move/rename file
  • sd.play - Run file from SD card
  • sd.pause - Pause the SD print
  • sd.abort - Stops the SD print immediately
  • sd.upload - Upload file to SD card
  • sd.progress - Shows progress of current SD play

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
  • featureList - List of supportet features
  • 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.