Skip to content

Commit

Permalink
bugfix: changing serial status did not check if the port was available
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Oct 30, 2024
1 parent 06ead89 commit 85dae22
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/osdep/amiberry_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,29 @@ void serial_hsynchandler (void)
}
}

void setserstat(int mask, int onoff)
{
if (mask & SP_FLOWCONTROL_DTRDSR)
{
if (currprefs.use_serial && port != nullptr)
{
check(sp_set_flowcontrol(port, onoff ? SP_FLOWCONTROL_DTRDSR : SP_FLOWCONTROL_NONE));
check(sp_set_dtr(port, onoff ? SP_DTR_ON : SP_DTR_OFF));
}
}
if (!currprefs.serial_hwctsrts)
{
if (mask & SP_FLOWCONTROL_RTSCTS)
{
if (currprefs.use_serial && port != nullptr)
{
check(sp_set_flowcontrol(port, onoff ? SP_FLOWCONTROL_RTSCTS : SP_FLOWCONTROL_NONE));
check(sp_set_rts(port, onoff ? SP_RTS_ON : SP_RTS_OFF));
}
}
}
}

int setbaud(int baud, int org_baud)
{
#ifdef WITH_MIDI
Expand Down Expand Up @@ -1401,7 +1424,7 @@ void serial_dtr_on(void)
#ifdef SERIAL_PORT
if (currprefs.serial_demand)
serial_open();
check(sp_set_flowcontrol(port, SP_FLOWCONTROL_DTRDSR));
setserstat(SP_FLOWCONTROL_DTRDSR, dtr);
#endif
}

Expand All @@ -1419,7 +1442,7 @@ void serial_dtr_off(void)
#ifdef SERIAL_PORT
if (currprefs.serial_demand)
serial_close();
check(sp_set_flowcontrol(port, SP_FLOWCONTROL_NONE));
setserstat(SP_FLOWCONTROL_DTRDSR, dtr);
#endif
}

Expand Down Expand Up @@ -1586,12 +1609,12 @@ uae_u8 serial_writestatus(uae_u8 newstate, uae_u8 dir)
if (!currprefs.serial_hwctsrts && currprefs.serial_rtsctsdtrdtecd && (dir & 0x40)) {
if ((oldserbits ^ newstate) & 0x40) {
if (newstate & 0x40) {
check(sp_set_flowcontrol(port, SP_FLOWCONTROL_NONE));
setserstat(SP_FLOWCONTROL_RTSCTS, 0);
#if SERIALHSDEBUG > 0
write_log(_T("SERIAL: RTS cleared\n"));
#endif
} else {
check(sp_set_flowcontrol(port, SP_FLOWCONTROL_RTSCTS));
setserstat(SP_FLOWCONTROL_RTSCTS, 1);
#if SERIALHSDEBUG > 0
write_log(_T("SERIAL: RTS set\n"));
#endif
Expand Down

0 comments on commit 85dae22

Please sign in to comment.