| 1 | //============================================================================ |
| 2 | // |
| 3 | // SSSS tt lll lll |
| 4 | // SS SS tt ll ll |
| 5 | // SS tttttt eeee ll ll aaaa |
| 6 | // SSSS tt ee ee ll ll aa |
| 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" |
| 8 | // SS SS tt ee ll ll aa aa |
| 9 | // SSSS ttt eeeee llll llll aaaaa |
| 10 | // |
| 11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony |
| 12 | // and the Stella Team |
| 13 | // |
| 14 | // See the file "License.txt" for information on usage and redistribution of |
| 15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 16 | //============================================================================ |
| 17 | |
| 18 | #ifndef SERIALPORT_UNIX_HXX |
| 19 | #define SERIALPORT_UNIX_HXX |
| 20 | |
| 21 | #include "SerialPort.hxx" |
| 22 | |
| 23 | /** |
| 24 | Implement reading and writing from a serial port under UNIX. For now, |
| 25 | it seems to be Linux-only, and reading isn't actually supported at all. |
| 26 | |
| 27 | @author Stephen Anthony |
| 28 | */ |
| 29 | class SerialPortUNIX : public SerialPort |
| 30 | { |
| 31 | public: |
| 32 | SerialPortUNIX(); |
| 33 | virtual ~SerialPortUNIX(); |
| 34 | |
| 35 | /** |
| 36 | Open the given serial port with the specified attributes. |
| 37 | |
| 38 | @param device The name of the port |
| 39 | @return False on any errors, else true |
| 40 | */ |
| 41 | bool openPort(const string& device) override; |
| 42 | |
| 43 | /** |
| 44 | Close a previously opened serial port. |
| 45 | */ |
| 46 | void closePort() override; |
| 47 | |
| 48 | /** |
| 49 | Write a byte to the serial port. |
| 50 | |
| 51 | @param data The byte to write to the port |
| 52 | @return True if a byte was written, else false |
| 53 | */ |
| 54 | bool writeByte(uInt8 data) override; |
| 55 | |
| 56 | private: |
| 57 | // File descriptor for serial connection |
| 58 | int myHandle; |
| 59 | |
| 60 | private: |
| 61 | // Following constructors and assignment operators not supported |
| 62 | SerialPortUNIX(const SerialPortUNIX&) = delete; |
| 63 | SerialPortUNIX(SerialPortUNIX&&) = delete; |
| 64 | SerialPortUNIX& operator=(const SerialPortUNIX&) = delete; |
| 65 | SerialPortUNIX& operator=(SerialPortUNIX&&) = delete; |
| 66 | }; |
| 67 | |
| 68 | #endif |
| 69 | |