pcomm.h Source File

Main Page Compound List File List Header Files Sources Compound Members File Members

# pcomm.h

    00001 #ifndef PCOMM_H_
    00002 #define PCOMM_H_
    00003 /*
    00004    Copyright (C) 1999 PolyWog and Javaman for Ghetto.Org
    00005    This file is part of the PCR-1000 API Library.
    00006
    00007    The PCR-1000 API Library is free software; you can redistribute it and/or
    00008    modify it under the terms of the GNU Library General Public License as
    00009    published by the Free Software Foundation; either version 2 of the
    00010    License, or (at your option) any later version.
    00011
    00012    The PCR-1000 API Library is distributed in the hope that it will be useful,
    00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015    Library General Public License for more details.
    00016
    00017    You should have received a copy of the GNU Library General Public
    00018    License along with the PCR-1000 API Library; see the file LICENSE.  If not,
    00019    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00020    Boston, MA 02111-1307, USA.
    00021  */
    00022
    00023 #include <sys/types.h>
    00024 #include <sys/stat.h>
    00025 #include <fcntl.h>
    00026 #include <sys/termios.h>
    00027 #include <stdio.h>
    00028 #include <unistd.h>
    00029 #include <sys/time.h>
    00030 #include <stdlib.h>
    00031
    00032 #include "pcrdef.h"
    00033
    00034 #define BAUDRATE B9600
    00035 #define PCRDEV "/dev/ttyS0"
    00036 #define _POSIX_SOURCE 1 /* POSIX compliant source */
    00037
    00038 typedef int size_pc;    /* i/o count confirmation */
    00039
    00041
    00047 class PComm {
    00048     public:
    00049         PComm(char *pcrDev, tcflag_t baudRate=B9600, const char *name=0);
    00050         ~PComm();
    00051
    00052         bool PCOpen(const char *pcrDev=PCRDEV, tcflag_t baudRate=B9600);
    00053         void PCClose();
    00054
    00055         size_pc PCTell(char *);
    00056         size_pc PCAsk(char *);
    00057         size_pc PCHear(char *);
    00058         size_pc PCRawWrite(char *);
    00059         size_pc PCRawRead(char *);
    00060
    00061     private:
    00062         size_pc Write(char *);
    00063         size_pc Read(char *);
    00064
    00065         void    resetCall();
    00066         void    countCall();
    00068         int     callCount;
    00070         char   callBuf[256];
    00071
    00073         struct  timeval *timeOut;
    00075         fd_set  *FDSet;
    00077         int     retVal;
    00079         struct  termios *oldtio;
    00081         struct  termios *newtio;
    00083         int     fd;
    00085         char    pcrDevice[256];
    00087         tcflag_t pcrSpeed;
    00088
    00090          bool errRead;
    00092          bool errWrite;
    00094          char askBuf[256];
    00096          char hearBuf[256];
    00098          char writeBuf[256];
    00100          char readBuf[256];
    00102          char int_name[256];
    00104          size_pc writeCtr;
    00106          size_pc readCtr;
    00108          size_pc askCtr;
    00110          size_pc tellCtr;
    00112          size_pc hearCtr;
    00113 };
    00114
    00115 #endif /* PCOMM_H_ */