USB Serial - differences between WIFI and MINIMA

To follow up on a question I was asking myself in the closed issue.
Does Serial.baud() work as I would expect on the MINIMA and return the current baud rate that the host is set to. So did a quick and dirty sketch:

void setup() {
  while (!Serial) ;
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
}

uint8_t loop_count = 0;
uint32_t last_baud = 0;
void loop() {
  digitalWrite(LED_BUILTIN, (++loop_count & 1)? HIGH : LOW);

  if (last_baud != Serial.baud()) {
    last_baud = Serial.baud();
    Serial.print("New Baud:");
    Serial.println(last_baud, DEC);
  }

  delay(500);
}

And yes it appears to work:

New Baud:31250
New Baud:115200
New Baud:9600

Which implies I could use one of these boards as a simple USB To Serial Adapter, i.e. in a similar way I might use an FTDI cable. Could probably even flash on old UNO.

As I implied in the first post, this sketch does not compile on the WIFI.

"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" -c -Wall -Wextra -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -MMD -nostdlib -DF_CPU=48000000 -DNO_USB -DBACKTRACE_SUPPORT -DARDUINO_UNOR4_WIFI -MMD -std=gnu++17 -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -DARDUINO=10607 "-DPROJECT_NAME=\"C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\E3B24E659668E10C130DFE1EDEF6C45C/USB_Serial_Test_change_baud.ino\"" -DARDUINO_UNOWIFIR4 -DARDUINO_ARCH_RENESAS_UNO -DARDUINO_ARCH_RENESAS -DARDUINO_FSP -D_XOPEN_SOURCE -mthumb "@C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\variants\\UNOWIFIR4/defines.txt" -DCFG_TUSB_MCU=OPT_MCU_RAXXX "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2/cores/arduino/tinyusb" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\cores\\arduino/api/deprecated" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\cores\\arduino/api/deprecated-avr-comp" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\cores\\arduino" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\variants\\UNOWIFIR4" "-iprefixC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2" "@C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.0.2\\variants\\UNOWIFIR4/includes.txt" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\E3B24E659668E10C130DFE1EDEF6C45C\\sketch\\USB_Serial_Test_change_baud.ino.cpp" -o "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\E3B24E659668E10C130DFE1EDEF6C45C\\sketch\\USB_Serial_Test_change_baud.ino.cpp.o"
C:\Users\kurte\Documents\Arduino\R4-Uno-wifi\USB_Serial_Test_change_baud\USB_Serial_Test_change_baud.ino: In function 'void loop()':
C:\Users\kurte\Documents\Arduino\R4-Uno-wifi\USB_Serial_Test_change_baud\USB_Serial_Test_change_baud.ino:12:27: error: 'class UART' has no member named 'baud'
   if (last_baud != Serial.baud()) {
                           ^~~~
C:\Users\kurte\Documents\Arduino\R4-Uno-wifi\USB_Serial_Test_change_baud\USB_Serial_Test_change_baud.ino:13:24: error: 'class UART' has no member named 'baud'
     last_baud = Serial.baud();
                        ^~~~

exit status 1
1 Like