Add SerialPort::isCTS() to all ports, and connect it to AtariVox.

This commit is contained in:
Stephen Anthony 2020-07-30 17:50:34 -02:30
parent 6d7ead1660
commit cd06ae69eb
9 changed files with 68 additions and 2 deletions

View File

@ -50,10 +50,11 @@ bool AtariVox::read(DigitalPin pin)
switch(pin) switch(pin)
{ {
// Pin 2: SpeakJet READY // Pin 2: SpeakJet READY
// CTS enabled means the SpeakJet can accept more data // CTS (Clear To Send) is connected inverted
// So CTS = 0 means the buffer is full, which pulls pin 2 high
case DigitalPin::Two: case DigitalPin::Two:
{ {
return setPin(pin, mySerialPort->isCTS()); return setPin(pin, !mySerialPort->isCTS());
} }
default: default:

View File

@ -73,3 +73,15 @@ bool SerialPortMACOS::writeByte(uInt8 data)
} }
return false; return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SerialPortMACOS::isCTS()
{
if(myHandle)
{
int status = 0;
ioctl(myHandle, TIOCMGET, &status);
return status & TIOCM_CTS;
}
return false;
}

View File

@ -48,6 +48,13 @@ class SerialPortMACOS : public SerialPort
*/ */
bool writeByte(uInt8 data) override; bool writeByte(uInt8 data) override;
/**
Test for 'Clear To Send' enabled.
@return True if CTS signal enabled, else false
*/
bool isCTS() override;
private: private:
// File descriptor for serial connection // File descriptor for serial connection
int myHandle{0}; int myHandle{0};

View File

@ -49,6 +49,9 @@ bool SerialPortUNIX::openPort(const string& device)
if(myHandle <= 0) if(myHandle <= 0)
return false; return false;
// Open the device in nonblocking mode
fcntl(myHandle, F_SETFL, FNDELAY);
struct termios termios; struct termios termios;
memset(&termios, 0, sizeof(struct termios)); memset(&termios, 0, sizeof(struct termios));
@ -71,3 +74,15 @@ bool SerialPortUNIX::writeByte(uInt8 data)
} }
return false; return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SerialPortUNIX::isCTS()
{
if(myHandle)
{
int status = 0;
ioctl(myHandle, TIOCMGET, &status);
return status & TIOCM_CTS;
}
return false;
}

View File

@ -48,6 +48,13 @@ class SerialPortUNIX : public SerialPort
*/ */
bool writeByte(uInt8 data) override; bool writeByte(uInt8 data) override;
/**
Test for 'Clear To Send' enabled.
@return True if CTS signal enabled, else false
*/
bool isCTS() override;
private: private:
// File descriptor for serial connection // File descriptor for serial connection
int myHandle{0}; int myHandle{0};

View File

@ -79,3 +79,15 @@ bool SerialPortWINDOWS::writeByte(uInt8 data)
} }
return false; return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SerialPortWINDOWS::isCTS()
{
if(myHandle)
{
DWORD modemStat;
GetCommModemStatus(myHandle, &modemStat);
return modemStat & MS_CTS_ON;
}
return false;
}

View File

@ -47,6 +47,14 @@ class SerialPortWINDOWS : public SerialPort
*/ */
bool writeByte(uInt8 data) override; bool writeByte(uInt8 data) override;
/**
Test for 'Clear To Send' enabled. By default, assume it's always
OK to send more data.
@return True if CTS signal enabled, else false
*/
bool isCTS() override;
private: private:
// Handle to serial port // Handle to serial port
HANDLE myHandle{0}; HANDLE myHandle{0};

View File

@ -1774,6 +1774,7 @@
<ClInclude Include="..\emucore\MindLink.hxx" /> <ClInclude Include="..\emucore\MindLink.hxx" />
<ClInclude Include="..\emucore\PointingDevice.hxx" /> <ClInclude Include="..\emucore\PointingDevice.hxx" />
<ClInclude Include="..\emucore\ProfilingRunner.hxx" /> <ClInclude Include="..\emucore\ProfilingRunner.hxx" />
<ClInclude Include="..\emucore\SerialPort.hxx" />
<ClInclude Include="..\emucore\TIASurface.hxx" /> <ClInclude Include="..\emucore\TIASurface.hxx" />
<ClInclude Include="..\emucore\tia\Audio.hxx" /> <ClInclude Include="..\emucore\tia\Audio.hxx" />
<ClInclude Include="..\emucore\tia\AudioChannel.hxx" /> <ClInclude Include="..\emucore\tia\AudioChannel.hxx" />

View File

@ -2087,6 +2087,9 @@
<ClInclude Include="..\gui\WhatsNewDialog.hxx"> <ClInclude Include="..\gui\WhatsNewDialog.hxx">
<Filter>Header Files\gui</Filter> <Filter>Header Files\gui</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\emucore\SerialPort.hxx">
<Filter>Header Files\emucore</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="stella.ico"> <None Include="stella.ico">