 All right Good afternoon evening everyone. Happy Friday Happy St. Patrick's Day to anybody who is interested or celebrates St. Patrick's Day I attempted to wear my green shirt But I failed to account for the fact that we have chroma key going and it's set to green so that the screen behind me gets cut out So today I'm gonna be a floating head with a mirf logo Well, let's go that way, but it is green and nonetheless If we all This actually update live. Yeah, there we go. You can see I've got green shirt and green screen, but Whoops didn't plan ahead very far How's it going see Grover? Let me nice this and Full a few of these windows around As I go and be out of graph on YouTube this one Good there Let's go into shippu So Hello to everyone. My name is Tim. I go by foamy guy on github and discord This is the deep dive program Which is a weekly live stream program where we are working on circuit python related stuff Sometimes we are in the circuit python core the actual C code that is circuit python itself Sometimes we're working on libraries documentation or infrastructure Projects all sorts of stuff. It just depends week to week. What's going on? If you are brand new and you've not caught one of these programs before you don't know really what I'm talking about when I say any of that You can learn more at circuit python org This is the main website for the project circuit python is a Implementation of python that runs on tiny computers called microcontrollers There's a bunch of pictures of them over here on the downloads page at circuit python org these little Devices each one is essentially a tiny computer And when you plug it into your computer with a USB cable like this one is connected It will show up as a thumb drive and you can edit the files on the thumb drive Save the code file and then it will execute on that device. That's kind of the you know Central core idea of circuit python is the device showing up like that as a thumb drive and you being able to edit the code With whatever text editor you want save it and then have it run if You are interested in Learning more about circuit python a couple of things you can do circuit python org is probably the best place to head to start Join us on the discord, which I think is yeah link down below 88 fru. It's discord. There's a circuit python dev channel help with circuit python channel So head there if you are interested in using circuit python or you know joining the circuit python community or project contributing code Or just want to hang out and say hi Circuit python is an open source project. It is primarily funded by Adafruit. This is their website Adafruit comm They are a hardware and software company based out of New York They manufacture some microcontroller devices as well as some other breakouts and things that you can hook up to your microcontrollers to interact with So if you want to get yourself some toys head over to Adafruit comm And then you know, thank you to Adafruit Of course for paying all the folks who are working on circuit python And thank you to everybody who wants to purchase hardware from them because obviously you're helping keep the lights on helping helping keep You know Adafruit factory running, which is helping them be able to keep paying the folks who are working the project But thank you for all of that Today, I am going to attempt a little bit of core development For anybody who Has followed some of my more recent streams You might know that I have been struggling a little bit with some hardware issues In particular that seem to expose themselves when we're working on the core. So I'm gonna say fingers crossed knock on wood Everybody do whatever your favorite thing for good luck is Because we are going to attempt this and hope that nothing goes too terribly wrong if the I will say right up at the top here before we really dive into that one of the things that was going wrong in the past Hopefully in the past was that my computer was freezing up Which unfortunately means then the stream is gonna cut out and I'll have to kind of reboot and come back and do all of that stuff So Hopefully this will not be happening. Hopefully we have gotten that kind of the worst of it You know in the past But that's one of the things that was happening. So I wanted to give a fair warning If I do disappear or the stream cuts out or something like that I will try to get it rebooted and come back as quick as I can But it may take me a minute and I'll try to drop a message in the discord or something like that from my phone If I can as well So that's the warning on that again fingers crossed. Hopefully we're not gonna be needing that. I will say I've I've had You know a little bit of okay news on that front, which is I did end up actually getting some new Ram and I have not had my computer freeze since then although I think I actually haven't had it freeze since I switched Kernels and updated a lot of stuff as well. So it's it's all kind of anecdotal Unfortunately, the things that are going wrong are kind of wrong very very randomly And so it's difficult to like change a variable and then test again because It's not failing consistently. It's it's pretty random. So Hopefully we're not gonna have any locking up But we'll see how it goes The thing I do want to work on which is in the core is this API inside the web workflow for Returning the free space on the device Uh from a url the url that was proposed in here was slash Uh device info json. I think disc info json like this So when web workflow is running you would open a browser on another device you would hit this url with the ip or whatever of the Circuit python device and it would return to you a json Which is going to tell you how much space is on the disk and how much of that space is available Yeah, thank you I went just like probably five minutes before I hopped on Uh, I was changing shirts and I was like, oh, let me grab the screenshot real quick for st. Patrick's day That'll be a good idea And then as soon as I uh, I sat down and I loaded up obs and everything and I was like, oh, right Yeah, but you guys can see more of the screen this way. Just a nice side benefit Kind of like a little piece of hair in my mouth or something. Okay So I do Have a branch for this. Oh, I will I will say too in in less fun news I actually um, I rebooted my computer before I started up the stream today You know for luck basically for hopefully, you know, try to make it not have any kind of messing up Um, one of the things I did though is I also went into like the BIOS and changed Some setting about memory speed, uh, because I thought the memory that I Have replaced like I put in new memory. I thought the speed was different So I went to the BIOS to change this thing Uh, and then it just wouldn't boot up at all or show me anything on the screen. That was uh, About 20 or 30 minutes ago. Um, so we luckily got it back just in time so that I could actually get everything up and running for the stream from that so Fun fun times all around On the on the hardware side for me, but we're hoping hoping for the best here Um, where I'm gonna start is I I actually do have a build already Uh, you all did not see me make the build, but I'm gonna use it as my first build because Essentially one of the things I'm gonna be doing is trying to minimize the number of actual builds that I need to make Uh, so that we are rolling the dice less on the computer messing up Um, and in this build it should I believe have the disk info json Um url the end point which maybe I should stop just scrolling. Let's find a disk There it is. So we have the url which is going to handle it That's going to call reply with disk info json right now. It is hard coded to something else, right? This was just a copy of version json, but it should be enough for us to test to see if this part of it is going to work or not So, um, I don't have the camera set up today pretty much everything I'm going to be doing is all just repel Um, so we're just going to go through the repel for now. No, uh, no desk cam Honestly, I have a bunch of stuff on my desk Uh, as well Okay, this is on Just got that connected Whoops We'll go to bootloader mode This is a feather tft is what happens to be connected right now, uh, which is what I have a build for This is like the exact perfect length to where It's on the end and I can't tell if it has a space or not One of the other things I did Uh, I guess you could say superstitiously to try to like rule out variables for what was causing my computer troubles was I uninstalled the Terminal prompt thing that I was using before Called starship Which would like change this prompt here to have some more Interesting useful information and generally I think also shorten it which was nice Um I should probably put that back because it turns out that was not really part of My problems because I've continued to have a little bit more problems after I did that Although again Since the last couple of things I changed I've been at least not freezing So It can steps in the right direction. So Uh in order for web workflow to be active. I have to also This is not the right thing to be open Uh one second here In order for web workflow to be active you have to have Uh This I think which I should not just open here obviously because it has my wi-fi network in it And some other stuff it turns out chameleonware Okay, so the code that's on it is unrelated. This was a test for bitmap tools. Uh, I don't Don't think it matters. What code is on it? It's been a minute since I used web workflow. Let's pull up the learn guide for web workflow If we want to save our code, we'll have to do that I think I need to do that. Yeah, uh, I guess really what I need is to be able to know the ip Which the easiest way to know the ip is going to be don't run And this code because this code is gonna Do stuff with display. I oh One two one. Okay Is there a port? Oh, it went to uh, yeah I feel like I've had that problem before haven't I? I don't think this I think this never did work for me. Unfortunately the dot local thing I don't know if my network is weird or something Slash code. I was usually able to do it from the uh See, I think the reason it's failing is it's going to HTTP Um, why is it doing that used to connect put the store. I can at least see it Um, there's something else we need to put in the Something else we need to put in this Settings.toml port and password could I have changed the port I guess? Fortunately, we got to bounce this back because I can't share my settings.toml You don't have a port. Will it not be active? Okay Still thinks it's on 121 defaults to 80 You know, it's interesting the uh, oh The coincidence Here we go I know why it wasn't working before but we made it there So Is this supposed to be after cp? Yeah We do it in here Nice if I could do it in here I'm failing the same way Okay, yeah, it doesn't like being open in both browsers either, but there we go. We made it. So this one returns json Theoretically this one now is existing disk info Which is mostly the same stuff really the one thing I changed is this is now version one instead of version Just because I wanted some kind of change so that I would know that this is actually working And it turns out it is so Really what we need to do is use this function that scott says f.gif free What do we actually do this though logical drive number? Let's search the code. Is this used anywhere? Let me have another one of these Get grep this no get grep this Yeah Result is that so let's see Come on this That go to there Oops What was it get free get free read only is that one? Oh get free That's actually part of it because So as it calls this get free Oh f versus t. I see f result Okay, so I have never messed with any of this stuff before do will I need to Do all of this I will right because How do I get this passed in? Get the status of vfs Or is there any way should we could we call this method instead? Because this has free available Where does this come from does this get used anywhere? and just to be Clear this page Shows the size of each file But not the size of the entire directory or anything like that If you can call os.stat Good bookmark that huh be a good thing for the bar here. You know, I had the index page bookmarked actually That's what I should do because that one is a bit faster Or was that index it wasn't this it was like But this was the one In the status of a file or directory status of the file system Path string so yeah, we could if we could just pass like slash probably so that is block size fragment size size of fs in These units number of free blocks Unprivileged number of inodes number of free inodes Mmm. How does that turn to bytes though? size of fs So is that saying 1881 times 512 and then that's the number of bytes So then how many that doesn't seem right. What if we had kilobytes? Okay, that's pretty spot on fair enough So then let's see back to this that was total size is number three, but you have to multiply it by number two And that gives you total size and bytes What this device was bigger than that? It's not That's the right size It feels weird about that. I don't have the reversal ones Four mags flash Maybe some of its use New euro at compatible digital pot driving Driver heading for the community bundle later today. Nice Sweet cool looking breakout I do remember something about there being like reserved space or something Like a circuit python itself takes up some space, but there's also Reserve space or something. I don't really looked before so I'm gonna assume that's probably right It at least matches a number of free blocks then would be 416 Times again the 512 416 whoops That's interesting 12 is this and then this into here is 112 free which is pretty close. Yeah zero block size times total blocks nice Yeah, okay, so let's look at um If we can just call that that'd be pretty nice is os a thing that exists in like shared bindings and shared module and all that or Should I be trying to should I be trying to call this? I guess not right because this is really the whole intention is to make it exist in python land But should I I should be probably just calling this directly then but we will need to like Unpack the tuple somehow still all right, so we're gonna cut out some of this stuff we can keep all the top stuff And then here The stuff we're gonna cut out Let's keep I'm gonna keep version. I don't know for sure if we'll want to keep that but I'm gonna keep version I'm gonna keep two more for total space and free space I think I'm gonna delete the rest Some of this we need though, huh? Oh man, I do not know if I'm gonna cut it off at the right spot this is tripping me out a little bit for the jason to be like Like the commas before the quote which is Super weird, right? So this should just be here so Okay Should we just say maybe total and free? I just Put some fake stuff here See if we can get see if we did all of that stuff, right? I think that the issue is that what we had before was a variable now we have not a variable but a literal So I think like this would get this back into the string Do close the json Oh, yeah, shoot Thank you Wait, where's it closed in here? Oh, okay, technically. I do still have this down here. So so we don't do we not need all that stuff? Is this No on the last line No, we don't need it put that at the end of this one, but I'm just gonna fill that in like that for now This is gonna have extra spaces. I think Then if we do that, we don't need this Oh, but we do need This and that We're not filling in any variables So we don't have anything after for now, but eventually we'll swap in these two for variables We'll get rid of this one It has this concatenating strings with Define string some string string. I got you a percent s D for the substitutes It's a char host name we have something Host name set but not used You don't need any of this, right? Should I Not actually that confident about that. Maybe I should comment before Right delete Okay, we got a build let's back up here I'm gonna let it chill for just a second Then push it That's going cute the e hope friday is going well you two friend. Thank you Should I open to in C line I'm not really doing anything with coat pie That's one less thing to be running Nice I've not broken anything She's a good sign. Obviously we haven't done anything that complex, but Those of you that don't know if you're new this like Not really formally trained on C. So I'm kind of just like poking around Not quite in the dark, but let's call it dimly lit. Yeah oftentimes I am Doing things that are probably like pretty obviously syntax errors, but I don't really know any better yet We're getting better over time though. I feel like I've come a long way since I've been digging around inside circuit python um So one thing we could do is get rid of this one for now Oh, okay, this would be number versus string, which would actually be better to be a number, right? Yeah, cut this Of course We are gonna be still having to do the substitution eventually. I think I did that part, right? Should we oh, I did get rid of the version. Should we have the version or no? Drive size is what's expected on a four mag without an extended mode, which is the default. Nice. Okay There's some bytes for the boot loader 1.5 1.5 for ot a remainder for circuit pi. Okay So we're in the right spot there I think I'll I think we'll just go with no version, right? I think it's okay to not have the version because version like there's version dot json That's the whole point of version dot json um I don't think we need it So let's make sure that we did this part right since I cut some more stuff out and I changed those two numbers uh, I Don't know that I would go so far as to say that I've definitely found this for certain yet but one thing that I think I've found is that Not doing clean in between every build Maybe helps my computer because it doesn't have to do as much work. I guess it's like saving some of the work it did Uh in the prior builds I don't I don't know if this is true, but I guess it it seems like it doesn't have to compile everything again if you don't do clean um I'm sure at some point it will be messed up for some reason. We'll have to do clean anyway, but for now, I'm gonna take what I can get and Just keep doing builds without clean in between Which also goes way faster, which is pretty convenient as well Press this. Okay. Perfect. We have numbers now instead of Strings and we also got rid of the version. So we are on the right path here Uh, and then I think we want to try probably calling this Uh, but the thing is we are gonna need to catch the object that comes out of it And because this is not python, we actually need to know the kind of object that it's gonna be I do not mp object t Fair enough when builds help reduce hidden and inconsistent errors though Uh, that is true and ordinarily like I would be on the side of doing them Um But I found that they go faster and that it seems slightly less likely that my computer messes up And so as long as they are working I'm gonna keep going with them If we do start getting any kind of weird stuff then clean will be the first step. I try for sure though Yeah, definitely as the first troubleshooting step for sure So let's see if this even builds. Obviously, we're not using the result at all or doing anything with it. So Still nowhere near Done, but see if it actually does Uh, that's a missing semicolon though, which is not so bad I've made it the wrong kind of thing somehow. Does this one need to be one of the star ones? Do the star ones go at the beginning? See as you can tell here, this is like When we start fumbling through the c syntax. No, okay, let's see How can I grab so I would need to know more regex I guess How can I find a spot in the code where something creates an mp object t As a variable by calling another function You know hard, isn't it? name equals So that's pretty similar nature to what I'm doing Maybe my error is not with The variable that I created but instead with the slash thing could this actually be Or I didn't add any kind of import or anything like that. I wish these would be clickable If k playing with cats nice Forget it finding monkey P object t name equals call the function Let's see actual error say stat result. Oh unused gosh Okay, obviously the insular here Uh, it is difficult though. How can I get a thing out of it? um so we need to Treat it like a tuple and pull a value out of it Um, okay, so this takes an mp object t that it calls x y tuple We want all of this I think so We're not gonna we're not gonna have x y And then when we get inside of here instead of And instead of putting these in x y That's what we'll put in our json So if it equals none, let's just raise an error for I guess let's return A json error would be a better way to do it. I think right this is gonna go in here Oh, should I have not done that? I probably should have not done that All right, if that was none, then we're just gonna say error stat result Was none Except we need these in this Okay, if it's none do that If it's not a tuple Do this, but we change it Then here if it was actually successful, that's where we can get our Stuff out of it Which is gonna be what now those were all ints. I think Or where they floats ints Are they always gonna be ints the way these have f in their name makes me think they would be floats, but I guess not Main two we need are these Well in this Or I guess Maybe blocks. I don't know if we're supposed to use block size or fragment size in my case. They're the same I don't know if they will always be the same though So let's see if I can pull int block size Equals Oops, we have the wrong one of this still here It's also not gonna be two. It's gonna be One two three four five six seven eight nine ten I I just put the wrong one in there. There we go. Okay. It is ten That's block size Let's try just like that. I think right. We at least have used our variable now. So We should be able to make a build. I think Block size and you yep Should have known that one, huh? Let's try to put it here You just put it in with no pluses like that Or should I be using the substitution? Maybe some of these are though, right? Maybe it has to be a string potentially We want percent d okay Okay We did need we need to import something for this Where did I see it being used? Not very many places Should we import it from there? Findings instead of shared modules Yes I wonder what's disco Okay So if that works, we'll have 512 as free which is obviously not the correct number, but it is A number that we got out of our tuple that we got back from calling stat vsf It like uh Reboot it again boot looping did not print this uh Not print the hey buddy get down from there So it did not print this in the repl but it says heap allocation when vm not running please file an issue with your program Just reset to exit safe mode. My code doesn't have anything Except for imports it turns out So did it get to safe mode? Because of my web workflow thing Okay, it's currently not in Safe mode and I do see codepie printed this it's on the screen It didn't show up here because it actually printed before to got connected Um, I guess we could put a time sleep or something if we wanted to be able to see it, but It's all right for now. So it's not Right now it's not showing safe mode. I'm gonna go to here That works cp slash version All right fingers crossed Not version though. We want disc info No, that crashes it Yeah, that crashes it all the way to safe mode We did something wrong for sure um shoot The problem is we can't just leave that because And it will fail for having an unused variable What if we don't do this line? so Now we are calling That We're getting the response. We're checking it for none We're checking it for if it's an object We're creating items We are trying to pull the 10 items out of The stat result But then we are still just hard code printing our old strings What exactly is safe mode a good question safe mode is So, okay I should say I should say a fair warning before I answer like what I am answering is my understanding of safe mode um And I certainly could be wrong so like Bear that in mind don't necessarily take whatever I say as like a hundred percent definitely for sure the exact right answer Because I the truth is I don't know a hundred percent of the way with that out of the way my understanding of what safe mode is Uh safe mode is a separate mode in circuit python where it will not execute the code py file So ordinarily in circuit python when the device boots up the first thing it will try to do is try to find a boot.py file If it finds that it will execute the code that's inside of it typically that will cause it to print out this stuff and boot out here Um, you know whether or not you have a boot py you'll get this stuff printed out Into your boot out dot text after all that's done the next thing it will try to do is launch code py In safe mode it will not launch Uh code py for sure. I don't know about boot py whether or not it will do that one or not Uh, but it won't launch code py the idea being That it is like a hard crash of the circuit python system Uh within circuit python you can have code that raises an exception at the python layer And then inside your python code you can catch that exception or Even if you don't catch that exception then you will see You know inside the repl You would see some kind of exception error get raised get some kind of print out or whatever your program will stop running There will be a trace back inside of here with your exception. That is if uh the error is like successfully handled by circuit python If the error is so bad that circuit python itself Can't actually handle it then the circuit python program crashes When that happens your device reboots and it goes to safe mode so that it won't execute code py The idea being you know the thought being like code py is probably what caused it to Hard crash Therefore we go to safe mode. We don't launch code py that way. We're not just stuck in a boot loop of hard crashing um, this lets you break the cycle of Hard crash and then it comes back up in safe mode. It doesn't execute Therefore, you know, you can change code py you can make whatever modifications you need In order to get rid of whatever the code that caused it to hard crash was Oh safe mode dot py i've not even messed with that one actually Safe mode that one's relatively new. I believe but yeah, I haven't even messed with that one at all yet. That's a good point though Um, so that's my understanding. It's like a secondary mode when circuit python hard crashes It will take you to safe mode I think you can access it yourself too if you press the reset buttons. Just right. I don't Ordinarily do it that way. Usually when I get to safe mode. It's because it hard crashed Okay So we made this build we want to get to bootloader Copy that I should have waited maybe an extra second So this is going to tell us whether or not Whatever I did to hard crash was this this or This part down here and the substituting into here If the hard crash was a result of these lines or the substituting I was doing down here Then we will not hard crash this time However, if we do still hard crash this time, we know that either this line or This line or I guess maybe this line one of those is responsible for the hard crash We are back up. We are on the same IP So we will validate That we're alive by going to version Then we will try this So hard okay that one hard crashed so we know that it's Keep allocation when vm not running allocation You can also programmatically go to safe mode. Oh nice So if you want to reset yourself from code or if you want to provide your own like press this extra button or whatever to get to safe mode The problem here though is I can't I can't build this Because it will tell me well, is it unused if I check it in here Maybe that counts as a usage Let's say it will tell me unused variable It won't actually So my next guess is maybe that we're not supposed to pass a string like this. My next guess is going to be uh, maybe we're supposed to be passing like a mp object string or something that's not just a literal c string like this Uh, this will kind of hopefully rule that out for us because if we still go to safe mode Then we know that this is actually the line that's causing it In boot litter copy that that actually made it. Okay 21 We're back up there Are gonna just go back and forth again just to like validate it's actually alive and working That much of it No still crashed. Okay. I think we don't we're probably not supposed to be passing a string like that and so the other place where this gets used is In shared bindings where it passes Const char Path We need to do this Buddy, don't climb the window, please How's it going digit ebb? Use this only Uh p string get string Uh, this one's a object So this one takes mp object t path in Seconds Uh, how do I get my literal c string to be a python string? This gets used on arguments a lot And typically get used on a hard coded thing to object This makes me think we will get The right are we gonna get the right thing? Double knight dreaming of a way to create 10 inch supple for mailbox So I found literal string Gonna be that easy. Um I don't know. I mean, uh, no, I don't I don't know. I don't think so. Maybe though. Scython. I've never seen a thing that says scython like that This is the old code Or Path is unused. Okay Yeah, I'm not a lot farther than I would have thought. Okay. There we go. I was gonna say I mean honestly, I'm surprised it wasn't just like I don't know what scython is I think we're going the wrong way. We need to get it to an object t So we need to Take We need to take a literal string and turn it into an object t Where is the place where all of the helpful functions for this are at? Um I don't remember Like where's this defined? My object string Try turning it off and out again. I don't know Yeah, it doesn't know things Doesn't the only thing it knows is which words are commonly together In the data that it consumed chances the It creates an answer that's relevant and helpful in the real world knowing only which words Are more likely to be together in the code or in the text that it consumed I think fairly small for the most part um It's that pi object quoted string print Ring make new bytes make new index the pointer substring string join ring split ring write split ring finder and find string are fine string index our index starts with ends with any strip string strip l strip format helper Where is a place in the code where it would convert a literal string Into an mp object t string format replace copy the object new string Yes, that looks promising f o object new string path out f o goes to here Thank you Nice, Ben. I don't know how you found that That does look right to me Nice pointy. Yes. Nice Thank you my friend Well, that's not what I wanted to do Okay, what are we doing? Let's back So we're still in the version where it's like it's back to being hard coded We're not actually gonna see the fruits of our labor here or I guess to put it another way If we are successful the only thing that happens is We don't hard crash and go to safe mode, but we do still get Our hard coded response. That's not actually the real data One step at a time You're just crossed Still crashed I feel like we're much closer though. You feel like we're much closer Hmm, I'm just gonna get rid of that line news variable Python pi pi object h This will tell us if we successfully created path o That did not crash It did not print which means that it wasn't none Hmm We we need this actually we need a const char pointer Oh, but this will get us to that Are we Are we like Are we taking an unnecessary trip through Micro Python object Can we take can we take a string and get a Const char Asterisk which I think means something with pointer C string Do we need to put it in a variable? Yeah, that may Work i'm curious though that feels like we're going from string to Micro Python object and then from Micro Python object to Constant char thing That's weird path string Set but not used But literally the next line uses it Did I have done string and not str? set but not used It's not true because I don't think I can do this Doesn't matter anyways because it still thinks path string is unused But why is it not doing this? Now path is unused I'm supposed to do Maybe I have path And if I turn this off, then it will say path string is unused And I don't know why it counts as unused though Maybe we don't want this Well, first of all the way I created my string was way different. Anyway This feels wrong, right? I feel like this is probably stupidly simple and I am completely showing How I have no real understanding of C an interesting syntax So I don't know is standard string. I guess is that what we have is that what this is? Is this a standard string std colon colon string? Does this not count as a usage? It feels silly that I'm like Trying to make a pretend usage to get it to compile we might this Has to be the wrong path, right? I guess I could go back to doing the object. I feel like we should Now that I have seen this though, I feel like we shouldn't need the object But I guess at least what was working maybe Wish I could just do this, but I don't think you can right? Excuse me It's the one I copied from first Not really Because it's like not existing Okay, I guess we go through object length I don't know. It feels like we shouldn't have to I'm guessing that we don't have to but I don't I don't know how Get string Yeah I will agree to that Maybe what if we say c plus convert literal string to crossed char Part of it is I don't is std string is I don't know if that's the thing I have or not, right? I don't know if that's what a literal string is which I'm sure like obviously that's a very Very very very basic component of the language I'm obviously missing But I just don't know That's actually what a literal string is a lot of these say c plus plus Makes me think is that Relevant to us or not and calls it a string This makes me think a constant char is a string Here's crossed Hard crashed How's it going axle? I don't know the answer to that I mean, I don't think const is a type by itself. I think it's like a modifier or whatever. I don't know the right term Truth is I don't know anything about it. What I know about it is like Kind of attributed from java I doubt really carries over the way it does in my head But I mean it's like a modifier you would say const and then the type of your variable and then your variable name So it's like modifier for the type Basically means it can't change after you set it I think it's a char and it const is limiter on how the memory is managed and crash Printed the slash So we have a const char Star path char We printed it it definitely has a single slash in it but if we pass it to common howl os stat bfs s We get a hard crash I think we have to do something with this or else it can't compile. Is there a way I can ignore Is there a way I could ignore unused variable? It'd be nice if I could Compile anyway Because like now I need to basically make a fake usage Just to be able to compile but the truth is Really what I want to know right now is does this line cause the hard fault? I don't want to do anything with the result or anything else All right brb Yeah, I like to be able to build without it though I could sprinkle in some more prints, but I'd like to be able to build with unused variables So I'm thinking that We're not allowed to call this Kind of thinking we're not allowed to call this I think maybe inside of here. We're like are we outside the circuit python vm I feel like maybe web workflow in here is like outside the circuit python vm And then maybe we're not allowed to use this because of that Like maybe we are creating the right kind of thing and passing it in And in fact, maybe even Just this technically would be enough, but We're not allowed to call this Because we're not actually inside the virtual environment That's my theory right now Unused for Yeah, well, I mean I don't want to leave it there for ever and ever and ever I want to like I want to make one build with it just so that I can like not have code Who's literal only intention in life like this code Will not make it into the final one the literal only reason this code exists is to make the compiler happy Because we pretended to do something with this But this gives us like an extra failure point, right? Like I would love to write my code and run it just this way knowing this is unused But just being able to test like do we get that far Without having to add that code that's like Basically just cheating right like I'm using it for the purpose of making the compiler happy For no other purpose Hard crashed And what it says when it hard crashes is Keep allocation when VM not running Keep allocation when VM not running So I'm starting to think we just can't call this function from web workflow I mean, I Think the VM is running. So I think the error message is not entirely Calling us exactly what's going on, but I think it's implying that We tried to do something from outside the VM This is the thing we tried to do Resumably that made it crash I'm thinking we're just not allowed to do that from here So I guess we need a look maybe in shared module Or wherever this came from third module This just turns around and calls that UFS Yeah, and I think this error message also is one that's not generally Probably seen by users This feels like not the right answer, but I also don't know though, right like Okay path out. I guess Is doing state VM stuff here though This time it's building a lot more stuff news variable plus a declaration so we need to We would have to include that if we wanted to use it But I don't know where it came from See, this is also in shared module os But if we're not allowed to use the os stuff, then I think this is not actually gonna work Maybe this bsf bfs is that one of the ones imported here? Okay No, though, right like we're allowed to use supervisor What is fata? What is in here? Is there anything useful in here? This implicit declaration Why does it think it's defining a function though? Recalling a function? Hmm safe mode gc alloc outside vm. Yeah So I do think that's like I think I'm on the right track there. I think we did something we're not allowed to allocate memory or allocate something I guess keep allocation And I think I think the truth is that it's not that vm's not running It's that where we tried to do the allocation from was not inside. I think that's kind of like my theory there That's to do with web workflow. Would it need something? No, we're not even the string that we give it I don't think so. I guess I can't really rule it out. I suppose but I don't think so. I don't I think this is a matter of Like I don't think it's a matter of we gave it the wrong string I think it's either we gave it the wrong kind of thing altogether like for a while I was trying to give it an object versus a string versus a const char or whatever I think I have figured out it's supposed to be a const char But maybe I'm still wrong So like maybe we're giving it the the entire wrong kind of thing or the other option in my head right now is that We're giving it the right kind of thing and it would be working if we were calling it from inside The vm, but I'm guessing like does web workflow exist outside the vm I feel like web workflow probably exists outside the vm right because it doesn't it it runs Independent of codepy and all the rest of the stuff And so I'm thinking that Right now I'm thinking I'm passing the right kind of thing Potentially even passing the right string as well, but we're not allowed to actually call the function we're calling From outside the vm and we are outside the vm I think this is again. This is all hypothesis Yeah, it's nice when it works was Feeling like it was a lot nicer about a month ago before I started having any kind of problems with it. I will tell you that That fs file system circuit pi that fs Maybe No Plus three It's odd you control click Yeah, I don't I never I don't even know Know what this is creating Maybe that one's a definite maybe Yeah, I don't I don't know obviously. I don't know what's wrong with it. Otherwise I would fix it, but I'm feeling like it's hardware Which has definitely soured me a little bit on Company that I bought the hardware from Maybe it's not though. Maybe it's software So one thing I will say these are using like f underscore which is Similar to what scott put fat fs Yeah, I don't know what this means But I think that you're probably on the right track because a lot of these like f open dur, right Where's another one? There's some more in here F rename F unlink So it does feel like this Would be the thing that we would pass to here as the third Variable path, I guess would be just our slash But I don't know what goes here It's f result Don't know what to put there and then I don't know what to do With this result object to get stuff out of it See if it compiles Yeah It's yeah, it's snappy. I will say when it when it's working. It's pretty snappy and it Till more recently here it can do a lot of things all at once and doesn't really get too mad about it And I like I said, I like I was super happy with it. I'll say like I was definitely super happy with it Could perhaps get back to being super happy with it if we can Once I am a little more certain that Some of the weirdness is in the past So Unsigned int but argument is const char. Yeah Unsigned int Number of free clusters But I put 512 that seems random, right? Number of free clusters How would you know that? See this is weird. This says it gets the number of free clusters the store Maybe that's where the result goes That where the result goes What's a d word? I think we don't need this stuff anymore right now. This is actually technically part of our other attempts Oh, okay. It's out. I see. I don't know if that's the right way to do it Oh, maybe unused result. Okay Unused result. Geez. I don't know how am I gonna even use it. I don't know what you do with it Where's next? Is this why is this so long What is wrong with this? This is like wonky. Where's the rest of it? Just that I didn't see that Uh, we could do this It's like a good thing to do with it I don't know if I actually need to put something in here for it to count too many arguments but got int Expected d word aka unsigned int I got int This looks like a different signature many arguments Seems wrong, right? Seems like different Seems like different uh signature. So we would not need the slash Instead it's just fs and the output thing And they are actually in the other order strangely I need an I need a I don't know how to make Can I just make d word? Or d word star uninitialized unsigned int Okay What version are we actually on here? Like what does this actually do? So This will just print hooray if it was successful And it will still put the hard coded one of these out. Okay If we see hooray, then it actually did at least Not puke which is It's up in the right direction Even if perhaps a small one Still hard crushed It has a different message now. It says fault detected by hardware This one Well, I think we're probably giving up for right now I guess because I highlighted something Let's look here Maybe I need and maybe I need ampersand Let's go look What is it? Okay, that's actually that's pretty close. This is different But it does look like we want that And then maybe we could get by without this And This Like it builds at least Nothing writing memory where it shouldn't be Yeah, very possibly Would not be surprised Unfortunately, I'm a bit of a A bowl in the china shop so to speak with c code like not really knowing like Like treating this one that was here as a an asterisk and this one as an ampersand and not having a clear picture of Why they would or wouldn't need it I think makes it very likely for me to Tell the CPU to do something that's probably not very good for it to do I'm guessing is how we got to the hard fault. Okay fingers crossed Yes, it didn't hard crash and we got a result Did it print hooray? It did. Okay. Are we actually We actually so close So then if we went I want to keep this one. I kind of want to keep this one No, it's fine. We could copy it from here if I needed it Percent d Free clusters What was it? Oops Looks like it's gonna build Go back to version It's ready Are we gonna get total though if this is only giving us one number? Hey, hey, hey, hey, hey, hey Come on, buddy. Hold on. Hold on. Let me get it out of there because Play with it. This is backup version just Didn't crash and it returned 416 Was that Indeed it was okay So if we multiply 416 by 512 That is going to give us the number of bytes Times 512, but I don't know how we would get total Or if we can get total Is there a Is there a different Thing then get free maybe there's like get space or size It's like why is nothing happening? Didn't copy it That is our number of free bytes. I wish there was like size By this oh, it's uh get free okay volume management I mean get size feels like a winner, right? Well, it was just size. I think it wasn't get size Guys But that's the size of a file Those are the only things that say size That says space Only one match Well, I don't know For the 512 there must be some literal for the block size so um maybe Maybe on the one that's doing the size of the files What's something doing the size of the files? This is my code though commentate all this out Is it different on different boards though? I think when the file name is slash it means volume So maybe we could use size with slash Okay, so that handles delete request that handles move request This handles get request Name directory it doesn't have the size modified file size File info dot size file info came from this seemingly How does So this was me typing fs and pressing enter It returned an html document On that html document it contained a load for this for this for this This made a request to the exact same URL But it got a different type of response. How did it know How did it how did it get a different kind of thing? Is there a dot? Maybe get her post But it shows get on both Method get there and method get there It has accept type as json does the server can the server return Different stuff based on the accept header Really Okay, I think I'm gonna call it for now. Usually I go about two hours. It's been about two and a half So I'm ready to definitely get up and walk around and do some other stuff equals slash Returns the list that's the api. Yeah, but I don't from the web Programming perspective. I don't understand how it works because my browser made a get request to slash fs slash That get request returned this html page On that html page it loaded this javascript and the css and this icon and This json here And then part of the javascript inside of here also made a get request to slash fs slash which is the same Address as this This made a request to the same address But it got a different I mean a different response, but a different kind of response as well. Obviously the first one Was html whereas this one was json. Ah, there you go. Yeah. Oh, I probably just wrecked the uh Yeah, I totally did. Let me fix that done that I guess Fortunately, it's tough to read without I suppose response away fetch Oh, that's passing those headers You can read the javascript Yeah, but I didn't but like on the server side. I mean first of all, I didn't know the server side could Have different behavior for those different accepts for one thing but even if that's Possible Maybe is this checking for it somehow? Where is this at? Then state header value I don't see anywhere where it has that logic though. Like I don't get In the server side and the code in here, I don't get how it managed to draw a distinction between This first request here where it returned this html and then this request down here Which came from fetch inside the javascript where it returned a son Maybe that maybe this bit that we were just on was the magic though This is like setting it into a header string. Maybe somehow this No, well, this is if it ends with json So in our case, it doesn't it's slash fs Or is that other one this one? Maybe somehow this is the logic, I guess I don't really follow it. Maybe this is somehow making it so that if the accept was application json Then it's going to know to return that Based on api one rather than the actual html Um This is a request json All of our tools isn't showing the headers just the headers That's good. And then content type. I mean it is Well, that's a response header though except would be the but it is I mean the accept header is definitely One of the differences between the two requests It's just I don't see any code in here. That's like if except equals application json then return this thing else if except equals, you know Text html then return this other thing. I don't see that Logic really in here somewhere. Maybe this I guess but this is looking at the end of the file name In our case. We're not we don't have a file name just fs slash There's nowhere else where this is at Then the only place where this exists is those spots. We already saw None of which to me seem like an if statement. That's doing that I mean this one would be the ending of the file. So we're not using that one right now Somehow maybe this I guess is doing it You're just on a search request json request json By static that one would be the html. Okay This is request json. Is that the body? Load in the body Make sense. Thank you. It's the mine types of the files Yeah It's json. So is this does this it turns into just a boolean I guess request json Which ultimately maps back to that except I guess Okay, I'm gonna call it for now. We did get the free space Um, I think what I'm probably gonna end up doing is submitting a pr with the free space And not the total Senior responses anymore 404 That only work once Recursion for question mark. Not sure what you mean by done I've wrecked it somehow. It's broken now I got I don't always get 404. I'm getting a response from the web server, but it's 404 Well, how did we man? Okay Nothing cp cp Yep. Thank you. Appreciate it I think you could get the total with something like this. I will have to try it later fstat on path F no I will try it out um So to wrap it up, I will say, um, I will not be streaming at the normal time tomorrow Ordinarily I stream at 10 a.m central time on saturdays Uh, which is tomorrow, but I won't actually be streaming at that time tomorrow I think I will be streaming but it will be later in the day some time and I don't have the exact time So unfortunately if you want to catch tomorrow's stream, the best advice I could give you is just keep an eye on the live broadcast Chat channel, um, and I will drop links in there when I get started But I have other plans for the morning So I won't be around at 10 a.m to stream, but I am planning to stream later in the day once the rest of my plans are over Uh, those numbers are different Shrat That means we need to figure out how to get that Somehow So that's something else we have to do I don't know how to find it though It's interesting. There are different fat types too. I thought they all would use the same. I didn't know that would be different Definitely interesting So we need to Try to do the total and then we need to figure out how to get that 512 versus the 1024 versus the whatever We need to figure out how to get that programmatically so that We can then multiply it to get to our bytes Um I will whenever I do stream. I think probably keep working on this So if you're interested in seeing the rest of this when I give this a try, thank you to who's this isek ben Thank you to isek ben for posting this Code which might get us the total here That is probably what I'll try when I do pop on the stream tomorrow Which again will be not at the normal time of 10 a.m central time instead. It will be later in the day Um, but that is it. Thank you for everybody who has been watching I appreciate all of you watching along and hanging out I especially appreciate those of you in the chat who are helping me out Antique data near doc isek ben did you devon see grover Keith Really everybody I appreciate you all in the chat Definitely the folks who are helping me out because as you could see I was very much fumbling my way through it Uh, and without help from the chat. I probably wouldn't have made it as far. So definitely super appreciate it Um, I will See you all later. I hope everyone has a good night I will see you uh tomorrow if you want to tune in just remember though Like I said a bunch of times already sound like a broken record. I'm sure it will not be at the normal time N a.m. It will be later in the day. So have a good night everybody