/*****************************************************************************
 * Copyright (c) 2005  Daniel Lerch Hostalot <http://daniellerch.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a 
 * copy of this software and associated documentation files (the "Software"), 
 * to deal in the Software without restriction, including without limitation 
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 * and/or sell copies of the Software, and to permit persons to whom the 
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in 
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 ****************************************************************************/

#ifndef __SERIAL_H__
#define __SERIAL_H__

#ifdef __cplusplus
extern "C" {            
#endif   


#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>


/** Estructura de control de un dispositivo serie */
typedef struct serial_t {

   /** private */
   int fd;
} 
serial_t;


/**
 * Crea un objeto de tipo serial_t
 *
 * @param device: nombre/ruta del dispositivo.
 * @return serial_t: nuevo objeto.
 */
serial_t* serial_new(char* device);

/**
 * Elimina un objeto de tipo serial_t
 *
 * @param obj: objeto a eliminar.
 */
void serial_free(serial_t* obj);


/**
 * Lee el bit CD (Carrier Detect) - PIN de entrada -
 *
 * @param *obj: objeto de trabajo.
 * @return int: valor, falso (0) o verdadero (diferente de 0).
 */
int serial_get_DCD_status(serial_t* obj);

/**
 * Lee el bit DSR (Data Set Ready) - PIN de entrada -
 *
 * @param *obj: objeto de trabajo.
 * @return int: valor, falso (0) o verdadero (diferente de 0).
 */
int serial_get_DSR_status(serial_t* obj);

/**
 * Lee el bit CTS (Clear To Send) - PIN de entrada -
 *
 * @param *obj: objeto de trabajo.
 * @return int: valor, falso (0) o verdadero (diferente de 0).
 */
int serial_get_CTS_status(serial_t* obj);




/**
 * Establece el bit TXD (Transmit Data) - PIN de salida - 
 *
 * @param *obj: objeto de trabajo.
 * @param value: valor, falso (0) o verdadero (diferente de 0).
 */
void serial_set_TXD_status(serial_t* obj, int value);

/**
 * Establece el bit DTR (Data Terminal Ready) - PIN de salida -
 *
 * @param *obj: objeto de trabajo.
 * @param value: valor, falso (0) o verdadero (diferente de 0).
 */
void serial_set_DTR_status(serial_t* obj, int value);

/**
 * Establece el bit RTS (Request To Send) - PIN de salida -
 *
 * @param *obj: objeto de trabajo.
 * @param value: valor, falso (0) o verdadero (diferente de 0).
 */
void serial_set_RTS_status(serial_t* obj, int value);



#ifdef __cplusplus
}       
#endif  

#endif






