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 "FileOperations.hh"
8 #include "Semaphore.hh"
9 #include "openmsx.hh"
10 #include "circular_buffer.hh"
11 #include <fstream>
12 #include <cstdio>
13 #include <memory>
14 
15 namespace openmsx {
16 
17 class EventDistributor;
18 class Scheduler;
19 class CommandController;
20 class FilenameSetting;
21 
22 class RS232Tester : public RS232Device, private Runnable, private EventListener
23 {
24 public:
25  RS232Tester(EventDistributor& eventDistributor, Scheduler& scheduler,
27  virtual ~RS232Tester();
28 
29  // Pluggable
30  virtual void plugHelper(Connector& connector, EmuTime::param time);
31  virtual void unplugHelper(EmuTime::param time);
32  virtual const std::string& getName() const;
33  virtual string_ref getDescription() const;
34 
35  // input
36  virtual void signal(EmuTime::param time);
37 
38  // output
39  virtual void recvByte(byte value, EmuTime::param time);
40 
41  template<typename Archive>
42  void serialize(Archive& ar, unsigned version);
43 
44 private:
45  // Runnable
46  virtual void run();
47 
48  // EventListener
49  virtual int signalEvent(const std::shared_ptr<const Event>& event);
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  const std::unique_ptr<FilenameSetting> rs232InputFilenameSetting;
61  const std::unique_ptr<FilenameSetting> rs232OutputFilenameSetting;
62 };
63 
64 } // namespace openmsx
65 
66 #endif
Represents something you can plug devices into.
Definition: Connector.hh:21
RS232Tester(EventDistributor &eventDistributor, Scheduler &scheduler, CommandController &commandController)
Definition: RS232Tester.cc:13
unsigned char byte
8 bit unsigned integer
Definition: openmsx.hh:33
virtual void signal(EmuTime::param time)
Definition: RS232Tester.cc:108
virtual string_ref getDescription() const
Description for this pluggable.
Definition: RS232Tester.cc:81
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
virtual ~RS232Tester()
Definition: RS232Tester.cc:30
virtual void recvByte(byte value, EmuTime::param time)
Definition: RS232Tester.cc:137
virtual const std::string & getName() const
Name used to identify this pluggable.
Definition: RS232Tester.cc:75
void serialize(Archive &ar, unsigned version)
Definition: RS232Tester.cc:147
commandController(commandController_)
virtual void unplugHelper(EmuTime::param time)
Definition: RS232Tester.cc:64
virtual void plugHelper(Connector &connector, EmuTime::param time)
Definition: RS232Tester.cc:36
std::unique_ptr< FILE, FClose > FILE_t