Page 1 of 2

Trouble declaring hardware serial... And Serial3 not declared in this scope

Posted: Fri Oct 16, 2020 3:29 pm
by Mangy_Dog
Having a strange issue thats just cropped up since my last one... Im using all 3 uarts Serial1 Serial2 Serial3, Ive got a define for each debugSerial, doorSerial and audioSerial...

And ive just started getting Serial3 is not declared in this scope.
Im using the generic f103c core, usbdebug is removed from the stlink upload method in boards.txt... This is the main problem im having right now.

Secondary to this while trying to fix this by redeclaring my HardwareSerial, i cant figure out either the syntax or the naming structures...

So instead of defines im trying to do ;
HardwareSerial debugSerial(UART1);
or
HardwareSerial debugSerial(PA9,PA10);

and so on and so forth with the other serial...

Trying either of these give me failed compile errors.

UART1 = UART1 is not declared in this scope. I also Tried USART1 as that what was written when it was recommended to me...

and when using the pin numbers i get No matching function call.

So i guess the question is, What is the correct syntax for this and what else do i need to do?

Re: Trouble declaring hardware serial... And Serial3 not declared in this scope

Posted: Fri Oct 16, 2020 5:15 pm
by evgeniy32
I also have this problem. I use Serial1 and Serial3 in many sketches, but they don't work anymore after the update stm32duino on 1.9!!!
Please? Help!

Re: Trouble declaring hardware serial... And Serial3 not declared in this scope

Posted: Sat Oct 17, 2020 8:47 am
by stevestrong
Mangy_Dog wrote: Fri Oct 16, 2020 3:29 pm Im using the generic f103c core, usbdebug is removed from the stlink upload method in boards.txt...
I don't know whether the generic core is supported anymore.
Try to post on that github site where you downloaded the package from.

Or dou you use the Libmaple (Arduino_STM32) core?

Re: Trouble declaring hardware serial... And Serial3 not declared in this scope

Posted: Sat Oct 17, 2020 11:52 am
by Mangy_Dog
Sorry i mean Rogers Arduino_stm32 core, but the generic f103 option for the board...

Re: Trouble declaring hardware serial... And Serial3 not declared in this scope

Posted: Sat Oct 17, 2020 1:04 pm
by fpiSTM
evgeniy32 wrote: Fri Oct 16, 2020 5:15 pm I also have this problem. I use Serial1 and Serial3 in many sketches, but they don't work anymore after the update stm32duino on 1.9!!!
Please? Help!
There is no change related to this btw 1.8.0 and 1.9.0. Moreover you are not in the correct section if you used the STM32 core. Here it is for Libmaple (Arduino_STM32) core.

Re: Trouble declaring hardware serial... And Serial3 not declared in this scope

Posted: Sat Oct 17, 2020 1:14 pm
by stevestrong
I just tried a blinky sketch in Arduino with Serial3.print, compiles without errors/warnings.

Re: Trouble declaring hardware serial... And Serial3 not declared in this scope

Posted: Sat Oct 17, 2020 2:02 pm
by Mangy_Dog
it works when i select maple mini,
but not with Genericf103c

Code: Select all

Arduino: 1.8.13 (Windows 10), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), STLink, 72Mhz (Normal), Smallest (default)"
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Mangy_Dog\AppData\Local\Arduino15\packages -hardware F:\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Mangy_Dog\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries F:\Arduino\libraries -fqbn=Arduino_STM32:STM32F1:genericSTM32F103C:device_variant=STM32F103C8,upload_method=STLinkMethod,cpu_speed=speed_72mhz,opt=osstd -ide-version=10813 -build-path C:\Users\MANGY_~1\AppData\Local\Temp\arduino_build_127486 -warnings=all -build-cache C:\Users\MANGY_~1\AppData\Local\Temp\arduino_cache_125681 -prefs=build.warn_data_percentage=75 -verbose C:\Users\MANGY_~1\AppData\Local\Temp\arduino_modified_sketch_15196\Blink.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Mangy_Dog\AppData\Local\Arduino15\packages -hardware F:\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Mangy_Dog\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries F:\Arduino\libraries -fqbn=Arduino_STM32:STM32F1:genericSTM32F103C:device_variant=STM32F103C8,upload_method=STLinkMethod,cpu_speed=speed_72mhz,opt=osstd -ide-version=10813 -build-path C:\Users\MANGY_~1\AppData\Local\Temp\arduino_build_127486 -warnings=all -build-cache C:\Users\MANGY_~1\AppData\Local\Temp\arduino_cache_125681 -prefs=build.warn_data_percentage=75 -verbose C:\Users\MANGY_~1\AppData\Local\Temp\arduino_modified_sketch_15196\Blink.ino

Using board 'genericSTM32F103C' from platform in folder: F:\Arduino\hardware\Arduino_STM32\STM32F1

Using core 'maple' from platform in folder: F:\Arduino\hardware\Arduino_STM32\STM32F1

Detecting libraries used...

"C:\\Users\\Mangy_Dog\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8000000 -DERROR_LED_PORT=GPIOC -DERROR_LED_PIN=13 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10813 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/include" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/stm32f1/include" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/usb/stm32f1" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/usb/usb_lib" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\cores\\maple" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\variants\\generic_stm32f103c" "C:\\Users\\MANGY_~1\\AppData\\Local\\Temp\\arduino_build_127486\\sketch\\Blink.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE

Generating function prototypes...

"C:\\Users\\Mangy_Dog\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8000000 -DERROR_LED_PORT=GPIOC -DERROR_LED_PIN=13 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10813 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/include" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/stm32f1/include" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/usb/stm32f1" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/usb/usb_lib" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\cores\\maple" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\variants\\generic_stm32f103c" "C:\\Users\\MANGY_~1\\AppData\\Local\\Temp\\arduino_build_127486\\sketch\\Blink.ino.cpp" -o "C:\\Users\\MANGY_~1\\AppData\\Local\\Temp\\arduino_build_127486\\preproc\\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\MANGY_~1\\AppData\\Local\\Temp\\arduino_build_127486\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Users\\Mangy_Dog\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" -c -g -Os -Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL -std=gnu++11 -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8000000 -DERROR_LED_PORT=GPIOC -DERROR_LED_PIN=13 -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10813 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/include" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/stm32f1/include" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/usb/stm32f1" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\system/libmaple/usb/usb_lib" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\cores\\maple" "-IF:\\Arduino\\hardware\\Arduino_STM32\\STM32F1\\variants\\generic_stm32f103c" "C:\\Users\\MANGY_~1\\AppData\\Local\\Temp\\arduino_build_127486\\sketch\\Blink.ino.cpp" -o "C:\\Users\\MANGY_~1\\AppData\\Local\\Temp\\arduino_build_127486\\sketch\\Blink.ino.cpp.o"

In file included from F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/wirish.h:69:0,

                 from F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/Arduino.h:30,

                 from C:\Users\MANGY_~1\AppData\Local\Temp\arduino_build_127486\sketch\Blink.ino.cpp:1:

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:204:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

  #if BOARD_HAVE_USART1

 ^~~~~~~~~~~~~~~~~~~

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:204:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:207:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

  #if BOARD_HAVE_USART2

 ^~~~~~~~~~~~~~~~~~~

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:207:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:210:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

  #if BOARD_HAVE_USART3

 ^~~~~~~~~~~~~~~~~~~

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:210:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:213:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

  #if BOARD_HAVE_UART4

 ^~~~~~~~~~~~~~~~~~~

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:213:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:216:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

  #if BOARD_HAVE_UART5

 ^~~~~~~~~~~~~~~~~~~

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:216:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:219:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

  #if BOARD_HAVE_USART6

 ^~~~~~~~~~~~~~~~~~~

F:\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/HardwareSerial.h:219:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]

C:\Users\MANGY_~1\AppData\Local\Temp\arduino_modified_sketch_15196\Blink.ino: In function 'void setup()':

Blink:29:3: error: 'Serial3' was not declared in this scope

   Serial3.begin(9600);

   ^~~~~~~

C:\Users\MANGY_~1\AppData\Local\Temp\arduino_modified_sketch_15196\Blink.ino:29:3: note: suggested alternative: 'Serial2'

   Serial3.begin(9600);

   ^~~~~~~

   Serial2

exit status 1

'Serial3' was not declared in this scope

this from blink, adding Serial3.begin(9600);

Could it be some thing I did when disabling jtag and remapping the pins in board.txt to get the jtag pins working cause this?

Re: Trouble declaring hardware serial... And Serial3 not declared in this scope

Posted: Sat Oct 17, 2020 2:21 pm
by stevestrong
I think it has to do with GCC v>=7, see here: https://bugs.webkit.org/show_bug.cgi?id=167643
You have to insert as extra compile flag (maybe to build.common_flags):

Code: Select all

-Wno-expansion-to-defined
in platform.txt.

Re: Trouble declaring hardware serial... And Serial3 not declared in this scope

Posted: Sat Oct 17, 2020 7:39 pm
by Mangy_Dog
Didnt work :/

Its literally only stopped working since the whole jtag disabling stuff... Weather i screwed up a IO map or changes a variable somewhere...

I think im going to have to download rogers core again refresh teh files and change things one by one till i find what broke it :/

Re: Trouble declaring hardware serial... And Serial3 not declared in this scope

Posted: Sun Oct 18, 2020 12:17 pm
by Mangy_Dog
Ok put a fresh download of rogers core in without edits. Serial3 works on its own again....
But im still not getting the syntax right on declaring the serial hardware myself...

Code: Select all

HardwareSerial debugSerial(PA9,PA10);
HardwareSerial doorSerial(PA3,PA2);
HardwareSerial audioSerial(PB11,PB10);

HardwareSerial debugSerial(USART1);
HardwareSerial doorSerial(USART2);
HardwareSerial audioSerial(USART3);

HardwareSerial debugSerial(UART1);
HardwareSerial doorSerial(UART2);
HardwareSerial audioSerial(UART3);

HardwareSerial debugSerial(USART1,PA9,PA10);
HardwareSerial doorSerial(USART2,PA3,PA2);
HardwareSerial audioSerial(USART3,PB11,PB10);

or
HardwareSerial debugSerial(UART1,PA9,PA10);
HardwareSerial doorSerial(UART2,PA3,PA2);
HardwareSerial audioSerial(UART3,PB11,PB10);
none of these work...