-
Notifications
You must be signed in to change notification settings - Fork 7
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
python library can't handle bare Tuple<T,S> return type from Arduino Library #23
Comments
The internal structure of both To circumvent this, we need two types of these objects, one that serialises to a flat list and one that has an explicit internal structure. To stick with the previous example, So in a sense, the I will try to explain this in the documentation as well. |
I tried to explain it in this note. |
Yeah after playing with it more I see the concept and understand the idea. Indeed merging them makes little sense. Perhaps my confusion is purely based on semantics about what the flat type is called and what the nested type is called. In a sense I was thinking of Regardless this was my mistake and I agree on all points you have made. I obviously missed the note! Sorry for the noise. Feel free to close the Bug Report. As always thank you for the excellent library P.S |
You did not miss the note, I wrote it after you opened this issue. I would have preferred using the STL as well, but to my knowledge it is not distributed by default with the Arduino cores. If this is the case, it may be a bit more difficult for an end user to use this library. Of course I could be wrong here. |
I just thought I could give it a go, but the standard installation does not seem to work, at least not in my setup. As soon as I include
|
Mini rant to start: I honestly hate how Arduino pushes this weird C within C++ style of programming. I understand they are trying to be beginner friendly but I feel it creates a bunch of weird corner cases when you are trying to do something a little more involved. Mini rant over. So honestly I have not used All that said the way I use the STL is to include Of course modifying Arduino files is daunting for many users so I understand that any STL inclusion would cater to a niche of a niche. (edit: made links visible) |
Changing the I mainly use I would not mind adding some optional extra complexity. We could think about an additional include for STL support in conjunction with some build instructions. |
I opened discussion #24 for this topic. |
Describe the bug
When an Arduino function with return type
Tuple<T,S>
(e.gTuple< int, const char*>
) They Python library fails withValueError: top level type can not be tuple
. If instead anObject<T,S>
is returned the system works fine.This may be purely a documentation issue (or even PEBCAK) rather than a "bug" since I can't seem to find anywhere where it mentions Tuples cant be returned "bare". The only hint I can find is here and here where it is mentioned
Objects<>
preserve internal structure.NOTE: This is with Python3.9 on a Windows system. No Linux system handy to test right now but I am 99% certain that it is not an OS level issue.
The Traceback is:
To Reproduce
Steps to reproduce the behaviour:
Load
test_tuple_rpc.ino
on Arduino:Run
test_tuple_rpc.py
on desktop machine:Expected behavior
If it is expected that
Tuples
can't be top level return types on their own then perhaps that needs to be explicitly mentioned in the docs.If
Tuples
are expected to be top level return types then perhaps the python code could "cast" them toObject
on the python side? That second option sounds like it would break stuff. AlternativelyTuple
andObject
could be merged to a single type (if so I personally prefer theTuple
name to match the C++ equivalent ofVector
)The text was updated successfully, but these errors were encountered: