 Looks like we're ready. We'll go live on YouTube. Live. Hello, YouTube. Restream. Pause. Pause. Live. Thank you, DJ Devon3. Hi, Penpengu. Hi, Fede2 from Costa Rica. Thanks for stopping by. Look at going in just a bit here. Biada. Hello. I'm sorry about cat cam. I did order a new camera and it's been kind of a crazy week. I did not get around to getting it set up. I have not actually worked a lot today either because we're going camping right after this, so it's going to be a short stream today, just an hour, and then we're going to get out and go. Is this YouTube? Hello. It is YouTube. Hello, Sea Grover. Yeah, so sorry cat cam stopped working, but I actually do have a kitty on my lap. Vyn decided that she wanted some pets when I got here. We've been loading the car up, so. Hi, Chris Burton. Hi, Deshipu. Yeah, this is the first time we're taking our kiddo camping. Hi, Bruce. Oh, my teeth. Do I have chocolate in my teeth? Fede2S, would you be interested if you sent the milk fives to me? I got to tell you that I have way more dev boards than I know what to do with, so I think there may be better people, better people than myself to send those to. I'll let you know if I ever do want one, but I've got, like, there were the, like, Ox64 chips that I think are risk five as well. Like, I got them because they were pretty cheap, but I've not used them at all. Hello, Space Pope. Okay, let's get going. Hello, everyone. My name is Scott. I go by Tanute Online. Welcome to a deep dive. I do these, I started, started doing this a few years ago during the pandemic, and I had a kid, and so I've been up and doing them. Thanks to FoamyGuy for taking the spot when I'm back. And what this tends to be is a, if you have questions, ask them, and I'll try to explain them about SuckerPython or electronics or anything, really. I generally usually do have a topic in mind that I'll try to cover a little bit. I'm committing to these being an hour long, but sometimes they run two hours, like last week did. And it's called a deep dive because we do get into very technical topics and stuff like that. So if you have questions, always feel free to just drop them in the chat and we'll get, we'll get to those. Thank you, Space Pope. I unexpected maker. I should say that I'm paid by Adafruit to work on SuckerPython, and that's been the case for a lot of years now. I was the first person they hired to just do MicroPython stuff, which turned into SuckerPython. And if you want to support me supporting Adafruit is the way to do it. Go to Adafruit.com and pick up some cool hardware for different projects that you have in mind, and that helps Adafruit out and they pay me. So that helps me out too. Hello, David. Honestly, Scott's deep dive is very deep for an advanced audience. Yep. And like David says, he's listening and soldering. I think a lot of people do have this on in the background as they do other things and that's totally cool. The reason I like to do deep dives is because it gives me a chance to, like I'm not great at written documentation, so it gives me a chance to show exactly what steps I do to do things. And there's not a lot of people that necessarily need to know the things that I'm doing, but if they, if they do, then it's nice and thorough. Let me turn the light. I forgot to turn the room light on. The cat was on my lap when I remembered, so now that she's off of it, I can do it. Okay. So if you have questions, feel free to drop them in the chat. Like I said, I'm going to do no more than an hour. If for some reason I wanted to stop earlier, I will. But that's kind of what I'm thinking. Sorry about cat cam. I haven't done the overhead stuff yet. Still either. Are there any questions to get us started, or should I jump into more USB host stuff? I see Sea Grover is typing on discord. So yeah, on the chats here, this is the 803 Discord server, which I'm on like all week usually. And that's the URL, adafru.it slash discord. Nice thing is that that sticks around rather than the YouTube chat that disappears. We need a camp cam now. Sea Grover says, yeah, I listen in to become exposed to the terminology. Once in a while, I catch a glimmer of understanding more often as time passes. Great. Hello, Mark. All right, let's get going. So USB host is what we were talking about last week, but also what I've continued to work on. USB host is the idea that you can plug a USB device into Circuit Python rather than Circuit Python also acts as a device there. So USB host is the idea that you can use other USB devices with Circuit Python standalone without your computer. DJ Devon 3 has a question that's not related to a USB host, but let's switch over to it. One of the latest boards, Lady Aida said there were two different types of debugging ports. One is SWD and the other I don't know. Why would you need two different debugging ports on one board? I think, so typically SWD is an arm specific technology. So for boards that are not armed like the ESP32s, you'll get JTAG. But it's usually one or the other. You don't usually have both on the same board. I don't actually watch all of the ESCEN engineers anymore because I'm really busy being a dad to a toddler. I think that it might have also been and I think that's what DCD is talking about is like a debug UART. So having like a separate USB to serial sort of converter so that you could do like debug logging out a different way. I think that's the case with the new ESP for example. Like the ESP Metro I think might do that. Sorry, I noticed I had a slack notification. What about your new show and tell? I'm not exactly sure what your my new show and tell. Oh, the trace connector? Yeah, so I can show that too. So this is a version of, wait, is this my version? Yeah, so this was a remix so to speak of a Metro M7. So this is the IMX 1011. I can leave it on product showcase. And what I have here is a, there I'm backwards. This connector here is an SWD plus trace. So I would still consider this like an SWD connector, but it's one that has more pins that carry trace signals along with that. And tracing is the ability to just like literally, well, you can configure what data you want to trace out. But the interesting bit to me is there's a mode so on the Metro like on the M7s, there's a mode where you can have it trace enough information that you can see exactly where in the code it executed or it's executing. Like it literally just like logs enough information. I think it's like every time, you know, some code, you just go from one instruction to the next, but then there's like jumps and branches. And so what it does is it logs like the results of those jumps and branches so that you can know exactly where the code's going at all times. And I haven't gotten it working. So I'll know a lot more once I get it working. But the cool thing there is that like you can do all sorts of performance analysis to know where your, where your code's going. So that's why I remixed it to a different connector. It's kind of like a larger, it's a super set connector. It's not completely different. Bruce says, yeah, good area to learn and approve my get knowledge move from beginner to low intermediate watching Scott work the magic. Yeah, I wouldn't call myself an expert either on git, but I ever since I left Google and I've been starting to work like I've learned a lot more about git as well. I ask you because you seem to know debugging anything I've never done debugging. I bet you've done debugging. I just didn't call it that debugging is anytime, anytime you got to figure out why something's not working. So it's a broad term. And I remember there was two things I should point out. One is there's a podcast called embedded.fm and they just had Damian on who's the creator of MicroPython. And the reason that came up with me is because they ask like step debugging, which is like GDB or print F debugging. And he responded print F debugging, which is the way I would respond to you. And then the other thing is that circuit Python day will be in two weeks. I had forgotten that. And it seems like the cat ones out. So hold your horses just one second. She's like, let me out. Okay, go. If you haven't seen deep dyes before, Vin never likes to be in here as I'm talking. She's one of the two cats. And I will I like I got a new camera for cat cam. I just didn't have time to get it going. So hopefully we'll have a cat cam here shortly. Print the code breaks here. Yeah. I enjoy listening to you go over efficiency and performance gains. You seem to really like that stuff. Oh, performance is one of those things that you you just like got to time box yourself because you'll never finish. You get a J tag and even a board like a Pico. It's pretty easy to get started and just try it. Yeah, J link and the Pico they have like the Pico probe that works with open open OCD as well and pi OCD. What kind of camera I got a C920S is what I got. I got a refurbed one, which is almost identical. The other one that's not been working for me is a C922. So I'm hoping hoping that one digit difference is enough to make it work. Let's see. I didn't want to get a like a super expensive one. Like this camera here is a lot more expensive, but it's also a lot a lot nicer. Not not not needed for cat cam. Yeah. And Fede too says they offer is open to any circle by the folks, even if it's not for a circle by themselves. So if you milk five is interesting, let me know. So Penpengu says I was literally right now playing around with Pico probe. Great. I've been working with Blackmagic. So another board I briefly showed and I think I can do it is this board. It's not open source. The software is I think it's called the Orbitrace Mini. And so what you do is you plug I'm so backwards you plug in your computer here and then this is actually an FPGA. And then you can see there's two connectors here. One is SWD and one is the SWD plus trace. So I'm trying to move my all of my debugging over to this because it's more open than a Jlink. And it can do trace like Jlink has a trace for capable thing, but it's like $1,200 or more. And it just like kind of just works with their tooling. I'd rather use open tooling for that kind of stuff. But unfortunately it supports the IMX 1060, but not the 1011, which I hadn't realized. So I'm poking around with Blackmagic, which is kind of like PyOCD and kind of like OpenOCD. If you're not a Git expert, then I'm a Git new. Yeah. Yeah, there's a lot to learn with Git. I think there's like a very much, I think I know the main path pretty well. It's like everything else that I don't necessarily know. All right. So that's 15 minutes. IMX 1060 is the big one, I think. It's the biggest of the 10 series. Yeah. Okay. This is a great segue. Thank you, David. I think you gave me the segue last week too. David says, USB host question for later, will it be possible to be a MIDI USB host? Then combined with SynthIO and an audio output, we could have a Synth for MIDI keyboard. You know, I was going to use, so I've been working on two libraries that if you look at my GitHub, you'll see that I did the last couple of days. One is the, I'm kidding, DJ Devon 3 is bugging me about IMX stuff. There's an 11 series that is even more insane than the 1060s. Like the 11 series has a SKU that is clocked at almost a gigahertz, which is wild. So what I was going to do is, I have two libraries. So one is a descriptor library that is just like some super basic stuff to help you figure out what USB device is connected. So USB, right, is like super flexible. And the way that you know what device you have is, is you use descriptors to see, does it do mass storage? Does it do a CDC, like serial link? Does it do, is it a camera? Is it a keyboard or a human interface device? All of that is, is discoverable through descriptors. So the first library I did was one called Adafruit Circuit Python USB host descriptors. And then the second library that I did, and maybe I should start here is Adafruit Circuit Python USB host mass storage, which is the kind of part of the USB spec that does things like USB keys. So like I have this like 16 gig no name flash drive sort of thing. And it could be cool that you could just like write to that from Circuit Python. So let me just actually start there and see if I can't just use this. So I actually, I do have a 10, actually I can unplug it enough to show. So I am using the 1060 Dev Kit. Let's just, let's just hope it works. I'll take all my debugging stuff off. So this is these, these are, they call them EVKs. And they're insane boards that NXP creates. If you watched my videos ages ago about these, they drive me a little nuts, because they're not well labeled. The newest one, the 1040 is better labeled, but they're still not that well labeled. Like they have all of the schematic designators on it, but they won't tell you like on the board, like this is the reset button, they'll just say like switch three. And I'm like, but so their designs are getting better. But these, these are really these giant EVK boards that they have, they're really meant to give you kind of all the functionality. Whereas like something like a Metro is breaking out all the pins, but it's not doing all the functionality. So like this is for the 1060 series. So you can see it has like two USB ports. It's got the Ethernet jack. This might be camera, like audio. And then this is the onboard debugger. So like you don't need a J-Link. You can just use the onboard one. If you do have an external one, this is the JTAG slash SWD port. They, it's funny. They have these like Arduino Metro headers. Like Arduino made a big enough, big enough like influence in the industry that a lot of the dev boards do have the have the headers. This is the chip itself, which is so funny how it's their SD card. And then this is power input into the board. So these, these boards are really complicated. They run about $100, which is not too bad. You can definitely get in the multi-hundreds with dev kits like this. And this is the same chip that's like on the teensie, for example. It's got like two types of flash. I think it's got SD RAM as well. So it's got, it's got a lot of different stuff going on. So that's what I've been using because it's relatively easy to debug. So what we're going to do is I'm going to, I think it's got a version of circuit python that works. So we'll pull that up, take the switch to the desktop. All right. So this is circuit python. So what we can do is we can go to code.py. And let's just open that up in here. So this is actually, I was playing around with a simple test because the descriptor, so when I prototyped it, I just wrote one code.py that kind of did everything I wanted. And then I was trying to figure out or decided like how to split it out. So like the code I was actually writing ended up being the simple test for the mass storage, the mass storage library. And then also I wanted to make a separate descriptor's library. And this is the simple test that I ended up for it. So let's take a look at the terminal output. So let's see what it's telling us at this point. So it says searching for devices. And it waits between it does that. So it's not finding anything. And the reason that it's not finding anything is because here's the thing that needs to be plugged into it. Right now it's plugged into the Beagle, but I'll actually remove the Beagle as well. And so we can play around. So this is a micro, it's a micro B. Oh, look at my face. Micro B USB to a USB A. They're known as like OTG cables. And it's particularly nice. I had some that were right angle, but this is a straight one. And it fits better on the board, especially because like I showed just earlier, like the two, the host and the device USB ports are right next to each other. So having a straight one of these actually had to buy one because they had right angle ones. So DJ Devon three says with USB host no more SD card just use a flash drive. Yep. That's the idea is that you could instead of using an SD card, you'd be able to do flash drive. I don't know which is faster. I don't know which would be faster, but yeah. So let's see how this code.py changes when I plug some different things into it. Let's talk about the scriptures. And here's my flash drive. It's a good start and test before plugging an unknown origin USB device and key into your computer. Yes, it is. Okay, so this is going to keep outputting it, but let's just control C and we'll go to the repel just so it doesn't reload. So we can see here searching for devices. So we see a vendor ID and a product ID. I think the speed would be dependent on the protocol like 2.0 versus 3.0. Yes, and in fact 2.0 has four has three speeds. Most circuit Python devices only support two, which is low speed, which is 1.5 megabits per second and then full speed, which is 12 megabits per second. And then there's also high speed, which is 480 megabits per second, which is what the IMX RT should be able to do, but it's not doing with the USB host right now. So I'm not sure why that's not working. But USB high speed gets more complicated and then it gets more complicated the higher speeds get basically. So let's just talk descriptors. This is super simple. And in fact, so these things come from, oh, sorry, these things come from what's known as the device descriptor. There's a number of different types of descriptors and you can get like the USB 2.0 spec PDFs and read all about the different types. But the first one that you usually get is the device descriptor, which tells you VID, which is vendor ID, and then PID, which is product ID. And if you've ever made a board definition for circuit Python, you know that we like to have unique product USB PIDs for different boards. So usually one of the biggest hurdles for getting that is just acquiring a USB PID. But the reason is that those are kind of like the key core identifiers for what device am I talking to. And then we can see here, the manufacturer, I should spell it out, the full product name and the full serial number. And one thing that's interesting about these is the strings themselves are not part of the device descriptor. The device descriptor itself stores an index and then you fetch a string descriptor that gets you the actual string. But this is doing that for you here. And I think, yeah, that's just the circuit Python API. DJ Devon 3 says you can get an open source PID if you use open source code anyway. Yeah, so there's a project that I administer stuff for called PID.Codes and that's for open source hardware and software projects. If you are a manufacturer and you have closed source or closed hardware in a product but want to use it, then I won't give it to you because the motivation of the project is to get people to open source their stuff. But if you are working on open source software for a third party's closed source hardware, I give it to you or not vice versa because closed source hardware, how would you set the PID if it was closed source? That'd be a little tricky. And there's actually one PID that we granted for an open, the tiny tape out project where they're doing community stuff into A6. They actually requested one. So they'll have a USB controller in there that has a PID.Codes PID. Quinman16 says what's you doing? We're just exploring USB device descriptors right now. We're talking more broadly about USB host functionality and the higher level libraries that we need to do that. Maybe you can split out what you discovered in a bootnip pie and then you use to clone a device. You could. And I think there's a project. So there's also like the security world of USB and I think there's like the Great Scott gadgets folks were doing that and they had a project for doing like man in the middle sorts of USB stuff. Face Dancer. Face Dancer is the project I think I'm thinking of. So if you're interested in doing that like more security oriented stuff that's the place to look. Okay so that's these are the highlights of the device descriptor. There's more there but this is this is the stuff that I thought was really kind of critical and useful. And then the device descriptor will tell you how many different configurations that a device will support. And it's almost always one. I don't like this is one thing that's interesting about specs that have been around a while is is there's the big broad spec that they thought people would use and then there's the reality of which parts actually get used. And I think in this case like multiple configs while are they're part of the spec I think they're rarely used. So what you would what you do is you say like I have three configurations and you would say this one or that one or this one and you tell the device which one you wanted it to be. But in reality I think it's almost always just it's almost always a single configuration. So this simple test that we have here is just printing out some very basic information about that first config descriptor. So so config zero the first one has a value of one. They have a separate configuration value but I think both tiny USB and therefore circuit Python assume that the configuration value is the index plus one because configuration value zero means it doesn't have a configuration. So it's basically like shifted by one. And then a configuration is made up of a series of interfaces and they have interface descriptors. So the the interesting bits I think the most interesting bits are class and subclass. So class eight and subclass six and there's actually a good let me pull up a browser here usb.org class codes. Yeah so let's take a look at this. So this is on the usb.org website. And so if we look here base class and it there's classes in both devices and interfaces. But we can see here the base class eight is mass storage. And if we zip down to there it says the base class is defined for the mass storage device class spec on the website that that other spec defines the usable set of subclass and protocol values. So that's what we're seeing here is we're seeing this interface is a mass storage interface and the subclass is six. And if we want to figure out what the six means we go to the specific mass storage device spec. That's I think pretty common like this this pair of stuff. So it actually really doesn't matter. You can just expect that they're both that. And then the other thing that's part of that is that usb uses a notion of end points as a way as well like a matter of like addressing where data goes or what what kind of data it is. So you have a device and it has a bunch of end points and the end points are the thing that you read and write to. They'll either be writable or readable like so end points have a direction and that's what we're printing out here is that for this mass storage interface the in end point has the address 81 and the 8 actually also tells you that it's in and then the out end point is 2. And that's relative to the host computer I think. So in would be data going from the device to the host and then out would be from the host to the device. And if you've ever seen errors in circuit pi thought about running out end points that's kind of what what this is talking about is that how many end points do you have in this descriptor and does the hardware have like hardware queues for each of them that it could actually use. So let's just I was thinking let's do some other usb devices that I have on the table here and the one I was thinking of would be a circuit python device. I had one I was using for an example and I do have a bunch. The question is is do I have the usb cables to plug them in. So I have a circuit playground here but I need an A back to micro. Here we go. I did find one on my desk. Okay so I'm going to unplug the mass storage device unplug the thumb drive and let's plug in a circuit python. Well I think I assume there's circuit python on this circuit playground. Yeah it's blinking at me. It's playing tones. I don't know if you can hear it. Okay oh boy. All right so we enumerated here and let's do the same trick of pulling up the ripples so it doesn't keep going. So okay so here we are now we're looking at the usb descriptor from a circuit python device. So we have a vendor ID 239a that's Adafruit's vendor ID and then the product ID here is 8019 and we generally allocate three product IDs per hardware device. One is used for the boot loader one is used for Arduino and one is used for circuit python. So this product ID here will be unique to circuit playground expresses and also to circuit python. You can see the manufacturer and the product that is like in the board desks that's where it comes from and then the serial number is coming from the unique ID that the chip has however the chip determines it. Quayman16 says will you be posting your usb host reading guide on Adafruit? I don't tend to write learn guides so I don't it probably won't be a learn guide for me. That doesn't mean that there aren't other Adafruit folks that will do usb host related learn guides kind of like downstream of me but right now like this is the best you get with the with the stream about it. Yep so that's that and Viada says I was wondering about the product IDs being different. Yeah so the product IDs are like not something that's burned in it's just something the software knows. So there's only well I think there's only one configuration I'm almost positive so here's again the the only configuration but now you can see that there are six different interfaces which is a lot and first let's actually see that we have the 86 one which is the mass storage so we have a mass storage interface that's the circuit pi drive and that's why if you're looking at an esp32 we can't do it because it doesn't actually have native usb so let's just take a peek at let me move this over here and we'll just do a quick look at the other stuff here so one is audio and we can see that interface four is audio and also internet phase five so this is your MIDI functionality for a circuit by phone so we've covered eight one and now we have two three and a so cdc here two this is your serial that's your serial link and it's interesting because it's only an in endpoint not an out and I'm not sure why that is oh here we go so there's this communications and cdc control but then there's also cdc data so that's a so so this class two and this class a this is what implements your serial connection so we have serial we have mass storage and we have audio and the last one here then would be human interface device so this is the interface that you allow circuit by phone to be a mouse and a keyboard and there are separate human interface device descriptors as well that this uh this library is not dealing with but would tell you like how many keys can be pressed and what kind of state there is like the hid descriptors were really complicated they're very very complicated and then as fed a two is pointing out that you can see here that device nine is actually a hub so a usb hub actually is something that the host can address address on its own as well and I've only just begun kind of understanding how that works but you can do things like turn power off and on to like different ports on the usb hub for example and that's just done over usb because the the hub itself is a device on the usb bus as well um okay so that's that let's uh keep going I have a couple maybe a couple other things that would be interesting one that's relevant for david because it's a within reach with me sitting here is this one so it's a midi keyboard um and if we look on the back we can see that it has a sorry let me switch to product showcase where it won't all eye track so we see that there's a usb plug here um and let's just take a look at that um there's also regular midi and sync signals and stuff but if we just unplug this circuit playground and I'll just plug this is the one that goes to the usb the python device will plug in the arteria and we can see oh we have power the buttons are lining up um and you know what I actually do have test script for this already so let's control d again and then we'll control c and stop ourselves so now we can see here and I should pad these numbers so that they're always four digits but we can see the vendor ID and the product ID we can see that it's arteria and that it's a key step 32 and that the serial number is 1a which sounds suspicious and it's probably not unique per device but you never know and I think I have opened this up and it's a an stm 32 of some some sort on the chip itself because I'm weird like that and then we can see here that we have two interfaces again we have a one and uh they're both one but they're different subclasses um and in fact we didn't look here oh yeah so it says the audio device class spec uh is there so that is that and so if you were and maybe we should just try it uh okay so Beata says I was having fun with some hubs years back all of the same retail product but some could do power but some could not okay so some some hubs can't do power on and off um but I'm not sure ah krimman 16 says because I have a feather rp20 40 with usb host that I wanted to make a usb keyboard remapper yeah so um maybe that's what we should do before I get down this path because this is audio so it won't be the same as as you as a usb keyboard and a usb keyboard is kind of tricky because circuit python will automatically do it so if I unplug I'll unplug the midi keyboard and I've got this uh like wireless wireless keyboard here that has a dongle so it's not like bluetooth or anything it's just like some random 2.4 gigahertz thing so if I plug it in and hit control d we'll see that we get class three which is hid but now on here I can do control c and like actually um do stuff but I should um let's see if I can't just write while true oh I missed a letter I'm gonna lose the keyboard the moment that I it's it gets a little tricky should we see if something that I haven't tested but should test works um let's duplicate this yeah there's already a project called hid remapper I think that can work code descriptor yeah krimman 16 I suggest getting on the discord there's folks that are interested in this too um and there is a project for it so let's open code.pi and let's start uh tweaking some things so I like to do is if divide so remember you could have a a hub plugged in so you may not have found the device so let's say while we don't have a device and we want to keep track of the in endpoint zero zero is not zero is the the control endpoint so in this case zero is okay to do we would say okay we don't actually compare about the configuration but we could say uh if interface class equals hid did my terminal go so there there's two interfaces here so I'm not sure which one is going to be the one we want unfortunately um we could just pick the second one one's probably mouse and one's probably keyboard so so and interface subclass equals one is that what it was and let's not make this ambiguous let's say hid device otherwise we have two names for devices so we say if interface class equals three and interface subclass equals one we say hid device equals device and then what we could say is if it's an in endpoint so from the device to the host if hid device then we could say in endpoint equals in point address and that will say print found hid device and in end point oh and the time's up sleep so once we find an end point we could break and that would make it faster except return to break two oh and then what I also realized is that um you don't actually have to do it this way be unless you want full control you could also just say while true print input or sys dot standard in read one that's what it is and maybe we wrapper it it doesn't mess us up we need to import sys so because um so circuit python automatically supports keyboards and um keyboards produce key events like key codes but they don't give you like actual um ASCII or unicode characters so there's an extra step that translates hid report events into a serial stream so what I'm doing here is I'm actually it's the same serial stream that we would get uh over the uh serial link so if I just say hi like that's what I'm typing in here but now if I go back to my keyboard and I take um h e l l o um and I don't know why it auto reloaded but I don't think it's pressing the o key that's not working anymore uh oh um I crashed it I wonder if it's fully crashed nope just the keyboard input is not working I'm not sure why um there are bugs in usb host still folks um and we have 10 more minutes or so so if you have any more questions now is the time to ask them um but yeah so if you if you want just like the characters themselves um you could just use like the standard in um I don't know why this is broken but ideally we'll fix it before it's stable um so that's one way to go and the other way to go is um if we comment out this I think what we need to do is we need to do device detach from kernel and I don't know if this works I've been meaning to test it but if we pull up the circuit python docs um and we go to core modules and we go all the way down to usb and this mirrors the pi usb api it's just a subset of it so this is what we're using to find the device here's like the device descriptor stuff quidman 16 we don't have a learn guide for this yet this is all very new um yeah it's all very new uh there's the arduino stuff might be a bit further along um so detach kernel driver is what we want and we actually need the interface for it as well interface and we'll say hid interface number equals interface number and so we'll say like hey uh stop using that for the internal circuit python stuff and then we can say um reports they're called hid reports usually and you can do um device dot read and we can reference the low level docs so we would give it the end point and then a buffer and the hid report descriptors will tell you how big they are but they tend to be eight bytes so we'll do buff equals byte array eight and so we'll say in end point and then buff and report is not right size and then what we do is we print buff and we do just the size of it so if it if it's less than eight bytes which it shouldn't be this will only print the the stuff so let's see what that does we might need to restart it too is that not what it's called detach kernel interface detach kernel driver and i don't actually know that this works we'll see no configuration set so we also have to say device set configuration and if you don't give it anything it'll do the first the first one all right so we managed to do a read from that end point so if i press oh it it is actually working awesome um so i'm pressing the b key so this five here is uh is the b key so the standard um hid report layout for keyboards tends to be the first two bytes are a mask of your modifier keys so your alt your shift your control end up here and then you get the key codes of six pressed keys after that and now we're now we're crashed um so like i said it's it's uh early days for us we have still and then yeah so you can see 19 here is a different key i forget which um but so this would give you like low level access to what the the hid device is doing um i don't know what this usb error is but uh we could see if it works again we have some issues about resetting it's unfortunate like like we were probably calling read here when it got interrupted and like we don't cleanly stop the read sort of stuff so yeah there's there's bugs there and please file issues if you're playing around the usb host and you run into this sort of stuff uh for now what i'll do is i'm just gonna eject the drive i'm just gonna restart it and we're just about to wrap up anyway because i gotta go i gotta go camp oh i control d so we got a usb error again and i'm not sure why but you can see that it is um working internally to circuit python still so um there's some work to be done there um but yeah so that's uh the delete key doesn't work oh that's delete not backspace interesting there's two separate ones anyway um okay so that's a brief tour of the new usb host descriptor library and uh the basics of descriptors and discovering the endpoints that you want to read or write to um super basic generally my approach to usb host on circuit python is like assuming that you've already learned a lot about the device that you're talking to uh probably from uh like a more full computer there's a lot of like variables and state and stuff that's in descriptors and full libraries will have all of those different bits and bobs but uh storing strings is actually really like variable names is actually like pretty large so i'm trying to keep the usb host libraries for circuit python super minimal and really like focused on exactly like the use cases that people are going to do so yeah check those out um i didn't get to the mass storage demo but you can use a usb thumb drive using the vfs fat thing um so you can read and write files to that um all from your user user code um it just does reads and writes to the endpoints and then the like scuzzy protocol that the mass storage stuff uh uses too um but yeah that's it uh thanks again for watching deep dive uh i should be here next week as well um it's been super fun if you want to support me support Adafruit by going to adafruit.com and purchasing stuff as pitquanman points out we do have a feather that has a native um usb a on it which makes it really easy to do to plug stuff into um if you were watching last week i was hitting a bug and i haven't gotten back to debugging that but i haven't fixed it as far as i know but then again tack tried to reproduce it and wasn't able to so it might just be my weird setup um anyway that's an example of stuff you can buy from adafruit.com um circuit python is broader than adafruit stuff so it is supported by other boards as well um although development is primarily driven by adafruit funded folks um circuit python day two weeks from today i'll i'm planning on streaming plus we'll have a bunch of other streams as well if you have ideas for circuit python day let us know i think you can email circuit python day at adafruit.com and uh yeah i should be here next week as far as i know so i'll uh see you all next week uh discord is uh adafruit.it slash discord uh lots of cool people there to check out and hang out and help out so with that uh have a great weekend everybody i'll talk to you next week when i'm back for my camping trip and sorry no cat cam again