Python integration?
Moderators: aardvark, davebush, Admin
Python integration?
I will shortly be attempting to integrate the Paylink device into one of our kiosks. We use Ubuntu 12.04 LTS and our software is developed in Python. Has anyone attempted this before? I guess i'm gonna have to import the Java library and use some sort of wrapper? Any advice would be most appreciated. Thanks.
Re: Python integration?
I've never heard of anyone using Python.
Unless Python / Java is specifically supported, it is unlikely to be the easiest. Most languages provide direct support for accessing DLL entry points.
In VBA you specify a DLL entry as:
and in Pascal you use
These quote the DLL name 'Aesimhei.dll' and the function name as exposed by the DLL '_NextEvent@4', and trhen inform the compiler of the types of inputs and outputs.
Assuming that Python provides something similar, then you would want to perform systematic edits on Aesimhei.pas or Aesimhei.VBA.bas
Unless Python / Java is specifically supported, it is unlikely to be the easiest. Most languages provide direct support for accessing DLL entry points.
In VBA you specify a DLL entry as:
Code: Select all
Declare Function NextEvent Lib "AesImhei.dll" Alias "_NextEvent@4" (ByRef EventDetails As EventDetailBlock) As Long
Code: Select all
Function NextEvent(var EventDetails : TEventDetailBlock) : LongInt ; stdcall ; external 'Aesimhei.dll' name '_NextEvent@4';
Assuming that Python provides something similar, then you would want to perform systematic edits on Aesimhei.pas or Aesimhei.VBA.bas
Aardvark software developer. Please put all communication on the problem through the board for the benefit of others.
Re: Python integration?
Any news on Python integration?
Have anybody done something in that regard?
I'm just starting with PayLink interface and I would like to use it from the Python program.
So before I try to do my own interfacing to C++ library I would like to know if anybody had done any work on that?
Any pointers at least?
Regards,
Dundo
Have anybody done something in that regard?
I'm just starting with PayLink interface and I would like to use it from the Python program.
So before I try to do my own interfacing to C++ library I would like to know if anybody had done any work on that?
Any pointers at least?
Regards,
Dundo
Re: Python integration?
So far as I know, no-on has ever done anything using Python.
If you are determined to try, it looks as though you're going to need to use the ctypes extensions - described here:
https://docs.python.org/3/library/ctypes.html
I know nothing at all about puthon, but I gather a simple Paylink call will be something like:
I have no idea if the above is valid Paython - but it might get you started.
If you are determined to try, it looks as though you're going to need to use the ctypes extensions - described here:
https://docs.python.org/3/library/ctypes.html
I know nothing at all about puthon, but I gather a simple Paylink call will be something like:
Code: Select all
Def CurrentValue :
CurrentValue0 = ctypes.windll.AesImhei.CurrentValue
CurrentValue0.argtypes = [None]
CurrentValue0.restype = ctypes.c_int
Result = CurrentValue0()
Re: Python integration?
Hi.
I am trying to use shared library libaes_access.so with python and ctypes. I did have some success with it for example i can execute function CurrentValue and PayOut. But I have problems with ReadAcceptorDetails:
This is the code for python3
When i try to read for example AcceptorCoin Inhibit status i get this values:
So i know i have something wrong in the struct table, because inhibit values should be 0 or 1.
Any suggestions?
Thank you.
I am trying to use shared library libaes_access.so with python and ctypes. I did have some success with it for example i can execute function CurrentValue and PayOut. But I have problems with ReadAcceptorDetails:
This is the code for python3
Code: Select all
from ctypes import *
MAX_ACCEPTOR_COINS = 256
class AcceptorCoin(Structure):
_fields_ = [("Value", c_int),
("Inhibit", c_int),
("Count", c_int),
("Path", c_int),
("PathCount", c_int),
("PathSwitchLevel", c_int),
("DefaultPath", c_char),
("FutureExpansion", c_char),
("HeldInEscrow", c_char),
("FutureExpansion2", c_char),
("CoinName", c_char_p)]
class AcceptorBlock(Structure):
_fields_ = [("Unit", c_int),
("Status", c_int),
("NoOfCoins", c_int),
("InterfaceNumber", c_int),
("UnitAddress", c_int),
("DefaultPath", c_int),
("BarcodesStacked", c_int),
("Currency",c_char*4),
("Coin", AcceptorCoin*MAX_ACCEPTOR_COINS),
("SerialNumber", c_int),
("Description", c_char_p),
("EscrowBarcodeHere",c_int)]
paylink = CDLL("libaes_access.so.1.2.0")
response = paylink.OpenMHEVersion(0x10001)
paylink.EnableInterface()
AcceptorCoinArray=AcceptorCoin*MAX_ACCEPTOR_COINS
structAcceptorCoinArray=AcceptorCoinArray()
structAcceptorBlock = AcceptorBlock()
structAcceptorBlock.Coin=structAcceptorCoinArray
paylink.ReadAcceptorDetails(0,pointer(structAcceptorBlock))
Code: Select all
for i in structAcceptorBlock.Coin:
... i.Inhibit
...
0
0
0
32
63
255
200
0
0
0
0
0
.........
Any suggestions?
Thank you.
Re: Python integration?
One thing is the size of a c_int - it should be 32 bits.
I would also suggest printing the fields of structAcceptorBlock so as to see if anything is correct in that.
If you have problems specifically as regards to the coins, note that the Coin field is an array embedded in the structure.
C# (for instance) assumes that the Coin field is a reference to an array stored elsewhere.
I would also suggest printing the fields of structAcceptorBlock so as to see if anything is correct in that.
If you have problems specifically as regards to the coins, note that the Coin field is an array embedded in the structure.
C# (for instance) assumes that the Coin field is a reference to an array stored elsewhere.
Aardvark software developer. Please put all communication on the problem through the board for the benefit of others.