openMSX
RS232Tester.hh
Go to the documentation of this file.
1 #ifndef RS232TESTER_HH
2 #define RS232TESTER_HH
3 
4 #include "RS232Device.hh"
5 #include "Thread.hh"
6 #include "EventListener.hh"
7 #include "FilenameSetting.hh"
8 #include "FileOperations.hh"
9 #include "Semaphore.hh"
10 #include "openmsx.hh"
11 #include "circular_buffer.hh"
12 #include <fstream>
13 #include <cstdio>
14 
15 namespace openmsx {
16 
17 class EventDistributor;
18 class Scheduler;
19 class CommandController;
20 
21 class RS232Tester final : public RS232Device, private Runnable
22  , private EventListener
23 {
24 public:
25  RS232Tester(EventDistributor& eventDistributor, Scheduler& scheduler,
26  CommandController& commandController);
27  ~RS232Tester();
28 
29  // Pluggable
30  void plugHelper(Connector& connector, EmuTime::param time) override;
31  void unplugHelper(EmuTime::param time) override;
32  const std::string& getName() const override;
33  string_ref getDescription() const override;
34 
35  // input
36  void signal(EmuTime::param time) override;
37 
38  // output
39  void recvByte(byte value, EmuTime::param time) override;
40 
41  template<typename Archive>
42  void serialize(Archive& ar, unsigned version);
43 
44 private:
45  // Runnable
46  void run() override;
47 
48  // EventListener
49  int signalEvent(const std::shared_ptr<const Event>& event) override;
50 
51  EventDistributor& eventDistributor;
52  Scheduler& scheduler;
53  Thread thread;
55  cb_queue<byte> queue;
56  Semaphore lock; // to protect queue
57 
58  std::ofstream outFile;
59 
60  FilenameSetting rs232InputFilenameSetting;
61  FilenameSetting rs232OutputFilenameSetting;
62 };
63 
64 } // namespace openmsx
65 
66 #endif
string_ref getDescription() const override
Description for this pluggable.
Definition: RS232Tester.cc:79
Represents something you can plug devices into.
Definition: Connector.hh:21
RS232Tester(EventDistributor &eventDistributor, Scheduler &scheduler, CommandController &commandController)
Definition: RS232Tester.cc:11
unsigned char byte
8 bit unsigned integer
Definition: openmsx.hh:27
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
const std::string & getName() const override
Name used to identify this pluggable.
Definition: RS232Tester.cc:73
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void plugHelper(Connector &connector, EmuTime::param time) override
Definition: RS232Tester.cc:34
void serialize(Archive &ar, unsigned version)
Definition: RS232Tester.cc:145
void recvByte(byte value, EmuTime::param time) override
Definition: RS232Tester.cc:135
void unplugHelper(EmuTime::param time) override
Definition: RS232Tester.cc:62
void signal(EmuTime::param time) override
Definition: RS232Tester.cc:106
std::unique_ptr< FILE, FClose > FILE_t