#ifndef PCOMM_H_ #define PCOMM_H_ /* Copyright (C) 1999 PolyWog and Javaman for Ghetto.Org This file is part of the PCR-1000 API Library. The PCR-1000 API Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The PCR-1000 API Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the PCR-1000 API Library; see the file LICENSE. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/termios.h> #include <stdio.h> #include <unistd.h> #include <sys/time.h> #include <stdlib.h> #include "pcrdef.h" #define BAUDRATE B9600 #define PCRDEV "/dev/ttyS0" #define _POSIX_SOURCE 1 /* POSIX compliant source */ typedef int size_pc; /* i/o count confirmation */ class PComm { public: PComm(char *pcrDev, tcflag_t baudRate=B9600, const char *name=0); ~PComm(); bool PCOpen(const char *pcrDev=PCRDEV, tcflag_t baudRate=B9600); void PCClose(); size_pc PCTell(char *); size_pc PCAsk(char *); size_pc PCHear(char *); size_pc PCRawWrite(char *); size_pc PCRawRead(char *); private: size_pc Write(char *); size_pc Read(char *); void resetCall(); void countCall(); int callCount; char callBuf[256]; struct timeval *timeOut; fd_set *FDSet; int retVal; struct termios *oldtio; struct termios *newtio; int fd; char pcrDevice[256]; tcflag_t pcrSpeed; bool errRead; bool errWrite; char askBuf[256]; char hearBuf[256]; char writeBuf[256]; char readBuf[256]; char int_name[256]; size_pc writeCtr; size_pc readCtr; size_pc askCtr; size_pc tellCtr; size_pc hearCtr; }; #endif /* PCOMM_H_ */