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

Import Arduino.h rather than Stream.h #464

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

soundanalogous
Copy link
Member

@soundanalogous soundanalogous commented Aug 19, 2020

Per this note in the Steam.h header file. I'm still trying to understand what led to this change on the Arduino side. Apparently Arduino is using a common core library and if you try to compile against an board from one of the 4 cores referenced in the readme, then you'll get an error regarding Stream.h not being found. Changing to Arduino.h per the note in the Stream.h header seemed to have resolved the issue. Not sure yet if there are other potential issues to be aware of per these changes.

@soundanalogous soundanalogous requested a review from zfields August 19, 2020 22:52
@soundanalogous
Copy link
Member Author

To repro the error I encountered, install the Arduino megaAVR boards package from the Boards Manager, then try to compile StandardFirmata (latest version in the master branch).

Copy link
Contributor

@zfields zfields left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By not including the full Arduino dependency, FirmataMarshaller can be ported to other C environments beyond the Arduino (e.g. Linux, RemoteWiring, etc.). If we include Arduino.h, we bring in all the dependencies of Arduino.

My original intention for FirmataMarshaller was to solely generate our byte protocol. Theoretically, it should not require a dependency on Arduino to arrange bytes into, or out of, our protocol.

Instead of solving it this way, let me see if I can drop the #include <Stream.h> statement altogether, by simply using a pointer in the public API, and forward declaring the class.

@soundanalogous
Copy link
Member Author

Sounds good.

@zfields
Copy link
Contributor

zfields commented Aug 31, 2020

Okay, I did a little research this weekend. Unfortunately, my quick fix will not appease the compiler, or address the larger problem of deprecation.

I propose that we leverage an interface to Stream, and/or use dependency injection. Unfortunately, doing so will break the FirmataMarshaller public API. Although, I don't really think we make guarantees about it, but I do believe people are using it.

Not only can we not support the megaAVR boards, but Arduino is forcing our hand with the deprecation of Stream. We definitely need to do something. @soundanalogous What are your feelings on breaking the FirmataMarshaller public API, specifically the .begin(Stream &s) method?

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

Successfully merging this pull request may close these issues.

2 participants