Página principal | Jerarquía de la clase | Lista alfabética | Lista de componentes | Lista de archivos | Miembros de las clases | Archivos de los miembros | Páginas relacionadas

jed_serial.h

Ir a la documentación de este archivo.
00001 //===========================================================================
00002 //= jed_serial.h                                              Julio de 1998 =
00003 //=-------------------------------------------------------------------------=
00004 //= Definicion de la clase PUERTO_SERIAL                                    =
00005 //=-------------------------------------------------------------------------=
00006 //= ADVERTENCIA: ESTE SOFTWARE NO ESTA CONCEBIDO NI DISENNADO PARA EL USO   =
00007 //= EN EQUIPO DE CONTROL EN LINEA EN ENTORNOS PELIGROSOS QUE REQUIERAN UN   =
00008 //= DESEMPENNO LIBRE DE FALLAS, COMO LA OPERACION DE PLANTAS NUCLEARES,     = 
00009 //= SISTEMAS DE NAVEGACION O COMUNICACION EN AVIONES, TRAFICO AEREO,        =
00010 //= EQUIPO MEDICO DEL CUAL DEPENDAN VIDAS HUMANAS O SISTEMAS DE ARMAMENTO,  =
00011 //= EN LOS CUALES UNA FALLA EN EL SOFTWARE PUEDA IMPLICAR DIRECTAMENTE LA   =
00012 //= MUERTE, DANNOS PERSONALES O DANNOS FISICOS Y/O AMBIENTALES GRAVES       =
00013 //= ("ACTIVIDADES DE ALGO RIESGO").                                         =
00014 //=-------------------------------------------------------------------------=
00015 //= Autor original: Oscar J. Chavarro G.  A.K.A. JEDILINK. Copyright (c),   =
00016 //= 1997 - 2003, oscarchavarro@hotmail.com                                  =
00017 //= AQUYNZA es software libre, y se rige bajo los terminos de la licencia   =
00018 //= LGPL de GNU (http://www.gnu.org). Para mayor informacion respecto a la  =
00019 //= licencia de uso, consulte el archivo ./doc/LICENCIA en la distribucion. =
00020 //= Con la colaboracion de Harold Cruz              ha-cruz@uniandes.edu.co =
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,  // RTS/CTS
00072     PSF_HARDWARE   // XON/XOFF
00073 };
00074 
00075 #define MAX_RETRIES 4000  /* Para los reintentos de lectura */
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;   // Una de las PS_VELOCIDADES
00126     int paridad;     // Una de las PS_PARIDADES
00127     int stop_bits;   // Uno de los PS_STOP_BITS
00128     int data_bits;   // Uno de los PS_DATA_BITS
00129     int flujo;       // Uno de los PS_CONTROL_DE_FLUJO
00130     BOOLEAN abierto; // Estado
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     // Constructora y destructora
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     // Servicios basicos
00150     BOOLEAN abrir(void);
00151     void cerrar(void);
00152 
00153     // Servicios de entrada/salida
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     // Servicios de configuracion  OJO: son metodos debatibles
00159     BOOLEAN  // Tiene sentido?
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     //void consultar(DATOS_PUERTO &datos_puerto);  // No es mejor esto?
00163 };
00164 
00165 #endif // __SERIAL__
00166 
00167 //===========================================================================
00168 //= EOF                                                                     =
00169 //===========================================================================
00170 

Este archivo HTML ha sido generado automáticamente a partir del código fuente AQUYNZA. NO LO EDITE. Para mayor información contacte al autor.