00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __SERIAL__
00024 #define __SERIAL__
00025
00026 #include "jed_defs.h"
00027
00028 enum ENUM_PS_VELOCIDADES {
00029 PSV_NULL = 0,
00030 PSV110,
00031 PSV300,
00032 PSV600,
00033 PSV1200,
00034 PSV2400,
00035 PSV4800,
00036 PSV9600,
00037 PSV14400,
00038 PSV19200,
00039 PSV38400,
00040 PSV56000,
00041 PSV57600,
00042 PSV115200,
00043 PSV128000,
00044 PSV256000
00045 };
00046
00047 enum ENUM_PS_PARIDADES {
00048 PSP_NONE = 0,
00049 PSP_EVEN,
00050 PSP_ODD,
00051 PSP_MARK,
00052 PSP_SPACE
00053 };
00054
00055 enum ENUM_PS_STOP_BITS {
00056 PSS_UNO = 1,
00057 PSS_DOS,
00058 PSS_UNO_Y_MEDIO
00059 };
00060
00061 enum ENUM_PS_DATA_BITS {
00062 PSD4 = 4,
00063 PSD5,
00064 PSD6,
00065 PSD7,
00066 PSD8
00067 };
00068
00069 enum ENUM_PS_CONTROL_DE_FLUJO {
00070 PSF_NONE = 0,
00071 PSF_SOFTWARE,
00072 PSF_HARDWARE
00073 };
00074
00075 #define MAX_RETRIES 4000
00076 #if PLATAFORMA == i386_WIN32_VC
00077 #define COM1 "COM1"
00078 #define COM2 "COM2"
00079 #define COM3 "COM3"
00080 #define COM4 "COM4"
00081 #endif
00082
00083 #if PLATAFORMA == i386_LINUX_GCC || PLATAFORMA == SPARC64_LINUX_GCC
00084 #define COM1 "/dev/ttyS0"
00085 #define COM2 "/dev/ttyS1"
00086 #define COM3 "/dev/ttyS2"
00087 #define COM4 "/dev/ttyS3"
00088 #endif
00089
00090 #if PLATAFORMA == POWERPC_AIX_VACPP
00091
00095 #define COM1 "/dev/tty0"
00096 #define COM2 "/dev/tty1"
00097 #define COM3 "/dev/tty2"
00098 #define COM4 "/dev/tty3"
00099 #endif
00100
00101 #if PLATAFORMA == ALPHA
00102 #define COM1 "/dev/tty00"
00103 #define COM2 "/dev/tty01"
00104 #define COM3 "/dev/tty02"
00105 #define COM4 "/dev/tty03"
00106 #endif
00107
00108 #if PLATAFORMA == SUN
00109 #define COM1 "/dev/ttya"
00110 #define COM2 "/dev/ttyb"
00111 #define COM3 "/dev/ttyc"
00112 #define COM4 "/dev/ttyd"
00113 #endif
00114
00115 #if PLATAFORMA == SGI || PLATAFORMA == CRAY_J90 || PLATAFORMA == CYGNUS_WIN32
00116 #define COM1 "/dev/null"
00117 #define COM2 "/dev/null"
00118 #define COM3 "/dev/null"
00119 #define COM4 "/dev/null"
00120 #endif
00121
00122 class PUERTO_SERIAL {
00123 private:
00124 char nombre_puerto[20];
00125 int velocidad;
00126 int paridad;
00127 int stop_bits;
00128 int data_bits;
00129 int flujo;
00130 BOOLEAN abierto;
00131
00132 BOOLEAN active_configuracion(void);
00133 #if PLATAFORMA == i386_WIN32_VC
00134 HANDLE com_fd;
00135 HWND instalar_sistema_asincronico_serial(void);
00136 #endif
00137 #ifdef UNIX_ENABLED
00138 int com_fd;
00139 BOOLEAN abrir_asincronico(void);
00140 #endif
00141
00142 public:
00143
00144 PUERTO_SERIAL(char *cad,
00145 const int v = PSV9600, const int p = PSP_NONE, const int s = PSS_UNO,
00146 const int d = PSD8, const int f = PSF_NONE);
00147 ~PUERTO_SERIAL();
00148
00149
00150 BOOLEAN abrir(void);
00151 void cerrar(void);
00152
00153
00154 int leer(char *buffer, int tam_buffer);
00155 BOOLEAN escribir(char *buffer, int tam_buffer);
00156 void registro_asincronico(void (*f)(void *, int), void *User_data);
00157
00158
00159 BOOLEAN
00160 configurar(const int v,const int p, const int s, const int d, const int f);
00161 void consultar(int &v, int &p, int &s, int &d, int &f);
00162
00163 };
00164
00165 #endif // __SERIAL__
00166
00167
00168
00169
00170