41. Abstract Communication Driver UART vs SPI

 Your task is to declare two pure virtual functions inside the base class CommDriver:

  • send(const string& data)
  • receive() → returns string

     

These functions will be implemented by derived classes UartDriver and SpiDriver. The program will read a driver type ("UART" or "SPI") and a message, create the correct driver, send the message, and then print what receive() returns.

Example
 Input:

UART Hello

Output:

UART SEND: Hello
UART RECV: Hello

 

Input:

SPI Ping

Output:

SPI SEND: Ping
SPI RECV: Ping

 

Loading...

Input

UART Hello

Expected Output

UART SEND: Hello UART RECV: Hello