Skip to content

STM32: Cpython compatibility flag 2 #2457

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

Merged
merged 3 commits into from
Jan 13, 2020
Merged

STM32: Cpython compatibility flag 2 #2457

merged 3 commits into from
Jan 13, 2020

Conversation

hierophect
Copy link
Collaborator

A continuation of #2439, which got merged prematurely. Please do not merge until @jerryneedell has had a chance to review. Should resolve #2433 when finished.

@jerryneedell
Copy link
Collaborator

jerryneedell commented Jan 6, 2020

still no joy

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.0.0-beta.2-91-gb778aee21 on 2020-01-06; Feather STM32F405 Express with STM32F405RG
>>> import minimqtt_demo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "minimqtt_demo.py", line 94, in <module>
  File "adafruit_minimqtt.py", line 120, in __init__
AttributeError: 'str' object has no attribute 'encode'
>>> string = "test"
>>> dir(string)
['count', 'endswith', 'find', 'format', 'index', 'isalpha', 'isdigit', 'islower', 'isspace', 'isupper', 'join', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rsplit', 'rstrip', 'split', 'startswith', 'strip', 'upper']
>>> 

for comparison -- on grand_central


Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.0.0-beta.2-90-g776c9b011 on 2020-01-04; Adafruit Grand Central M4 Express with samd51p20
>>> string='test'
>>> dir(string)
['__class__', 'center', 'count', 'encode', 'endswith', 'find', 'format', 'index', 'isalpha', 'isdigit', 'islower', 'isspace', 'isupper', 'join', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'upper']
>>> 

@hierophect
Copy link
Collaborator Author

This will require further investigation then. I was hoping the build order would put the board settings and overrides last. I'll need to dig deeper on how things are ordered.

Can you provide a zip of this minimqtt_demo.py file you're using so I can test it?

@jerryneedell
Copy link
Collaborator

yes but you don't need it to test -- just do the dir(string) to see if encode is there.
will post the code in a sec.

@hierophect
Copy link
Collaborator Author

yes but you don't need it to test -- just do the dir(string) to see if encode is there.
will post the code in a sec.

In that case, I'll just need a full list of whatever other includes I need to replicate your result.

@jerryneedell
Copy link
Collaborator

jerryneedell commented Jan 6, 2020

yes but you don't need it to test -- just do the dir(string) to see if encode is there.
will post the code in a sec.

In that case, I'll just need a full list of whatever other includes I need to replicate your result.

none - do a clean boot
at REPL

string = "test"
dir(string)

if encode is in the list -- it is fixed

the code needs an airlift and several libraries -- do you want it?

@hierophect
Copy link
Collaborator Author

Ah, sorry! I'm actually quite bad at python. All C over here :)

@hierophect
Copy link
Collaborator Author

Shouldn't need anything else. I'll ping you once I've got the attribute back in there and we'll do another full hardware test.

@jerryneedell
Copy link
Collaborator

Ah, sorry! I'm actually quite bad at python. All C over here :)

no problem! it's a simple check -- also if you have another board - any express board with full build -- you can do the same thing to compare the output -- that was what I meant by showing the grandcentral result.

@jerryneedell
Copy link
Collaborator

jerryneedell commented Jan 6, 2020

Shouldn't need anything else. I'll ping you once I've got the attribute back in there and we'll do another full hardware test.

it worked ok when I changed it in py/circuitpy_mpconfig.h

#define MICROPY_CPYTHON_COMPAT                (CIRCUITPY_FULL_BUILD)
to
#define MICROPY_CPYTHON_COMPAT                1

@hierophect
Copy link
Collaborator Author

Right, the trick is that's overriding the port level define, rather than the other way around. So I'll need to add some logic there to get around that.

@hierophect
Copy link
Collaborator Author

Sorry for the delay, slipped my todo list today. Just needed to swap over to a CFLAG and add the redefine logic to the .h file. Works for me now (raw test with string dir, I don't have MiniMQTT set up). This whole section still needs a conceptual revamp, but we'll follow up on that in #2458.

Give this a spin and hopefully we can get it in stat.

@hierophect hierophect requested review from tannewt and dhalbert January 8, 2020 22:41
Copy link
Collaborator

@jerryneedell jerryneedell left a comment

Choose a reason for hiding this comment

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

tested on feather_stm32f405_express with minimqtt_adafruit_io_wifi demo -- works normally !!
also verified that .encode is available for strings....
Looks good

@hierophect
Copy link
Collaborator Author

@dhalbert just wanted to quickly check with you whether this mpconfig.h change is ok

@jerryneedell
Copy link
Collaborator

Is this awaiting further review?

@hierophect
Copy link
Collaborator Author

I was hoping either @tannewt or @dhalbert would review this small addition to circuitpy_mpconfig.h, since that's a micropython holdover, and I'm not always aware of cascade affects that can occur from changes to that kind of file.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Looks good! Sorry for the delay.

@tannewt tannewt merged commit 2eb26a6 into adafruit:master Jan 13, 2020
@hierophect hierophect deleted the stm32-cpython-compat branch January 14, 2020 15:19
@hierophect hierophect added the stm label Feb 29, 2020
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.

STM32: possible problem with strings and adafruit_minimqtt library (AdafruitIO)
3 participants