#circuitpython-dev
1 messages Β· Page 352 of 1
Katie Bell
https://lca2021.linux.org.au/schedule/presentation/45/
I confess, I hate writing code in text files. I hate dealing with syntax errors, carefully matching brackets, style rules, line-by-line git diffs and tiny character-specific cursor movements. That's why I set out on an epic quest to build a coding interface with no bracket match...
Thanks! π
Don't forget my TinyPICO Nano, just to double down on cute words that get over used π
https://www.tinypico.com/tinypico-nano
But the PICO in my case is not for "SMALL" but for the PICO-D4 on the board.
@atomic summit Ergo, the need for Nano. π
I'm eagerly awaiting the itsy bitsy tiny pico nano
Exactly! A smaller than pico PICO! π
pico^2 π
Makes me think of "jumbo shrimp"
I missed how this conv started though - I assume the rPI Pico?
@atomic summit Originally last week sometime. The vaguely confusing branding of the board as Pico, but the chip is RP2040. And then other PIco-named boards. And then Adafruit is carrying another Pico-named board so it came up again today.
Somebody should port Circuitpython to ShenzhenIO
So I was comparing apple and apple... that's a change!
Let's say I tested the PIO code found in the assembler library for doing Neopixel.
I reviewed, indeed. π
Thank you!
You're welcome! I need to test it, but wanted to get that review in first.
I may not be able to stay on to hear the bus device stuff, but I'll for sure listen to the recording later or someone can ping me here.
Thanks for that info @idle owl. Will look at structuring the library that way, and will PR at will!
https://cutoutfoldup.com/981-torus-from-villarceau-circles.php
If you want to practice on your patience or βbuild characterβ...
Interesting things to make out of paperβfrom mathematical models to toys.
@fossil gorge Thanks! You can do a WIP PR, simply mention that it's a work in progress, and open the discussion. Bear in mind that breaking changes are allowed, but we need to be aware of what documentation such as Learn guides that need to be updated along with an eventual PR merge.
wild!
no good deed goes unpunished!
Thanks.
Thanks all!
Thanks for an awesome meeting -- I had a work call in the middle of it, so I'll have to catch the VoD π
Pretty short today, done about an hour into it.
Here is the notes document for Mondayβs CircuitPython Weekly meeting. It is at the normal time of 11am Pacific / 2pm Eastern here on Discord. Everyone is encouraged to attend! Please add your hug reports and status updates even if youβll be attending the meeting - itβs super helpful! If you are unable to attend but would still like to include updates, feel free to include them in the notes and weβll read them off during the meeting. Hope to see you there! <@&356864093652516868> https://docs.google.com/document/d/1RTjIOUogdNgKSO5TdfzvsEoJBb1ohP5yREz6ZulzORA/edit?usp=sharing
CircuitPython Weekly for February 8th, 2021 Here is the notes document for Mondayβs CircuitPython Weekly meeting. It is at the normal time of 11am Pacific / 2pm Eastern here on Discord. Everyone is encouraged to attend! Please add your hug reports and status updates even if youβll be attending ...
@tannewt you were right, that was the problem. After trying again using the branch 6.1.x everything works fine now.
Thanks for solving my problem.
This looks good to me now. Your own testing vets it.
Adafruit CircuitPython 6.2.0-beta.1 on 2021-01-27; Raspberry Pi Pico with rp2040
import simpleio
Traceback (most recent call last):
File "", line 1, in
File "simpleio.py", line 34, in
ImportError: no module named 'pulseio'
There is no pulseio yet for CircuitPython on the RP2040. simpleio imports pulseio, but usually you just need simpleio for the map_range() function it defines. You can copy that function and add it to your program for now.
Is this an Adafruit-supplied example? We can change the example.
Oddly enough the simpleio module is used as an example for import errors in the getting started tutorial, mostly wanted to make sure I understood why I was getting the error after adding simpleio.mpy to the lib folder on the device.
https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries#example-importerror-due-to-missing-library-2978247-20
@tulip sleet Oi, maybe we should choose a library that does not import other modules/libraries. Is that even a thing?
thinks
Even neopixel requires pixelbuf or pypixelbuf.
The example would need to work the same on all boards.
Helper library maybe.
@idle owl is a specific widget used to embed source code in the learn system or is it something custom for Adafruit?
@gloomy shuttle The entire Learn system is basically proprietary software. I'm not sure what they used. It uses the "embed" element in the Learn system software, and renders the GitHub code, as well as the links to view/download/copy it.
Thanks! I kind of figured that, but it one of the best embed code displays I have seen.
@gloomy shuttle If you'd like, I can ping Learn dev to find out if it was internal code or whether they implemented something existing.
I would be interested to find out if it is not proprietary.
@gloomy shuttle I'll ping them, then. I'll let you know what I find out.
@ionic elk Thanks for unblocking me with the socket timeout core bug, just PR'd the library which was blocked π₯³
@prime flower That was a BEEFY PR. Nicely done.
Started in November 2020 π
Way to stick with it!
I want to use it π
I know that feeling π
though, it's not fully done - I need to add SSL sockets for CPython and a test suite so I don't need to test 4 different implementations.
Have to start somewhere though, oi. And yeah testing would save you a lot of time!
very fun way of soak testing π
Nice!
@gloomy shuttle if you are intersted in an open source widget for embedding code into web pages I've used this one: https://codemirror.net/ in a work project and found it to be pretty nice to work with and has a nice looking UI with many desirable features.
@prime flower wait I did? I thought I didn't have that fix up until SSLSocket goes in
Maybe neopixel is a good example because just adding it might still generate another error (when no _pypixelbuf), so the reader could see the step-by-step process.
@tulip sleet Yeah maybe. Except also not all boards have a NeoPixel so maybe not so great. hmph.
i was just thinking of making a new library, like adafruit_simplemath, which would include map_range(), and maybe constrain(). Not sure about the naming, but it kind of parallels adafruit_simpleio.
Thanks, I will check that out!
@tulip sleet I'm annoyed we have simpleio to begin with.
I've written the map range stuff into my code to avoid using it.
or maybe just adafruit_math, but that's pretty open-ended. ... yeah, I would like to substitute something simpler
Repeatedly.
@ionic elk https://github.com/adafruit/circuitpython/issues/3836 seems to have fixed it
I just subscribed to the SSLSocket PR you opened
3854 probably had the fix but further issues solved in 3836 might have borked it
3854 had a bunch of issues like making the timing default wrong and sockets timing out even when successful if the timeout was 0
MiniMQTT doesn't rely on the timing default, it's set up by the application itself. Not sure if timeout is set to 0 anywhere though... dont think so
anyway, good to hear it's working for you now
Just a data point. The BNO085 on a Raspberry Pi 4 running the example code from the guide prints one line and throws an index out of range error (latest library). It's been running on the Pico for three days without a hiccup - latest CircuitPython and library bundle. Nice! At the same time, I have a 055 running on a CM4 and it's been chugging along for ten days.... Good stability.
@drowsy geyser Huh! Did you file an issue on the 085 lib? Good that the others are working well!
@ionic elk Yeah, I think I've (somehow) avoided the issues but I'll leave that PR up for a day
There shouldn't be any now, 3836 is in
I haven't yet, @idle owl . I will shortly. I wanted to test on the Pico to make sure it wasn't a hardware issue.
SSLSocket is coming but it doesn't have anything related to your issue (I got it mixed up)
Good plan. Thanks ahead of time for filing an issue!
I'll likely need to implement the SSLSocket interface when it's merged in. :\
@ionic elk https://docs.python.org/3/library/ssl.html#ssl-nonblocking << btw, if you're going for CPython behavior, maybe see if nonblocking sockets can be handled like in CPython.
nonblocking ssl sockets are weird in Cpython (imo)
Now I need to be better about following up on them!
Hah, valid. But life happens, we understand.
@prime flower SSLSocket has an identical interface. No changes should be required.
ok!
as for nonblocking, I'm already trying to do that, I don't know how successfully haha. You're welcome to bring up divergent cases with me and I'll try and fix them
Some non-blocking stuff is easy, like recv and accept - they just fail if they're going to block, and you gotta try them over and over until they work. Those should already be working as intended. But other stuff I haven't figured out yet, like connect, which returns an exception, and you're supposed to use select to deal with it, which I haven't touched at all. I've just been defaulting to blocking on cases like that
I guess documenting those inconsistencies would probably be good
at least in the comments, or something
@drowsy geyser that pi+bno08x combo is pretty tricky. it's another clock stretcher. maybe some help here:
https://forums.adafruit.com/viewtopic.php?f=19&t=174424
I get this same error on both ESP32-S2 and Raspberry PI pico, but works on Seeeduio Xiao with same version of CP
Fix to avoid using any long int for builds that have it disabled. The end keyword is now also omitted if the default value of INT_MAX is given to avoid converting it to a smaller value.
Tested on a Feather M4 Express with long int disabled and a BME280.
Tested on hallowing_m0_express by running lis3dh_simpletest -- worked fine.
@gloomy shuttle I heard back from my devs. The actual display of the GitHub embedded code is simply using Google Prettify, wrapped around a container with the header that shows it's a GitHub embed and the links to it, etc. To get the code and keep it in sync, they use the GitHub API and save it within our system for performance reasons. Then they have webhook integration that notifies us if the files change via commits, and if they do, update the files in the Learn database. (If also notifies if a file is moved and allows us to alert the authors to the situation, as handling files that have moved is super tricky and prone to failure in Learn.)
Not sure if that helps, but that's what I got. π
Thank you, that helps a lot! I was just looking at the Google Prettify after I originally asked.
@gloomy shuttle Excellent!
So trying to commit some changes in the Adafruit_CircuitPython_ProgressBar, and I'm running afoul of the pre-commit hook. Technically speaking, existing code is, but I'm working to correct the issues.
What's failing right now is the "reuse" hook, which checks for copyright and license information for every file. Every file. This includes .github/workflows/* files, .pylintrc, favicon.ico, requirements.txt, docs/* etc.
To make sure I get it right, what would the license and copyright information be for most of these files, if not all? Some have info in them, such as "(c) 2020 Brent Rubell for Adafruit Industries", and some mention either the Unlicense or MIT. However, all files that don't, well... don't!
@fossil gorge If no one else gets to this, I'll be able to help you tomorrow. But it's getting late here and I'm done for the night.
Sounds good, thanks! Have a good night!
@fossil gorge what files are missing it? the cookiecutter should have licenses for everything it adds
It's complaining about these files...
The following files have no copyright and licensing information:
* .github/workflows/build.yml
* .github/workflows/release.yml
* .pylintrc
* .readthedocs.yml
* CODE_OF_CONDUCT.md
* README.rst
* docs/_static/favicon.ico
* docs/api.rst
* docs/conf.py
* docs/examples.rst
* docs/index.rst
* examples/progressbar_magtag_simpletest.py
* examples/progressbar_simpletest.py
* requirements.txt
* setup.py
The following files have no licensing information:
* adafruit_progressbar.py
hrm, do you have a docs/api.rst.license file? There is one in cookiecutter
There is not one, no.
when did you run cookiecutter?
I didn't. This is an existing library: https://github.com/adafruit/Adafruit_CircuitPython_ProgressBar
ah, that'd be why
Initial commit was... 13 months ago
kattni and dherrada would know how to update it. or you can try copying the newer versions of files from cookiecutter
Just added that one file, and reuse is happy. Literally!
Congratulations! Your project is compliant with version 3.0 of the REUSE Specification :-)
Smiley and all
No, it was checking all of them
At least running reuse lint directly. I didn't change anything under ".github", and I even tried it on a clean "main" branch.
But through pre-commit, it only did the changed ones, since pre-commit stashes anything not already added
kk, well that unblocks you then π
Definitely. Thank you kindly!
np
Welp, it was happy. Then I created a branch to work from and commit into, and it's back to that error. π
does the new branch have that file?
yep
Comparing the files to the cookiecutter, none of those listed files have the header though
Ah it seems like this one got left out of the sweep that added lots of this stuff
Well crud, I think I saw why it was happy originally... I was on the branch where I was trying to see what was needed for reuse to pass, and not a clean branch π€¦
There are quite a few changes needed I think. Here is a similar one of the PRs https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes/pull/30/files
I'd probably recommend skipping it for now. There might have been a script used that will make the process simpler
That's what I was thinking. I'll commit locally without pre-commit running, and circle back around to the license stuff later
yep. we can get progress_bar sorted. Then you'll be able to merge it in and not have to deal with it much I think.
Except for any new files I add, because space-time, bits and bytes and such
When you are around @idle owl and maybe @trim elm It seems like https://github.com/adafruit/Adafruit_CircuitPython_ProgressBar got left out of the run pre-commit / add license sweep. Was there a script in adabot or somewhere that was used to make those branches from the PRs?
No.
That was all done manually I think, or Dylan ran something locally.
I'll have Dylan take a look when he's around next.
Looks good to me! Thank you!
Single CI failure was a network error. Merging anyway.
I suspect that code.py was working but the GP15 button didn't work. The errata fix doesn't restore the mux setting last I checked. @kilograham, is this on your radar?
@hierophect Can you open the second LWIP socket only when you do the server APIs?
Does rotaryio provide pull-ups for encoder pins? I've been able to read encoders without pull-up resistors. Hmmm.
I don't think so. I think our guide has you hook one up.
Before trying countio, an internal pull-up was sufficient to work with both optical and hall-effect interrupter sensors. The pull-up value is not critical for most low to medium-speed applications like motor RPM. Don't know if the internal pull-up value provides enough current for the speed of a remote control IR sensor.
I'm ok if you want to add a kwarg for this.
I get this same error on both ESP32-S2 and Raspberry PI pico, but works on Seeeduio Xiao with same version of CP
I think the Xiao works because it uses the python version of bus device. The other two have it built in.
Looks good to me too! Thanks!
I'm completely unsure about where to start when it comes to modifying one of the core elements. Time to look at how that's done. Thanks.
@CedarGroveStudios you can do it! we can help support ya, try making a draft PR when you're ready for some eyes :)
Thanks! Another fun trip outside my comfort zone!
@tannewt: Interestingly, the rotaryio guides I've looked through that involve CircuitPython have no pull-up resistors for the two quadrature encoder pins. https://learn.adafruit.com/rotary-encoder/overview
Looks good to me! Thank you so much!
@lone axle thanks for letting me know. Iβll take a look tomorrow afternoon
Thank you. You've fixed it for me and my last push has passed all the checks. Much appreciated.
There seems to be race condition with the background code, I put segger rtt for debugging. Normally after usb irq, background is added and then run_all. When the issue occurs, the irq is trigger, background is added, along with tick is also added, but there is no run_all() afterwards. background_callback_add_core: 48: repeatedly is tick timer trying to add its background while already existed in the queue. Doing more testing
usb_irq_handler: 103:
background_callback_add_core: 52:...
Hi there,
I'm currently trying to write the display init code for the newly merged ESP32-S2 LilyGo T8 board with ST7789 display.
In general it's working so far. But I'm struggeling somehow with the backlight pin. If I've understood the whole thing correctly it should be enough to pass the adress of the mcu_pin_object as parameter to the common_hal_displayio_display_construct() function.
But if I do that the board is hanging at startup. If I pass NULL as backlight pin and set the ...
update: tracing down the background callback, it does solve the race condition pretty well, however, somehow the run_code.py decide to run background_callback_reset() while background list is still queued up with usb event. https://github.com/adafruit/circuitpython/blob/main/main.c#L305
usb_irq_handler: 103:
background_callback_add_core: 52:
callback_head = 0
callback_tail = 0
callback_head = 200029BC
callback_tail = 200029BC
background_callback_add_core: 65:
run...
I suspect that code.py was working but the GP15 button didn't work. The errata fix doesn't restore the mux setting last I checked. @kilograham, is this on your radar?
@tannewt I tried building my own fork and playing around with the errata fix and seems like the call to this function is causing the problem.
// Force LS_J
const uint dp = 15;
//const uint dm = 16;
gpio_set_function(dp, 8);
Even I tried saving the original value prior to calling the function and restore i...
@BiffoBear Your latest commits rolled back the ulab submodule a few commits by accident. I think this may have been due to not pulling from your own repo after I made changes to the PR, so they got out of sync. Also the circuitpython.pot may have lost a bunch of new messages.
Let's start over again to clean this up. Could you get the latest adafruit/main into your main, start a new fix branch, and then include only the error message changes in the various I2C.c files, and my shrink...
I suspect that code.py was working but the GP15 button didn't work. The errata fix doesn't restore the mux setting last I checked. @kilograham, is this on your radar?
i had heard some mention from someone, not sure the specifics... can you open an SDK issue
this happens when I try to use:
busio.UART(board.GP0, board.GP1, baudrate=9600)
@idle wharf Hey! Ping me when you're around, please.
@ionic elk does this work for you with #4049 https://github.com/adafruit/Adafruit_CircuitPython_Requests/issues/63#issuecomment-771712906?
@slender iron how is flash partitioning done on rp2040?
I need NVM_SIZE and NVM_START_ADDR.
@analog bridge it's all part of the LD script. you could take the last 4k of the 1MB I set aside
right now it's 1MB for the core and the rest for FS
yep not implemented yet
please subscribe to
https://github.com/adafruit/circuitpython/issues/4036
to get updates when we've added it :)
got it π
Fixes a number of things and exposes a way to get a flash's unique id: https://github.com/raspberrypi/pico-sdk/releases/tag/1.0.1
MicroPython 1.14 has been tagged: https://github.com/micropython/micropython/commit/78b23c3a1f064dc19bbee68930ef3aba110c781c
I would like to work on this, could someone point me to what I would need to change? I see /ports/raspberrypi/sdk_config/pico/, is there anything else?
Epic! you'll need to change the commit referenced by ports/raspberrypi/sdk and then rebuild. Things may have changed so you'll likely need to update Makefile too. I think the linker script also changed so compare the CP copy to the sdk's default one.
Sorry, I'm having git troubles. I can't work on this anymore, please disregard my previous comment.
@idle owl ping
@idle wharf pong!
Ok, for this PR:
Are you comfortable taking over it?
I have a few questions about it, and I assume its not time-driven, but yeah I'd be happy to help out with that.
That's a yes. π
@idle wharf I am around to answer any questions. It's not time-driven, as should be obvious by the fact that it hasn't really been touched since it started.
That would be greatly appreciated, it's a feature I'd really like to see added.
We'll have to update the documentation if needed, but we'll cover that closer to merging.
My biggest question is about the Travis stuff... I assume now you would want to remove that and just do Github Actions
Yes, 100%.
That might trip up folks creating community libs, but no more than Travis would have, really.
I think it's not worth keeping Travis in there.
OK... I'll have a look at during the evening this week or on Friday.
github process... should I start a new PR or can I jump in on the current pr... not had to do that before. What's the CP-Community way ?
@idle wharf You should be able to grab that PR and work on it. I can help you with that process. If that ends up being too complicated for you, it's perfectly fine to start a new PR as well.
It's a little tweaky to push to an existing PR using Git, but it's doable. I have to refer to notes on how to do it every time, but it works.
You right... I wasn't thinking that I have commit privileges so yeah that makes sense
OK, consider it done.
Great! Thank you so much.
Yup, I'm wrong. IncrementalEncoder on the SAMD turns them on automatically: https://github.com/adafruit/circuitpython/blob/main/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c#L59-L63
@hathach That makes sense to me! I think we need probably need to remove VM initiated task only (not USB.) An alternative would be run all tasks while interrupts are off and then we reset before turning them back on.
@slender iron Does https://github.com/adafruit/circuitpython/pull/4110 fix https://github.com/adafruit/circuitpython/issues/4067 ? If so I'll link them and close it.
nope
Ok.
it's a good question π
What does RTC support look like then?
Someone asked about it, and assumed it wasn't implemented because of that issue
the PR enables python access to the RTC
the issue is about using the RTC internally for sleeping
Ok
ah what about time.time() ?
so, for users, they'll be able to use the RTC
@jaunty juniper Support was merged 14 hours ago.
They may not be running the latest version.
@jaunty juniper ideally it'd be hooked up but I'm not sure we have it connected yet
https://github.com/adafruit/circuitpython/pull/4110 Allows us to set the RTC. For sleeping, we need to modify https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/supervisor/port.c#L164-L187 for sleep support.
@slender iron Thanks!
I suspect this is a bug in the ESP32-S2 PWM implementation used by display. I'd be ok merging it with the digitalinout code for now and leaving this issue open for someone to look into it.
@tulip sleet Working on this CP Essentials page for Pins and Modules. Discussing import board. Is it worth including a pins.c reference? Or is that too in depth for this. I have it in my notes to discuss microcontroller.pin so those pin names will be referenced on this page somewhere.
I think dir should be enough
ok
@slender iron Without checking pins.c, how can you tell what pin is which? For example, the QT Py has A0, A1, A2, A3, SDA, SCL, TX, RX, SCK, MISO, and MOSI on the silk. but 'A0', 'A1', 'A10', 'A2', 'A3', 'A6', 'A7', 'A8', 'A9', 'D0', 'D1', 'D10', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'I2C', 'MISO', 'MOSI', 'NEOPIXEL', 'NEOPIXEL_POWER', 'RX', 'SCK', 'SCL', 'SDA', 'SPI', 'TX', 'UART'] in board. How do I know which pin is D2 for example, without checking pins.c?
try print(board.D2)
board.D2 results.
I've been using that to map pins:
import microcontroller,board
for pin in dir(microcontroller.pin):
if isinstance(getattr(microcontroller.pin, pin), microcontroller.Pin):
pins = ["{:28s} ".format("microcontroller.pin."+pin)]
for alias in dir(board):
if getattr(board, alias) is getattr(microcontroller.pin, pin):
pins.append("board.{}".format(alias))
print(" ".join(pins))
microcontroller.pin.GPIO0 board.IO0
microcontroller.pin.GPIO1 board.IO1
microcontroller.pin.GPIO10 board.SD_CS
microcontroller.pin.GPIO11 board.IO11 board.SD_MOSI
microcontroller.pin.GPIO12 board.IO12 board.SD_CLK
microcontroller.pin.GPIO13 board.IO13 board.SD_MISO
[...]
We have something like that for identifying SPI/UART/I2C combinations.
Looks similar except it tries to init pin pairs, and prints when it succeeds and fails.
@jaunty juniper That might come in handy though. Thanks for sharing it.
@slender iron That simply prints board.D2.
@idle owl I don't know why there is a D2 in board if it isn't on the silkscreen
@slender iron Because we seem to assign Dx names to everything even when it's not on the silk. π€·ββοΈ
probably in the learn guide
There's a great many more pins in board for QT Py than are on the silk.
Same with most boards. I2C etc aside.
ah I believe it's to give access to A pins as D pins ?
the pins.c should have them listed so the top one matches the silk
I guess that's my point. About mentioning pins.c. However, maybe I'll include Neradoc's script instead. We included scripts like that in the I2C/SPI/UART pages of this guide.
the order should be reversed here: https://github.com/adafruit/circuitpython/blob/main/ports/atmel-samd/boards/qtpy_m0/pins.c#L10
@jaunty juniper It is ok with you if I possibly include this script in a guide page?
like, they have D names so you know they can be used as Digital IO ?
the first entry for a pin should be the one on silk
sure absolutely
They can be used for digitalio if they are digital pins regardless of the pin name.
and that'll change what prints when you do print(<pin>)
Oh so that's a QT Py issue.
If I want to contribute a python library for CircuitPython - is there a canonical github repo for libraries that I should be sending PRs to ?
I did print(board.A2) and it gave me board.D2. I see.
@stark ledge We have the CircuitPython Community bundle for community supported libraries, if that's what you're asking. https://github.com/adafruit/CircuitPython_Community_Bundle Are you saying you have a library you want to share? Or you want to contribute to a current library?
I have a new library that I wanted to add
Thanks ! that is exactly what I was looking for
Excellent! We have a guide on contributing if you're interested. https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library
Thanks that is perfect !
@slender iron Alright, I think fixing all of the pins.c's right now isn't the best use of my time, so I think I'll include the script to find the pin map for now since the print method will be dubious at best if we've been that inconsistent with the naming. Thanks for the help.
yup, that's ok with me
if you need to indicate the matching pin names, aren't they on the pinouts page of the guide ?
@jaunty juniper In theory, yes. However, this page is going into a standalone guide. It's mean to explain what's going on with board and other built-in modules. In explaining board I want to enable folks to use the module to figure out what pin is what etc.
It'll end up mirrored into all of the board guides which means it will show up as being part of each board guide, but still. If you simply go through the guide without a board guide to go with it, you should be able to find your way around.
I see
@slender iron If there's a microcontroller.pin.x without an associated board alias, does that mean it isn't broken out on the board? Or what's going on there.
π I was going to ask you if you could help me modify the script. @jaunty juniper
I want them included, but I think we shouldn't print out the ones without board aliases.
Actually. I see where you're going with it.
I think I want both versions. π
if it isn't in board I assume it's hard to get to
Ok
and I wouldn't recommend telling folks about them
That's what I was thinking
Ok thanks
@jaunty juniper Ok, so I like your idea, but also like your current script. However, I'd like to modify it so it doesn't print any microcontroller.pin.x that doesn't have a board alias.
But I do like the idea of one that prints only the board aliases.
the script doesn't print any microcontroller pins that don't have a board alias
microcontroller.pin.PA03 board.A1 board.D1
microcontroller.pin.PA04 board.A2 board.D2
microcontroller.pin.PA05 board.A3 board.D3
microcontroller.pin.PA06 board.A6 board.D6 board.TX
microcontroller.pin.PA07 board.A7 board.D7 board.RX
microcontroller.pin.PA08
microcontroller.pin.PA09 board.A9 board.D9 board.MISO
microcontroller.pin.PA10 board.A10 board.D10 board.MOSI
microcontroller.pin.PA11 board.A8 board.D8 board.SCK
microcontroller.pin.PA15 board.NEOPIXEL_POWER
microcontroller.pin.PA16 board.D4 board.SDA
microcontroller.pin.PA17 board.D5 board.SCL
microcontroller.pin.PA18 board.NEOPIXEL
microcontroller.pin.PA19
microcontroller.pin.PA22
microcontroller.pin.PA23
08, 19, 22, 23?
no, sorry, I take that back, but could be easily modified, I forgot I did that originally
π No worries
I could have been reading it wrong.
I can't figure out how to modify it. π It's a bit beyond my skills.
@jaunty juniper Nice!
it's missing a natural sort but well
I don't think they need to be sorted necessarily
Or does sort do something I don't know about. Probably.
oops, that's secret, I guess I shouldn't post the link o_O
oh it is ? my bad
it's OK if I link to it?
sure
thanks
I sorted them because I think it's easier to read alphabetically but the lack of natural sort irks me π (natural sort is where D10 is after D9 instead of after D1)
@jaunty juniper Ahhhh ok.
natural sort is unfortunately rare in computers, as far as I know only the mac's Finder does it while on windows or linux you'll name your files "something001" etc. to keep the order correct
or with ls
and there is no way from board to know which is the silk screen name and make sure it's first or last in the line
right.
Which is fine, really.
We're getting the info to folks in a pretty clean way.
They can figure out beyond that. π
@tulip sleet Are you around?
@idle owl yup
@tulip sleet Trying to explain the I2C/UART/SPI singletons. They eliminate the need for busio and simplify the code. What else do they do? Something about making it so you can use it multiple times without a pin in use error? Or is that not specific to the singleton.
@crimson ferry Hey, sorry I didn't get on this earlier, we had power knocked out by a snowstorm for most of the day
the first time you call board.I2C() or similar, it will create the object. The times thereafter it returns the already-created object. Sometimes this is called "lazy initialization", though I am not sure if that is an intuitive term or not. It does not reserve the pins up front, so you could use those pins for something else if you never call board.I2C()
I'll try it out now
@tulip sleet Hmm alright.
or "created on demand"
And instantiating it is not calling it? So like.... creating the sensor object doesn't call it until you use the sensor object?
no, it's instantiated when you call it, but not before
the point is only that board.I2C() creates it on the first call, and returns the already-created object on subsequenct calls
Ok
maybe "lazy instantiation" is better
"instantiation" is ... not a term most people know
Hmm yeah
but if you can define it, great
"lazy creation"
I am not going to make you a grilled-cheese sandwich for lunch unless you ask for it. I am not going to make one in advance.
Hah! π
and when you ask for it again and again, I will give you the same one
(not exactly the best analogy, since it gets consumed0
But I get the idea.
@tannewt Thanks Scott for your fast reply.
In the meanwhile I have looked a little deeper. It seems that common_hal_pwmio_pwmout_construct() function couldn't find a non-reserved channel because the pwmout_reset() function is called to late.
pwmout_reset() is called by reset_port(). But in main.c the board_init() which does the display initialization is called before reset_port(). So some initializations are not done yet.
I changed the order quick&dirty for testing in mai...
@idle owl re your proposed language:
I would not say board is just for pins: it's for any board-specific objects, most of which are pins. So I2C, etc. are default objects for those busio objects. You could also say "You can call board.I2C() as many times as you like, and it will always return the same object." just to emphasize the point.
those are not "pins"
@tulip sleet I was wondering how to word that re: board. Thanks. Also I like that emphasis.
Right.
Exactly.
I almost asked earlier what they were, but remembered they are singletons, but didn't know how to broaden the explanation of board.
stray + sign: Instantiating an object+
Yeah I caught that already
hehe π
- has been sneaking in a bunch lately.
@tulip sleet Thanks much. I am sure I will have more questions with this page.
hello, I have a question ... if I am writing a driver for an IC with circuit python and I need to write a non standard pulse e.g a low and delay for 88uS what are my options? time.delay() is obviously not very good, but would microcontroller.u_delay() is quite good but is it universal across all board implementations? Sorry if I am asking something that is easily found in docs
@fossil gorge just fyi, it did end up being the matrix portal π
https://learn.adafruit.com/matrix-portal-room-co2-monitor
@scarlet scroll "non standard" - so it's not something I2C, SPI, etc?
no DMX512 its basically standard serial but has an unusual make before break, make after break at the beginning.. its not that strict actually, I guess I am trying to understand with CP what people do when they have to do a funny toggle like that
some interesting discussion here:
https://github.com/adafruit/circuitpython/issues/673
time.sleep(88E-6)
that number looks familiar π
To true. Most people I knwo say "new up" (C#-ism?). I'm on team "Instantiate". Nice to see I'm in good apparent company!
I thought that looked familar on Sunday night's Desk of Ladyada! That looks REALLY good! And I LOVE the smile/frown quick-look status.
thanks, helpful! hah funny, the first to code in this post points back to old micropython I wrote for it, full loop. https://github.com/adafruit/circuitpython/issues/673#issuecomment-442356216
time.sleep() is never going to be that accurate, and even microcontroller.delay_us() is only a minimum, because there may be other things happening that delay things further. There is some RS485 support in the esp32-s2 and mimxrt10xx ports, but you need an external IC to get the electrical part right
afaik, there's no simple way to do tight timing like that in user code
Thanks for trying @ajs256! I'll do it so I can get the correct timers for DMA.
or, maybe, no way. at least with anything like a time. something approach.
Thank you, just wondering if there was a trick I was missing
what about PulseOut?
yes, PulseOut could be possible, if it can run fast enough
cool. was thinking maybe that also.
https://circuitpython.readthedocs.io/en/6.0.x/shared-bindings/pulseio/index.html#pulseio.PulseOut
so you wouldn't bit bang with hand crafted timing delays. instead you'd preload the pulses and then send them.
Now that's a library I didn't spot, thanks! I'll test it out
I went with it and tried to explain it.
@fossil gorge Speaking of you, did you get your PR sorted out with the licensing bits? Dylan is working through the few we missed. There was more than one. Glad we caught it, sorry it had to be an issue with your PR.
I did - ish. I'm working around it locally by bypassing the pre-commit hook when committing to git (for now). Once the repo's been updated with the necessary licensing information, I will pull that down, and rebase my changes on top of that to ensure it's all good.
And no worries about it happening "on my PR". I've been on both the receiving and giving end of those "Oh yeah, this has to be done before that because of X" enough times. All part of the development experience π
Oh perfect, ok! Glad you're unblocked. Should be in the next day or two for it being updated. I'll have Dylan prioritise it so it's done tomorrow, because otherwise it will end up sitting until Monday.
Sounds good. If Dylan can't get to it, like I said, I'm more than happy to do it for that repo as a separate PR π
Is there somewhere in the code where the overall memory map for CircuitPython is itemized... stack, heap, pystack, sleep memory, etc.?
No worries, he replied to my prioritisation request. He said he'll do it first. π
Sounds good to me. Thanks for checking in and the update
For all of our reviewers: I tested the GitHub CLI today. I run MacOS, so I have no idea if it works on other platforms (I imagine it must?). But it was super simple to install, and one command to pull down the code from a PR for testing. It clearly runs all of the git magic I usually have to do to check out a PR in the background, but it is definitely easier and it worked quite well. I highly recommend it if you simply want to grab some PR code for testing.
Looks like PYSTACK is set to 1536 globally in py/circuitpy_mpconfig.h, but could be easily overridden at the port level (no existing overrides I could find) or board level (I think only TG-Watch does this).
In cases where there is sufficient external RAM for heap, what's the downside to using more internal RAM for IDF/sockets and pystack?
A fresh attempt at clarifying the I2C init error message, after I ran git train --wreck on the last one.
Sounds like it's worth taking the time to learn it. I have been using the hub package for a while, which mainly lets you avoid having to type https://github.com/ most of the time, like hub clone adafruit/circuitpython, hub remote add somebody/circuitpython ,etc. gh does other stuff and I should learn it.
@idle owl are there instructions for downloading and installing the CI stuff?
@tulip sleet I think so, yes.
@solar whale I found the install command inside a PR. I opened an active PR in a browser, and in the upper right of the PR, there is an "Open With" button, and the resulting dropdown had the install command. It was MacOS specific, so I'm not sure if you're running something else, whether it shows you the command for your OS. In that same dropdown is the command to get the PR code.
I imagine there's a man page for it via commandline and I assume they've documented it somewhere, but I haven't looked further into it yet.
Thanks. Iβll take a look.
You're welcome!
Does anyone know if the best way to get a Unique ID from the a board (specifically a m4) is microcontroller.cpu.uid?
@random oasis I think that is the intent.
yes, that is a unique id burned into each chip by the mfr
we might be using it in backwards order (there is some kind of canonical order), but that has not been a big deal: https://github.com/adafruit/circuitpython/issues/2087
@solar whale @tulip sleet Do you know if there is a way to get the crc32 value of that id? (I've done this in the past with other languages) I'm trying to get a shorter, but almost always unique id, something that I can show on a display and someone could easily copy down.
you could just xor some bytes with others
xor?
+1 for the GitHub CLI. I found it made things easier in the git workflow for me as well. I am on Linux, and it works fine there as well.
As long as you remember to use gh repo fork ... if you don't have a fork. Otherwise, you have to manually setup the upstread with git remote ... commands. That's SO 2019
Hello, can I have some help I am trying to do my first PR, however the CI check did not pass. As far as I can see the error message is Process completed with exit code 1. in line 32. I want to understand what I am doing wrong. any help will be appreciated :). this is for https://github.com/adafruit/Adafruit_CircuitPython_Display_Text/pull/112
Adding some documentation functions parameters in functions in label.py. Trying to standardize the documentation with Bitmap_label.py docs.
New documentation included for:
Label main class
create...
Looks okay to me (a grammar nerd), but some more experienced eyes should check first.
@still zephyr It's not you. Something changes with a part of how our CI works and things are now failing.
I think we only discovered it in the last couple of days. We're trying to figure out how best to fix it without creating a significant amount of future work for ourselves.
Oh thanks @idle owl. as a first timer, you always think is you π . Thanks for the info.
Looks like the CI fail was for Trinket M0 in ja, that might need some shrinking.
@still zephyr You're welcome. For your own reference, usually if the CI fails on something you did, it's forgetting to run black locally, or Pylint errors, and those are much clearer errors in the CI results. Black says it would reformat files, and Pylint gives you line numbers.
This one is a weird one, and isn't something you'd usually run into.
Looks like the CI fail was for Trinket M0 in
ja, that might need some shrinking.
Thanks, this caused mayhem in my last attempt. @dhalbert has a fix, so I'll wait for his advice. I appreciate you taking the time to review my PR.
I see. question then, if I understand correctly I have to run black locally, maybe I miss that step, I was following the contribute to circuitpython and I did not see it.
Oh! It's another guide. Maybe we didn't mirror it into the contributing guide. https://learn.adafruit.com/improve-your-code-with-pylint This covers Pylint and Black.
Anyone have insight into issues with the FeatherSTM32F405 not playing nicely with the MPR121 STEMMA-AT breakout? Traceback (most recent call last): File "<stdin>", line 1, in <module> File "adafruit_mpr121.py", line 131, in __init__ File "adafruit_mpr121.py", line 180, in reset RuntimeError: Failed to find MPR121 in expected config state!
Thank you very much, I followed the guide and know the PR passed the checks. Thanks again and have a good night.
@still zephyr You're entirely welcome! Well done!
ESP32-S2 question vs. pyportal: I'm running some bitmap manipulation (rotating some bitmaps) on the pyportal vs. the ESP32-S2 Saola, both running ParallelBus.
I'm surprised that the Pyportal is updating faster than the ESP32-S2. Is it possible there's some sleep-related issues that are affecting performance on the ESP32-S2?
Is there any way to ensure that the ESP32-S2 isn't sleeping?
An alternative would be run all tasks while interrupts are off and then we reset before turning them back on.
This can be a bit tricky to do, since when background_callback_run_all() exit critical section to run task function, the tud_task() will then generate more usb isr to add to background queue. For this example, msc host will continuously bumping data fast enough, that will effectively causes MCU to actually have to complete the whole MSC copying before able to do the reload
...
Just replace boards/trinket_m0/mpconfigboard.mk with this version:
https://github.com/adafruit/circuitpython/blob/595356d7fdd132c41c42a1441d41ade999b8f7b4/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk
I make a quick hack to add usb background after the background_reset() for quick test, it does solve this issue and quickly complete the file copying without issue https://github.com/hathach/circuitpython/pull/1 . There is also a couple of minor code clean up as well.
Looks okay to me (a grammar nerd), but some more experienced eyes should check first.
@tannewt updated and rebased. unfortunately I could not get the display_init code to work. I do have the code working in python. but, my C skills are just garbage.
@skieast I'll wait for your tinyuf2 PR. I suppose you already saw the PID for that.
I've created a PR for the tinyuf2 support.
https://github.com/adafruit/tinyuf2/pull/67
I did some research into options for dealing with the rev: in pre-commit.yaml.
It doesn't support mutable names (stable, latest) any longer and there is a wish to also not have to hardcode the versions or to manage it centrally.
Full notes on the tail end of this Issue's description. https://github.com/adafruit/cookiecutter-adafruit-circuitpython/issues/99
Summary:
There is one path where a custom local pre-commit hook is used to get a config file and then run pre-commit --config based on that file.
There is one path where where all repos are kept up to date by automating pushing changes to them. (links to options I found in the issue)
NOTE: Both of these options are suggestions from the pre-commit maintainer.
If anyone has additional suggestions, please add comments to that issue linked above.
oh the use of the screen for the bootloader on the ttgo is brilliant
when do we get that on the Clue (and others) ? π
Just replace
boards/trinket_m0/mpconfigboard.mkwith this version:
https://github.com/adafruit/circuitpython/blob/595356d7fdd132c41c42a1441d41ade999b8f7b4/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk
OK that's done. Thank you for your help and patience.
After #4114 was closed, I tested a Pico with adafruit-circuitpython-raspberry_pi_pico-en_US-20210202-9140bfb.uf2 and the latest library bundle as 20210203. I modified the pin number in the demo and it still draws and error:
`Traceback (most recent call last):
File "code.py", line 23, in
File "adafruit_sdcard.py", line 101, in init
File "adafruit_sdcard.py", line 122, in _init_card
File "adafruit_sdcard.py", line 111, in _clock_card
AttributeError: 'SPIDevice' object has no ...
As reported by a Discord User, the accessing a Character LCD fails on a Raspberry Pi Pico
The same example runs normally on a metro-esp32s2
For this example I used SCL on GP1 SDA on GP0
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 6.2.0-beta.1 on 2021-01-28; Raspberry Pi Pico with rp2040
>>>
>>> import charlcd_i2c_rgb_simpletest
Traceback (most recent call last):
File "", line 1, in
File "charlcd_i2c_rgb_simpletest.py", line 18...
Also ran against current tip of main -- same result
Adafruit CircuitPython 6.2.0-beta.1-68-gcd616f639 on 2021-02-03; Raspberry Pi Pico with rp2040
>>> import charlcd_i2c_rgb_simpletest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "charlcd_i2c_rgb_simpletest.py", line 18, in <module>
File "adafruit_character_lcd/character_lcd_rgb_i2c.py", line 75, in __init__
File "adafruit_mcp230xx/mcp23017.py", line 52, in __init__
File "adafruit_mcp230xx...
It would be nice to have default board busio devices on the Raspberry Pi Pico. The question is which pins to pick.
In the Get Started with MicroPython on Raspberry Pi Pico book, the I2C examples use GPIO0 and GPIO1:

SPI uses GPIO2, 3, and 4:

I like the first option. I expect there will be many folks following the book at first then trying CP.
Would you put the default UART on GP7 and GP8?
@tulip sleet Around for a question about the issue you filed?
on the phone, will ping you
Ok thanks
I don't know why it would be. Do you have wifi active while you are testing?
@slender iron are you working on busio.UART for rp2040?
I haven't started it yet
I've been thinking about how to do the dma/buffering
did you make progress on nvm?
yes... I'll PR tomorrow
nice!
How ubiquitous is the SDK within CircuitPython - which is to say, how likely is the typical user to be aware of the SDK info? Our goal is to make CircuitPython as simple as possible to use. As long as everything is documented, I think it's almost irrelevant what pins we use. That said, if we think the book is going to be/already is popular, we should follow those examples for simplicity. Otherwise, we should consider what the decision means in the long run - is the SDK going to be a longer-us...
@idle owl did you state your q in the issue?
@tulip sleet I did, figured that was a better place for it since you were busy and folks were replying already.
@slender iron This is a comprehensive list of the built in circuitpython modules, yes? https://circuitpython.readthedocs.io/en/latest/shared-bindings/index.html#modules
@slender iron I took some time measurements and the nested for loop in my updated "blit" function (written in python) is taking about 75-100% longer on the ESP32-S2 than on the pyportal.
With the faster clock speed of the ESP32-S2 (240 MHz) versus the PyPortal (120 MHz) I suspected the S2 would outperform.
I was surprised by this, but there must be some differences that I don't understand. The inner loop is copying pixels from one bitmap into another. Should this memory access/writing be slower on the ESP32-S2?
It's the best one I know of. There is a chance it won't have modules we inherit from MP
it doesn't include those, see https://circuitpython.readthedocs.io/en/latest/docs/library/index.html
e.g. json, etc.
the support matrix is actually a good starting point
help("modules") does include those
help("modules") should be the same as the support matrix for any particular board
memory access can definitely be slower due to external PSRAM and external flash
@tulip sleet Fair enough, where the support matrix? I hadn't considered that.
Ok. Yeah I'll need the other two links. I want to show everything available, then discuss how to find out what works on your board.
Thanks!
in "Core Modules". We could probably hack the "Core Modules" .rst to point to json, etc., somehow, for now.
Ok, got it. Sounds like performance comparison between the two will not be so obvious to predict. Thanks for the feedback.
@tulip sleet It would be ideal to have them all in one place.
the real solution is to move all the modules to shared-bindings, but that's not done yet. I can see about fixing up the .rst's temporarily
Yup, it's definitely more complex than clock speed. (Memory bandwidth is something the rp2040 should be good for.)
Also, I had assumed that the "python" overhead would be the limiting factor and not memory access time.
@idle owl Do you have a UART example preference for default pins, since the book has no UART example?
Makes sense. I'll tweak the wording in the guide for now and include both links I suppose. Bleh.
There's no UART support yet I thought. There's no UART examples. We could follow the SDK in that one.
I doubt it in this case because code gets cached as it's executed (rp2040 does this too) but RAM isn't cached afaik.
As long as it doesn't clobber the other two anyway.
unfortunately they would overlap with the book SPI pins
Let me look at it and let you know what I think.
I think the average CircuitPython user is not going to be looking at the MicroPython SDK document. The book is much easier to read and I can imagine it being a taking-off point. So using the first set makes sense. The main thing is to document it clearly.
@tulip sleet SPI and I2C are numerical order, might as well arbitrarily go with 5/6..
@tulip sleet Actually
There's a ground pin between those two
that overlaps with SPI
ARGH!
I have been programming Python for TOO LONG, and it got SMARTER, and I DIDN'T NOTICE.
it can't be GP5 and GP6 because they are not a UART pair
@fringe trench π
@tulip sleet I was going to change to 6/7 anyway.
Because ground pin.
So that coincidentally would work.
has to be GP8, GP9 or high
You don't have to explicitly pass self to super().__init__ in Python 3, apparently.
GP6/7 are not attached to a UART
i keep making the same mistake, it's a nightmare
having the silk labeled 1,2 is crazy
@tulip sleet So frustrating.
@tulip sleet GP#, or super?
Anyway, go with 8/9.
GP π
could you propose in the issue?
@fringe trench yes, that is nice in Python 3
the main trouble for a while was old examples on the web
Does it mtter if it is UART0 or UART1 -- UART0 is on 12/13
You can tell how long it's been since I wrote class hierarchies...
goes to get a cane and slippers....
@solar whale not really; MicroPython optionally has the REPL on UART0, but we are not proposing that
@idle owl I have a PR to add these in progress
Thank you for humoring me.
I wish they did not use the term "SPI_TX/RX" confusing....
or is that the new standard replacing MOSI/MISO?
Right on.
As we do not have a UART example yet, please put UART on GP8/GP9. It's a UART pair, and avoids I2C and SPI suggested above.
Done
@solar whale SPI TX/RX is new to me. I know of MOSI/MISO, COPI/CIPO, SDI/SDO, but not TX/RX, which is ambiguous. https://www.oshwa.org/a-resolution-to-redefine-spi-signal-names
SDI/SDO are also ambiguous, as diagram shows.
Ugh, it makes it like UART where they're backwards. I get that wrong now every time I'm wiring up SPI.
@tulip sleet I highly doubt you'll remember why I put this in my notes for this guide page, but I have "Special pin scl aka D2" as a bullet point, and I have no idea why. Any clue?
the preview guide page from yesterday?
Yeah
Supposed to be explaining board, import board, dir(board) and separately, built in modules.
I still need to put in an example of the ESP32S2 or Pico with different pin names, but I'm getting close to done.
but that was on my list, and I don't know why
@solar whale i agree, about SPI_TX/RX. it's going to be nothing but wiring confusion. "try swapping wires" is going to have a new resurgence in trouble shooting land. π¦
Welcome back to UART, I guess.
yep
@idle owl I don't know what the D2 note means, but is D2 also SCL or some board or another, like gemma or CPX or something?
@tulip sleet D3 is SCL on CPX. I have no idea. I guess I'll skip whatever it was, and if Limor remembers, she'll catch it in review as missing.
Thanks for thinking about it with me.
This pin map script is super convenient. Thank you @crimson ferry and @jaunty juniper.
maybe it was just a fictitious example of a pin with two names?
Not sure why I would have said "special pin" though.
But yeah maybe.
And I covered that thoroughly.
Hah, adafruit_bus_device messes up the layout now.
@tulip sleet Can you review the page for content accuracy? And copy edit while you're at it, but you do that naturally.
@tulip sleet Take over for that, yeah. That would be great.
Another issue to fix! π
Indeed!
@idle owl, ok, made a number of edits for clarification
Thank you so much!
@idle owl Worth explaining: I removed "external" from "external library" because I thought what "external" meant wasn't that clear, and it might raise more questions.
@tulip sleet I added that at the last minute because I thought it was needed. But yes. Good call.
i also added "built-in" more places, as you'll notice
Ok
The esp32-s3 (S3) could be amazingly useful from KWS to image recognition but if Espressif try to shoehorn into Espressif only solutions of esp32-who & esp32-skainet its likely going to be a flop.
If we get anywhere near a complete port of tensorflow-lite then wow its got big potential.
Apparently sleeping on a problem helps, realized the (dumb) mistake I was making getting ParallelBus on rp2040 going. The code is a mess still (and not optimized for the PIO totally) but works.
@tidal kiln I created a new draft PR on the adafruit_nunchuk library to start the discussion about adding support for other accessories and if it should go here or be migrated to a community library. https://github.com/adafruit/Adafruit_CircuitPython_Nunchuk/pull/25
anyone else have thoughts on bundle location for above?
@tidal kiln If you feel it should go in the Community Bundle, then follow that.
i'm fine with either and open to suggestions though. can see plus/minus either way.
I understand, but I think it's going to end up falling to you to make the decision. I can see it working in both locations, but I think as Adafruit sells the nunchuk but not other things, it might be best in the community bundle for now. We can't easily support other controllers without one of us finding the hardware etc.
that's why i lean toward community also
Sounds like a plan, then.
That makes sense to me.
cool. thanks @gloomy shuttle . feel free to take whatever you want from the nunchuk lib.
great thank you. I was hoping to keep the stuff from the nunchuk so there could be a single library that had everything and not have to point people back to the other in case.
@gloomy shuttle I would include in whatever you submit to the community bundle, the refactor format you chose, though, to make it extensible. And if Adafruit starts carrying other controllers, we can easily port your code to nunchuk.
So make it a package with a base class like you have in the PR.
Got it. Next question, should I start fresh using the cookie cutter and just copy code over
That would be great.
yah, having two libs to point people to isn't great (one of the minuses). but the implied hardware support is also important to consider.
@gloomy shuttle You'll have to tweak some things post-cookiecutter to make it work for the Community Bundle. We have a PR in to make it so you can choose which bundle you're aiming for, but it's not merged yet.
Okay, I think I ran into some of that when I first started this endeavor. I had to tweak some of the workflow/pre-commit stuff
Yeah I think that covers it.
And setup.py as well I think... I'm not sure honestly.
But I know some things have to be tweaked.
That PR should be in today or Monday. (I'm the reviewer, and I'm only in Mon-Wed, so if I don't get a reply on my review today, it'll be next week.)
Alright, thank you
@tidal kiln any thoughts on what this library should be named? Should I name it CircuitPython_WiiChuck as I want to slightly mimic the Arduino WiiChuck library. https://github.com/madhephaestus/WiiChuck
@tannewt Is it ok to call pwmout_reset() in the board_init()function to temporary solve the problem? if yes then I can try to create a PR (will be the very first π―)
Power failed. Sigh.
I also get this error on ESP32-S2 Metro
@jfabernathy Can you set it to this and try it? (In adafruit_sdcard.py)
self._spi.spi.configure(baudrate=250000)
Thanks for testing this!
I'm going to need a little help the adafruit_sdcard I have is the one in the bundle which is a mpy version. Where to I get the .py version?
It's apparently a huge outage due to loss of power to the provincial grid. They're working to restore it, but ETA is ???
I'm going to send you what you need in a bit so we can get that merged.
Lovely, thank you. Like you mentioned, I might catch something you wouldn't.
So I got adafruit_sdcard.py and just put that in the CIRCUITPY/lib directory on the ESP32S2 and changed to self._spi.spi.configure(baudrate=250000)
Now I'm getting another error.
File "code.py", line 18, in <module>
File "/lib/adafruit_sdcard.py", line 101, in __init__
File "/lib/adafruit_sdcard.py", line 122, in _init_card
File "/lib/adafruit_sdcard.py", line 112, in _clock_card
AttributeError: 'SPIDevice' object has no attribute 'chip_select'
@idle wharf We're pretty confident at this point that the current answer is an Adabot patch is necessary and we'll pin everything. Correct?
@jfabernathy try commenting line 112 out. The pin should already be high
Hey I have power again!
Yes, I agree.
The alternative is writing or own hook (in its own repo) which we then use to get a global pre-commit.yaml.
Totally doable and would work with community repos too.
Hmph. Perhaps in the future.
Simply wanted to make sure I hadn't missed something before setting Dylan off on a mission.
No, you got it
Wonderful news! Thank you π
...once I can manage to get through this work day...
with #112 commented out in adafruit_sdcard.py
line 18 in demo program, sdcard = adafruit_sdcard.SDCard(spi, cs)
still give this error
File "code.py", line 18, in <module>
File "/lib/adafruit_sdcard.py", line 101, in __init__
File "/lib/adafruit_sdcard.py", line 166, in _init_card
AttributeError: 'SPIDevice' object has no attribute 'chip_select'
@idle wharf Hmm, what do we do with setup.py in the community bundle version? Is it even possible to change it for the community bundle version? I'm not sure if it's templated or not.
Still includes # The project's main homepage. url="https://github.com/adafruit/Adafruit_CircuitPython_test_comm", # Author details author="Adafruit Industries", author_email="circuitpython@adafruit.com",
etc.
I'm not even sure the community bundle is deploying to PyPI, maybe we don't include it at all?
I commented on the PR.
I think there are many more things one could change in the community v. adafruit library. This probably isn't an exhaustive list, but I had thoughts on that here:
https://github.com/adafruit/cookiecutter-adafruit-circuitpython/issues/100
Those are my opinions though and I think someone like yourself should be the decider. It plays into how "CircuitPython" the literal string is used community libraries by default.
My thought would be yes, do it.
@idle wharf Is it feasible to have it ask which bundle you're targeting first and give you different options based on that? Or is that not a thing.
Honestly, I'm not sure. I don't know much about cookiecutter (yet).
Fair enough. If you want to look into that, consider it. If not, no worries. I'll reply in the issue you linked.
@lone axle I have another mission for you, should you choose to accept it. We're updating cookiecutter, and the Sharing a CircuitPython Library guide will need to be updated to go with it. Is this something you'd be willing to do?
@idle owl yep I am up for that. I'm still planning to write a section on pre-commit for that Sharing a library guide as well. So definitely can make any other needed changes at the same time.
or around the same time at least, if not in the exact same sitting
Ok great. I'll add you to the PR so you're aware of the timing.
@lone axle You can work with @idle wharf once the PR is merged to make sure the documentation is clear and accurate.
this pylint report seems odd, it seems to want secrets before a native lib, and is calling wifi a "third party import"? https://github.com/adafruit/Adafruit_CircuitPython_Requests/pull/68/checks?check_run_id=1826084237
@crimson ferry Sometimes it's weirdly picky. Does reordering the imports make it happy? Or does it continue to fail?
I don't know, I was going to try to guide the author, but it makes no sense to me... do we blindly follow pylint's advice, or try to fix some underlying problem?
@slender iron So the bus device built into CircuitPython now works? I confused myself when this sensor worked without me loading the bus_device library onto the board.
I just haven't had much encounter with pylint before, so I don't know
@crimson ferry Fixing an underlying problem would likely involve changing how Pylint works, and I don't think we're going to do that. If you don't agree with it, you can disable it in the code, but you should have a good reason for doing that. In this case, I would say follow it.
yeah, is should. only sdcard seems unhappy about it
@idle owl ok, cool, thank you
Nice! Ok. Seems like this should have been a bigger deal. π One less thing to add to guides I suppose.
@idle wharf FYI, the patch is in Adabot, but Dylan likely won't get to it until next week. He's prepared for the mission though, so in theory we'll have everything updated within a couple of weeks.
@idle owl should this get archived?
https://github.com/adafruit/Adafruit_Python_LED_Backpack
@tidal kiln Probably?
i think this replaces it:
https://github.com/adafruit/Adafruit_CircuitPython_HT16K33
Have you archived a lib before?
yes
just came across someone using it forums. will figure out how they got there, in case a guide is still ref'ing it.
Sounds like a plan.
but i'm not finding anything
it has some reasonably recent issue/pr activity
but the last commit was 2018
Hmm
I guess ping Limor.
If you're not sure about it. I know she wanted everything archived eventually.
ok. yah. i probably will just to be sure there's not some odd reason it's being kept around.
i can blink an led π
If so I'm pinging you in the help-with channel because I'm not and it's not working and I don't even know where to begin troubleshooting.
lol.
Ok.
i'll jump over there and take a look
I think your 2 idea is the best way to go about it for now. There isn't a single VM task.
We don't have a way to know which tasks to drop because we're stopping and those we can to keep doing. Perhaps we should add a critical flag or something.
My vote would be to follow the book.
However, I'm not a huge fan of adding default busses when the board doesn't document them itself. At some point its on the board maker to do the designation.
Reading over the last few hour or 2 from #help-with-circuitpython, particularly the thread with coolmandude545, it made me realize something I'd noticed that felt disjointed, but I couldn't put my finger on it. But thanks to that conversation, I JUST did...
The issue I've had in the past, is that there's no obvious callout or indication which go from the code from a project's learn guide, to the documentation on ReadTheDocs. At least not on the projects I've been looking at or following
Just mentioning it since it occurred to me. Something that might be worth adding to guides, maybe on the code page/tab/section would be a listing of the libraries used, and links to the ReadTheDocs for them
yep, going from an example to the API is an involved process with much googling, and google often does not return the best version of readthedocs which can also lead to confusion
Agreed for the RTD version. And I always forget to check that, and then need a moment to remember where the version selection is
I'm not familiar with the learning system backend, so I'm making some assumptions here... Something else that could be interesting from there, if the libraries for each guides are indexed, is a "other projects using library X". That way, it may make it easier to find different parts of the same library that can be used together.
I'm mostly thinking "out loud" about this, but figured I'd share the thought.
</ramble>
@tannewt Is it ok to call
pwmout_reset()in theboard_init()function to temporary solve the problem? if yes then I can try to create a PR (will be the very first π―)
Yup! (Usually the in use checks default to free.) If you find it gets reset you may need a never_reset call.
Thanks for debugging this!
I think you'll find that the tradeoff is between IDF/sockets (which gets the remainder) and pystack.
As a new user of CP and the Adafruit products, I agree with Hugo that pointing users to the relevant ReadTheDocs from the guides would be very helpful. Finding a relevant guide is fairly obvious on the Adafruit website but, in my experience so far, going the next step to ReadTheDocs is not.
Looks like we could be getting an error from pico-sdk: https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/common-hal/busio/I2C.c#L148-L157
then there is the arduous task of going through the inheritance tree
so I'm showing someone the doc to adafruit_display_text, and I'm puzzled because it doesn't have x and y properties listed, so I look at the source code, class Label(displayio.Group): , and now I'm looking at another RTD
Ah, yeah. Inherited parts of a lib. Hmmmm
I wonder if Sphinx has a way to include the inherited portions as well. I know that I've seen it with GhostDoc and Doxygen, I think.
yup, agreed we have good docs but they could be better organized
maybe we could parse example code and link each function/module out to readthedocs
My thinking was, depending on how the guide's backend works, it might be easier to have the list of libraries as part of the guide's metadata
But like I said, that's making some assumptions about the backend
learn is all custom so we could add it π
I was hoping that circuitpython library RTD would have links to products
That's the developer's answer right there! Not that I've ever said that! lol
and guides do know products
I don't work on learn so I'm signing others up for work. π
So yeah, that cross-referencing and links between libs, projects and docs would be awesome
Well shoot. Here I was hoping to sneak something onto your "honey-do" list!
it's already plenty long
Ok, looks like sdcard takes in the chip select so it should just remember it.
I think your 2 idea is the best way to go about it for now. There isn't a single VM task.
We don't have a way to know which tasks to drop because we're stopping and those we can to keep doing. Perhaps we should add a critical flag or something.
Ok, I will make an PR using this method
Issue
run_code.py decide to reload (AUTO_RELOAD) and run background_callback_reset() while background list is still queued up with usb event.
background_callback_run_all: 95:
callback_head = 200029A4
callback_tail = 200029A4
background_callback_run_all: 100: // background_callback_run_all() exit while there is queuing callbacks
run_code_py: 340: // reload request == true
usb_irq_handler: 103: // usb isr occurs -> more callback queued up
callback_head = 20002...
I am not sure that we could just run usb_background() here, if it is then, we could remove the need to add this usb_background_schedule()
this function name is the best I could come up, let me know if you want to rename it.
the pointer should be volatile rather than the data it is pointed to. We actually can have it as
STATIC background_callback_t * volatile callback_head, * volatile callback_tail;
But I will leave it as both volatile just in case I misunderstand its purpose.
this function seems to be redundant
I have requested and received a PIDs from Espressif for the CucumberRIS board.
I have also created a PR for the UF2 Bootloader using the appropriate PID.
0x800C | GRAVITECH CUCUMBER RIS ESP32S2 - Arduino
0x800D | GRAVITECH CUCUMBER RIS ESP32S2 - CircuitPython
0x800E | GRAVITECH CUCUMBER RIS ESP32S2 - UF2 Bootloader
Thank you.
From: 'Bruce Segal' via Engineering engineer@gravitechthai.com
Sent: Thursday, February 4, 2021 8:33 PM
To: adafruit/circuitpython circuitpython@noreply.github.com
Cc: gravitech-engineer engineer@gravitechthai.com; Mention mention@noreply.github.com
Subject: Re: [adafruit/circuitpython] Add Gravitech Cucumber R board definition (#3349)
I have requested and received a PIDs from Espressif for the CucumberRIS board.
I have also created a PR for the UF2 Bootloader usin...
Just a heads up if anyone has time to see if they can reproduce: on a Raspberry Pi Pico , I have a 7 neopixel string (Jewel). If I set it up and write to indiviual pixels with ```
Adafruit CircuitPython 6.2.0-beta.1-80-gadaf43d6d on 2021-02-04; Raspberry Pi Pico with rp2040
import board,neopixel
pix = neopixel.NeoPixel(board.GP27,7)
pix[0] = 0xff0000
pix[0] = 0x0000ff
I'll dig further this afternoon and open an issue if no else gets to it first,
@netroy I've created a PR for the display init code. #4124
i'll test and leave my comments later. thanks for doing this :)
this is from Atmel Studio
anyone know how to get the equivalent of that Device signature number via JLink command line tools?
@tidal kiln looking...
thanks. i've been punching at it and nothing obvious.
@tidal kiln
J-Link>mem32 0x41002018,1
41002018 = 10010305
number above is from a Metro M0
cool. thanks @tulip sleet
i was foolishly thinking there'd just be a command for it
vs. a low level read
i hoped so too. It's a standard "CoreSight" thing that exists across all ARM chips.
this is a ROM location, not writable
yep. thanks. was noting the R access. so really no way to shoot one self in foot and accidentally change that.
by comparison, on a SAMD51J19:
J-Link>mem32 0x41002018,1
41002018 = 60060005
J-Link>mem32 0x41002018, 1
41002018 = 10010305
J-Link>w4 0x41002018, 0x98bec2
Writing 0098BEC2 -> 41002018
J-Link>mem32 0x41002018, 1
41002018 = 10010305
J-Link>
doesn't complain if you try. but doesn't do anything.
I don't know what the problem we discussed earlier is, but changing the BOOTPROT fuses should not be related to the ID, so I suspect some kind of software bug
most likely. was just wanting a second way to get that chip id value. and also verify there's really no way to accidentally mess it up.
do you know if there's a decoder ring for them somewhere?
@tidal kiln the SAMD21 datasheet screenshot above is fairly informative, but the SAMD51 datasheet page is less so. I did some websearching for the various fields but found no master key.
thanks. it must exist somewhere. atmel studio is comparing against something for "expceted" values.
it looks like it's getting the wrong value when it tries to read it, but I don't understand how
could there be a range of acceptable values? like to cover all known revisions. and it would need updating when new revisions come out.
but in this case it's changing out from under someone to an unrecognized value
yes, there certainly would be a range because there are revision fields
hmm. yah. and also 0x10010305 vs 0x1001031F would only differ in the DEVSEL bits
We want to be able to use this to measure VSYS.
@jerryneedell can you retest this and see if it works for you now? My personal test works.
@onyx hinge Could I just throw together a super quick PR to resolve #4023? I just noticed it while browsing the ESP32-S2 issues, it'd take me all of 10 seconds to add the missing claim-pin for each of the I2S construct pins.
@ionic elk that would be awesome of you!
I put a WEBUSB_README.md file in the top-level directory, but in brief - this PR incorporates the functionality from the tinyusb example program "WebUSB serial demo". When this option is enabled, websites like
https://adafruit.github.io/Adafruit_TinyUSB_Arduino/examples/webusb-serial/index.html can access a WebUSB serial console from the browser.
The functionality of the tinyusb "WebUSB serial" demo has been incorporated into a webusb branch. It turns out you can have your CDC console and a WebUSB console at the same time, but depending on how many USB endpoints your chip supports, you might have to give up SOMETHING. For some ESP32-S2 work we are doing at Firia Labs, we have been trading USB HID for WebUSB at compile time. A PR has been submitted.
Two issues I'm encountering post-4049:
- HTTP doesn't work for me https://github.com/adafruit/Adafruit_CircuitPython_Requests/issues/63#issuecomment-771712906
- Under certain circumstances, OSError: Failed SSL handshake occurs, particularly if there has been some delay since the previous Request [https://github.com/adafruit/Adafruit_CircuitPython_Requests/issues/63#issuecomment-771909006](https...
@anecdata I'm looking into the HTTP thing now, sorry for the delay, I've been having power cutouts from the weather. As for the second point, are we sure that isn't defined behavior? I'm not an SSL expert but can an SSL session just persist indefinitely?
The OSError: Failed SSL handshake seems to be correlated to no keep-alive, so either no Connection header, or Connection: close.
@crimson ferry @tulip sleet I have a weird python thing going on. When you do try: except SomeException: the docs imply it's supposed to look for that particular exception, but throw any uncaught exceptions that might happen, right? https://docs.python.org/3/tutorial/errors.html
But I'm finding that this block:
try:
print("REQ: send attempt")
self._send_request(socket, host, method, path, headers, data, json)
except _SendFailed:
print("REQ: send fail")
seems to just ignore whatever it doesn't catch
it just moves on to the rest of the program.
If I add another line:
except OSError:
print("OSError")
else:
print("Another Problem")
it'll land on these, but when they're gone, it just ignores them
is there an enclosing try-catch that's catching the uncaught inside exception?
There is, and it should be, but it isn't.
it's just acting like there was no uncaught exception at all
Adafruit CircuitPython 6.2.0-beta.0-43-g351a0e747-dirty on 2021-01-26; Adafruit Metro M0 Express with samd21g18
>>> try:
... 3/0
... except ZeroDivisionError:
... print("caught it")
...
...
...
caught it
>>> try:
... 3/0
... except ValueError:
... print("caught it")
...
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "<stdin>", line 2, in <module>
ZeroDivisionError: division by zero
>>>
Could you point to your code
Sure, I'm using @crimson ferry 's last example here: https://github.com/adafruit/Adafruit_CircuitPython_Requests/issues/63, and I'm modifying the lines described in this issue: https://github.com/adafruit/Adafruit_CircuitPython_Requests/issues/67
The same thing also happens with Jerry's code here: https://github.com/adafruit/circuitpython/issues/4061
the Requests mod I used to catch and show the trace on line 566 is:: except (_SendFailed, OSError) as e: sys.print_exception(e) ok = False
I'm finding that else: catches an error that is neither of those, but if you don't include it, it never gets caught
Don't know what it is yet
@ionic elk you can do except Exception as e: and then print(e) so you can see what the uncaught one is
unfortunately you cannot do else as e:
i didn't see anything weird about the code you uploaded
yes, I am testing it now
ok! thank you!
you were having a dialogue with him, so I though you were more enmeshed, but happy to t do it
np, I was just trying to keep him moving
Here is a pending PR to restore the pad state: https://github.com/raspberrypi/pico-sdk/pull/80
Code looks good! Will approve and merge after @netroy tests. Thanks!
ok great @cotdp please update this PR :)
@hierophect I just tried with tip of main and it still fails with time.sleep(60)-- do I need pull in a PR or update any libraries?
Ah! That's what it's used for! Do you have any reason to call it A3? We commonly have a VOLTAGE_MONITOR pin name on other boards. That'd make it clearer that the pin isn't broken out.
Yes, GPIO4 is the LCD_MISO pinβ¦thatβs why I removed it
@jerryneedell you'd need to go into Requests and search for except _SendFailed and replace it with except (_SendFailed, OSError):
@tulip sleet I assigned the webusb pr to you too. I think it fits into your usb thinking now
Setup
- Microcontroller: UnexpectedMaker FeatherS2 (ESP32-S2) (fw: 0.2.1)
- CircuitPython: 6.1.0 & custom build from
main - Host computer: macOS 11.2
- Tools used: Wireshark
Description
It seems that port for socket.sendto() is bound to the length of an uint8_t, capping it out at 255, and then overflowing back to 0 when port numbers above that are specified.
I confirmed this by seeing seemingly random ports show up when I was trying to send data over port `9000...
Thanks for noticing this, definitely an oversight! Might have been an unintended carryover from another API.
Tested while copying files: this works either way: usb_background() or usb_background_schedule(). I think they accomplish the same thing.
Good catch. We can leave it as volatile both ways.
@hierophect That appears to have fixed it for my initial example -- made it through 3 cycles so far
@ionic elk did you figure out the disappearing exception? Is the whole program failing and restarting??
I'm still muddling through it, I think I'm missing something obvious
Going to take a quick lunch break and come back to it, clear my head
@jerryneedell you'd need to go into Requests and search for
except _SendFailedand replace it withexcept (_SendFailed, OSError):
Is this change being incorporated into Requests?
Closed in favor of #4122.
How about having both A3 and VOLTAGE_MONITOR names available? The RPi Pico docs seem to call it A3 so I would think it would be best to have this name available for the people coming from that side but VOLTAGE_MONITOR for the people who come from the Adafruit / CircuitPython side.
Thanks for doing this work. Before reviewing it in detail, I'd like to ask you if you also considered using the "Serial API", sometimes known as "WebSerial". This does not need its own descriptor on the device side, unlike WebUSB. Discussed in this closed issue: #605. #3950 is basically a duplicate of that.
Spec: https://web.dev/serial/
Status in Chrome: https://www.chromestatus.com/feature/6577673212002304
The Chrome demo does not...
Note that another alternative is the "Serial SPI", sometimes known as "WebSerial". This was first mentioned in closed issue #605.
Spec: https://web.dev/serial/
Status in Chrome: https://www.chromestatus.com/feature/6577673212002304
The Chrome demo does not quite work with CircuitPython (I see repeated <DISCONNECTED> <CONNECTED>). But I think we could get it to work
@tulip sleet thank you and Thach for working on that USB thing which I guess turns out to be my fault. I wonder whether the mistake is cancelling all background calls, vs just those that refer to objects on the gc heap ... since my real goal with that API was just to make sure those got cleaned away without directly tracking them all.
(I'm not sticking around to discuss it right now though, and I probably missed at least some of the discussion on the PRs for context)
@tulip sleet @crimson ferry Ok, I'm trying to sort out what exactly I should continue testing here
I had a misconception about how try except worked because I'm still not great at python and didn't read the docs right, so that's the disappearing exception out of the way.
It seems like the except (_SendFailed, OSError): solves at least part of the problem
I don't think of it as a fault. Exactly what is going on in terms on USB tasks is tricky to understand. I thought there were things to do that were not triggered by an interrupt, and I still am not sure I understand it fully.
@ionic elk So what happened to the OSError exceptions?
Now I've got two things left: 1) @crimson ferry is HTTP still messed up for you? I don't really get what was going on with your code and 2) is the SSL connection timing out after about a minute and having to be replaced with a new socket expected behavior
@ionic elk I just submitted a Requests PR with that fix, it masks the issue of Failed handshake, cause unknown.
@tulip sleet I thought that else was only supposed to catch exceptions. Because I am bad at reading.
So I thought it was catching an exception that was going away
(2) the SSL handshake is failing for some unknown reason on certain circumstances, I don't know why. With the PR in Requests, it will get a new socket, but the failures will continue silently.
This is kind of a @slender iron question, maybe, since he wrote the SSL stuff
(1) HTTP still doesn't work for me, the code block in the issue is complete, also fails the same way with the simpler/better requests.Sesion call.
(http = requests.Session(socket) instead of http = requests.Session(socket, ssl.create_default_context())) ...for insecure HTTP
My intuition is that SSL might just be timing out? As in, the handshake requires you to maintain the connection and not just go silent for minutes at a time. But I don't know
well, except that it seems to happen when the TCP connection is closed, not when it's kept alive
Is your sense that the HTTP stuff goes down to the low level Socket layer? I haven't worked in the HTTP library at all
Β―_(γ)_/Β―
I'm really not sure, I am by no means an expert
@crimson ferry I don't quite know what you mean by that last part
regarding (2): it seems to happen when the HTTP/TCP connection is severed between Requests, rather than when it stays alive between requests
Me neither, I don't think anybody knows what's going on π¬
Really? I see it happening when it tries to fetch a socket, and can't reach it
REQ: attempting request
REQ: Got Socket 1
REQ: send attempt
ERROR: Failed SSL handshake
REC: try recvinto
REQ: Socket should close
REQ _close: attempt to close
REQ _close: closed
REQ _close: deleted
REQ _close: end
REQ: Socket closed
REQ: Got Socket 2
REQ: send attempt
REC: try recvinto
REQ: break
REQ:
in any case, re: (2), user code is happy with the Requests patch, we may just need to keep in mind that something deep down may be lurking
I'm not sure how to interpret that log, perhaps IDF is doing something counterinituitive when it doesn't get a Connection: keep-alive, or maybe it's not even aware of that level?
^Here's what my internal messaging indicates: it fetches an existing socket with _get_socket, and then attempts _send_request, which fails with an SSL handshake exception. Because this is now caught, it automatically closes that socket, because it's invalid, and opens a new one to try again
right, so user code is happy, but we really don't know why the handshake failure
it's reproducible, circumstances seems constrained (not just any old HTTPS request)
My suspicion is that it's a timeout - I'm not an SSL expert, but maybe it's like USB, where if you don't maintain it, it'll die on you.
Because it works with short periods, but after a minute, the socket goes "stale" and can't be used anymore.
I have no idea if that's true, and tbh I'm not really sure where to start on researching it π
maybe it's because IDF/Requests is not explicitly doing any behavior based on presence (and value) or absence of an HTTP Connection header ??
Some consideration was given to "Web Serial", and in fact if we had not been able to add support for "WebUSB Serial", the newer "Web Serial" was our backup plan. The reason we had such a high level of interest in "WebUSB serial" is that we have existing products already shipping that use it.
The reason we went with WebUSB originally is that the project/product line predates the addition of "Web Serial" to Chrome.
On a related note, we are also going to try to make use of WEB_DFU on this...
Is IDF purely TCP level? If so, then it's something that Requests would handle.
That I don't know anything about, I'm just coming from the Sockets perspective. I don't even understand why we're using a module called HTTP for HTTPS.
But I'm fine with masking it for now, and we see if something crops up later.
We now have two different versions of Socket - the regular Socket is TCP only, and SSLSocket, which wraps a Socket, uses MBED TLS under the hood.
I still would like to help with this HTTP error but I don't properly understand what it is or whether it's something I should be helping with on the C end
and those TCP sockets can carry any higher-layer protocol presumably... so I'm thinking this is a limitation of current Requests
By carry, you mean you add additional application layer code on top of them?
@ionic elk I'd propose we call (2) done, leaving only the insecure HTTP case.
right, like HTTP, HTTPS, etc
ok
@slender iron, if you're following, does this make sense?
SSLSocket simply looks like Socket with a more restricted set of functions
When it wraps an existing Socket, it creates an mbed TLS object. Connect calls esp_tls_conn_new_sync, which maybe is the Handshake part? And it does mention a timeout. But I don't know where that code came from. @slender iron did you write that stuff from scratch or were you working from an example?
I'm closing this issue now as @jerryneedell's remaining issue is in the Requests library and is continued in this issue: https://github.com/adafruit/Adafruit_CircuitPython_Requests/issues/67
@crimson ferry Ok when I try to run your sketch I immediately get:
Traceback (most recent call last):
File "code.py", line 23, in <module>
File "/lib/adafruit_requests.py", line 613, in get
File "/lib/adafruit_requests.py", line 567, in request
File "/lib/adafruit_requests.py", line 435, in _get_socket
RuntimeError: Sending request failed
Traceback (most recent call last):
File "code.py", line 39, in <module>
NameError: name 'response' is not defined
HTTP? right, that's what I get, I can't do an insecure HTTP at all anymore
can you just quickly reiterate what this is supposed to be doing?
Ah, ok
Yes, what's probably going on here is that the Requests library automatically attempts to create a TLS socket no matter what?
so it doesn't even have an option for regular HTTP
I don't know, Requests often baffles me, it used to work when sockets were combined
I don't know which Socket call is used for an insecure HTTP get, I can try and look that up.
Right, that was when we had both plain TCP and TLS sockets side by side under the hood and you didn't know what calls were using what. So you could be totally unencrypted for some stuff when you thought you were.
I thought that Requests might break a bit given the separation but didn't know to what extent.
How should Requests get a non-TLS socket?
I think this simply deserves a new issue for Requests
I don't know, is Requests based off a Cpython module?
wouldn't it just be by leaving off the wrap/default-ssl-context?
^oh, mechanically, yes. You just don't wrap it, and it'll stay TCP
Scott may know
or Brent
@prime flower would you be able to chime in here?
So, in theory, http = requests.Session(socket) instead of http = requests.Session(socket, ssl.create_default_context()) should bypass TLS socket and get a regular one? That still produces the same exception trace.
I'm pretty sure requests is based off https://requests.readthedocs.io/en/master/
circuitpython-requests is "requests-like", or I;'ve seen it described like that
Yes, if you detected the lack of an ssl context, you could just make a regular socket
The library
I'm saying maybe it should work as you said above? That http = requests.Session(socket) should make an non-TLS socket? I just meant to say I can see how that would work.
do we need to be passing another parameter to socketpool? or socket?
I would say let's check the source code of @prime flower's link and see how they do it. Cpython shares the Socket and SSLSocket distinction, it's what my code is based off - we were non-conforming before the split.
my question is: what API should the library use to get a non-TLS socket? https://circuitpython.readthedocs.io/en/latest/shared-bindings/socketpool/index.html
not invoking ssl for one
I mean to say that I don't know, and I'm the wrong person to ask, I'm just looking this up as I go. My ballpark is C drivers, not the HTTP layer, sorry!
@crimson ferry this is also of interest to me in the app layer for minimqtt
I do
which wraps the socket if context has been provided, otherwise i dont wrap the socket.
I really don't have a clear idea of where the issue is
Is that incorrect? is it always making a SSL socket?
I don't know, HTTPS is working great now, but no HTTP
@prime flower if you don't wrap the Socket it isn't a SSLSocket.
@crimson ferry this is on esp32s2 right?
there's no SSL in a regular <Socket> object anymore.
@prime flower yes, ESP32-S2
ok,
when we don't wrap the socket, getting a socket for HTTP fails https://github.com/adafruit/Adafruit_CircuitPython_Requests/issues/63#issuecomment-771712906
(see the edit at the bottom of the comment to use: http = requests.Session(socket))
@crimson ferry and wrapping a socket for a HTTP url succeeds?
this also doesn't work for an HTTP URL: http = requests.Session(socket, ssl.create_default_context())
I can't figure out a way to get HTTP URLs to work
@crimson ferry I'm a bit tied up today with work but I'm curious if this also effects insecure (non SSL) mqtt sockets in minimqtt..
that would be an interesting test
I could try isolating the socket creation code from the library and connecting to netcat
I'm having problems with non SSL sockets too in my websockets code
@tulip sleet quick style question for you. Is there a preference to use mp_uint_t in the common_hal layer rather than a simple uint or unsigned int?
Both socket modules are a bit all over the place right now
if you are going to be passing it back to shared-bindings, you should use mp_uint_t, since that signifies the type that is used internally for non-Python ints. But uint and unsigned int are both ambiguous. Perhaps it should be uint32_t for those places?
Re-reading and actually clicking on links, I see the "Chrome Demo" you referenced was in regards to the "Web serial" API.
I thought you were saying you had trouble with the "WebUSB Serial" demo at https://adafruit.github.io/Adafruit_TinyUSB_Arduino/examples/webusb-serial/index.html
I almost never use bare int, since its size can be in question
@prime flower @crimson ferry my raw Socket examples are still working on Main but if anything comes up that seems like it might be a low level problem feel free to tag me
@tulip sleet yeah uint32_t is what I typically used for all my common hal stuf
you would use an mp_uint_t if it was going to be converted to or from a python object
I am sort of considering pivoting to the XBee3 which already runs MicroPython out of the box and can be bought as dev boards or modules. All the (nasty) low-level ZigBee code abstraction is already dealt with. At this point I do not see the point in all the hassle with trying to reinvent the wheel on nrf52.
As far as I know, the XBees do not have the Zigbee cluster communicati...
Well, these are parameters being passed in from Python into the common_hal layer
It's stuff like what should bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const char* host, size_t hostlen, mp_uint_t port); use
yes, that makes sense there
But that's inconsistent with the other common hal modules like Busio
which also directly take in parameters but rarely use an mp_ prefixed typedef
It should "just work", but does anything in here look extra or inconsistent with our LWIP implementation? https://github.com/espressif/esp-idf/blob/6e776946d01ec0d081d09000c36d23ec1d318c06/examples/protocols/http_request/main/http_request_example_main.c
Should I also change things like the size_t used for hostlen, or the const char* for host?
can you give me some examples, e.g. I see this:
The .u_int is declared as a mp_int_t (here u_ does not mean unsigned)
@prime flower I don't know quite how I'd interpret that. Our stuff is implemented based on the LWIP examples provided by the ESP-IDF and I tested it with basic server and client examples on my host machine over my local network
was the size_t converted from a python int? I don't think so. That's ok
@tulip sleet so, in shared-bindings/busio/I2C.h and most other shared-bindings header files, we use exclusively types like uint32_t
in shared-bindings/socketpool/Socket.h we had kind of a hodgepodge and since that code started out with a basis from Micropython I was wondering if there was a reason for why the older functions were using mp_uint_t
it doesn't matter -that- much; the busio code was written a long time ago and might not be completely consistent
my preference is to do uint32_t for everything, but I wanted to make sure that's the right call
I don't like the micropython types because it seems inconsistent with the rest of the common_hal code which looks more like traditional embedded C
well, be careful you validate the incoming python arguments as being >=0 before passing on to common-hal
wait mp_uint_t should still be unsigned, right?
we might eventually use a 64-bit processor
it is, but you have to make sure any incoming python arg is >= 0 before casting it to unsigned, otherwise you will end up with a very large value.
As a (bad) example, the frequency value in I2C() should be non-negatvie, but that currently isn't checked. It should be.
Well, that seems like maybe a different project, going through all the inputs and making sure they're sanitized.
A good project though, I'll make a note of it.
If you grep for mp_int_t and mp_uint_t in ports/*/common-hal, you will find a lot of uses. It's a mistake that the busio routines pass an mp_int_t on one side and receive a uint32_t on the other.
yeah, complain about negative timeouts, etc.
I guess this is an opportunity for a wider cleanup.
I still don't like that mp_ prefixed stuff is in common_hal though, that doesn't seem right to me. I don't like the ambiguity of it in a scenario where we're doing bit-level math
At the very least, I'd like to make it consistent. Do we have mp_ versions of size_t, char, uint8_t, etc?
Re-reading and actually clicking on links, I see the "Chrome Demo" you referenced was in regards to the "Web serial" API.
Yes, sorry, I explicated the link.
I tried the one you mentioned, and it won't let me "Add a port". I can access the same CDC UART via putty (with WebUSB running too).
I wonder if some sort of "experimental flag" needs to be enabled in Chrome...
I think I must have enabled it ages ago, when it first appeared behind a flag in Chrome 80-ish. It is suppose...
I wonder if some sort of "experimental flag" needs to be enabled in Chrome...
Yep... I happen to be running Chrome 88.0.4324.150 so I had to enable "Experimental Web Platform features" and "Use system serial port enumerator", but I did get it to finally bring up the REPL in the Chrome demo.
I think i have a solution... not as elegant but ill just provide the "metadata" by hand as a property.
class Program(object):
'''to be filled out in programs to let us know the input types they want'''
props = {}
def exec():
'''to be implemented in programs'''
pass
def run(self):
inputParams = {}
for param in self.props:
inputParams[param] = self.props[param](
input(f"{param}: ")
...
mp_int_t and mp_uint_t are meant to designate integers that were converted from a Python object. If you want to cast them to uint32_t, that's fine. I think it's just clearer if that's explicit. If it makes sense for the the common-hal routine to take a uint32_t, you could do that.
See grep mp_int_t shared-bindings/*/*.h for instance
lots of mp_int_t's being passed in; do the same for mp_uint_t as well, there are fewer
@ionic elk Yeah this is some functionality I didn't see mirrored over from cpython, "If a non-zero value is given, subsequent socket operations will raise a timeout exception"
mp_uint_t is weird, because it implies it's been vetted as >= 0. mp_int_t is more typical
I'm not following along. Just back from lunch. I think you two are past my knowledge anyway.
Examples
I still think it is worth having the option to build with WebUSB support. Since that standard has been defined longer, it may make it into other web browsers sooner.
is this the same problem you are investigating ?
this code https://gist.github.com/Neradoc/469fe2918083c2a4bc3d584e481079c2
- ends properly on 6.1
- gives me
OSError: [Errno 9] EBADFat connect() on latest S3 - ends properly on latest with SSL = True
(FeatherS2)
Chrome is somewhat of an outlier in trying to implement WebUSB and the Serial API; you can see in the links above that Firefox and other browsers have decided not to support it in the interest of safety.
I am fine with the basic idea of this PR: we'll just leave it turned off by default. Unfortunately at the moment my own PR has a bunch of additions and cleanups to gen_usb_descriptor.py, and I'm also changing how to specify which USB and USB HID devices to provide, so there's a lot of c...
@prime flower what do you mean? My two most recent PRs have improved the timeout system from what it originally was - you can pass in 0 for no timeout, which will result in EAGAIN for calls that would block, actual timeouts which will result in ETIMEOUT, or None, which is passed into the common_hal as (uint)-1 and is specifically caught to make sure it never times out.
@jaunty juniper you're closing the socket before you run connect()
that's why you get a EBADF
@slender iron do you have a preference on where we should sanitize and cast mp_uint_t into things like uint32_t and uint8_t? Common hal or shared bindings?
I'm not particular about it
This is fine to include turned off by default. I think we will tend toward the Serial API to avoid needing new descriptors, but this is valuable.
Just two minor things.
www.circuitpython.org redirects to circuitpython.org, so leave off the www.. But if this is an actual URL, shouldn't it have https://?
// These next two hardcoded descriptors were pulled from the usb_descriptor.c file
I don't though
@jaunty juniper wait nevermind yeah I read your code wrong, my bad
thought it was with, I'm off my game today
Same comment as above re www. and https:// prefix
No objection to leaving off the www. The C struct that uses this has a different field that controls the prefix, look for bScheme.
Same answer. OK to drop the www and the scheme is hardcoded to https:// via the bScheme field
@dhalbert Just checking in to see what your thoughts are.
One refactor I can do, just rolling back up a loop.
The other with timers, I'm understanding a little bit, there's some library to help manage resource conflicts iiuc. I'm just curious if it's just a question of migrating to use an existing library, or if the existing library doesn't exist / is under-featured and will need more work.
@dearmash Sorry, I haven't had time to look at this in more detail. I think you will be able to use an existing clock generator, since we have several at different rates, but we have to check the clock speed and the divisors. The library is very low-level and assumes little infrastructure, and we have to fit that into the current clock infrastructure, etc.
URL changed to omit www. in gen_usb_descriptor.py
change www.circuitpython.org to circuitpython.org in gen_usb_descriptor.py
@slender iron Two quick questions about ParallelBus on RP2040. 1) I have the PIO program set to 60Mhz any higher seems to not work, I couldn't find anything in the spec docs for the display of the maximum, so guessed at that.
- I found an issue in the StateMachine code I believe. I can fix it in the PR I will submit soon or could make it its own if you prefer?
does parallelbus take a frequency? seems like it should
Sorry for the "cross"... can you fix it from your side?
nice! you can fix it π
No frequency in the constructor i'll double check
probably wise to add it since we'll start seeing mcus faster than displays can handle
RP2040 already is π I'll take a look at adding that as well
thanks!
@tulip sleet so there are no helpers to use in shared-bindings already that check whether an incoming argument is negative and throw an exception/cast it if so?