using Manufactor snippets (Convert C programs to Gambas)
Posted
#1
(In Topic #1216)
Enthusiast

I was wondering if someone could advise me
a Supplier of my PoS Terminal has given me a few programs they have made in C to get the status of the cash drawer port as well as Open the drawer
I also have libptcash.so and libptcash.a files and the read me is telling me to use that from my user program (but I have no clue how to do that)
but they are small single run program
does anyone know how they could be converted to Gambas so i could monitor the cash drawer port all the time (i have attached the C source code so if someone smarter then me wants to see it they can)
My machine a 2 (PT621X_A)
Code (gambas)
- //MACHINE_TYPE
- #define PT6200_A 1
- #define PT621X_A 2
- #define PT5700_A 3
- #define PT571X_A 4
- #define PT6900_A 5
- #define PT691X_A 6
- #define PT8800_A 7
- //\{==add by frankie on 20111027
- #define PT8850_A 8
- #define SP800_A 9
- #define SP1000_A 10
- #define SP820_A 11
- #define PT6315C_A 11
- #define SP600_A 12
- #define SP810_A 13
- #define WT_110_A 14
- #define SP2500_A 15
- #define SP3515_A 15
- #define SP1060_A 16
- #define SP7615_A 17
- #define SP7615_A_IO 19
- #define SP5615_A 18
- //==}
- #define PT6200_B 21
- #define PT621X_B 22
- #define PT5700_B 23
- #define PT571X_B 24
- #define PT6900_B 25
- #define PT691X_B 26
- #define PT8800_B 27
- //\{==add by frankie on 20111027
- #define PT8850_B 28
- #define SP800_B 29
- #define SP1000_B 30
- #define SP820_B 31
- #define PT6315C_B 31
- #define SP600_B 32
- #define SP810_B 33
- #define WT_110_B 34
- #define SP2500_B 35
- #define SP3515_B 35
- #define SP1060_B 36
- #define SP7615_B 37
- #define SP5615_B 38
- //==}
- /********************************************************************
- Description:
- Open the cash drawer.
- Parameter:
- int machine_type : should be one of
- PT6200 , PT621X , PT5700 , PT571X , PT6900 , PT691X,PT8800
- return :
- 0: open success
- 1: open fail
- ********************************************************************/
- // 0: success -1: fail
- /********************************************************************
- Description:
- Open the cash drawer.
- Parameter:
- int machine_type : should be one of
- PT6200 , PT621X , PT5700 , PT571X , PT6900 , PT691X ,PT8800
- return :
- 0: cash drawer closed
- 1: cash drawer opened
- ********************************************************************/
- /********************************************************************
- Description:
- read the MB Serial Number.
- Parameter:
- psnbuf,will return the SN, 12 characters
- return :
- 0: success
- -1: fail
- ********************************************************************/
Code (gambas)
Ideally I would like to be able to click on the Gambas App a button that says "Open Drawer" and it will open the drawer and then show a mesage saying "Please close the drawer" until they close the Drawer
Below is the readme file (and it talks about threaded API)
Code (gambas)
- 1) tar -xvzf PT_Cashdrawer_Driver.tar.gz
- 2) cd PT_Cashdrawer_Driver
- 3)
- sh install.sh
- 4) reboot
- sh uninstall.sh
- 5.Thredd APIs be provided:
- the description like these:
- /********************************************************************
- Description:
- Open the cash drawer.
- Parameter:
- int machine_type : should be one of
- PT6200 , PT621X , PT5700 , PT571X , PT6900 , PT691X, PT8800........
- return :
- 0: open success
- 1: open fail
- ********************************************************************/
- /********************************************************************
- Description:
- Open the cash drawer.
- Parameter:
- int machine_type : should be one of
- PT6200 , PT621X , PT5700 , PT571X , PT6900 , PT691X, PT8800........
- return :
- 0: cash drawer closed
- 1: cash drawer opened
- ********************************************************************/
- /********************************************************************
- Description:
- read the MB Serial Number.
- Parameter:
- psnbuf,will return the SN, 12 characters
- return :
- 0: success
- -1: fail
- ********************************************************************/
- 5.About the "machine_type"
- #define PT6200_A 1
- #define PT621X_A 2
- #define PT5700_A 3
- #define PT571X_A 4
- #define PT6900_A 5
- #define PT691X_A 6
- #define PT8800_A 7
- #define PT8850_A 8
- #define SP800_A 9
- #define SP1000_A 10
- #define SP820_A 11
- #define PT6315C_A 11
- #define SP600_A 12
- #define SP810_A 13
- #define WT_110_A 14
- #define SP2500_A 15
- #define SP3515_A 15
- #define SP5514_A 15
- #define SP1060_A 16
- #define SP2600_A 16
- #define SP7615_A 17
- #define SP5615_A 18
- #define PT6200_B 21
- #define PT621X_B 22
- #define PT5700_B 23
- #define PT571X_B 24
- #define PT6900_B 25
- #define PT691X_B 26
- #define PT8800_B 27
- #define PT8850_B 28
- #define SP800_B 29
- #define SP1000_B 30
- #define SP820_B 31
- #define PT6315C_B 31
- #define SP600_B 32
- #define SP810_B 33
- #define WT_110_B 34
- #define SP2500_B 35
- #define SP3515_B 35
- #define SP5514_B 35
- #define SP1060_B 36
- #define SP2600_B 36
- #define SP7615_B 37
- #define SP5615_B 38
Posted
Regular

C CODE:
#include <stdio.h>
#include "cashdrawer.h"
int main(int argc,char *argv[])
{
int machine_type;
int ret;
machine_type = atoi(argv[1]);
ret=Open_Cash(machine_type);
printf("open cash return = %d\n",ret);
if(ret == 0)
printf("open success\n");
else
printf("open fail\n");
}
- - - - - - - - - - - - - - - - - - - - - -
GAMBAS CODE:
Code (gambas)
==========================================================
C CODE:
#include <stdio.h>
#include "cashdrawer.h"
int main(int argc,char *argv[])
{
int machine_type;
int status;
machine_type = atoi(argv[1]);
status=Get_Cash_Status(machine_type);
printf("get cash status = %2x\n",status);
if(status == 1)
printf("cash drawer is opened\n");
else if(status == 0)
printf("cash drawer is closed\n");
else
printf("get cash status fail\n");
}
- - - - - - - - - - - - - - - - - - - - - -
GAMBAS CODE:
Code (gambas)
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Enthusiast

vuott said
Uhmmmm….
C CODE:
#include <stdio.h>
#include "cashdrawer.h"
int main(int argc,char *argv[])
{
int machine_type;
int ret;
machine_type = atoi(argv[1]);
ret=Open_Cash(machine_type);
printf("open cash return = %d\n",ret);
if(ret == 0)
printf("open success\n");
else
printf("open fail\n");
}
- - - - - - - - - - - - - - - - - - - - - -
GAMBAS CODE:Code (gambas)
==========================================================
C CODE:
#include <stdio.h>
#include "cashdrawer.h"
int main(int argc,char *argv[])
{
int machine_type;
int status;
machine_type = atoi(argv[1]);
status=Get_Cash_Status(machine_type);
printf("get cash status = %2x\n",status);
if(status == 1)
printf("cash drawer is opened\n");
else if(status == 0)
printf("cash drawer is closed\n");
else
printf("get cash status fail\n");
}
- - - - - - - - - - - - - - - - - - - - - -
GAMBAS CODE:Code (gambas)
Thank you so much I shall give them a go over the next few days
1 guest and 0 members have just viewed this.



