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 "EventListener.hh"
6#include "FilenameSetting.hh"
7#include "FileOperations.hh"
8#include "circular_buffer.hh"
9#include "Poller.hh"
10#include <fstream>
11#include <mutex>
12#include <thread>
13#include <cstdint>
14#include <cstdio>
15
16namespace openmsx {
17
18class EventDistributor;
19class Scheduler;
20class CommandController;
21
22class RS232Tester final : public RS232Device, private EventListener
23{
24public:
25 RS232Tester(EventDistributor& eventDistributor, Scheduler& scheduler,
26 CommandController& commandController);
27 ~RS232Tester() override;
28
29 // Pluggable
30 void plugHelper(Connector& connector, EmuTime::param time) override;
31 void unplugHelper(EmuTime::param time) override;
32 [[nodiscard]] std::string_view getName() const override;
33 [[nodiscard]] std::string_view getDescription() const override;
34 [[nodiscard]] std::optional<bool> getDSR(EmuTime::param time) const override;
35 [[nodiscard]] std::optional<bool> getCTS(EmuTime::param time) const override;
36
37 // input
38 void signal(EmuTime::param time) override;
39
40 // output
41 void recvByte(uint8_t value, EmuTime::param time) override;
42
43 template<typename Archive>
44 void serialize(Archive& ar, unsigned version);
45
46private:
47 void run();
48
49 // EventListener
50 int signalEvent(const Event& event) override;
51
52private:
53 EventDistributor& eventDistributor;
54 Scheduler& scheduler;
55 std::thread thread;
58 std::mutex mutex; // to protect queue
59 Poller poller;
60
61 std::ofstream outFile;
62
63 FilenameSetting rs232InputFilenameSetting;
64 FilenameSetting rs232OutputFilenameSetting;
65};
66
67} // namespace openmsx
68
69#endif
This implements a queue on top of circular_buffer (not part of boost).
Represents something you can plug devices into.
Definition Connector.hh:21
Polls for events on a given file descriptor.
Definition Poller.hh:15
void plugHelper(Connector &connector, EmuTime::param time) override
std::string_view getName() const override
Name used to identify this pluggable.
std::optional< bool > getCTS(EmuTime::param time) const override
void signal(EmuTime::param time) override
~RS232Tester() override
void serialize(Archive &ar, unsigned version)
void unplugHelper(EmuTime::param time) override
std::optional< bool > getDSR(EmuTime::param time) const override
void recvByte(uint8_t value, EmuTime::param time) override
std::string_view getDescription() const override
Description for this pluggable.
std::unique_ptr< FILE, FClose > FILE_t
This file implemented 3 utility functions:
Definition Autofire.cc:11
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:444