mirror of
https://github.com/autc04/Retro68.git
synced 2024-09-07 13:54:33 +00:00
65 lines
1.4 KiB
C++
65 lines
1.4 KiB
C++
#include "SerialConnectionProvider.h"
|
|
#include "MacSerialStream.h"
|
|
#include <ReliableStream.h>
|
|
#include "StatusDisplay.h"
|
|
|
|
struct SerialConnectionProvider::Streams
|
|
{
|
|
MacSerialStream serialStream;
|
|
ReliableStream reliableStream;
|
|
|
|
Streams(int port, int baud)
|
|
: serialStream(port, baud)
|
|
, reliableStream(&serialStream)
|
|
{
|
|
}
|
|
};
|
|
|
|
SerialConnectionProvider::SerialConnectionProvider(int port, int baud, StatusDisplay *statusDisplay)
|
|
: port(port), baud(baud), statusDisplay(statusDisplay)
|
|
{
|
|
resume();
|
|
}
|
|
|
|
SerialConnectionProvider::~SerialConnectionProvider()
|
|
{
|
|
|
|
}
|
|
|
|
Stream* SerialConnectionProvider::getStream()
|
|
{
|
|
return streams ? &streams->reliableStream : nullptr;
|
|
}
|
|
|
|
void SerialConnectionProvider::idle()
|
|
{
|
|
if(streams)
|
|
{
|
|
streams->reliableStream.setListener(listener);
|
|
streams->serialStream.idle();
|
|
if(statusDisplay)
|
|
statusDisplay->SetErrorCount(streams->reliableStream.getFailedReceiveCount()
|
|
+ streams->reliableStream.getFailedSendCount());
|
|
}
|
|
}
|
|
|
|
void SerialConnectionProvider::suspend()
|
|
{
|
|
streams.reset();
|
|
}
|
|
|
|
void SerialConnectionProvider::resume()
|
|
{
|
|
if(!streams)
|
|
streams = std::make_unique<Streams>(port, baud);
|
|
}
|
|
|
|
void SerialConnectionProvider::unloadSegDummy()
|
|
{
|
|
}
|
|
|
|
void *SerialConnectionProvider::segmentToUnload()
|
|
{
|
|
return (void*) &unloadSegDummy;
|
|
}
|