utiles_v2017/puerto_com.h

35 lines
1011 B
C++

#pragma once
#include "base_head.h"
#define MODULO_CPUERTO_COM "Cpuerto_com"
typedef struct Puerto_com_conf//configuracion del puerto com
{
char com[10]; //puerto EJEM:"\\\\.\\COM1"
int baud; //velocidad( baudrate) desde CBR_110 hasta CBR_256000
int nb; //numero de bytes (normalmente 8)
int paridad; //normalmente NOPARITY
int b_parada; //(normalmente ONESTOPBIT)
}Puerto_com_conf;
class C_error;
class UTILES_EXPORT Cpuerto_com
{
public:
//variables---------------------------------------------
C_error *er;
BYTE* buf[1024];
private:
BOOL borra_error;
HANDLE hport;
public:
Cpuerto_com(C_error *err=NULL);
~Cpuerto_com(void);
//funciones---------------------------------------------
BOOL inicia(Puerto_com_conf* conf );
BOOL escribe(BYTE* b,int nb);
int lee(int nb=512);//recibe nb bytes (1024 maximo (total del buf))
int lee( int nb, int ms, int veces=10);//recive nb bytes insiste veces con esperas de ms
int escribeylee(BYTE* b,int nb, int time_sleep);
void termina();
};