#circuitpython-dev

1 messages Β· Page 352 of 1

thorny jay
#

Waiting for a die shot jigsaw puzzle...

lone axle
slender iron
#

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...

β–Ά Play video
idle owl
#

Thanks! 😊

atomic summit
#

But the PICO in my case is not for "SMALL" but for the PICO-D4 on the board.

idle owl
#

@atomic summit Ergo, the need for Nano. πŸ˜„

jaunty juniper
#

I'm eagerly awaiting the itsy bitsy tiny pico nano

atomic summit
#

pico^2 πŸ˜‰

solar whale
#

Makes me think of "jumbo shrimp"

atomic summit
#

I missed how this conv started though - I assume the rPI Pico?

marble hornet
#

"CDC" ?

#

thank you.

idle owl
#

@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.

ionic elk
#

Somebody should port Circuitpython to ShenzhenIO

thorny jay
#

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.

idle owl
#

I reviewed, indeed. πŸ™‚

lone axle
#

Thank you!

idle owl
#

You're welcome! I need to test it, but wanted to get that review in first.

blissful pollen
#

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.

slender iron
#

I'm planning on adding a .spi property to SPIDevice

#

it's needed for sdcard

fossil gorge
#

Thanks for that info @idle owl. Will look at structuring the library that way, and will PR at will!

slender iron
mental nexus
idle owl
#

@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.

mental nexus
slender iron
#

wild!

solar whale
#

no good deed goes unpunished!

thorny jay
#

Thanks.

mental nexus
#

Thanks all!

modern wing
#

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.

slender iron
#

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

manic glacierBOT
manic glacierBOT
idle owl
#

@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.

gloomy shuttle
#

@idle owl is a specific widget used to embed source code in the learn system or is it something custom for Adafruit?

idle owl
#

@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.

gloomy shuttle
idle owl
#

@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.

gloomy shuttle
#

I would be interested to find out if it is not proprietary.

idle owl
#

@gloomy shuttle I'll ping them, then. I'll let you know what I find out.

prime flower
#

@ionic elk Thanks for unblocking me with the socket timeout core bug, just PR'd the library which was blocked πŸ₯³

idle owl
#

@prime flower That was a BEEFY PR. Nicely done.

prime flower
#

Started in November 2020 πŸ™‚

idle owl
#

Way to stick with it!

prime flower
#

I want to use it πŸ™‚

idle owl
#

I know that feeling πŸ˜„

prime flower
#

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.

idle owl
#

Have to start somewhere though, oi. And yeah testing would save you a lot of time!

prime flower
idle owl
#

Nice!

lone axle
#

@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.

ionic elk
#

@prime flower wait I did? I thought I didn't have that fix up until SSLSocket goes in

tulip sleet
idle owl
#

@tulip sleet Yeah maybe. Except also not all boards have a NeoPixel so maybe not so great. hmph.

tulip sleet
#

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.

gloomy shuttle
idle owl
#

@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.

tulip sleet
#

or maybe just adafruit_math, but that's pretty open-ended. ... yeah, I would like to substitute something simpler

idle owl
#

Repeatedly.

ionic elk
#

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

prime flower
#

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

ionic elk
#

anyway, good to hear it's working for you now

drowsy geyser
#

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.

idle owl
#

@drowsy geyser Huh! Did you file an issue on the 085 lib? Good that the others are working well!

prime flower
#

@ionic elk Yeah, I think I've (somehow) avoided the issues but I'll leave that PR up for a day

ionic elk
#

There shouldn't be any now, 3836 is in

drowsy geyser
#

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.

ionic elk
#

SSLSocket is coming but it doesn't have anything related to your issue (I got it mixed up)

idle owl
prime flower
#

nonblocking ssl sockets are weird in Cpython (imo)

drowsy geyser
idle owl
ionic elk
#

@prime flower SSLSocket has an identical interface. No changes should be required.

prime flower
#

ok!

ionic elk
#

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

tidal kiln
manic glacierBOT
manic glacierBOT
manic glacierBOT
idle owl
#

@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. πŸ™‚

gloomy shuttle
idle owl
#

@gloomy shuttle Excellent!

fossil gorge
#

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!

idle owl
#

@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.

fossil gorge
slender iron
#

@fossil gorge what files are missing it? the cookiecutter should have licenses for everything it adds

fossil gorge
#

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
slender iron
#

hrm, do you have a docs/api.rst.license file? There is one in cookiecutter

fossil gorge
#

There is not one, no.

slender iron
#

when did you run cookiecutter?

fossil gorge
slender iron
#

ah, that'd be why

fossil gorge
#

Initial commit was... 13 months ago

slender iron
#

kattni and dherrada would know how to update it. or you can try copying the newer versions of files from cookiecutter

fossil gorge
#

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

slender iron
#

interesting πŸ™‚

#

maybe it's only checking files you've changed

fossil gorge
#

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

slender iron
#

kk, well that unblocks you then πŸ™‚

fossil gorge
#

Definitely. Thank you kindly!

slender iron
#

np

fossil gorge
#

Welp, it was happy. Then I created a branch to work from and commit into, and it's back to that error. πŸ˜•

lone axle
#

does the new branch have that file?

fossil gorge
#

yep

#

Comparing the files to the cookiecutter, none of those listed files have the header though

lone axle
#

Ah it seems like this one got left out of the sweep that added lots of this stuff

fossil gorge
#

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 🀦

lone axle
#

I'd probably recommend skipping it for now. There might have been a script used that will make the process simpler

fossil gorge
#

That's what I was thinking. I'll commit locally without pre-commit running, and circle back around to the license stuff later

lone axle
#

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.

fossil gorge
#

Except for any new files I add, because space-time, bits and bytes and such

lone axle
idle owl
#

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.

manic glacierBOT
#

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.

trim elm
lavish saffron
#

Thank you. You've fixed it for me and my last push has passed all the checks. Much appreciated.

manic glacierBOT
#

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:...
manic glacierBOT
#

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 ...

manic glacierBOT
#

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...

manic glacierBOT
#

@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...

manic glacierBOT
manic glacierBOT
idle owl
#

@idle wharf Hey! Ping me when you're around, please.

crimson ferry
analog bridge
#

@slender iron how is flash partitioning done on rp2040?
I need NVM_SIZE and NVM_START_ADDR.

slender iron
#

@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

manic glacierBOT
slender iron
manic glacierBOT
manic glacierBOT
idle wharf
#

@idle owl ping

idle owl
#

@idle wharf pong!

#

Ok, for this PR:

#

Are you comfortable taking over it?

idle wharf
#

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 owl
#

@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.

idle wharf
#

My biggest question is about the Travis stuff... I assume now you would want to remove that and just do Github Actions

idle owl
#

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.

idle wharf
#

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 owl
#

@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.

idle wharf
#

You right... I wasn't thinking that I have commit privileges so yeah that makes sense

#

OK, consider it done.

idle owl
#

Great! Thank you so much.

idle owl
slender iron
#

nope

idle owl
#

Ok.

slender iron
#

it's a good question πŸ™‚

idle owl
#

What does RTC support look like then?

#

Someone asked about it, and assumed it wasn't implemented because of that issue

slender iron
#

the PR enables python access to the RTC

#

the issue is about using the RTC internally for sleeping

idle owl
#

Ok

jaunty juniper
#

ah what about time.time() ?

slender iron
#

so, for users, they'll be able to use the RTC

idle owl
#

@jaunty juniper Support was merged 14 hours ago.

#

They may not be running the latest version.

slender iron
#

@jaunty juniper ideally it'd be hooked up but I'm not sure we have it connected yet

idle owl
#

@slender iron Thanks!

manic glacierBOT
idle owl
#

@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.

slender iron
#

I think dir should be enough

idle owl
#

ok

idle owl
#

@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?

slender iron
#

try print(board.D2)

idle owl
#

board.D2 results.

jaunty juniper
#

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
[...]
idle owl
#

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.

slender iron
#

@idle owl I don't know why there is a D2 in board if it isn't on the silkscreen

idle owl
#

@slender iron Because we seem to assign Dx names to everything even when it's not on the silk. πŸ€·β€β™€οΈ

slender iron
#

probably in the learn guide

idle owl
#

There's a great many more pins in board for QT Py than are on the silk.

#

Same with most boards. I2C etc aside.

jaunty juniper
#

ah I believe it's to give access to A pins as D pins ?

slender iron
#

the pins.c should have them listed so the top one matches the silk

idle owl
#

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.

slender iron
idle owl
#

@jaunty juniper It is ok with you if I possibly include this script in a guide page?

jaunty juniper
#

like, they have D names so you know they can be used as Digital IO ?

slender iron
#

the first entry for a pin should be the one on silk

idle owl
slender iron
#

and that'll change what prints when you do print(<pin>)

idle owl
#

Oh so that's a QT Py issue.

slender iron
#

the A and D naming is an unhelpful arduinoism

#

yes, and likely other boards too

idle owl
#

Oh........

#

ok

stark ledge
#

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 ?

idle owl
#

I did print(board.A2) and it gave me board.D2. I see.

stark ledge
#

I have a new library that I wanted to add

#

Thanks ! that is exactly what I was looking for

idle owl
stark ledge
#

Thanks that is perfect !

idle owl
#

@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.

slender iron
#

yup, that's ok with me

jaunty juniper
#

if you need to indicate the matching pin names, aren't they on the pinouts page of the guide ?

idle owl
#

@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.

jaunty juniper
#

I see

idle owl
#

@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.

jaunty juniper
#

I believe so

#

we can make a script that doesn't show the microcontroller pins

idle owl
#

πŸ˜„ 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. πŸ™‚

slender iron
#

if it isn't in board I assume it's hard to get to

idle owl
#

Ok

slender iron
#

and I wouldn't recommend telling folks about them

idle owl
#

That's what I was thinking

slender iron
#

it's only useful for a new board

#

without a def

idle owl
#

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.

crimson ferry
#

the script doesn't print any microcontroller pins that don't have a board alias

idle owl
#
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?

crimson ferry
#

no, sorry, I take that back, but could be easily modified, I forgot I did that originally

idle owl
#

πŸ™‚ 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.

idle owl
#

@jaunty juniper Nice!

jaunty juniper
#

it's missing a natural sort but well

idle owl
#

I don't think they need to be sorted necessarily

#

Or does sort do something I don't know about. Probably.

crimson ferry
#

oops, that's secret, I guess I shouldn't post the link o_O

jaunty juniper
#

oh it is ? my bad

crimson ferry
#

it's OK if I link to it?

jaunty juniper
#

sure

crimson ferry
#

thanks

jaunty juniper
#

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)

idle owl
#

@jaunty juniper Ahhhh ok.

crimson ferry
#

dir does that too 😦

#

which I guess is the issue

jaunty juniper
#

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

idle owl
#

right.

#

Which is fine, really.

#

We're getting the info to folks in a pretty clean way.

#

They can figure out beyond that. πŸ™‚

idle owl
#

@tulip sleet Are you around?

tulip sleet
#

@idle owl yup

idle owl
#

@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.

ionic elk
#

@crimson ferry Hey, sorry I didn't get on this earlier, we had power knocked out by a snowstorm for most of the day

tulip sleet
#

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()

ionic elk
#

I'll try it out now

idle owl
#

@tulip sleet Hmm alright.

tulip sleet
#

or "created on demand"

idle owl
#

And instantiating it is not calling it? So like.... creating the sensor object doesn't call it until you use the sensor object?

tulip sleet
#

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

idle owl
#

Ok

tulip sleet
#

maybe "lazy instantiation" is better

#

"instantiation" is ... not a term most people know

idle owl
#

Hmm yeah

tulip sleet
#

but if you can define it, great

idle owl
#

hehe

#

I'll try.

tulip sleet
#

"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.

idle owl
#

Hah! πŸ˜‚

tulip sleet
#

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

idle owl
#

But I get the idea.

manic glacierBOT
#

@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...

tulip sleet
#

@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"

idle owl
#

@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.

tulip sleet
#

stray + sign: Instantiating an object+

idle owl
#

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.

scarlet scroll
#

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

tidal kiln
#

@scarlet scroll "non standard" - so it's not something I2C, SPI, etc?

scarlet scroll
#

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

tidal kiln
#
        time.sleep(88E-6)

that number looks familiar πŸ™‚

fossil gorge
fossil gorge
scarlet scroll
tulip sleet
#

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

tidal kiln
#

afaik, there's no simple way to do tight timing like that in user code

manic glacierBOT
tidal kiln
#

or, maybe, no way. at least with anything like a time. something approach.

scarlet scroll
crimson ferry
#

what about PulseOut?

tulip sleet
#

yes, PulseOut could be possible, if it can run fast enough

tidal kiln
#

so you wouldn't bit bang with hand crafted timing delays. instead you'd preload the pulses and then send them.

scarlet scroll
#

Now that's a library I didn't spot, thanks! I'll test it out

idle owl
#

@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.

fossil gorge
# idle owl <@!361158808501747735> Speaking of you, did you get your PR sorted out with the ...

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 πŸ™‚

idle owl
fossil gorge
crimson ferry
#

Is there somewhere in the code where the overall memory map for CircuitPython is itemized... stack, heap, pystack, sleep memory, etc.?

idle owl
fossil gorge
#

Sounds good to me. Thanks for checking in and the update

idle owl
#

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.

manic glacierBOT
manic glacierBOT
tulip sleet
solar whale
#

@idle owl are there instructions for downloading and installing the CI stuff?

idle owl
#

@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.

solar whale
#

Thanks. I’ll take a look.

idle owl
#

You're welcome!

random oasis
#

Does anyone know if the best way to get a Unique ID from the a board (specifically a m4) is microcontroller.cpu.uid?

solar whale
#

@random oasis I think that is the intent.

tulip sleet
#

yes, that is a unique id burned into each chip by the mfr

random oasis
#

@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.

tulip sleet
#

you could just xor some bytes with others

random oasis
#

xor?

lone axle
#

+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.

fossil gorge
#

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

still zephyr
#

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

manic glacierBOT
idle owl
#

@still zephyr It's not you. Something changes with a part of how our CI works and things are now failing.

idle owl
still zephyr
#

Oh thanks @idle owl. as a first timer, you always think is you πŸ˜† . Thanks for the info.

manic glacierBOT
idle owl
#

@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.

manic glacierBOT
still zephyr
idle owl
umbral dagger
#

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!

still zephyr
idle owl
#

@still zephyr You're entirely welcome! Well done!

mental nexus
#

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?

manic glacierBOT
#

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

...

manic glacierBOT
manic glacierBOT
manic glacierBOT
idle wharf
#

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.

jaunty juniper
#

oh the use of the screen for the bootloader on the ttgo is brilliant
when do we get that on the Clue (and others) ? πŸ˜„

manic glacierBOT
manic glacierBOT
#

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 ...

manic glacierBOT
#

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...
manic glacierBOT
manic glacierBOT
idle owl
#

@tulip sleet Around for a question about the issue you filed?

tulip sleet
#

on the phone, will ping you

idle owl
#

Ok thanks

slender iron
analog bridge
#

@slender iron are you working on busio.UART for rp2040?

slender iron
#

I haven't started it yet

#

I've been thinking about how to do the dma/buffering

#

did you make progress on nvm?

analog bridge
slender iron
#

nice!

manic glacierBOT
#

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...

tulip sleet
#

@idle owl did you state your q in the issue?

idle owl
#

@tulip sleet I did, figured that was a better place for it since you were busy and folks were replying already.

idle owl
mental nexus
#

@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?

slender iron
tulip sleet
#

e.g. json, etc.

idle owl
#

Oh. Hmm.

#

But help("modules") wouldn't include those either?

tulip sleet
#

the support matrix is actually a good starting point

#

help("modules") does include those

idle owl
#

Ah ok

#

Then I'll link to both in the guide.

tulip sleet
#

help("modules") should be the same as the support matrix for any particular board

slender iron
idle owl
#

@tulip sleet Fair enough, where the support matrix? I hadn't considered that.

idle owl
#

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!

tulip sleet
#

in "Core Modules". We could probably hack the "Core Modules" .rst to point to json, etc., somehow, for now.

mental nexus
idle owl
#

@tulip sleet It would be ideal to have them all in one place.

tulip sleet
#

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

slender iron
mental nexus
#

Also, I had assumed that the "python" overhead would be the limiting factor and not memory access time.

tulip sleet
#

@idle owl Do you have a UART example preference for default pins, since the book has no UART example?

idle owl
idle owl
slender iron
idle owl
tulip sleet
#

unfortunately they would overlap with the book SPI pins

idle owl
#

Let me look at it and let you know what I think.

manic glacierBOT
idle owl
#

@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

tulip sleet
#

that overlaps with SPI

idle owl
#

Ok I'm missing something.

#

SPI in the book is 2,3,4

#

Are we doing more than one SPI?

tulip sleet
fringe trench
#

ARGH!

#

I have been programming Python for TOO LONG, and it got SMARTER, and I DIDN'T NOTICE.

tulip sleet
#

it can't be GP5 and GP6 because they are not a UART pair

idle owl
#

@fringe trench πŸŽ‰

#

@tulip sleet I was going to change to 6/7 anyway.

#

Because ground pin.

#

So that coincidentally would work.

tulip sleet
#

has to be GP8, GP9 or high

fringe trench
#

You don't have to explicitly pass self to super().__init__ in Python 3, apparently.

tulip sleet
#

GP6/7 are not attached to a UART

idle owl
#

oh

#

I'm not reading GP#s I'm reading pin numbers.

#

Bleh

#

8/9 it is.

tulip sleet
#

i keep making the same mistake, it's a nightmare

#

having the silk labeled 1,2 is crazy

idle owl
#

@tulip sleet So frustrating.

fringe trench
#

@tulip sleet GP#, or super?

idle owl
#

Anyway, go with 8/9.

tulip sleet
#

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

solar whale
#

Does it mtter if it is UART0 or UART1 -- UART0 is on 12/13

fringe trench
#

You can tell how long it's been since I wrote class hierarchies...

#

goes to get a cane and slippers....

tulip sleet
#

@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

fringe trench
#

Thank you for humoring me.

solar whale
#

I wish they did not use the term "SPI_TX/RX" confusing....

#

or is that the new standard replacing MOSI/MISO?

manic glacierBOT
idle owl
tulip sleet
#

SDI/SDO are also ambiguous, as diagram shows.

idle owl
#

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?

tulip sleet
#

the preview guide page from yesterday?

idle owl
#

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

tidal kiln
#

@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. 😦

tidal kiln
#

yep

tulip sleet
#

@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?

idle owl
#

@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.

tulip sleet
#

maybe it was just a fictitious example of a pin with two names?

idle owl
#

Not sure why I would have said "special pin" though.

#

But yeah maybe.

#

And I covered that thoroughly.

idle owl
#

@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
#

@idle owl should I take over editing for copyediting?

#

or just tell you?

idle owl
#

@tulip sleet Take over for that, yeah. That would be great.

blissful pollen
idle owl
tulip sleet
#

@idle owl, ok, made a number of edits for clarification

tulip sleet
#

@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.

idle owl
#

@tulip sleet I added that at the last minute because I thought it was needed. But yes. Good call.

tulip sleet
#

i also added "built-in" more places, as you'll notice

idle owl
#

Ok

manic glacierBOT
blissful pollen
#

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.

gloomy shuttle
#

@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

tidal kiln
#

anyone else have thoughts on bundle location for above?

idle owl
#

@tidal kiln If you feel it should go in the Community Bundle, then follow that.

tidal kiln
#

i'm fine with either and open to suggestions though. can see plus/minus either way.

idle owl
tidal kiln
#

that's why i lean toward community also

idle owl
#

Sounds like a plan, then.

gloomy shuttle
#

That makes sense to me.

tidal kiln
#

cool. thanks @gloomy shuttle . feel free to take whatever you want from the nunchuk lib.

gloomy shuttle
#

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.

idle owl
#

@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.

gloomy shuttle
#

Got it. Next question, should I start fresh using the cookie cutter and just copy code over

idle owl
#

That would be great.

tidal kiln
#

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.

idle owl
#

@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.

gloomy shuttle
#

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

idle owl
#

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.)

gloomy shuttle
#

Alright, thank you

gloomy shuttle
#

@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

tidal kiln
#

that seems fine

#

sounds better than CircuitPython_WiiMote_I2C_Accessory_Devices πŸ™‚

manic glacierBOT
idle owl
#

Power failed. Sigh.

idle owl
#

It's apparently a huge outage due to loss of power to the provincial grid. They're working to restore it, but ETA is ???

idle wharf
idle owl
manic glacierBOT
#

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 owl
#

@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?

manic glacierBOT
idle owl
#

Hey I have power again!

idle wharf
#

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.

idle owl
idle wharf
#

No, you got it

fossil gorge
#

...once I can manage to get through this work day...

manic glacierBOT
idle owl
#

@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.

idle wharf
#

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 owl
#

@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.

idle wharf
#

Honestly, I'm not sure. I don't know much about cookiecutter (yet).

idle owl
#

@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?

lone axle
#

@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

idle owl
#

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.

crimson ferry
idle owl
#

@crimson ferry Sometimes it's weirdly picky. Does reordering the imports make it happy? Or does it continue to fail?

crimson ferry
#

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?

idle owl
#

@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.

crimson ferry
#

I just haven't had much encounter with pylint before, so I don't know

idle owl
#

@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.

slender iron
crimson ferry
#

@idle owl ok, cool, thank you

idle owl
idle owl
#

@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.

tidal kiln
idle owl
#

@tidal kiln Probably?

tidal kiln
idle owl
#

Have you archived a lib before?

tidal kiln
#

yes

#

just came across someone using it forums. will figure out how they got there, in case a guide is still ref'ing it.

idle owl
#

Sounds like a plan.

tidal kiln
#

but i'm not finding anything

#

it has some reasonably recent issue/pr activity

#

but the last commit was 2018

idle owl
#

Hmm

#

I guess ping Limor.

#

If you're not sure about it. I know she wanted everything archived eventually.

tidal kiln
#

ok. yah. i probably will just to be sure there's not some odd reason it's being kept around.

idle owl
#

Sounds like a better plan.

#

Are you good with Arduino?

tidal kiln
#

i can blink an led πŸ™‚

idle owl
#

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.

tidal kiln
#

i'll jump over there and take a look

manic glacierBOT
fossil gorge
#

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

jaunty juniper
#

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

fossil gorge
#

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>

manic glacierBOT
cedar moth
jaunty juniper
#

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

fossil gorge
#

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.

slender iron
#

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

fossil gorge
#

But like I said, that's making some assumptions about the backend

slender iron
#

learn is all custom so we could add it πŸ™‚

#

I was hoping that circuitpython library RTD would have links to products

fossil gorge
#

That's the developer's answer right there! Not that I've ever said that! lol

slender iron
#

and guides do know products

#

I don't work on learn so I'm signing others up for work. πŸ˜›

fossil gorge
#

So yeah, that cross-referencing and links between libs, projects and docs would be awesome

fossil gorge
slender iron
#

it's already plenty long

manic glacierBOT
manic glacierBOT
manic glacierBOT
#

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...
manic glacierBOT
manic glacierBOT
#

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...

solar whale
#

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,

manic glacierBOT
tidal kiln
#

this is from Atmel Studio

#

anyone know how to get the equivalent of that Device signature number via JLink command line tools?

tulip sleet
#

@tidal kiln looking...

tidal kiln
#

thanks. i've been punching at it and nothing obvious.

tulip sleet
#

number above is from a Metro M0

tidal kiln
#

cool. thanks @tulip sleet

#

i was foolishly thinking there'd just be a command for it

#

vs. a low level read

tulip sleet
#

i hoped so too. It's a standard "CoreSight" thing that exists across all ARM chips.

#

this is a ROM location, not writable

tidal kiln
#

yep. thanks. was noting the R access. so really no way to shoot one self in foot and accidentally change that.

tulip sleet
#

by comparison, on a SAMD51J19:

J-Link>mem32 0x41002018,1
41002018 = 60060005 
tidal kiln
#
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.

tulip sleet
#

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

tidal kiln
#

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?

tulip sleet
#

@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.

tidal kiln
#

thanks. it must exist somewhere. atmel studio is comparing against something for "expceted" values.

tulip sleet
#

it looks like it's getting the wrong value when it tries to read it, but I don't understand how

tidal kiln
#

could there be a range of acceptable values? like to cover all known revisions. and it would need updating when new revisions come out.

tulip sleet
#

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

tidal kiln
#

hmm. yah. and also 0x10010305 vs 0x1001031F would only differ in the DEVSEL bits

ionic elk
#

@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.

onyx hinge
#

@ionic elk that would be awesome of you!

manic glacierBOT
#

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:

  1. HTTP doesn't work for me https://github.com/adafruit/Adafruit_CircuitPython_Requests/issues/63#issuecomment-771712906
  2. 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...
manic glacierBOT
ionic elk
#

@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

tulip sleet
#

right

#

but SomeException could be a superclass of other exceptions

ionic elk
#

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

tulip sleet
#

is there an enclosing try-catch that's catching the uncaught inside exception?

ionic elk
#

There is, and it should be, but it isn't.

#

it's just acting like there was no uncaught exception at all

tulip sleet
#
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

ionic elk
tulip sleet
#

could you just upload the whole thing?

#

use the "+" on the left

ionic elk
#

That has messaging modifications in Requests

#

no secrets file

crimson ferry
#

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

ionic elk
#

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

tulip sleet
#

@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

slender iron
#

@tulip sleet are you planning on reviewing 4122?

#

thach's usb fix

tulip sleet
#

yes, I am testing it now

slender iron
#

ok! thank you!

tulip sleet
#

you were having a dialogue with him, so I though you were more enmeshed, but happy to t do it

slender iron
#

np, I was just trying to keep him moving

manic glacierBOT
slender iron
#

@tulip sleet I assigned the webusb pr to you too. I think it fits into your usb thinking now

manic glacierBOT
#

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...

tulip sleet
#

@ionic elk did you figure out the disappearing exception? Is the whole program failing and restarting??

ionic elk
#

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

manic glacierBOT
manic glacierBOT
manic glacierBOT
#

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...

onyx hinge
#

@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)

ionic elk
#

@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

tulip sleet
#

@ionic elk So what happened to the OSError exceptions?

ionic elk
#

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

crimson ferry
#

@ionic elk I just submitted a Requests PR with that fix, it masks the issue of Failed handshake, cause unknown.

ionic elk
#

@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

crimson ferry
ionic elk
#

This is kind of a @slender iron question, maybe, since he wrote the SSL stuff

crimson ferry
#

(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

ionic elk
#

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

crimson ferry
#

well, except that it seems to happen when the TCP connection is closed, not when it's kept alive

ionic elk
#

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

slender iron
#

Β―_(ツ)_/Β―

crimson ferry
#

I'm really not sure, I am by no means an expert

ionic elk
#

@crimson ferry I don't quite know what you mean by that last part

crimson ferry
#

regarding (2): it seems to happen when the HTTP/TCP connection is severed between Requests, rather than when it stays alive between requests

ionic elk
#

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:
crimson ferry
#

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?

ionic elk
#

^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

crimson ferry
#

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)

ionic elk
#

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 πŸ˜•

crimson ferry
#

maybe it's because IDF/Requests is not explicitly doing any behavior based on presence (and value) or absence of an HTTP Connection header ??

manic glacierBOT
#

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...

crimson ferry
#

Is IDF purely TCP level? If so, then it's something that Requests would handle.

ionic elk
#

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.

crimson ferry
#

But I'm fine with masking it for now, and we see if something crops up later.

ionic elk
#

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

crimson ferry
#

and those TCP sockets can carry any higher-layer protocol presumably... so I'm thinking this is a limitation of current Requests

ionic elk
#

By carry, you mean you add additional application layer code on top of them?

crimson ferry
#

@ionic elk I'd propose we call (2) done, leaving only the insecure HTTP case.

#

right, like HTTP, HTTPS, etc

ionic elk
#

ok

crimson ferry
#

@slender iron, if you're following, does this make sense?

ionic elk
#

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?

ionic elk
#

@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
crimson ferry
#

HTTP? right, that's what I get, I can't do an insecure HTTP at all anymore

ionic elk
#

can you just quickly reiterate what this is supposed to be doing?

crimson ferry
#

just doing an HTTP GET on a URL

#

but not TLS

ionic elk
#

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

crimson ferry
#

I don't know, Requests often baffles me, it used to work when sockets were combined

ionic elk
#

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.

crimson ferry
#

How should Requests get a non-TLS socket?

ionic elk
#

I think this simply deserves a new issue for Requests

#

I don't know, is Requests based off a Cpython module?

crimson ferry
#

wouldn't it just be by leaving off the wrap/default-ssl-context?

ionic elk
#

^oh, mechanically, yes. You just don't wrap it, and it'll stay TCP

crimson ferry
#

or Brent

ionic elk
#

@prime flower would you be able to chime in here?

crimson ferry
#

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.

prime flower
#

circuitpython-requests is "requests-like", or I;'ve seen it described like that

ionic elk
#

Yes, if you detected the lack of an ssl context, you could just make a regular socket

crimson ferry
#

"you" being the core circuitpython Socket code?

#

or the library, or me the user?

ionic elk
#

The library

crimson ferry
#

but how does the library do that? what's the API?

#

I thought it was as above

ionic elk
#

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.

crimson ferry
#

do we need to be passing another parameter to socketpool? or socket?

ionic elk
#

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.

crimson ferry
#

not invoking ssl for one

ionic elk
#

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!

prime flower
#

@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.

crimson ferry
#

I really don't have a clear idea of where the issue is

prime flower
#

Is that incorrect? is it always making a SSL socket?

crimson ferry
#

I don't know, HTTPS is working great now, but no HTTP

ionic elk
#

@prime flower if you don't wrap the Socket it isn't a SSLSocket.

prime flower
#

@crimson ferry this is on esp32s2 right?

ionic elk
#

there's no SSL in a regular <Socket> object anymore.

crimson ferry
#

@prime flower yes, ESP32-S2

crimson ferry
#

(see the edit at the bottom of the comment to use: http = requests.Session(socket))

prime flower
#

@crimson ferry and wrapping a socket for a HTTP url succeeds?

crimson ferry
#

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

prime flower
#

@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..

crimson ferry
#

that would be an interesting test

prime flower
#

I could try isolating the socket creation code from the library and connecting to netcat

jaunty juniper
#

I'm having problems with non SSL sockets too in my websockets code

ionic elk
#

@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

tulip sleet
#

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?

manic glacierBOT
tulip sleet
#

I almost never use bare int, since its size can be in question

ionic elk
#

@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

tulip sleet
#

you would use an mp_uint_t if it was going to be converted to or from a python object

manic glacierBOT
ionic elk
#

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

tulip sleet
#

yes, that makes sense there

ionic elk
#

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

ionic elk
#

Should I also change things like the size_t used for hostlen, or the const char* for host?

tulip sleet
#

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)

ionic elk
#

@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

tulip sleet
#

was the size_t converted from a python int? I don't think so. That's ok

ionic elk
#

@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

tulip sleet
#

it doesn't matter -that- much; the busio code was written a long time ago and might not be completely consistent

ionic elk
#

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

tulip sleet
#

well, be careful you validate the incoming python arguments as being >=0 before passing on to common-hal

ionic elk
#

wait mp_uint_t should still be unsigned, right?

tulip sleet
#

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.

ionic elk
#

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.

tulip sleet
#

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.

ionic elk
#

For now I can make sure the inputs to Sockets are sanitized though.

#

oh, hmm.

tulip sleet
#

yeah, complain about negative timeouts, etc.

ionic elk
#

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?

manic glacierBOT
#

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 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}: ")
     ...
tulip sleet
#

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

prime flower
tulip sleet
#

mp_uint_t is weird, because it implies it's been vetted as >= 0. mp_int_t is more typical

slender iron
manic glacierBOT
jaunty juniper
manic glacierBOT
#

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...

ionic elk
#

@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?

slender iron
#

I'm not particular about it

manic glacierBOT
jaunty juniper
#

I don't though

ionic elk
#

@jaunty juniper wait nevermind yeah I read your code wrong, my bad

#

thought it was with, I'm off my game today

manic glacierBOT
#

@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.

blissful pollen
#

@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.

#
  1. 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?
slender iron
#

does parallelbus take a frequency? seems like it should

manic glacierBOT
slender iron
#

nice! you can fix it πŸ™‚

blissful pollen
#

No frequency in the constructor i'll double check

slender iron
#

probably wise to add it since we'll start seeing mcus faster than displays can handle

blissful pollen
#

RP2040 already is πŸ™‚ I'll take a look at adding that as well

slender iron
#

thanks!

ionic elk
#

@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?