DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/hardware/serialport/serialdummy.cpp
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 "dosbox.h"
00021 
00022 #include "setup.h"
00023 #include "serialdummy.h"
00024 #include "serialport.h"
00025 
00026 CSerialDummy::CSerialDummy(Bitu id,     CommandLine* cmd):CSerial(id, cmd) {
00027         CSerial::Init_Registers();
00028         setRI(false);
00029         setDSR(false);
00030         setCD(false);
00031         setCTS(false);
00032         InstallationSuccessful=true;
00033 }
00034 
00035 CSerialDummy::~CSerialDummy() {
00036         // clear events
00037         removeEvent(SERIAL_TX_EVENT);
00038 }
00039 
00040 void CSerialDummy::handleUpperEvent(Bit16u type) {
00041         if(type==SERIAL_TX_EVENT) {
00042         //LOG_MSG("SERIAL_TX_EVENT");
00043 #ifdef CHECKIT_TESTPLUG
00044                 receiveByte(loopbackdata);
00045 #endif
00046                 ByteTransmitted(); // tx timeout
00047         }
00048         else if(type==SERIAL_THR_EVENT){
00049                 //LOG_MSG("SERIAL_THR_EVENT");
00050                 ByteTransmitting();
00051                 setEvent(SERIAL_TX_EVENT,bytetime);
00052         }
00053 
00054 }
00055 
00056 /*****************************************************************************/
00057 /* updatePortConfig is called when emulated app changes the serial port     **/
00058 /* parameters baudrate, stopbits, number of databits, parity.               **/
00059 /*****************************************************************************/
00060 void CSerialDummy::updatePortConfig(Bit16u divider, Bit8u lcr) {
00061     (void)divider;//UNUSED
00062     (void)lcr;//UNUSED
00063         //LOG_MSG("Serial port at 0x%x: Port params changed: %d Baud", base,dcb.BaudRate);
00064 }
00065 
00066 void CSerialDummy::updateMSR() {
00067 }
00068 void CSerialDummy::transmitByte(Bit8u val, bool first) {
00069     (void)val;//POSSIBLY UNUSED
00070         if(first) setEvent(SERIAL_THR_EVENT, bytetime/10); 
00071         else setEvent(SERIAL_TX_EVENT, bytetime);
00072 
00073 #ifdef CHECKIT_TESTPLUG
00074         loopbackdata=val;
00075 #endif
00076 }
00077 
00078 /*****************************************************************************/
00079 /* setBreak(val) switches break on or off                                   **/
00080 /*****************************************************************************/
00081 
00082 void CSerialDummy::setBreak(bool value) {
00083     (void)value;//UNUSED
00084         //LOG_MSG("UART 0x%x: Break toggeled: %d", base, value);
00085 }
00086 
00087 /*****************************************************************************/
00088 /* setRTSDTR sets the modem control lines                                   **/
00089 /*****************************************************************************/
00090 void CSerialDummy::setRTSDTR(bool rts, bool dtr) {
00091         setRTS(rts);
00092         setDTR(dtr);
00093 }
00094 void CSerialDummy::setRTS(bool val) {
00095     (void)val;//UNUSED
00096 #ifdef CHECKIT_TESTPLUG
00097         setCTS(val);
00098 #endif
00099 }
00100 void CSerialDummy::setDTR(bool val) {
00101     (void)val;//UNUSED
00102 #ifdef CHECKIT_TESTPLUG
00103         setDSR(val);
00104         setRI(val);
00105         setCD(val);
00106 #endif
00107 }