1 |
60 |
budinero |
/*
|
2 |
|
|
*
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
* Check action status is forced when return value is used.
|
6 |
|
|
* When reading the port, data is obtaiend by reference (for consistency)
|
7 |
|
|
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
#ifndef EPP_PARALLEL_USE_WIN_H
|
13 |
|
|
#define EPP_PARALLEL_USE_WIN_H
|
14 |
|
|
|
15 |
|
|
#include "epp_parallel_access_win.h"
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
class EppParallelUseWin {
|
19 |
|
|
public:
|
20 |
|
|
enum PPStatusType
|
21 |
|
|
{
|
22 |
|
|
PP_STATE_IDLE = 0, // Estado inicial, sin negociación previa
|
23 |
|
|
PP_CONECTED = 1, // Luego de la negociación
|
24 |
|
|
PP_COMUNICATION_FAIL = 2, // Fallo en la comunicación (dispositivo no accesible o
|
25 |
|
|
// desconectado)
|
26 |
|
|
PP_NEGOTIATION_FAIL = 3, // Dispositivo accesible, pero fallo en la negociación (existe
|
27 |
|
|
// dispositivo pero no soporta modo EPP)
|
28 |
|
|
PP_TIME_OUT = 4, // Time out
|
29 |
|
|
/* PP_RA_TIME_OUT = 4, // Read address fails
|
30 |
|
|
PP_WA_TIME_OUT = 5, // Write address fails
|
31 |
|
|
PP_RB_TIME_OUT = 6, // Read byte fails
|
32 |
|
|
PP_WB_TIME_OUT = 7, // Write byte fails
|
33 |
|
|
PP_RW_TIME_OUT = 8, // Read word fails
|
34 |
|
|
PP_WW_TIME_OUT = 9, // Write word fails*/
|
35 |
|
|
PP_LOAD_LIBRARY_FAIL = 5, // Falla al cargar la librería
|
36 |
|
|
PP_WRONG_BASE_ADDRESS = 6 // Dirección base incorrecta
|
37 |
|
|
};
|
38 |
|
|
|
39 |
|
|
// Inicializacón
|
40 |
|
|
EppParallelUseWin();
|
41 |
|
|
// Inicialización con negociación
|
42 |
|
|
EppParallelUseWin(const short int &base_address);
|
43 |
|
|
~EppParallelUseWin();
|
44 |
|
|
|
45 |
|
|
// Negociación con devolución de estado
|
46 |
|
|
PPStatusType negotiateEPP();
|
47 |
|
|
// Negociación con devolución de estado y seteo de dirección del puerto
|
48 |
|
|
PPStatusType negotiateEPP(const unsigned short int &base_address);
|
49 |
|
|
|
50 |
|
|
// Reinicia el estado del puerto
|
51 |
|
|
void closeEPP();
|
52 |
|
|
|
53 |
|
|
// Dirección base del puerto (solo soporta 0x3BC, 0x378 y 0x278)
|
54 |
|
|
PPStatusType setBaseAddress(const short int &address);
|
55 |
|
|
short int getBaseAddress();
|
56 |
|
|
|
57 |
|
|
// Escribe/lee dirección sin/con retorno de estado
|
58 |
|
|
void writeAddress(const char &address);
|
59 |
|
|
//PPStatusType writeAddress(const char &address);
|
60 |
|
|
|
61 |
|
|
void readAddress(char &return_address);
|
62 |
|
|
//PPStatusType readAddress(char &return_address) const;
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
// Escribe/lee un byte sin/con retorno de estado y selección de direccón destino
|
66 |
|
|
void writeByte(const char &byte);
|
67 |
|
|
void writeByte(const char &byte, const char &address);
|
68 |
|
|
// PPStatusType writeByte(const char &byte) const;
|
69 |
|
|
// PPStatusType writeByte(const char &byte, const char &address) const;
|
70 |
|
|
void readByte(char &return_byte);
|
71 |
|
|
void readByte(char &return_byte, const char &addresss);
|
72 |
|
|
// PPStatusType readByte(char &return_byte) const;
|
73 |
|
|
// PPStatusType readByte(char &return_byte, const char &addresss) const;
|
74 |
|
|
|
75 |
|
|
// Escribe/lee dos bytes sin/con retorno de estado y selección de direccón destino
|
76 |
|
|
void writeWord(const unsigned short int &word);
|
77 |
|
|
void writeWord(const unsigned short int &word, const char &address);
|
78 |
|
|
// PPStatusType writeWord(const short int &word) const;
|
79 |
|
|
// PPStatusType writeWord(const short int &word, const char &address) const;
|
80 |
|
|
void readWord(unsigned int &return_word);
|
81 |
|
|
void readWord(unsigned int &return_word, const char &address);
|
82 |
|
|
// PPStatusType readWord(short int &return_word) const;
|
83 |
|
|
// PPStatusType readWord(short int &return_word, const char &address) const;
|
84 |
|
|
|
85 |
|
|
// Devolución de estado del puerto
|
86 |
|
|
PPStatusType getStatus();
|
87 |
|
|
|
88 |
|
|
// make private
|
89 |
|
|
PPStatusType testDataTransfer() ;
|
90 |
|
|
|
91 |
|
|
private:
|
92 |
|
|
short int baseAddress;
|
93 |
|
|
//int errorsCount;
|
94 |
|
|
PPStatusType status;
|
95 |
|
|
|
96 |
|
|
PPStatusType loadDLL();
|
97 |
|
|
// Verifica si es un estado compatible con transferencia de datos (1 = posible, 0 = no permitir)
|
98 |
|
|
bool testStatusForDataTransfer();
|
99 |
|
|
// Resetea estado de time out
|
100 |
|
|
void prepareTestDataTransfer();
|
101 |
|
|
// Verifica estado de time out
|
102 |
|
|
//PPStatusType testDataTransfer() ;
|
103 |
|
|
|
104 |
|
|
};
|
105 |
|
|
|
106 |
|
|
#endif //EPP_PARALLEL_USE_WIN_H
|