| 1 | /* |
| 2 | * Copyright (C) 2002-2010 The DOSBox Team |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | /* $Id: serialdummy.cpp,v 1.5 2009-05-27 09:15:41 qbix79 Exp $ */ |
| 20 | |
| 21 | #include "dosbox.h" |
| 22 | |
| 23 | #include "setup.h" |
| 24 | #include "serialdummy.h" |
| 25 | #include "serialport.h" |
| 26 | |
| 27 | CSerialDummy::CSerialDummy(Bitu id, CommandLine* cmd):CSerial(id, cmd) { |
| 28 | CSerial::Init_Registers(); |
| 29 | setRI(false); |
| 30 | setDSR(false); |
| 31 | setCD(false); |
| 32 | setCTS(false); |
| 33 | InstallationSuccessful=true; |
| 34 | } |
| 35 | |
| 36 | CSerialDummy::~CSerialDummy() { |
| 37 | // clear events |
| 38 | removeEvent(SERIAL_TX_EVENT); |
| 39 | } |
| 40 | |
| 41 | void CSerialDummy::handleUpperEvent(Bit16u type) { |
| 42 | if(type==SERIAL_TX_EVENT) { |
| 43 | //LOG_MSG("SERIAL_TX_EVENT"); |
| 44 | #ifdef CHECKIT_TESTPLUG |
| 45 | receiveByte(loopbackdata); |
| 46 | #endif |
| 47 | ByteTransmitted(); // tx timeout |
| 48 | } |
| 49 | else if(type==SERIAL_THR_EVENT){ |
| 50 | //LOG_MSG("SERIAL_THR_EVENT"); |
| 51 | ByteTransmitting(); |
| 52 | setEvent(SERIAL_TX_EVENT,bytetime); |
| 53 | } |
| 54 | |
| 55 | } |
| 56 | |
| 57 | /*****************************************************************************/ |
| 58 | /* updatePortConfig is called when emulated app changes the serial port **/ |
| 59 | /* parameters baudrate, stopbits, number of databits, parity. **/ |
| 60 | /*****************************************************************************/ |
| 61 | void CSerialDummy::updatePortConfig(Bit16u divider, Bit8u lcr) { |
| 62 | //LOG_MSG("Serial port at 0x%x: Port params changed: %d Baud", base,dcb.BaudRate); |
| 63 | } |
| 64 | |
| 65 | void CSerialDummy::updateMSR() { |
| 66 | } |
| 67 | void CSerialDummy::transmitByte(Bit8u val, bool first) { |
| 68 | |
| 69 | if(first) setEvent(SERIAL_THR_EVENT, bytetime/10); |
| 70 | else setEvent(SERIAL_TX_EVENT, bytetime); |
| 71 | |
| 72 | #ifdef CHECKIT_TESTPLUG |
| 73 | loopbackdata=val; |
| 74 | #endif |
| 75 | } |
| 76 | |
| 77 | /*****************************************************************************/ |
| 78 | /* setBreak(val) switches break on or off **/ |
| 79 | /*****************************************************************************/ |
| 80 | |
| 81 | void CSerialDummy::setBreak(bool value) { |
| 82 | //LOG_MSG("UART 0x%x: Break toggeled: %d", base, value); |
| 83 | } |
| 84 | |
| 85 | /*****************************************************************************/ |
| 86 | /* setRTSDTR sets the modem control lines **/ |
| 87 | /*****************************************************************************/ |
| 88 | void CSerialDummy::setRTSDTR(bool rts, bool dtr) { |
| 89 | setRTS(rts); |
| 90 | setDTR(dtr); |
| 91 | } |
| 92 | void CSerialDummy::setRTS(bool val) { |
| 93 | #ifdef CHECKIT_TESTPLUG |
| 94 | setCTS(val); |
| 95 | #endif |
| 96 | } |
| 97 | void CSerialDummy::setDTR(bool val) { |
| 98 | #ifdef CHECKIT_TESTPLUG |
| 99 | setDSR(val); |
| 100 | setRI(val); |
| 101 | setCD(val); |
| 102 | #endif |
| 103 | } |