Giter VIP home page Giter VIP logo

gparse's People

Contributors

wallacoloo avatar

Watchers

 avatar  avatar  avatar

gparse's Issues

Add support for string parameters (M32 filenames)

M32 ("print from sd card file") can be formatted like so, according to http://reprap.org/wiki/G-code#M23:_Select_SD_file and https://github.com/ErikZalm/Marlin/blob/058e4465313191bf769e00a347ceccb4fbd1112c/Marlin/Marlin_main.cpp (line 105):

M32 filename.gco
M32 /path/to/file
M32 !filename.gcode#
M32 S<startpos bytes> !filename#

First off, it becomes obvious that there are a variety of syntaxes. Secondly these are clearly not float parameters. Also, not all formats identify a variable name for the filename. For example, blending the first and last example, M32 S10 S11 is ambiguous - the file could either be named 'S10', and the offset is 11 bytes OR the file could be named 'S11' and the offset is 10 bytes. "Correctly" parsing this ambigious example is literally impossible.

There are a few ways to fix this:

  1. require filenames to have an extension (123.456 is now a valid filename, so then all other arguments must be integers. Can also require filenames have at least 1 non-leading letter to separate them from floats).
  2. Require paths to be full (start with the a '/', or 'C:...'). This could be useful, because we can control the path formatting returned from M20.
  3. Require paths to start with '!' as in example 3&4. This might lead to incompatibilities with (most) hosts.

I vote for #2, as it would be the easiest to implement, and doesn't have any edge-cases.

Optimize vector usage in command.h

Storing each space-separated value into a vector of strings is costly - especially with all that heap allocation. It may be best to just parse the command all in one go and store the float values (eg X**, Y**, Z**), or to preserve the original string and keep a vector of pointers instead (less string allocation).

Remove inline constants in isXXX() functions

Command has functions like isG1() and isM105().

Currently, these use inline constants; isG1() is defined as return isOpcode(0x4731u). This 0x4731u is a magic number, but is really the equivalent of "G1" in big-endian. It is equivalent to ('G'<<8) + '1', but precalculated. So ideally, these magic numbers should be replaced with either the above, or something like isOpcode(makeStr('G', '1')).

Add automated testing

Basic tests for gcode parsing & serializing. Not sure what testing framework to use for this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.