serialEventRun HardwareSerial.cpp issue

Working libraries, libraries being ported and related hardware
Post Reply
Zebedee68
Posts: 7
Joined: Wed Mar 08, 2017 9:32 pm

serialEventRun HardwareSerial.cpp issue

Post by Zebedee68 » Wed Mar 08, 2017 9:49 pm

Hi all,

New to the STM32 - great forum, some fantastic submissions and some amazing work done getting the Arduino ported..

I have an issue with a library calling serialEventRun - AFAIK, this function should be in HardwareSerial.cpp, the problem I have is if I add the following:

Code: Select all

// SerialEvent functions are weak, so when the user doesn't define them,
// the linker just sets their address to 0 (which is checked below).
// The Serialx_available is just a wrapper around Serialx.available(),
// but we can refer to it weakly so we don't pull in the entire
// HardwareSerial instance if the user doesn't also refer to it.
#if defined(HAVE_HWSERIAL0)
  void serialEvent() __attribute__((weak));
  bool Serial0_available() __attribute__((weak));
#endif

#if defined(HAVE_HWSERIAL1)
  void serialEvent1() __attribute__((weak));
  bool Serial1_available() __attribute__((weak));
#endif

#if defined(HAVE_HWSERIAL2)
  void serialEvent2() __attribute__((weak));
  bool Serial2_available() __attribute__((weak));
#endif

#if defined(HAVE_HWSERIAL3)
  void serialEvent3() __attribute__((weak));
  bool Serial3_available() __attribute__((weak));
#endif

void HardwareSerial::serialEventRun(void) {
#ifdef serialEvent_implemented
  if (Serial.available()) serialEvent();
#endif
#ifdef serialEvent1_implemented
  if (Serial1.available()) serialEvent1();
#endif
#ifdef serialEvent2_implemented
  if (Serial2.available()) serialEvent2();
#endif
#ifdef serialEvent3_implemented
  if (Serial3.available()) serialEvent3();
#endif
}
to each of the HardwareSerial.cpp I can find under the \hardware\Arduino_STM32-master\ folder, the function is still not in scope..
which HardwareSerial.cpp is being used?
(I would assume that all the AVR libs have the function in already, but not checked)

On an unrelated issue, but coming from the same library I am trying to use, some of the none ANSI string calls like atoi() aren't anywhere to be found, should they be in stdlib?

Zebedee68
Posts: 7
Joined: Wed Mar 08, 2017 9:32 pm

Re: serialEventRun HardwareSerial.cpp issue

Post by Zebedee68 » Wed Mar 08, 2017 9:58 pm

Haha - found the answer 30sec after posting..

add
extern void serialEventRun(void) __attribute__((weak));

to

HardWareSerial.h

bloody c..

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest