DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/hardware/serialport/directserial.h
00001 /*
00002  *  Copyright (C) 2002-2020  The DOSBox Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License along
00015  *  with this program; if not, write to the Free Software Foundation, Inc.,
00016  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 
00020 // include guard
00021 #ifndef DOSBOX_DIRECTSERIAL_WIN32_H
00022 #define DOSBOX_DIRECTSERIAL_WIN32_H
00023 
00024 #include "dosbox.h"
00025 
00026 #if C_DIRECTSERIAL
00027 
00028 #define DIRECTSERIAL_AVAILIBLE
00029 #include "serialport.h"
00030 
00031 #include "libserial.h"
00032 
00033 class CDirectSerial : public CSerial {
00034 public:
00035         CDirectSerial(Bitu id, CommandLine* cmd);
00036         ~CDirectSerial();
00037 
00038         void updatePortConfig(Bit16u divider, Bit8u lcr);
00039         void updateMSR();
00040         void transmitByte(Bit8u val, bool first);
00041         void setBreak(bool value);
00042         
00043         void setRTSDTR(bool rts, bool dtr);
00044         void setRTS(bool val);
00045         void setDTR(bool val);
00046         void handleUpperEvent(Bit16u type);
00047 
00048 private:
00049         COMPORT comport;
00050 
00051         Bitu rx_state = 0;
00052 #define D_RX_IDLE               0
00053 #define D_RX_WAIT               1
00054 #define D_RX_BLOCKED    2
00055 #define D_RX_FASTWAIT   3
00056 
00057         Bitu rx_retry;          // counter of retries (every millisecond)
00058         Bitu rx_retry_max;      // how many POLL_EVENTS to wait before causing
00059                                                 // an overrun error.
00060         bool doReceive();
00061 
00062 #if SERIAL_DEBUG
00063         bool dbgmsg_poll_block = false;
00064         bool dbgmsg_rx_block = false;
00065 #endif
00066 
00067 };
00068 
00069 #endif  // C_DIRECTSERIAL
00070 #endif  // include guard