Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add libmaple STM32F1 SoftwareSerial capable define #54

Merged
merged 1 commit into from
Jul 23, 2019

Conversation

GerogeFu
Copy link
Contributor

If you add this , so i can add software serial for stm32f1 boards.

@teemuatlut teemuatlut merged commit 5092e4a into teemuatlut:master Jul 23, 2019
@teemuatlut
Copy link
Owner

Thanks!

@thinkyhead
Copy link
Contributor

For some reason some of our STM32F1x platforms can find <SoftwareSerial.h> while others cannot. See recent comments on MarlinFirmware/Marlin#14832

@tpruvot
Copy link

tpruvot commented Aug 6, 2019

Which pio/arduino lib are you using for the STM32 ?

@teemuatlut
Copy link
Owner

@thinkyhead Do you know how many of our build tools support __has_include?

@thinkyhead
Copy link
Contributor

I have been told that we can use #ifdef __has_include to check for its existence, because it is a builtin of the preprocessor.

@thinkyhead
Copy link
Contributor

Aha, actually this did work. Not sure if it works with defined(__has_include) on the same line as the test.

#ifdef __has_include
  #if __has_include(<Arduino.h>)
    #error "Arduino.h is seen by __has_include!"
  #else
    #error "Arduino.h is NOT seen by __has_include!"
  #error
#endif

@thinkyhead
Copy link
Contributor

Nope. Don't do this:

#if defined(__has_include) && __has_include(<Arduino.h>)

@tpruvot
Copy link

tpruvot commented Aug 6, 2019

its not that some find it.. its just all the F1 which doesnt find it.. Others does not include it at all. This release change is only for STM32F1 (ARDUINO_ARCH_STM32F1)

@teemuatlut
Copy link
Owner

b9b3796

@thinkyhead
Copy link
Contributor

That patch will be helpful to future-proof the library. So basically, any platform that's using C++17 will be able to avoid the include automagically. But note that if the library isn't installed, there will be no #include error. But other undefined symbol errors will still pop up.

@teemuatlut
Copy link
Owner

teemuatlut commented Aug 6, 2019

Yea if the library isn't installed (maybe because the platform doesn't have it), then you can't use SW Serial. Makes sense to me but I need to think about whether or not I want to add a more verbose warning of some sort.
I think C++ had a deleted or deprecated features I could use if a user was trying to invoke a constructor the compiler doesn't have access to.

@thinkyhead
Copy link
Contributor

I think C++ had a deleted or deprecated features I could use…

I've seen some tricks employed to add warnings to deprecated things and errors to obsolete things, but I've never seen official support in C++ yet. But I grabbed the new specification PDF so I'll see if it mentions it.

@thinkyhead
Copy link
Contributor

Ah, yes. Here it is…

[[ deprecated ]] void hello() { printf("Hello"); }

@thinkyhead
Copy link
Contributor

And we also have… [[ maybe_unused ]] which will allow us to get rid of UNUSED(thing) eventually.

@teemuatlut
Copy link
Owner

Also see https://en.cppreference.com/w/cpp/language/function#Deleted_functions

Any use of a deleted function is ill-formed (the program will not compile).

@GerogeFu
Copy link
Contributor Author

GerogeFu commented Aug 9, 2019

@teemuatlut
I think we can change ARDUINO_ARCH_STM32F1 to ARDUINO_ARCH_STM32 to support all stm32 not only stm32f1. I am writing the lib to support it.
https://github.com/FYSETC/SoftwareSerialM
And maybe someday we can add it to Marlin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants