Code Monkey home page Code Monkey logo

essp's People

Contributors

canterburycomputers avatar minege avatar ymaktepi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

essp's Issues

.

.

Comply with PEP8

The code has multiple PEP8 violations to be fixed, including but not limited to:

  • two blank lines before a class declaration (L12, L17, L25, L31, L35)

  • class name should use CamelCase (L12, L17, L25, L31, L35)

  • use new style classes: class ClassName(object): (L35)

  • 2 spaces before comment: # (L44 and more)

  • block comment should start with a pound and a space after it (L48, L91, L199, L204, L315)

  • missing space after , (L98, L220, L230 and more)

  • redundant parenthesis (L220, L224, L227, L230)

  • missing spaces around operators: 3*x -> 3 * x, self.actions+="y" -> self.actions += 'y'

I'm also leaving here a couple other minor issues which are not exactly PEP8:

  • use .format instead of % for string formatting.

  • cannot return value from init (L52, L66, L72, L95, L101)

    If you need a catastrophic failure here, raise an exception, preferably a custom one for clarity.

  • use setup_req.UnitType in {0x06, 0x07} instead of or L90

    Using set membership will make your condition shorter and more readable, esp. if you need to add another value
    later on.

  • In my opinion I would remove the t1 variable or if you want to keep it, use a clearer name such as loop_thread (L102)

  • variable ACTION_SIZE should be lowercase. (L116)

    This is irrelevant once #3 is fixed

Segmentation fault

python3 main.py
PORT: /dev/ttyACM0
##/dev/ttyACM0##
Segmentation fault (core dumped)

why i am having that error message

Remove repetitive return statement

return (0,0,events.event) is present is almost every if/elif block (L214-L303).

This version is a bit more readable and avoid the repetition:

if events.event == Status.CUSTOM:
    return something_custom
elif events.event == Status.OTHER_CUSTOM:
    return other_custom
return 0, 0, events.event

I believe return (0,0,NO_EVENT) should be placed in the except ValueError block referenced in #4

essp not working

Hello,

we have nv200 device and trying to use your script and testing it on ubuntu 18 but we are getting below error

python ex1.py
PORT: /dev/ttyS0
##/dev/ttyS0##
Segmentation fault (core dumped)

also please suggest any best solution for this

also help us for payout with nv200

thank you

Can not find unit Smart Hopper on Ubuntu

Hi, I connect Smart coin system and Smart Payout with two USB cables, but when I try to put coin into Smart Hopper, the door didn't open. And find that the program only find unit type 9 or 6, but the unit type of Smart Hopper is 3. They can run perfectly on Windows with offical software. Can you guide me how to do? Thanks, regard!

Take the banknote values from NV10 acceptor

Hello
I'm using NV10 and don't know what function to use to take the banknote values ​​and write the total amount to a variable.
This library implements that in a loop the bill acceptor is polled and the text is output to the console, and I need to take the value of the bills.
Please share an example.

Scenario of disabling and then enabling validator doesn't seem to work

Hello Minege! First of all, wanna thank you tour python implementation of eSSP, saved us lots and lots of time. Great work!

Although, we've currently got a problem when we disable_validator() and then, when the machine should be activated, enable_validator() sometimes doesn't enable it, and even if it does, we continue to see "Poll Disabled" in logs each time in event looping.

Could you propose a code snippet to correctly disable and enable validator, each time returning to a valid working state? Would be awesome thank you.

NV11 First Run

Hi,
1 ) I want to run NV11 using IF17/IF18 Interface converters do I need any Software development kits from ITL or any other software/drivers ?
2 ) This python package is suffice enough to run NV11 ?
3 ) On which Linux flavor it is stable, because i am getting error during the installation of this package in windows machine ?

Use Enum for constants

Use Enum rather than variables or magic numbers for status and actions

I.e. go from this

if self.actions[0] == "y": # Payout next note ( NV11 only )

To something like:

Definition

class Status(Enum):
    OK = (1, "debug message ok")
    FAIL = (2, "debug message fail")
    # ...

    def __init__(self, value, debug_message):
        self.value = value
        self.debug_message = debug_message

    def __int__(self):
        return self.value

    def __eq__(self, other):
        return self.value == other

Usage

from sys import stderr

from constants import Status, Action


try:
    self.print_debug(Status(events.event).debug_message)
except ValueError:
    print('Unknown status: {}'.format(events.event), out=stderr)

if events.event == Status.SOME_STATUS:
    pass
    # do something custom
elif events.event == Status.SOME_OTHER_STATUS:
    pass
    # do something different
#...

This also gets rid of the from constants import * which is never a good idea

Credit to florv for the Enum class definition

Can not use this Library in Windows

I am very interested in using Mineage/eSSP for Python (2.7) on Win32 (and on Win64) platform, but I always get some error during installation:

\python.exe setup.py install
running install
running build
running build_py
Compiling library
error: [WinError 2] The system cannot find the file specified

or

pip install eSSP6
Collecting eSSP6
Using cached eSSP6-1.0.6.tar.gz
Installing collected packages: eSSP6
Running setup.py install for eSSP6 ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;file='c:\users\dejan\appdata\local\temp\pip-build-ah_vot\eSSP6\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record c:\users\dejan\appdata\local\temp\pip-xsiqij-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib
creating build\lib\eSSP
copying eSSP\constants.py -> build\lib\eSSP
copying eSSP\eSSP.py -> build\lib\eSSP
copying eSSP_init_.py -> build\lib\eSSP
Compiling library
error: [Error 2] The system cannot find the file specified

----------------------------------------

Command "c:\python27\python.exe -u -c "import setuptools, tokenize;file='c:\users\dejan\appdata\local\temp\pip-build-ah_vot\eSSP6\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record c:\users\dejan\appdata\local\temp\pip-xsiqij-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\dejan\appdata\local\temp\pip-build-ah_vot\eSSP6\

Use an actions queue instead of a string

Use a Queue rather than a string to handle the actions may be more adapted (L118)

It's clearer and you can get rid of ACTION_SIZE and i logic.

Here is an example on how you would handle it:

from queue import Queue


def __init__(self, *args, **kwargs):
    self.actions = Queue()

def do_actions(self):
    while not self.actions.empty():
        action = self.actions.get()
        # do something with action
        
def add_action(action):
    self.actions.put(action)  # instead of self.actions += action

This is also much easier to make thread-proof in the future, when you have ATMs with octo-cores... 😁

libessp.so: undefined symbol: Status

Hello

I'm working with a device NV200 and get the following error:

PORT: /dev/ttyACM0
##/dev/ttyACM0##
Validator Found !
Encryption Setup
Firmware 0420
Channels :
Channel 1 : 10 RUB
Channel 2 : 50 RUB
Channel 3 : 100 RUB
Channel 4 : 500 RUB
Channel 5 : 1000 RUB
Channel 6 : 5000 RUB
Channel 7 : 0
Channel 8 : 0
Channel 9 : 0
Channel 10 : 0
Channel 11 : 0
Channel 12 : 0
Channel 13 : 0
Channel 14 : 0
Channel 15 : 0
Channel 16 : 0
Channel 17 : 0
Channel 18 : 0
Channel 19 : 0
Channel 20 : 0
Payout
ERROR: Payout failed
Traceback (most recent call last):
File "test.py", line 103, in
validator.do_actions()
File "/usr/local/lib/python2.7/dist-packages/eSSP/eSSP.py", line 155, in do_actions
self.essp.Status.SSP_get_response_data(
File "/usr/lib/python2.7/ctypes/init.py", line 375, in getattr
func = self.getitem(name)
File "/usr/lib/python2.7/ctypes/init.py", line 380, in getitem
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/local/lib/python2.7/dist-packages/eSSP/libessp.so: undefined symbol: Status

get_last_event() don't work?

Hi. get_last_event() always return (0, 0, 0) I have a NV11, S.O. armbian and running on python 3.7.3 Thank You.

Refactor `set_route_...` and other action methods

There is some copy/paste on those set_route_... and other action methods (L334-L366).

Use a helper method instead:

class eSSP(object):

    def _action_helper(self, amount, currency, prefix, action):
        self.actions += action
        self.actions_args['{}_amount'.format(prefix)] = amount * 100
        self.actions_args['{}_currency'.format(prefix)] = currency.upper().encode()
        
    def set_route_cashbox(self, amount, currency="CHF"):
        """Set the bills <amount> in the cashbox
           NV11: Set the bills <= amount in the cashbox"""
        self._action_helper(amount, currency, 'routec', 'c')

TypeError: unsupported type for timedelta seconds component: NoneType

I always get this when calling sync()

Traceback (most recent call last):
  File "./cc_ssp.py", line 11, in <module>
    k.sync()
  File "/home/user/eSSP.py", line 289, in sync
    result = self.send([self.getseq(), '0x1', '0x11'])
  File "/home/user/eSSP.py", line 402, in send
    response = self.read(process)
  File "/home/user/eSSP.py", line 410, in read
    timeout_expired = datetime.datetime.now() + datetime.timedelta(seconds=self.timeout)
TypeError: unsupported type for timedelta seconds component: NoneType

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.