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

Godmode should probably use std::string (or STL container maybe) for SPI/Wire/UART data #143

Open
matthijskooijman opened this issue Aug 26, 2020 · 2 comments
Labels
arduino mocks Compilation mocks for the Arduino library enhancement New feature or request

Comments

@matthijskooijman
Copy link
Collaborator

The Arduino String class is only intended for string data currently. In particular, it cannot handle embedded 0x0 bytes, which you might very well want to send or receive. See arduino/ArduinoCore-API#111 and arduino/ArduinoCore-API#97. If those issues are fixed, the String class could still be used, though.

@ianfixes
Copy link
Collaborator

Can you add some context here? Is this an area where arduino_ci deviates from the standard Arduino library currently? Or is it at risk of deviating in the future?

I had some trouble using std:: anything when compiling, as we are essentially mocking the AVR behavior on non-AVR... which was frustrating. If fixing #146 enables std::string to be used, I'm all for it.

@ianfixes ianfixes added arduino mocks Compilation mocks for the Arduino library enhancement New feature or request labels Aug 26, 2020
@matthijskooijman
Copy link
Collaborator Author

Is this an area where arduino_ci deviates from the standard Arduino library currently?

No, the Arduino String class is just broken when it comes to embedded nul bytes. Internally, the class uses some standard libc functions (e.g. things like strcpy) that will stop processing at the first embedded nul, so things might break when you use the String class for arbitrary binary data, rather than actual strings.

Also, since the Godmode stuff is only for unittests (i.e. it never has to actually run on AVR/MCU), it can use non-Arduino classes just normally (though using the Arduino String class could make interaction with other library code easier, of course).

I had some trouble using std:: anything when compiling, as we are essentially mocking the AVR behavior on non-AVR...

Hm, I haven't actually tried std::string yet, I'll have a look at #146 then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arduino mocks Compilation mocks for the Arduino library enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants