#ifndef _UNIXSerialPort_h_INCLUDED_
#define _UNIXSerialPort_h_INCLUDED_

/*****************************************************************************/
/* ここから                                                                  */
/*****************************************************************************/

/*****************************************************************************/
/* クラスの定義                                                              */
/*****************************************************************************/

typedef struct _UNIXSerialPort * UNIXSerialPort;

/*****************************************************************************/
/* ヘッダファイルのインクルード                                              */
/*****************************************************************************/

#include <stdio.h>
#include <stdlib.h>

/*****************************************************************************/
/* メンバ関数の宣言                                                          */
/*****************************************************************************/

/*---------------------------------------------------------------------------*/
/* ポートの open/close                                                       */
/*---------------------------------------------------------------------------*/

int UNIXSerialPort_Open(UNIXSerialPort unix_serial_port);
int UNIXSerialPort_Close(UNIXSerialPort unix_serial_port);

int UNIXSerialPort_IsOpened(UNIXSerialPort unix_serial_port);
int UNIXSerialPort_IsClosed(UNIXSerialPort unix_serial_port);

/*---------------------------------------------------------------------------*/
/* 受信データがあるかどうか                                                  */
/*---------------------------------------------------------------------------*/

/*
 * タイムアウト時間をミリ秒単位で指定．
 * 0 のときは，即時
 * -1 のときは，無期限待ち
 */

int UNIXSerialPort_IsDataExisting(UNIXSerialPort unix_serial_port,
				  int timeout);

/*---------------------------------------------------------------------------*/
/* 受信                                                                      */
/*---------------------------------------------------------------------------*/

int UNIXSerialPort_ReceiveCharacter(UNIXSerialPort unix_serial_port,
				    int timeout);

/*---------------------------------------------------------------------------*/
/* 送信                                                                      */
/*---------------------------------------------------------------------------*/

int UNIXSerialPort_SendCharacter(UNIXSerialPort unix_serial_port,
				 unsigned char c);

/*---------------------------------------------------------------------------*/
/* オブジェクトの作成                                                        */
/*---------------------------------------------------------------------------*/

UNIXSerialPort UNIXSerialPort_Create();

/*---------------------------------------------------------------------------*/
/* オブジェクトの削除                                                        */
/*---------------------------------------------------------------------------*/

UNIXSerialPort UNIXSerialPort_Destroy(UNIXSerialPort unix_serial_port);

/*****************************************************************************/
/* ここまで                                                                  */
/*****************************************************************************/

#endif

/*****************************************************************************/
/* End of File.                                                              */
/*****************************************************************************/
