Python integration?

Support for the Milan Intelligent interface, sold by Money Controls as the Paylink USB unit and for the earlier PCI card version.

Moderators: aardvark, davebush, Admin

Post Reply
t3r3x
Posts: 1
Joined: Fri Jan 24, 2014 11:33 pm

Python integration?

Post by t3r3x »

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.
davebush
Posts: 482
Joined: Fri Oct 22, 2004 12:20 pm

Re: Python integration?

Post by davebush »

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:

Code: Select all

Declare Function NextEvent Lib "AesImhei.dll" Alias "_NextEvent@4" (ByRef EventDetails As EventDetailBlock) As Long
and in Pascal you use

Code: Select all

Function NextEvent(var EventDetails : TEventDetailBlock) : LongInt ;  stdcall ; external 'Aesimhei.dll' name '_NextEvent@4';
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
Aardvark software developer. Please put all communication on the problem through the board for the benefit of others.
dundo
Posts: 1
Joined: Sat Mar 16, 2019 1:22 am

Re: Python integration?

Post by dundo »

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
aardvark
Posts: 19
Joined: Mon Jun 21, 2004 6:05 pm

Re: Python integration?

Post by aardvark »

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:

Code: Select all

Def CurrentValue :
CurrentValue0 = ctypes.windll.AesImhei.CurrentValue
CurrentValue0.argtypes = [None]
CurrentValue0.restype = ctypes.c_int
Result = CurrentValue0()
I have no idea if the above is valid Paython - but it might get you started.
urosh
Posts: 1
Joined: Tue Sep 03, 2019 2:25 pm

Re: Python integration?

Post by urosh »

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

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))

When i try to read for example AcceptorCoin Inhibit status i get this values:

Code: Select all

for i in structAcceptorBlock.Coin:
...  i.Inhibit
...
0
0
0
32
63
255
200
0
0
0
0
0
.........
So i know i have something wrong in the struct table, because inhibit values should be 0 or 1.

Any suggestions?
Thank you.
davebush
Posts: 482
Joined: Fri Oct 22, 2004 12:20 pm

Re: Python integration?

Post by davebush »

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.
Aardvark software developer. Please put all communication on the problem through the board for the benefit of others.
Post Reply