Skip to content

Commit fa19ced

Browse files
committed
Work around lack of polymoprhism
1 parent 61a24f1 commit fa19ced

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/bus/sio/sio.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void systemBus::_sio_process_cmd()
224224

225225
// Wait for CMD line to raise again
226226
#ifdef ESP_PLATFORM
227-
while (_port->commandAsserted())
227+
while (commandAsserted())
228228
fnSystem.yield();
229229
#else
230230
int i = 0;
@@ -660,8 +660,12 @@ void systemBus::setBaudrate(int baud)
660660

661661
Debug_printf("Changing baudrate from %d to %d\n", _sioBaud, baud);
662662
_sioBaud = baud;
663-
RS232ChannelProtocol *rs232 = dynamic_cast<RS232ChannelProtocol*>(_port);
664-
rs232->setBaudrate(_sioBaud);
663+
664+
// Yah this looks stupid but C++ doesn't do true polymorphism
665+
if (isBoIP())
666+
_netsio.setBaudrate(_sioBaud);
667+
else
668+
_serial.setBaudrate(_sioBaud);
665669
}
666670

667671
// Set HSIO index. Sets high speed SIO baud and also returns that value.
@@ -860,7 +864,7 @@ bool systemBus::motor_asserted()
860864
bool systemBus::commandAsserted()
861865
{
862866
#ifdef ESP_PLATFORM
863-
return fnSystem.digital_read(_command_pin) == DIGI_LOW;
867+
return fnSystem.digital_read(_commandPin) == DIGI_LOW;
864868
#else /* ! ESP_PLATFORM */
865869
if (_port == &_netsio)
866870
return _netsio.commandAsserted();

0 commit comments

Comments
 (0)