Mostrando entradas con la etiqueta Bill Acceptor. Mostrar todas las entradas
Mostrando entradas con la etiqueta Bill Acceptor. Mostrar todas las entradas

jueves, 14 de julio de 2016

JCM UBA-10-SS (ID003 Protocol) Simple Driver gcc (Raspberry Pi /Banana Pi/ PC Linux)


Simple Driver JCM UBA-10-SS (ID003 Protocol)

 JCM UBA-10-SS (ID003 Protocol)

Simple driver (gcc) para un billetero JCM UBA-10-SS usando el protocolo ID003.

Las tramas del protocolo ID003 tienen la forma:

| SYNC | Length | CMD | Data Fields | Checksum |

SYNC (1byte): 0xFC
Length (1byte): Longitud total del string (todos los bytes)
CMD (1byte) (instrucción, tipo de orden)
Data (variable)( datos, opcional)
CRC (2byte)( CRC-Kermit)

Para mayor comprensión del CRC-Kermit probar la librería de Lammert Bies, la cual se puede compilar en gcc. Las funciones para el crc-kermit en este driver han salido de aquí.
----------------------------------------------------------------.
crc: tst_crc.o lib_crc.o
    gcc -o crc tst_crc.o lib_crc.o

lib_crc.o: lib_crc.c
    gcc -Wall -c lib_crc.c

tst_crc.o: tst_crc.c
    gcc -Wall -c tst_crc.c

clean:
    rm tst_crc.o lib_crc.o
----------------------------------------------------------------.

 Crc kermit


 
Communication settings:

BaudRate: 9600 (variable)
DataBits: 8 Bits
StopBits: 1 Bit
▪ Paridad: EVEN

Ejemplos de tramas ID003:
FC 05 11 27 56 (STATUS REQUEST)
FC 05 88 6F 5F (VERSION REQUEST)
FC 06 13 62 2B C9 (ESCROW)

Las denominaciones en el id003:

0x61 = 1st
0x62 = 2nd
0x63 = 3rd
0x64 = 4th
0x65 = 5th
0x66 = 6th
 ______________________________________________________________

 uba: main.o wiringSerial.o id003.o crc_kermit.o
    gcc -o uba main.o wiringSerial.o id003.o crc_kermit.o -l pthread

wiringSerial.o: wiringSerial.c
    gcc -Wall -c wiringSerial.c

main.o: main.c
    gcc -Wall -c main.c

id003.o: id003.c
    gcc -Wall -c id003.c

crc_kermit.o: crc_kermit.c
    gcc -Wall -c crc_kermit.c

clean:
    rm main.o wiringSerial.o id003.o crc_kermit.o
 ______________________________________________________________

Descargar Código fuente (Simple Driver JCM UBA)

Descargar herramienta para comprender Id003 by igrotechnics

Driver UBA (JAVA/C++ [Qt]) ID003 Protocol

Disculpen si no respondí antes, password: "sydbernard", "sydbernard1", "maniacmansion" ,"maniacmanison1". Alguno ha de servir.

Código fuente (Simple Driver JCM UBA)



miércoles, 13 de julio de 2016

Bill Acceptors Apex 5000/7000 Simple Driver gcc (Raspberry Pi /Banana Pi/ PC Linux)


Apex 5000/7000 Simple Driver (gcc) 

 Bill Acceptor Apex 7000
 
Aquí se ha usado de la librería WiringPI los archivos wiringSerial.c, wiringSerial.h ademas de la función Delay(), pero el código funciona en ambos (Raspberry Pi / Banana Pi/ PC Linux).

En el caso de la librería wiringSerial, esta debería trabajar para 7 bits de datos, 1 bit de paridad EVEN.
Por lo que se ha modificado la función serialOpen ;


options.c_cflag |= PARENB; // Paridad activada.
options.c_cflag &= ~PARODD; // Paridad EVEN.
options.c_cflag |= CS7; // 7 bits de datos.

Este simple driver consta de 5 archivos; main.c, apex.c, apex.h, wiringSerial.c, wiringSerial.h. Para compilarlos;
---------------------------------------------------------+
 Descargar Código Fuente

Disculpen si no respondí antes, password: "sydbernard", "sydbernard1", "maniacmansion" ,"maniacmanison1". Alguno ha de servir.
---------------------------------------------------------+
$ gcc -Wall -c main.c wiringSerial.c apex.c
$ gcc -o apex main.o wiringSerial.o apex.o -l pthread
$ rm main.o wiringSerial.o apex.o
---------------------------------------------------------+
 
makefile;

apex: main.o wiringSerial.o apex.o
gcc -o apex main.o wiringSerial.o apex.o -l pthread

wiringSerial.o: wiringSerial.c
gcc -Wall -c wiringSerial.c

main.o: main.c
gcc -Wall -c main.c

apex.o: apex.c
gcc -Wall -c apex.c

clean:
rm main.o wiringSerial.o apex.o
----------------------------------------------------------+
  
Para este ejemplo en la función loop_apex se indica que cuando haya un billete valido, este sea aceptado automáticamente, una vez almacenado el billete se envia el mensaje: Accept bill: #billete
Ademas de los BYTE 0, BYTE1, BYTE2 enviados por el billetero.

Simple driver Apex bill acceptor (Linux Mint, x86)

Raspberry Pi
 
Conexión Rpi - Apex (conector 18 pin)

conector 18 pin (verde-Tx, rojo/blanco-Rx)

Pyramid Bill Acceptors Apex 5000/7000

Los billeteros (Bill Acceptors) Pyramid APEX 5000/7000 :

Comunicación:
Baud rate- 9600
1 start and 1 stop bit
7 data bits (bit 0 = sent first (LSB))
1 parity bit ( even parity)

Inactive Timing – Si el Bill Acceptor no detecta comunicación con el Host dentro de un lapso de 5 segundos, iniciando desde la última comunicación enviada por el host, el bill acceptor:

 
1 – rechazara cualquier billete mantenido en escrow.
2 – Dejará de aceptar billetes hasta que el master inicie la comunicación nuevamente.


Formato común para la transmisión:

| STX | Length | MSG Type and Ack Number | Data Fields | ETX | Checksum |

STX- 0x02 El inicio del mensaje es indicado por 1 byte.

Length- Número de bytes en cada mensaje (binary), incluyendo STX, ETX y Checksum.

Tipo de MSG y número Ack – Un byte de dato.

Tipo de MSG - (Bits 4, 5 y 6 de este byte)

1- Mensajes De Maestro a esclavo (Bill Acceptor).
2- Mensajes de esclavo (Bill Acceptor) a Maestro.

Número ACK - 0 ó 1 (bits 0-3) (Revisar RS-232 Serial Interface Specification

ApexSeries Acceptors para mayor información.

Data- Porción de mensaje, el data consiste de múltiple campos;
Data Fields para los mensajes enviados por el Master. (Byte 0 es enviado primero)
ETX- 03H Byte Fin del mensaje.
Checksum- (1 byte checksum). El cheksum es calculado con todos los bytes (except: STX, ETX y
el checksum mismo). Haciendo (XOR) a todos los bytes.

/* ***************************************************************** */


Campo de datos para el mensaje enviado por el Master

BYTE 0
BIT 0- $1 Accept Enable (Set to a “1” to accept a bill)
BIT 1- $2 Accept Enable (Not used on Apex series acceptors)
BIT 2- $5 Accept Enable
BIT 3- $10 Accept Enable
BIT 4- $20 Accept Enable
BIT 5- $50 Accept Enable
BIT 6- $100 Accept Enable

BYTE 1
BIT 0- Reserved for future use. (Set to 0)
BIT 1- SECURITY (Reserved for future use.)
BIT 2- ORIENTATION (Reserved for future use.)
BIT 3- ORIENTATION (Reserved for future use.)
BIT 4- Escrow (Set = 1 to enable escrow)
BIT 5- Stack (Set = 1 causes bill to be stacked)
BIT 6- Return (Set = 1 causes bill to be returned)

BYTE 2
BIT 0- 6 - Reserved for future use.



Ejemplo (-->):  
02 08 11 7F 00 00 03 66 (Todas las denominaciones activadas)
02 08 10 7F 00 00 03 67 (Todas las denominaciones activadas)




 
Campo de dato enviado por el Slave (Bill Acceptor)

BYTE 0
Bit 0- Idling (Set = 1 if acceptor is in idle state)
Bit 1- Accepting (Set = 1 if accepting a bill)
Bit 2- Escrowed (Set =1 if a bill is in escrow)
Bit 3- Stacking (Set = 1 if a bill is being stacked)
Bit 4- Stacked (Set = 1 if a bill was stacked, Idle (Bit 0) also set during this state)
Bit 5- Returning (= 1 if a bill is being returned)
Bit 6- Returned (Set = 1 if the bill has been returned, Idle (Bit 0) also set during this state)

BYTE 1
Bit 0- Cheated (Set = 1 if acceptor suspects cheating)
Bit 1- Bill rejected (Set = 1 if a bill was rejected)
Bit 2- Bill jammed (Set = 1 if a bill is jammed)
Bit 3- Stacker full (Set = 1 if the stacker is full)
Bit 4- Bill cassette present (Set = 1 if cassette is present)
Bit 5- Reserved for future use (Set to 0)
Bit 6- Reserved for future use (Set to 0)

BYTE 2
Bit 0- Power up (Set = 1 if acceptor is initializing)
Bit 1- Invalid command (Set = 1 if an invalid command was received)
Bit 2- Failure (Set = 1 if acceptor has failed)
Bit 3-5 Bill value field
000 = None/unknown bill or note
001 = $1 or 1 st note type
010 = $2 or 2 nd note type
011 = $5 or 3 rd note type
100 = $10 or 4 th note type
101 = $20 or 5 th note type
110 = $50 or 6 th note type
111 = $100 or 7 th note type
Bit 6- Reserved for future use.

BYTE 3
Reserved for future use.
BYTE 4
Model number (00-7FH)
BYTE 5
Revision of firmware (00-7FH)


Ejemplo (<--):  
02 0B 21 01 10 00 00 14 07 03 28 (Idling, Stacker Presente)
02 0B 20 01 10 00 00 14 07 03 29 (Idling, Stacker Presente)


/* ****************************************************************** */
BYTE 0
typedef union {
    uint8_t byte;
    struct {
        uint8_t idling:1;
        uint8_t accepting:1;
        uint8_t escrowed:1;
        uint8_t stacking:1;
        uint8_t stacked:1;
        uint8_t returning:1;
        uint8_t returned:1;
    };
} rxbyte0;

BYTE 1
typedef union {
    uint8_t byte;
    struct {
        uint8_t cheated:1;
        uint8_t bill_rejected:1;
        uint8_t bill_jammed:1;
        uint8_t stacker_full:1;
        uint8_t bill_cassette_present:1;
    };
} rxbyte1;

BYTE 2
typedef union {
    uint8_t byte;
    struct {
        uint8_t power_up:1;
        uint8_t invalid_command:1;
        uint8_t failure:1;
        uint8_t bill_value_field:3;
    };
} rxbyte2;

Simple Driver Apex 7000(LinuxMint x86)