/* * Serial.h & Serial.cpp - (C) 2007 by Torben H. Nielsen * * A wrapper class for communicating with a serial port */ #pragma once #include typedef std::vector UCVector; class CSerial { HANDLE mComport; DCB mDcbRestore; CString mPortstr; int mBitrate; bool mIsopen; protected: void printByte(char* description, unsigned char byte); public: CSerial(); CSerial(char* port, int bitrate); ~CSerial(void); void close(); void open(char* port, int bitrate); unsigned char readByte(); void writeByte(unsigned char out); COMSTAT getComstat() const; int bytesReady() const; int outQueueSize() const; CString getPort() const {return mPortstr;} int getBitrate() const {return mBitrate;} bool isOpen() { return mIsopen; } //void writeBytes(UCVector out); //UCVector readBytes(int maxcount); protected: void open(); };