Code Monkey home page Code Monkey logo

pysteprocker's Introduction

Python module for Trinamic StepRocker stepper motor drivers

MIT license

This software is not associated with Trinamic. Use it at your own risk.

Info

The code here is released under the MIT license.

pysteprocker's People

Contributors

ap-- avatar nichtjens avatar rbrown-acertaralabs avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pysteprocker's Issues

License

Under which license is this code released? We would like to ship it with the next Mission Pinball Framework release to support the steprocker. We are currently releasing our code under the MIT license. So MIT would be perfect for us. Alternatively, we could use any library license such as LGPL but we might have to ship it as separate pypi package. What do you think?

TMCL.py gio and sio need self parameter

PyStepRocker is fantastic...thank you for creating it.
While using it, I noticed that TMCL.py has two bugs inside class TMCLDevice.
The following two method definitions are missing the "self" parameter:

def sio(port_number, state):
...
def gio(port_number, bank_number):

So the above should read:

def sio(self, port_number, state):
...
def gio(self, port_number, bank_number):

Thanks!

COORDS string typo

Inside TMCL.py, CMD_MVP_TYPES has key of 'COORDS' rather than 'COORD'. The result is that the method "mvp" does not work since it is expecting 'COORD'. Also, the Trinamic documentation uses 'COORD' (not 'COORDS'), so changing to 'COORD' provides consistency with the Trinamic implementation.

Suggest changing the following portion:

CMD_MVP_TYPES = {'ABS': 0,
                 'REL': 1,
                 'COORDS': 2}

To this:

CMD_MVP_TYPES = {'ABS': 0,
                 'REL': 1,
                 'COORD': 2}

gio bank logic bug

Inside TMCL.py, there is a logic bug hidden in the method function "gio" within class TMCLDevice:

Currently, the code is:

if bank == 0 and not (0 <= outp <= 3):
    raise TMCLError("GIO: output_number not in range(4) @ bank0")
elif bank == 1 and not (0 <= outp <= 2):
    raise TMCLError("GIO: output_number not in range(3) @ bank1")
elif bank == 2 and not (0 <= outp <= 4):
    raise TMCLError("GIO: output_number not in range(5) @ bank2")
else:
    raise TMCLError("GIO: bank_number not in range(3)")

...but the above code will erroneously fail if gio is called with:

gio(2,2)

...the above (erroneously) returns "GIO: bank_number not in range(3)" because the following condition will be false:

elif bank == 2 and not (0 <= outp <= 4)

...and then it will fall through to execute the else clause, even though bank=2 and outp=2 (a valid case).

I would recommend refactoring this block to the following, to break up the "and" statements to get it working properly:

if bank == 0:
    if not (0 <= outp <= 3):
        raise TMCLError("GIO: output_number not in range(4) @ bank0")
elif bank == 1:
    if not (0 <= outp <= 2):
        raise TMCLError("GIO: output_number not in range(3) @ bank1")
elif bank == 2:
    if not (0 <= outp <= 4):
        raise TMCLError("GIO: output_number not in range(5) @ bank2")
else:
    raise TMCLError("GIO: bank_number not in range(3)")

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.