Upgrading to new core

Post here first, or if you can't find a relevant section!
Post Reply
DrBanana
Posts: 16
Joined: Thu Jun 10, 2021 3:02 pm

Upgrading to new core

Post by DrBanana »

Hi,
I'm changing my project core to newer one of stm32duino. I'm getting many many errors, which is expected. But the problem comes when a library becomes incompatible at fullest. One of which is https://github.com/mike-matera/ArduinoSTL. It was working fine on Steve's core but not on new core v.2.0.0.

Also I have a static method of a library with USBSerial* and now getting the following error
error: 'USBSerial' does not name a type; did you mean 'Serial'?
18 | static USBSerial *DebugSerialUsb
| ^~~~~~~~~
| Serial
in CoreLib class
static USBSerial *DebugSerialUsb;
static HardwareSerial *DebugSerialHardware;
static void Init(HardwareSerial *DebugSerial);
static void Init(USBSerial *DebugSerial);
in main .ino
USBSerial *CoreLib::DebugSerialUsb = NULL;
HardwareSerial *CoreLib::DebugSerialHardware = NULL;
then later init them whenever need to.

I'm not getting error on HardwareSerial only on USBSerial.
User avatar
fpiSTM
Posts: 1746
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Upgrading to new core

Post by fpiSTM »

You have to enable USB in the menu. The name is SerialUSB.
About STL, it is not required as the core already use the C++ standard library by default.

For ref:
https://github.com/stm32duino/Arduino_C ... 2/pull/129
https://github.com/mike-matera/ArduinoSTL/pull/12
DrBanana
Posts: 16
Joined: Thu Jun 10, 2021 3:02 pm

Re: Upgrading to new core

Post by DrBanana »

how to use std::vector<> in stm core
User avatar
fpiSTM
Posts: 1746
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Upgrading to new core

Post by fpiSTM »

DrBanana wrote: Tue Mar 22, 2022 11:22 am how to use std::vector<> in stm core
Simply like that:

Code: Select all

#include <vector>
using namespace std;

template<typename T> void printVect(T const & xs) {
  Serial.print("[ ");
  for (auto const & x : xs) {
    Serial.print(x);
    Serial.print(" ");
  }
  Serial.println("]");
}

void setup() {
  vector <int> numbers;

  Serial.begin(115200);

  printVect(numbers);
  numbers.push_back(5);
  numbers.push_back(3);
  numbers.push_back(4);
  printVect(numbers);
  numbers.pop_back();
  printVect(numbers);
}

void loop() {
}
Result:

Code: Select all

[ ]
[ 5 3 4 ]
[ 5 3 ]
Post Reply

Return to “General discussion”