npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

smoothie-commands

v2.3.0

Published

A Smoothie firmware (http|serial) commands API

Downloads

26

Readme

smoothie-commands

A Smoothie firmware (http|serial) commands API

Sent commands to smoothie firmware hardware over HTTP or Serial connexion and get in returns some structured data.

  • Work In Progress...

Table of contents

Online demo

Install

> yarn add smoothie-commands

Usages

HTTP interface

ES6 module

import { command } from 'smoothie-commands/http'

command({
  address: '192.168.1.42',
  command: 'ls',
  args: ['/sd']
  timeout: 1000
})
  .then(response => {
    console.log('response:', response)
    console.log('data:', response.data)
  })
  .catch(error => {
    console.error(
      `${error.name}::${error.type}:`,
      error.message,
      error.response
    )
  })

Browser

index.html

<script src="./dist/bundle.http[.tiny].js"></script>
<script src="./index.js"></script>

index.js

smoothieCommands.command({
  address: '192.168.1.42',
  command: 'ls',
  args: ['/sd']
  timeout: 1000
})
  .then(response => {
    console.log('response:', response)
    console.log('data:', response.data)
  })
  .catch(error => {
    console.error(
      `${error.name}::${error.type}:`,
      error.message,
      error.response
    )
  })

Serial interface

  • Work In Progress...

Commands queue

By default parallel request are prohibited and you need to wait for the end of a request before sending another. But fortunately there is the queue() helper to help you manage this constraint.

import { queue } from '../src/http'

const address = '192.168.1.121'

const commands = [
  { address, command: 'version' },
  { address, command: 'get status' },
  { address, command: 'ls', args: ['/sd'] },
  { address, command: 'G0 X10 Y50' },
  { address, command: 'get status' },
  { address, command: 'get status' }
]

const myQueue = queue({
  commands,
  onStart (payload) {
    console.log('start:', payload.commands.length)
  },
  onPause (payload) {
    console.log('pause:', payload.commands.length)
  },
  onResume (payload) {
    console.log('resume:', payload.commands.length)
  },
  onStop (payload) {
    console.log('stop:', payload.commands.length)
  },
  onSend (payload) {
    console.log('send:', payload.command, payload.commands.length)
  },
  onResponse (payload) {
    console.log('response:', payload.response)
  },
  onError (payload) {
    console.error('error:', payload.error)
  },
  onDone (results) {
    console.log('done:', results)
  }
})

myQueue.start()
  .then(results => {
    console.log(results)
  })
// myQueue.pause()
// myQueue.resume()
// myQueue.stop()

Error types

CommandError

ALREADY_SUSPENDED_ERROR
COULD_NOT_CREATE_ERROR
COULD_NOT_DELETE_ERROR
COULD_NOT_MOVE_ERROR
COULD_NOT_OPEN_ERROR
COULD_NOT_UPLOAD_ERROR
CURRENTLY_PLAYING_ERROR
FILE_NOT_FOUND_ERROR
INVALID_ARGUMENTS_ERROR
INVALID_COMMAND_ERROR
KILL_ERROR
MINIMAL_DURATION_ERROR
NOT_CURRENTLY_PLAYING_ERROR
NOT_ENOUGH_SPACE_ERROR
NOT_SUSPENDED_ERROR
NO_HEATERS_FOUND_ERROR
NO_LASER_MODULE_ERROR
UNDEFINED_ERROR
UNDEFINED_SETTING_ERROR
UNKNOWN_DEVICE_ERROR
UNKNOWN_FILE_SIZE_ERROR
UNKNOWN_RESPONSE_ERROR
UNSUPPORTED_COMMAND_ERROR
UNSUPPORTED_PARSER_ERROR
UNSUPPORTED_SUBCOMMAND_ERROR

RequestError

NETWORK_ERROR
REQUEST_ABORTED_ERROR
REQUEST_OPEN_ERROR
REQUEST_TIMEOUT_ERROR
PARALLEL_REQUEST_ERROR
SERVER_ERROR

Supported commands

abort                                              - Abort currently playing file
break                                              - Enter in MRI mode
calc_thermistor <T1,R1,T2,R2,T3,R3>                - Calculate the Steinhart Hart coefficients
cat <file> [limit]                                 - Output the contents of a file
cd <path>                                          - Change current absolute path to provided path
config-get [local|sd|cache] <setting>              - Get config setting value from the specified source
config-load <load|unload|dump|checksum>            - Load config values from the specified source
config-set <source> <setting> <value>              - Set value to the specified source setting
dfu                                                - Entering boot mode
echo <message>                                     - Echo echo echo...
fire <power|off|status> [duration]                 - Fire laser manualy
get <fk|ik|pos|state|status|temp|wcs> <...options> - Get some values
get fk [-m] x[,y,z]                                - Do forward kinematics on the given actuator position and display the cartesian coordinates
get ik [-m] x[,y,z]                                - Do inverse kinematics on the given cartesian position and display the actuator coordinates
get pos                                            - Get all the various M114 variants
get state                                          - Get state
get status                                         - Get status
get temp [device]                                  - Get temperature for a device
get wcs                                            - Get world coordinate system
help                                               - Get some help
load <file>                                        - Load config values from the specified file
ls [-s] <file>                                     - List directory
md5sum <file>                                      - Get the md5 sum for a file
mem [-v]                                           - Get memory informations
mkdir <path>                                       - Create new directory
mv <source> <target>                               - Move a file from source to target path
net                                                - Get network informations
play <file>                                        - Play file from SD card
progress [-b]                                      - Get SD or File playing progression
pwd                                                - Get (print) current working directory
remount                                            - Remount SD card
reset                                              - Reset the board
resume                                             - Resume the suspended print
rm <file>                                          - Remove a file or an empty folder
save <file>                                        - Saves the specified config-override file
set_temp <device> <value>                          - Set device temperature
suspend                                            - Suspend a print in progress
switch <name> [onf|off]                            - Set or get switch state for a named switch
test circle <radius> <iterations> [feedrate]       - Draws a circle around origin
test <square|circle|jog|raw> <...options>          - Execute some tests
test jog <axis> <distance> <iterations> [feedrate] - Jogs back and forth from origin
test raw <axis> <steps> <speed>                    - Issues raw steps to the specified axis
test square <size> <iterations> [feedrate]         - Draws a square from origin
thermistors                                        - Get predefined thermistors
upload [path] <filename> <...contents>             - Saves a stream of text to the named file
version                                            - Get firmware version

Development

Install

> yarn install

Run dev server

> yarn serv:dev

Run demo server

> yarn serv:demo

Build bundle

> yarn bundle:http

> yarn bundle:http:tiny

Build demo

> yarn build:demo

Publish demo

> yarn surge:demo

Build all

> yarn build

Lint code

> yarn lint