ESP32 Meet-up - FreeRtos

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

This is a meetup I did a little while back introducing some key concepts in FreeRtos,

Also check out my course at https://learnesp32.com

👍︎︎ 4 👤︎︎ u/m_swa 📅︎︎ Dec 15 2019 🗫︎ replies
Captions
okay so let's get started with free artists okay so what is free artists Priyanka stands for the free real-time operating system okay so when we're talking about an operating system right what we're actually talking about is something that's running in the background now if you think about something like a Linux machine or Windows machine there's certain processes that are happening behind the scenes right there are essentially monitoring and kicking off tasks for each individual application so you can have multiple applications up on your screen and you've got something in the background called a scheduler and the show that's going to say all right now you can run and then it's go to the next step and I say you can run and it's going to go to the next and say you can run so even if you've only got one even if you've only gotten in one CPU or one core you can still run multiple applications or if you've got a dual core you can still run more than two applications right that this happens is because you've got something called a scheduler that goes and basically says you're on your own your own urine goes back to the beginning now interesting enough if you recall the old sort of Windows ME remember this okay so they had a problem with a scheduler and if one application crashed the entire system had to get me booted and that was partly because there was a problem with the operating system so in order for an operating system to be robust it needs to be able to cater and handle you know various different things in various different tasks and so on okay so this is what we're actually talking about when we're talking about a free artist we're talking about not a whole again in the launch applications and I'm gonna have a user interface and a GUI and what have you on a microcontroller what we're talking about is we're talking about a mechanism to schedule various different tasks okay and just something that's very important okay free our class is part of the ESP idea now the Arduino libraries and the advisor are they're doing a framework for the ESP idea for the ESP 32 is built on top of the idea so everything that I show you tonight even though I'm going to be utilizing the IDF because it's something that I I like it on I prefer all right everything I show you tonight is also applicable in the sp30 to Audrina horse as well so you can use all this stuff in Adreno as well okay all right so let's just have a quick look at some stuff over here okay if I go through to Google all right and then go through to free artists free I hit this website free artist a torque okay and as you can see and the guy admittedly the the guy that actually created this thing even since that it's written for engineers and not for marketers it's not a pretty sight it's goddamn Magli but it does give you some really interesting information now if you go through to books and materials and then you can download sorry let's get rid of all these fantastic alerts if you if you go ahead and download right mastering the free arctos real-time operating system you wind up with this very large very intimidating PDF that's only 400 pages long okay yes okay all right so you download this book now what I would recommend is you first thing you do is you basically skip over all over the beginning and other stuff right and until you get to the point where it's essentially talking about tasks this is how I picked it up because I started looking at it from the beginning and I couldn't make heads or tails of it and then went I went actually went through to the task side then all of a sudden started to make a lot of sense okay so here we are choice functions so I could probably do there we are chapter 3 task management and you start reading the stuff and it's sort of like okay I'm starting to get it and then all of a sudden you download the zip file that comes along with it and then they get some demo code going and then it's like oh yeah now it's easy okay I get it it's like okay that's cool I got it so this will take you this took me a couple hours to get through okay the book looks very intimidating it's very large but when you actually look at it there's a lot of pictures there's a lot of code snippets which you read through very very quickly so if you're really interested in learning all the ins and outs of free outsource or understanding all the ins and outs of artists I recommend going through that code it really is very good so right so before we continue with some theory I actually just want to go through a little bit about so I have a client okay my client comes to me and says to me please create for me an application what I really want is I want a blinking LED and the meant a method and the nicest sense of the word for linking a lady okay so I do something like this I'm sure everybody's seen something like this right so sit up loop and then now this looks very so we know ish yeah except for it's not quite at doing no code but I'm just this sort of written like that we have to give you some of an idea okay so go a set up loop and then I come down here all right now and then I look through and I say set my levels to do one then turn it off and then turn it on and this is what it looks like oh yeah on my board you can see I've got a blinking LED hey very easy okay great okay and I show this to the client and he says that's great thank you very much but actually what I really want is I want two LEDs okay I want two ladies you think yourself alright I can do two LEDs hmm let's see how am I gonna do two LEDs alright so I'll just basically come in here all right so this is what I'm gonna do all right because what he wants is he wants to LEDs but he wants to be able to you know cover them at different time so let's get tricky all right so what we'll do is well basically heavily be one on for positive milliseconds led to on full parking over the seconds it will switch off or they do you want an LED to it in that sequence so let's go ahead and try this out all right so let's make sure I save it otherwise it won't work okay all right so let's 22 yeah I do thank you let's try that now okay so just and he says to me all right a little bit more complicated please okay now we want to LEDs flashing and we want them at different times so now what's gonna happen is we're gonna flash that and bingo we've got two LEDs flashing yeah okay cool that's great then everybody's kissing and very cool right no no no no no that's not what I meant my second LED needs to flash at 100 milliseconds on my first day daddy needs to flash and I'm thinking to myself now if you can't actually worked it out in terms of how do you miss event within yeah okay it becomes you know my brain starts to hurt and then after that they come away and I say I want four LEDs and I wanted all the different times okay just think about that for a second sir customer cookie fillets into everything else works wait not gone after something a hundred milliseconds something else it's really the second sort of ice cream my second one it becomes that and that our final segment now yes there are things like interrupts that will help or basically timing interrupts but even interrupts right there is an issue with this it doesn't scale that's the problem the more complex of my code gets the more our requirements my code gets in my code has it does not scale okay so for your artist and rescue let's have a look and see what actually we can do it's something like free artists I'm gonna actually write this out at risk of making a complete idiot of myself okay because I actually like to code and I actually just want to show you what this actually looks like okay so over here I'm gonna I've got this app main event loop which is what we kind of set up and then we did this loop this wallet what I'm gonna do is I'm gonna get rid of that and I'm gonna create a task instead so let's creates two functions okay so the first one is going to be task one okay and in order for it to be a valid task we should actually hit point posit void parameter params okay and it should return nothing it should return void okay so that's task 1 sorry alright yeah there we go and what I'm gonna do here I'm going to go back to this previous code over here I'm just gonna grab this over here and I'm gonna put it in there so now task 1 is is responsible for handling one led okay and I'm gonna delete this over here now the first rule okay so first of all about free are tossed tasks they return nothing the parson avoid pointed params the second rule and very very important rule is they never ever return you've got to block them from returning one of the simplest ways to basically stop them from returning is to just put them into an infinite loop by the way this code and the recordings will be shared so don't do you don't have to try and remember at all okay so now I've got this in an infinite loop okay right now let's go ahead and create this task right to create the sauce the first thing I need to do is make sure that I've got the free art sauce libraries included and this is also going to be applicable for the aired we know okay and now I'm gonna start with the first command of cold x tasks create okay now as you can see the extras create takes a couple of parameters the first parameter is going to be the function that we've actually just created so this is going to be task 1 the second parameter right is just a name we can get a call that whatever we want the third parameter right is how much space do I actually want to give this particular task how much memory don't want to give it okay so at this point in time I'm just gonna give it one or two four times let's say two and that is a bit of a misnomer because this is not bytes this is works so it's half a bite each so that's one kilobyte okay so just whatever it is divided by two according to the documentation that I've looked at the other one the next one is parameters now over here we can pass in a parameter but we'll actually discuss that a bit later about what that is and that's going to come through over here if we need it I'm gonna plus a null for now all right and then essentially we've got this other concept called a priority all right and priorities we will also discuss in detail in a little bit but essentially that depends on how I know which task if it's got a choice between two tasks it's gonna pick the high priority okay and then the last one is a task amlo which I'm not going to need right now we'll go have a look at that a bit later as well I'm gonna make that null as well okay so now that I've actually done that okay actually I do need to set up as well so this is gonna make sure that we've actually set up our LED okay let's try and actually compile this and see what actually happens you know coming by but what same genders sorry what singing Jojo let's see how it's a compiler it's compiled yeah oh it's just GCC it's part of the IDF it's part of a sort of suite off of frameworks that you get for the SBPD - all right yeah yeah all right so what actually happened with regards to that is I've now got my blinking LED back okay fantastic good all right thank you but now check this out right so this is actually running on its own task so what I can do here is I can essentially just copy this let's make this let's say 200 milliseconds we'll make this responsible for number two and we'll call this toss here and then over here we can just basically create another task and this will be task tier toss - and that's all good okay now let's run this yeah one second and what we wind up with is two individual applications running at the same time okay that's the point so they're essentially two idempotence totally independent phrase they work on the same CPU they work on the same thread but they're actually as far as the as far as its concerned they're Thomas okay so this is one of the the benefits of the free artist it gives us the capability of writing instead of one massive application we try to interleave timings and stuff like that it gives us the capability of basically splitting up like applications complex applications or complex tasks into simple five little versions of applications so over here you could set up two tasks or two little applications that are running independently okay so you just said on the same that's read yes to each other that's right yeah yeah that's correct all right so I'm just going to show you a couple of things with in here so firstly what we actually have is four cuts at this point in time all right in that application we actually hit one point at three tasks okay the first one is actually at me so when it starts off when it actually starts behind the scenes have actually creates a task that's our son goes in creates to us we can then go in and decide how much memory we want to actually give each one of those tasks it'll take memory of the heap and apply it to those particular tasks which they can then use individually for our stacks okay is everybody okay with the concept of heaps and stacks does anybody need some explanation already good you like some help and tell them that problem at all okay so in in computer terms all right specifically was right we've got this concept of a heap it's just a huge month of and a know of spice that we have right it's just it's just memory now every single time we actually call the function we display all of the variables right we take the those variables and we'll put those on the sect okay so essentially let's say for example we start off yeah zero okay we call our first function and it has the Pacific's on or a couple of difference it declares a couple of different integers and some charez then we basically use that much stack now what will actually happen is also that functions might call another function which has some additional memory right and some others so what wind up was was we want to go to a bunch of different memory of again there isn't why it's called a stack another queue is because the stack basically looks like a bunch of place if I take some flights out of my dishwasher put them down and then I put some more on top of that and put some more on top of that and I wind up with a stack of plates now if I want to clear those plates I don't go from the bottom there would be a cube a cube basically someone signing lining in the back so accuse like somebody at the bank the first person that comes in is the first person that served the stack the first person who the last person who came in is the first person that gets up so I take stuff off the stack so what will happen is when I'm actually running that function it'll eventually exit out of that function now all of those pieces of memory that was inside that that function or other stuff nobody cares about their name anymore that disappears all the stuff and I get that space back and then the next function runs and then that disappears off the stack okay so C programming a C function called malloc memory allocation right what that basically does is a text memory of the heap and basically allows me to use that right so essentially we've got this thing all heap we can create memory or we can create variables within our heap but we can also basically use local variables and that'll little basically fill up our stack and one of the problems that you will run into with things like the edweena is that if you basically have functions of bigger and bigger and primary memory or if you put them into a recursive loops you eventually get it crashed and it's called a stack overflow it means that you've actually utilized more memory then you have our beta belonging and then your stack just runs out of space and that causes a crush okay does that clear it up cool all right so so that's essentially what we do with the free artist tasks so coming back over here just to quickly show you we can see that we allocated some memory each one of those then run independently and I'm allowed to use that much memory within that particular task okay all right so now the next couple of little things are quite interesting I'll just show you what they look like so the next one is the textured EULA let's welcome grab yourself with some pizzas make this up at home okay this is okay so we've got two tasks okay and it's gonna basically saying to look at task 1 it's gonna say alright you run for some time and then we're gonna hit something called beet sauce delay which is a delay and the minute it does that right the program stops and then what will happen is the sugar levels say ah okay well something else can run now let's go to plus 2 and thoughts do one pull-up delay and so on and so forth okay so that's that's how that that works so we've got the scheduler who's basically monitoring how these things actually work and here you can actually see the kernel runs and tip interrupts so essentially as an interrupter happening and then the basic a decides again which one that's gonna run so that's that's how that works not just a timer lip inside there actual free artists now there is another task which is a little bit invisible but it'll become apparent over here and that's the idle task yeah I didn't ask is essentially not doing very much most of the time you'll Chuck doesn't do very much and this is doing some very heavy computation or spinning in some sort of folder for something like that it's usually just waiting for something to happen - and then it's sitting there idle and these are delays this is when we waiting for stuff to happen okay and that's essentially what we call the idle the idle clause and that's actually a toss that we could it's it's a toss that we could actually do certain things with if you want to on the summer they happen more jobs actually when it gets to idle talks they just basically automatically go to sleep we don't do them as far as I'm aware but you know just to know just to be a way that it's there and now we've come through to the last little one that I want to show you which is toss priority which is interesting because we talked about this concept over here that we've got this this over here now we can basically say three over here that'll make this one a higher priority okay zero being the lowest priority higher the higher the number of the hiders of the priority and what's interesting is that the scheduler right while it's running a toss right essentially say okay I need to basically decide which talks to run women will actually do is will basically figure out if there is a higher toss party even though the other toss things in the middle of something it will basically run that toss alright and then tiller basically gets the blocking point for delay or something else so behind the scenes it's basically sort of doing all the stacking in terms of so we'll run a couple of CPU cycles on here a couple of CP new class cycles in there back to the first one and so on and so forth and the good news is we don't really need to worry about that we can just think of these things as individual applications within our program okay so right so that was sort of an introduction to tasks now what is interesting is that you know from a from a programming perspective I look at this and I think to myself I don't like this idea that I've got two tasks that look identical why not do something like this right let's have a look and see what what's happening here no that wasn't it did I save it I've overridden a trap alright so I'll just show you what we can do over here very quickly right so we've got I'm gonna take this one out and it's not gonna have two tasks but this time what I'm going to do is I'm going to call gonna create I'm gonna call the same method right but let's go ahead and create what we can do here is we can actually just pass in some parameters that will allow us to decide how we actually want to run these things so let's see let's create a a I had this pre set up but I've kind of seemed to have overridden that I'm sorry about that so let's go ahead and do this right type if it becomes too arduous and painful I'll skip it but this is see if I can get it right so I'll do a type def struct and what we'll do over here is we basically just call this thing something like lead params and will basically have in there two things that are our interest the first one is going to be an int and it'll be the led and let's call it lowercase LED and the second one is going to be an int and that'll be time okay and okay so what we'll do here is we'll create a structure and the D params we'll call it led params sorry live cuttings always fun and always susceptible to the most severe scripts okay so what I'll do over here is others say that the first one is going to be led is going to be equal to led one and the second one which is going to be time is equal to time is equal to let's say 1000 okay and this is led params one is realized that's a C syntax yeah oh yeah yeah okay well you can always you can always just create them and just secretly yeah and then I'll this basically make that two so what we'll do here is we'll basically say that we're gonna pass in ampersand LED one and we'll pass in here and purse and LED see now and then I'm just gonna do this and I'll explain to you why I'm doing this it's gonna make an inflow to the loop over here and then I'll just put in a delay I know life coding is almost so much fun to watch and apologize to that so what I'll do here is I'll just place a key point in the white pointer params okay and let's go ahead and say LED or this is called it L LED params the actual structure let's call it L is equal to the costing of LED params and that's gonna be params and then what we can do over here R that's going to be a void pointer great so now we've got l dot L going to I made a mistake so it's a pointer help going to LED L going to time and this is the last time I'll be live coding so all right so going back to main until I a control V and if I haven't totally totally botched that we should get the same output but this time what you'll actually notice is that we actually are only using one method okay so you have the opportunity over here to actually really consolidate or console you know make your work more precise and to minimize sort of your restrictions and okay ah that would actually help as well if I change this I'm just noticing that there's no change on my output and that's because I didn't actually change it so yeah so you've got an opportunity to okay so that should work now now the question that you might be wondering is why did I actually put in this you know internet and loop at the bottom over here it's quite simple right and the reason for that is because when we actually dropped out there the first thing it does is actually delete the task and then I'm not gonna get into memory and we can see that this is actually running on one single application or one single function and we're just passing in various different parameters to it so we can actually use the same function and we actually create multiple thoughts as many as we want to put different purpose okay hey oh yeah so so what actually happens is the remember that this is this is the start at main okay when it drops out of yeah all right it actually deletes the task so you can go ahead spawn up other tasks but the primary tasks or the first task but it's no longer needed don't want it it's essentially disappears so the problem is that if there is a delay or anything else like that then essentially if I create these things over here then of course they're going to get removed from the stack if I actually if I if the task gets delivered that the original toss doesn't actually have an exit there is other ways to do this I could have actually used malloc and actually made them as a point to put one second then I would not have to actually retain this particular function isn't it no it doesn't because if you have a look at it right it's basically using something called V toss delights we toss the light is a special device that does it actually just use a slider plus yeah so it doesn't actually it's not a folder for anything else like that so this it's a yield function yeah so that's other functions other tastic up there yeah processing cycles okay so yeah so that's essentially an introduction to tasks okay there's one other thing I'd like to discuss with tasks which is a little bit interesting okay and then we'll basically just do a sort of a sort of a brief on that so one of the things that we have with toss is we've got this concept today's tasks here's the next one tasks pintu cool so what this does this is essentially the same as what we had before but what you'll notice is that we actually have an additional parameter at the end all right and what this is actually telling me is that I can actually run it on the CPU that I want to actually pause it so this is to do multi-threaded on my two CPUs so you can do this with with the do you know as well alright so just to give you a sort of an overview a very quick one on this perspective as to why you want to actually do something like this this is enabling you to use the second call which can be helpful if your first score is tied up doing very very heavy duty calculations or or doing something that is very very process of intensive ok but you do need to what you do need to be a little bit aware about the idea that there is a reason why we actually usually only use one call for application and the reasons for that is because the idea for essentially the the ESP 32 usually uses the second core to do things like network connectivity and wireless connections and communications and stuff like that so for wireless inclusive whatever this was a problem at the head back on the esp8266 if you were enacted to a wireless and you all of a sudden had to do some very heavy processing right you would sort of get it in a way or basically stop the communications and the pain signals from happening with the wireless and drop the connection we don't have that problem in ESP 32 because it happens on a different core so obviously if you use the second core for both or for processing intensive you might run into something like that again yes it was known the upcoming list with you to this one it was little claw that's right so this is some opportunities admittedly acquired a number of processes and staying at your code or would you there is actually yes there are method calls you can actually call in to the idea that will tell you how many calls you've got okay the new SP 32 is what one advantages that it actually comes with the it comes with USB stack as well so you can actually create USB peripherals and stuff like that when we plug in our SP 32 into USB it's got this other little trip over here I'll just take this off over here you've got this little trip this little sort of square one and sometimes it's a little so that rectangle one that's actually a USB to serial converter so you don't really get USB going straight through to the chip that's just serial communication the new SP 32 has got direct USB it's only got a single core so you could basically do some interesting sort of hid human interface devices yeah yeah probably I haven't really played with it but that's what I'm gonna soon yeah yeah yes also if you're not connected to the Wi-Fi and now you're not needing it at that time but you do need a heavy set of maybe parses imaging or doing some sort of you know maybe maybe running some sort of sort of scanning to try and actually do some AI against let's say image or something like that yeah then yes the second poll could come in handy of course I think they'll use the first pretty much yeah so the only people that if I'm less you explicitly tell them to actually use the second corner unless you're explicit Kinsella - right the only place that they explicitly tell it to out of the out of the box is when they're doing wiping some internet communications go to the communications all that stuff that needs to happen in the background we don't want your application to crush the coms on those interrupts in song okay cool so that's how we can make you know double the power of it alright so now the rest of this particular talk is actually we can actually create these individual sort of like you could call them applications they're not really applications but you could you know these tasks and we can create as many as we want you know we've got a fair amount of memory to play with so as long as we don't run on the memory we can create all these fast ok the problem that then one would basically see is that these tasks have got different memory allocations ok they kind of either you know the kind of sort of individual how do we basically get one talk to talk to another one and that's sometimes needed ok maybe we've got to toss it sitting there you know reading our isolates EBUS looking at some sort of temperature a sensor and then we've got another task over here that's doing all their interconnection with you know it's connecting to the wireless and connecting to an PTT broker or whatever and all of a sudden we get this little thing saying hey I've got a reading I need to basically publish it on my mqtt Branca alright how do I get that information from that task over to this completely separate us everything else that we discussed over here is going to be about into communications between put everything outside don't listen to him okay alright so what is going to happen now is I'm going to really scare you because when we start looking at these things we come into a sort of you know scientific or as I say computer science terminology which sounds awfully scary and so they actually get it defined it realized it's not really that scary okay but this is essentially a bit of a decision train this is the way I think this is not officially documented anyway this is just my thoughts on that again okay so essentially I want to communicate directly to another task alright I care about counting or sending simple data right well that's I'm going to be utilizing call the task notification we'll look at that lost okay next one someone needs to block or unblock a task I don't care who in other words I've got this other thing that's running and I want to basically trigger and say you cannot run but then I need something called a c-more fault okay the sema4 sounds like an awfully complicated word right until you actually look it up until we look at and it basically says it's a system of sending messages by holding the arms of two flags or poles in certain positions have you ever seen anything like this yeah where people basically are communicating with flags it's a sema4 so what you're doing is you're taking one toss can you basically waving a flag in another toss okay so that's essentially a sema4 it sounds complicated but it's just basic okay the next one is called a mutex and this was only with only the task that blocks another task can unblock it in other words I've got a precious resource okay I've got a precious resource when you're talking about mutexes by the way who takes mutual exclusion no it's nobody else can touch it okay so with a mutex right I've got a precious resource let's say a nice fancy bus okay I've got lots of different things happening on my fancy plus a lot of different people but wait when I grabbed it the icy crust nobody else is allowed attention that's when I would use something like a mutex I basically grab the the the I squared C plus I do my work and then I release it to my step back in the SP 32 I squared C bus is not really a really great sort of example because of the way that they've done that I squared C bus it's actually really good because what actually happens is you build up all this only all the communications at once and you send them through at one time then it comes back and that's it it's not like you're sitting there on the bus but if you were then that would maybe cereal you can use if you're a bit banging something yes like I need RGB LEDs yeah if you put banging something but banging basically means you're turning off one in ones and zeros to try and you know do communication you don't want anybody else talking to that pan because you screw up the timing that's right yeah okay all right now next one I need to pass data from one task to another for that I'm going to use something called a Q the Q is different to a stack you basically first one comes in is person like this okay next one multiple things need to happen before I unblock it sauce you know it's maybe I need to read from the humidity sensor and I need to read from the temperature and I need some of the condition to occur and then I will basically send my information through to the wireless well that I will use an event okay so let's have a look at what these things look like in the real world so we'll start off with a binary semaphore or a sema4 I'll just close this alright so here we can see so we can look at this and we can immediately by by its definition we can see that this is a task why is it a toss can anybody tell me why it's a toss yes basically crosses and boy perhaps turn down to the bottom we can see that we've got two tasks over here okay toss one and toss to alright so let's have a look and see how this works so the first thing that states happen is do something with HTTP right that goes off to task to task one alright and you got this concept called XML for tag actually let me start from the beginning right from the beginning we create this thing called a binary semaphore we declare it well just will this file yeah it's not external okay we create this thing called a binary semaphore okay so this is just something that we create all right now that's not assigned to anything in order for us to actually create that right we'll say by the phrase binary semaphore Exene will for create binary so we've created this binary semaphore now we've got this thing available then we'll start our squad notice that it doesn't actually know anything when we created we don't pass any any other sema4 through anything else like that we don't pause it through here or anything and then we'll start tossed - alright so task one right what that does is it basically does something called X sema4 take now what is my sema4 available right no no order for me to be able to see if that Singapore is available somebody else would have had to have given us so this this sema4 is basically a and i take and that's really all it is and it's a binary so it's either given or it's taking and that's it it will either be in one of those two states now I have never given it so essentially what's going to happen is that the processor will stop at this point in time they're free arts our task will actually just kill that but stop that task from running it's not going to proceed past that line okay and specifically because I also over here said max port delay okay and we'll have a look at why this is interesting in a moment okay and then what will actually happen is the task this this listening for HTTP this task over here will start at the same time okay and it's gonna then print something out received HTTP message so I'm just sort of mocking up that I'm receiving an HTTP message okay and then what's gonna happen is it's going to give that sema4 see the that binary seen before that's the same one that we're using all along it gives that now the minute it gives it this one has an opportunity to say yeah I got it I'll take it and then little basically print doing something from HTTP then once it's done that will then basically proceed with proceeding as you miss it so let's see if that is going to be as we expected it's gonna have to start up a new console over here term law you notice at first this is much it's actually flashing right now okay but because you've really built yeah okay so so we can see some messages coming through right there little delay five seconds and it'll continue so let's have a look and see what actually happened here so the first thing that actually happened was that says received HTTP message so remember it started both of these and then essentially printed that out all right then what actually happened is it says doing something with HTTP because it gave that sema4 and then it was able to print that out and then it basically says process HTTP message that went back here so the sequence of events in terms of the way that this program flow worked was one two three okay but there is something that is quite interesting and if you have a look at these over here they both assign priority right let's make this one over here this listen for HTTP a higher priority okay so listen for HTTP let's make that a priority of two now let's run it again can you show me what header falses use odd sister free on toast they actually don't even need this one same oh you don't need no okay okay so now we can see that our output is slightly different let's have a look and see what actually happened here so receive HTTP message then processed HTTP message it finished this loop and then doing something with HTTP so the priority makes a big difference in terms of the sequence of how your program runs okay the higher priority will take precedence if it's not a choice so when it basically came to that point where it says all right I'm not either going to continue running this current application or I've got the sema4 which basically has been released and I can actually operate on that I always will make a decision based on which one has the highest priority okay so that is something that you need to be aware of and you can control your program flow like this now there is something else which is quite interesting is that we've got this thing called port max delay okay and at this point in time what that basically means is that this thing is going to wait indefinitely right there is however something we can do with this let's have a look and see if we can do something like this we can say if if it was able to work right and that'll be within a specific period of time so if I basically say I'm only going to wait for two seconds right now notice that this thing over here is waiting for five seconds when it gets to end of that loop so we'll see what actually happens all right I'll say else and we'll just printf time Mouse okay so the first thing that happened is it worked okay everything is okay and then all of a sudden it timed out and now it's continued to timeout then let's have a look and see why that that worked out that way so it came in here right it was gonna wait and then at the same time it came in here that processed that processed that fired that fired that's all good everything is fine then that fired and now this is waiting for five seconds this looked around and said I'm only allowed to wait for two seconds and after two seconds that file so we can basically put some this is how we can basically control that mr. so we can say something happened within a particular period of time or not is this is this too deep or you guys come are you guys gonna tracking with me or is it a little bit so it's okay okay I think we need the header file because when I remove the header file it says that the tick semaphore if doesn't show up it's undefined yeah yeah I don't think so I think it's okay you tell these sense doesn't work you're on today I can't come with ya so you need a little bit slow so yeah okay so you do need that that hit on all right cool so that's a sema4 any questions on a semaphore it's not very difficult to that yeah you can have as many as you want okay they're just flags I don't like to be one of the things is that just flax it this place if you say yeah you can go or I couldn't I couldn't get it you know something else I was expecting somebody else to release it somebody else to give it I couldn't take it or yeah I took it and then I was able to execute one yeah that's yeah that's that's pretty much all there therefore that's everything that they can do well all right moving on next one is a mutex so a mutex basically holds precious resource I'm just going to go ahead and run the city up all right let's have a look in the code flow so again right you notice that the only difference between this code and the previous one is the fact that you see we've got to the sema4 handle a mutex bus and that could be sort of anything and then we've also got this thing's called XML for take action will forgive there's no difference the only difference over here is this is not called if you have a look at the previous code we said XML for create binary now we're basically saying XML for create new text that's the only difference okay so you can actually take a binary seen before okay they just worked better and totally okay I'm not entirely sure but they definitely do better so if we have a look at this particular application we've got two tasks tasks one over here okay and what this does is it says reading temperature so then it's essentially going to take that sema4 it's gonna wait for that sema4 okay so i'm now going to take it and then see basically lock it and then what's going to happen is it's going to write to the bus now this is the bus over here so this is my precious resource nobody else can actually while this is happening nobody else can actually do anything with it okay and then if it doesn't work within that particular period of time it's also going to bomb out okay at the same time we can then say reading humidity and then we can take it and then we can write to the bus okay and this is where we can give it back so let's go ahead and try this well it's actually running it as we speak it's gonna start stop it and just start it again so we can see it from the beginning yes yeah so we can see that it it's doing what we expect it to do you know it's reading further from the from the humidity and then essentially it's just flipping and flopping between those two tasks and the only difference is between this and the previous one is that one of those things will basically control the rights of us ahead of time because it's coming after the tank okay so yeah that's pretty much all there is to a mutex they're pretty simple next one this over here is one of the more interesting ones this is essentially direct tossed notifications now with the other ones I'm just going to close all of these down okay just collapse that collapse that I'm just cleaning up a little bit all right alright so with the other ones right we've always created a semaphore we always created a mutex all right here we're going to be doing something quite a bit different okay notice that over here we don't actually have any of these other intermediate three objects but we do have this thing called a task handler okay and where does that come and play well remember that last parameter this is where we can actually have that last parameter this task handler by the way is we can want to control the task right and we want to get a reference to that sauce we can create the task gambler and that's essentially what I'm doing over here okay so so we create this task so let's collapse this in with a little bit dinner to show you how this looks so we've got we've got two tasks over here okay the one is called receiver and a sender now what's going to happen is the receiver over here has this youant which is an unassigned integer okay and it basically is going to wait on an estas notify wait okay and over here we can say X notify and what we basically pass in to an X X task notify is the receiver handler this thing that we've created over here and then we can pass in some sort of integer the binary and we'll come to that in a moment and then we've got some sort of flags that we actually want to actually utilize okay um I'm just wondering if I actually am starting off with the simplest example I'm not sorry we'll start that again it's a bit too high gradient we'll start that from the beginning all right toss handler okay same thing we basically have this task and ler as we put it as we and we created as part of the the the task now we've got this thing called a sender which you can see is a little bit simpler X to X notify give okay and we pass and let receive handler so this is really simple we just basically say go ahead and fire and then over here we've got this thing called ul tossed note if I take and that's basically going to then tell us that the thing has been taken now watch what actually happens when we run this so check this out sorry watch this okay now I'm calling it multiple times so now it makes a difference so he starts everything well watch what happens so you can see four three two one okay so what actually happened is that it basically put all these it called all these notifications right but it didn't actually fire any of them until it basically got to this V toss delay ah and then it basically wins it actually called each one of us so you need to eat you yeah but what's there's an interesting thing so essentially what happens so if you can just just to go over that again right so essentially the application went in there and then trying to be tossed away and said alright now I can basically run another another task it went to the went down to here and it said alright four three two one go so it actually plays if you didn't for time but now if we change this to true we get an interesting little change now watch what happens with with when the flag is at the true now it just says I received it four times just once so that might be helpful I'm not sure if it's really that helpful in debouncing but it can do if you've got something that's very very very very fast and you only wanna file once and this thing gets pulled multiple times this is one way to basically spot blood okay no it's not it's just it's just basically counting how many times it was called before it was actually able to fire it so you know I basically called it four times five times one over four times and it's basically just said all right I was able to call it and then okay I can run another task now oh you called me four times yeah and the previous one we headed to true it's at five five five five four three two one decrement it at each time it's almost like a good normal semaphore yeah it is and you can use these in place of a semaphore and I'm you ticks as well all right now notice that over here we've got this thing called ex notify give okay and this is just basically returning the count and all we basically pass to it is the actual handler itself it's one of the more simpler versions of the extras notify and notifications right now we've get one other one which is a little bit more complicated but pretty much very much more powerful let's have a look at this guy okay so we've got the same story over here this time I'm not actually counting what actually happened with the output okay but I notice over here I've got this port max delay so it's essentially gonna block the task and wait for the notification to occur and then after it's actually received it it's gonna go ahead and say I received it okay now over here right I have a couple of different options that I can pass send so notify ex notify is different to ex notify give give basically I just pass in the toss handler over here I need to pass in the task handler and then I can pass in a value of some sort and we'll discuss that in greater detail and then there is this sort of the enumeration over here where I can have some options okay and then the ex notify white also is a little bit more complicated to the previous one before we just said ex notify white actually it's the same okay so never mind alright so let's have a look and see what actually happens when we actually run this as is so we expect it to basically pass in okay so it received two one two four one two four and that's because I'm passing in one two four okay now this is basically a set value with overwrite in other words what's gonna happen is every single time I call this it's going to give me a new message inside there there are a couple of different options right if we actually have a look at the definition of this so this is essentially what that looks like let's go to this guy here all right so we've got some options over here I'll just show you what these are we're using this one II set value with overwrite we've also got e set that's right let's try that one bless you so if you guys are you guys familiar with binary are you happy with this thing 1 2 4 it's just moving one bit along yeah so it's essentially just one now we see 1 3 7 and that remains at 7 so this is a particularly interesting one so what is actually happening over here is it's not resetting it okay so in other words every single time I calls it it basically says I call that come on and then I retain the fact that actually we call there come on ok useful in certain circumstances where you want to actually keep that particular state so you can use that as like a beat flame oh yeah bitwise flip that's right but what's also very interesting is that I can also say all right look when you come in here all right what I want you to do is if you have a look at these parameters right when you come in here I want you to clear a certain bit ok so let's say for example I wanted it clear let's say the second bit oh I didn't save it yes okay and we'll have a look at an example as to where this is useful in a moment alright so it proceeded 1/3 and then it's fire and have remains 5 because it keeps on clearing that - ok so if I wanted to always clear it I could basically say this what I'm gonna write over here 0 X 1 2 3 4 5 6 ok this over here is gonna be the same as using the previous flag so if I save this so now it's gonna basically clear out each time and you'll see that the output is gonna be very similar to what we looked at before 1 - okay so depending on what you're trying to do ok all right next one this is something which yeah ok so that's that alright so that's all the the task groups now some so you know we really looked in that task we we have this capability after sending through a little come on ok I can show you a little bit of code that I wrote a little bit earlier this week where I was actually using this guy on an in qtt where I get to basically say look give me something and then go ahead and depending on what you what you got I can basically set up a command and then I consider the switch seconds after that and then I can actually courting me ok so communication from one source to another but the thing is that you know we can so cook it to basically pass in a pointer or you know the string or appointed to reference in memory or something like that but that's not really why it's but if we want to actually send through sort of packets of data or large packets of data then we can do something like a queue we haven't actually done the okay I will do they will do the cute and they oh they meant groups lost so the queue is actually a really straightforward little guy okay let's go ahead and run this guy and you'll see that it's actually very easy so the hard but is all done by the way no more so you don't have to run so much it's all good what thank you alright I'm assuming it static no wouldn't be because it's essentially done on run time so it's probably Malachor do you need to specify a maximum size yes you do yeah so I'm sorry but they're probably using my luck behind the scenes okay probably just putting it onto the heap let's have a look and see how the queue works okay so the queue we start off by actually creating with queue handler okay once we've actually created the queue then we can essentially create the queue by saying execute create and that takes in two parameters alright the first parameter is essentially the length of the queue you can have one two ten whatever and the second parameter is the size of that particular one so if we wanted to pass in like a string or something like that it would basically you know like depending on the size of it you could basically say I want a chunk of ten bytes times ten you could also basically say I want a point in memory which is basically four bytes times how many chunks you want okay so it's possible to just pass in a pointer obviously if you're gonna pass since from the local stack make sure that your current task is not going to run out of scope because obviously then it'll disappear okay so I've got two tasks over here okay they're very straightforward tasks okay the task one and task 2 okay task 1 listen for HTTP this one over here right it's got a counter okay and then what actually happens is it receives something from it received something from HTTP and then it sends something okay and you can see that it's actually just sending a number in this particular case why number because I said right at the beginning that you basically want three times integers so three InSAR allowed on this particular queue and now interestingly enough it also has this thing where it basically says all right I'm gonna try and push that push it onto the queue and it's gonna give me that amount of time to be able to push something onto the queue if that queue is full and it fails to put it onto the queue it's gonna basically go into the second if state all those else statement over here right otherwise if it's okay it'll basically are is able to add it now I've got another task over here alright that is just gonna wait for something to come onto the queue and the minute something comes onto the queue it's gonna grab it off the queue and it's going to put it into that particular variable and then it can actually print that out over here Oh everybody tracking you need to deal with this I've already pre-built anything okay except for this one ah okay I must have changed the name of it okay so while this is actually cleaning and building okay this is going to take a couple of seconds maybe I can have a slice of pizza while that's happening anybody got any questions it's not efficient and also there's no reason why you put a pointer to whatever size you wanted yeah I mean you know you specify the size of say good cue fragments that you push in but you know with with the point to the sky's the limit you can put it with no but if you want you can put into massive structures you can put in strings whatever you want blows point is to MVS I think I think the data is put in its allocated as a contiguous block yeah so you can you can just stick pun and then add another block later yeah unless you copy it to a new there's a couple okay okay so whether I should pause something to here it's copy that maybe copy out the handle of the cue order no later okay so when I push data into it copied into it okay so that means that even if the original toss disappears otherwise you can I guess you can this way I guess you can just what not see another pointer but if you pass in a pointer yeah you can queue up yeah the pointer will remain there but if the original data disappears because it's gonna stop and I get to you have all right so number four so remember I was talking to you early on about I said as you an increase as you add more files than that number tends to get a bit bigger I don't mean 2014 stupid logic it's a lot all right so here we go so you can see that it's basically a message to you and then it's essentially received message from the cube now if you have a look at this right this is this is popping something onto the stack and this is reading off the stack and it's going to allow to wait for let's say you know it's going to allow to wait for five seconds before it you know breaks or basically says I couldn't read anything off the stack so if I basically come in here and I say this toss delay over here is going to be longer than that and I could expect write this thing to start complaining let's try and make it break so now what's going to happen is it's going to have the capability of basically pushing something onto the stack and it's going to only allow for one second so let's go one two three and then after that it's going to be full and we can expect that to complain so doing something with HTTP this is now waiting for five seconds to come out all right added message let's see if we can get this thing to break this by the way is is or you know so we should probably put an else statement in here because this thing is actually complaining every once in a while we're not actually seeing that and it's when times all right yeah cuz let's just see if we can get that to break it's a good idea it's always try and make something break once more then you're sure that it's working when it is okay so what I expect to have happen here is it's gonna go ahead and put put something on the stack it's gonna wait as six seconds and they're gonna go oh no it broke and then essentially as that as that six seconds expires it's gonna come around and you're gonna add something else to the stack then it can actually run and then after it's finished running it's gonna wait another five seconds gonna I know it broke and then see myself yeah yeah okay all right so let's see what happens right so first thing is I so good I've got three buckets okay so I'll put something in the bucket okay and then what happens is I then once I've actually finished putting in the bucket I wait for for six seconds all right this one over here this one over here right we'll put something I'll see you tomorrow we'll read something off the bucket but then it's only allowed to wait five seconds before compliance but this delay over here is waiting for six seconds yeah so it basically pushes something onto the stack and then waits for six seconds but this thing over here is said I'm only allowed to wait for five before I break and then essentially it'll come over it here all right so we can prove that we can break a queue wait yeah that's right yeah so if I make that let's say let's make this very short let's make this 500 now what's going to happen next is it's essentially this queue is gonna get really full very quickly yeah and we should see the fail to add message but we might need to put a delay in here because this might actually just be able to actually cope with its cover up yeah so we'll basically add delay in here to stop it from being able to consume that queue now we'll break it the other way now that'll basically try to add things to the queue and it'll get to the point where it says now I can't add anymore okay so still coping yeah okay well you get the idea all right oh yeah maybe you want to decrease this plane yeah I mean I could decrease that to let's say 100 milliseconds oh that's why because this is 500 not 5,000 that's why it was coping okay that's it definitely break okay cool all right let's have a look at I'll have a look at events and then that's it we're done I think the 5000 supposed to be on yet at us good 5,000 there I think it's a I think the other thought but it's okay yeah that's like that's like coatings like all right last one and then we're done event groups okay so event groups are enable me to think of them like a handful so over here I've got three tasks okay so I've got this event group by the way this is how I created I create an event group and then I create these bits okay but I CDP and really the idea is that what I want to do is I want to have something from HTTP and then I want to have something from Billy and 170 I've gotten those two don't wanna actually fire my last task so first thing I do is I create this event group and then I can go ahead and create these tasks now what's going to happen is listen to a four four eight what's going to happen is let us go start with task 1 task 1 essentially sits there and writes for the event group and it waits for both bits and it's got some interesting parameters right what we can actually do is we can actually say we want these bits to clear well if I say true that basically means that it's got a chance to reset and now it can basically wait for those bits to actually get set again if I set that to false then I can actually have something else fire off it so I can actually fire to multiple tasks at the same time ok and then over here I can say white for all butts and that gives me an opportunity to say actually I don't care I just want one of these boots to go off before actually fire and then I've got I've got this you know the delay again so I can basically say yeah look wait for this period of time and fail if it doesn't work all right so let's have a look at how this looks so if you can do an and or an or so this over here is this is basically just pouring these together to basically give me one final value and I'm saying I want those both to be so what I'm saying over here is I want those both to be in place wait for all butts okay and also clear an exit which basically means that when you actually finish running this when you get when you get past here those things will then read the set back to zero okay in order for me to set that vent that better just say X event group set bits X event group set bits a pass in the event the group event handler which I created up here okay and then I pass in the BRIT okay and then I can print something out and then I can die so essentially this this this car is a head from fires then some time passes all right actually I'm gonna move this actually well just to leave it as is all right in a sense yeah yeah it's yeah you could say that you could sound like you either want to and all of them or you want to basically you're going to say either all of them or are all set or one of them all set and in that really not depending on my switches and then I could I can fire I can fire the task okay so let's have a look at this my D F dot py flash neat or that spelling mistake Monaco right so this gets blocked Evette event group said sorry not that one this one over here gets blocked okay and we got the stink of cup HTTP got ble received HTTP and Billy and then we essentially can fire so got HTTP waits for two seconds and while that's basically writing copy le carré HTTP right get them both and now we can print that out so we're ending them together in this particular case because of this delay over here we are I'm not sure if I actually explained this to you savvy toss delay takes in a parameter and that's in milliseconds this is actually in ticks okay so this will wait for a certain amount of ticks to occur in other words every single time the the CPU crystal basically oscillates it's going to wait for that but that's very very very very very very very fast so what we do is we divide that by port tech period milliseconds that gives us milliseconds so 5,000 is 5 5 seconds so this is a delay of 5 seconds and this is a delay of 2 seconds sorry now this this is this is the standard convention its platform dependent that that constant is platform dependent so depending on which microcontroller using the speed is obviously different but I think the other thing is that what take period ms I think that's a art sauce cake it's not the piece it's no it's not the microcontroller really no I don't think so because we be looking right I think it says how many hoods is there so such in the config yet right you can set the frequency of a chip but that's what that's operating on there actually is artistic or CPU tick or whether they're actually the same I'm not sure you can you can look inside if you go if you look at the definition it's actually tick tock thousand divided by tick rate cuts mm-hm so that's the host of the Chuck okay maybe I'm not sure it's actually it's a config tree are toasters yeah it's a hundred fifty finest hundred well so it's a free artists foot so it's like the artist the artist sticks it's not a computer okay it's like defines defines define you just have to go down the rabbit hole so that brings me to the conclusion of an introduction to interesting okay so I will push this mic it's awesome and I'll clean up the video and also just put that onto YouTube yeah it's it's actually configurable yeah it's what we enjoy then then you'll run slower if you do that I mean I can show you where you can configure this yeah it's in there it's number it's a soft the sauce is a source file so you can just write the number 100 or 200 I think I've ever I saw expression a little bit yeah good costume anyone know [Music] dancing is denser than the Aptos is usually a costume of surgery it's weight so I think it probably needs there's another layer that actually deals with the change in the CP so I guess yeah I don't know three I'll spend pretty much every other operating systems yeah I'm sure there's usually something we can tell what number cheeks our first number takes per seconds earlier she looks like an average when you handles no and it's usually cost developers slowly hey they're not gonna leave you in a situation where you can't deal with a microcontroller that changes speed during runtime I mean like that's what you can change it when you're building it so you can put in a convict so you can set what kind of sauce pan you want to run it by don't think you can change it during runtime okay maybe I don't know I don't know have a nice interesting cuz I know I do you know IDE you can select the speed you won but no no fall for you well another time actually actually clock all the WRO and this chapada yeah it's chocolate because the Wi-Fi can't deal with the speed that it's capable of so dropping from 120 megahertz to 80 alright cool so any question like time a intro like so so what are you trying to do yeah all right so this was two seconds if I say 1,000 times yeah yeah yeah so that's all that's okay well that is this it's part of them Pat mentioned you can they what you can enable without any frequency changing so change on the fly between 180 I mentioned saying to the famish when you get this that would make them in frequency scaling that's a lot of fun food so you might connect to the wireless so dumb to what it needs to be and then after it's finished communicating speed it up to processing but you have to read on to read all the details between that's not modern your perceive never need him in a program Pat mentioned that vegetation then what you're up to so obviously gonna cheat battery life a bit prior alright yeah I know that it's supported but if you have a look at the doctors this definitely support for it I've seen in fact um just a quick one just tortured you might find this interesting alright I'll just walk through a very quick application with you it's two files but now that you've actually gone through a lot of the stuff it should actually make sense to you so this is just a little sort of demonstration on how to use mqtt okay so over here at the top I've got some declarations don't worry about all that other fluff I'll get to that in a minute over here you can recognize these two guys alright so go to cue Handler and the task camera and then when I actually start my application you can see what I'm doing I'm basically creating a cube which is basically got ten integers on the cube and then I do something called Wi-Fi in it which I'll get to in a minute and then I create two tasks and this one has got a toss handler which is now going to be sitting at the top of this file now if I go through to Wi-Fi in it I'll show you what that does Wi-Fi in it right basically just initializes flash because that's where they keep their Wi-Fi settings and there's prettier look it's not the only place they can if you keep it there but by default that's where it's at then I'm going to initialize my TCP adapter right then I've got this thing called an event loop which is part of the Wi-Fi stack which allows me to which allows me to handle Wi-Fi and TCP connections and we'll look at that in just a minute this this is actually a callback which we'll have a look at then I do some initialization for my of configuration I'm setting up my Wi-Fi as a station pass in my username and password and if it goes now this thing over here what this does right is it does this over here does this event look all right so over here every single time something happens with the wireless this by the way is here so every single time something happens with a wireless either I'm essentially starting or I'm connected or I got an IP address or disconnected this method or this functions gonna fire and it's gonna give me that particular event so what's happening over here is I've got just some you know it's gonna start and then I'm gonna say ESP Wi-Fi connect and then once once it's actually connected I'm gonna get an IP address and now you can see over here X tasks notify all right so that should look familiar to you that's just notifying a task all right so let's go back to my main dot C alright and let's have a look and see where that's at so we've got this thing called generals Australia this first before we get into that you got the sinkhole generating a reading this is a very simple little task and all this is doing is it's essentially generating a random number and pushing it onto a queue and then waiting for 15 seconds that's all that's doing then it starts this other one unconnected alright unconnected looks like this it basically initializes a whole bunch of fluff including my mqtt broker which I'm just using the open sandbox at the moment and then what it does is it sets yet in this infinite loop and the first thing it does is it just blocks it just Waits and the first thing that I expect to have happen is this unconnect that we saw just a minute ago this tossed notifies gonna fire and it's gonna fire with the sync old Wi-Fi connected then what's gonna happen is it's gonna come in here and it's gonna say alright I've got a come-on Wi-Fi connected then it's going to initialize MQTT and it's going to register an event on the forum qtt and then it's going to start in qtt when it starts the mqtt well that's gonna do is it's gonna call this guy here and it does the same thing as what you saw on the Wi-Fi it's just gonna white sit there in a loop waiting for events to happen so the first thing that's going to happen is it's going to go ahead and get connected ok and once it's connected I'm gonna notify it somebody saying hey you've been connected so that's basically comes back in to you and it says hey you've been connected then I'm going to subscribe to a topic and I'm going to publish it epic and then it breaks and that's it it's out of here then this thing comes in and says alright something was published let's notify that something was published after its published stops destroys the client returns that's it done now we wait for the next cue to cancer so okay and you know maybe you don't know well that ins and outs or what all the various different things doing now but you can see over here unconnected this particular tasks which we which we generate over here all that does is basically wait for a cue and then once it's got a cue it basically falls into the switch statement and that just waits for events the fire and then act accordingly so I've got two tasks and I'm able to handle quite complex and arias of connecting and waiting for IP addresses and then you know waiting for just by basically just firing it off like this so you think that and that actually look yeah that's important so much use in doing interview on the I 266 yeah that's for sure and also you know look they're doing our library store do you have tracked a lot of it out you don't line up with these event loops but if you need fine-grained control or if you want to do something unconnected or one list so if you want to handle and you know if you want to handle very specific scenarios and you can see it's legible it's easy to read it's not appointments you know you spend them if you spend a half now at this good question okay so there are a couple of functions alright so your first guess is essentially let me guesstimate it okay it's always gonna be that way and then there's a couple of questions or get water walk record here and I look at the snap if I am water let's see if I can find something it'll tell you yeah it'll tell you what stack size you've got left yeah that's it over here so this will basically tell you how much sacks I have got left for that particular task so in my in the course that I'm doing I'm actually got a whole module on memory management where you can actually have a look at the toss the stack you can have a look at the stack space you can have a look at you know because also the thing is for a minute it's in your conten actually I'm not like a whole bunch of it at once you've got to basically figure out what the biggest block you've got so all of these methods are available if you really are concerned about that but I mean you know you the the SP 32 comes with 512 kilobytes on the stack but by the time you're actually finished with all the various different bits and pieces which come with it and reserve stuff you only actually wanted but it is close to 200 so but still that's you know if you basically consider that versus let's say no do you know I'd kill a bus it just you've got ample space to do lots of stuff yeah but then you also you know yeah it's for sure you know and and in that case you probably might start thinking to yourself look I'm either thanks you stop consolidating a lot of that stuff into one toss like I showed you before we're connected as poss and parameters or I wanted because one of the other things of course you can do is you can destroy these tasks if you don't need them anymore which will give it back to the stack or you can say I need a bigger bike control yeah yeah cool very plain yeah that's right okay so guys that's it from me I hope you I hope you found that interesting not slightly amusing or just after what you know or a second useful and yeah I'm going to what I'll do is I will put this code on get up so you can freely download it and I'll clean up the video if it worked out okay no promises and I'll basically post that on YouTube there are a couple of little tutorials around with regards to free artists I tried very hard now to condense pretty much the whole subject into you know into like say one of the authors to those and I think I did a Kenny you know and that's pretty much it there's not very much else to it actually you know you can get into the management very and you can begin to all the various different but you know if you understand the basics essentially there's two things that you need to think about tasks and how do I interoperate between tasks and if you've got that concept you kind of got free office and if you understand why you need it because doing everything an event it can be unscalable you kind of understand why you want to do it and then yeah cool so I'd like to thank you for your attention it was a pleasure to a computer and yeah if you got any questions reach out to me eat a slack or meet up if you guys if you guys like the pizza if you want to write I have pipe work but if you guys want to basic a paucity in one buck two bucks no bucks I don't care it doesn't matter give you my number I'm you're gonna support that money to me or whatever if you don't watch it that's totally fine I'm happy that with all as well but yeah I do appreciate you guys coming and it means a lot to me that you come here and attend and find it interest in it as well so thank you plans workshops so people keep us with a regular sessions going yeah so there's been a couple of different there's been a couple of different you know ideas and that lacks its sort of get an idea from you guys you know we could do this sort of thing where we do that say for example take a particular topic into an in-depth lecture on it we could also do workshops if you guys are more interested in like that's like getting your hands on in terms of things like setups or you know maybe you're interested in a particular topic anyone actually you know it's easier to explain stuff and you can definitely cover a lot more ground if you're covering theory or showing code then if you're actually just you know everybody's typing it out but they're having said that it's as possible to basically take a topic and make sure everybody's mastered by everybody's getting it so it really depends on what you guys what would you guys like any ideas any suggestions anything that you're working on that you'd like to sort of get tackles yeah yeah some suggestions there's a person here I'm a member of the space we're just here Carrie come on for these people to see because yes there's not an intimacy of my that's okay well I tricked who is quietly fighting on the back there and myself is hiding quite as efficient particularly zactly guy from the committee been here for a long time it's practically max come down and doing this to everyone so the space operates you know to two ways one is some there isn't it was a membership basically keeps the space going after people who come down quite regularly it doesn't mean you're not welcome you know remembered not know something Christians or but that's that's how space lots of people who are just very passionate here and they're using all the water keep acquitting around you the lights cuts off and then we do these things where we want to reach out to people without a purpose for groups like ESP 32 or 3d printing so it's really hard pretty small group to actually manages physical space and so that our group is effectively I feel like an umbrella for all these other sports groups who they couldn't know wouldn't have the time I guess to do that so um so we basically went around be self-sustaining and so some little groups are on the fourth Winstead month is the SPP to micro parking group so Damien George the guy who created market - comes down and that's and that runs it's a very tough group so even though it's microbiome Nazi turf wars here those those people know a lot about these species to a lot of our peripherals walk over to such fun one goodness and that's you don't can be moving to come down on the fourth but instead months that's why they keep them touch would be nice if we can get people a nice bethey to IDF group going Mike Wolfe you know Andrew the aedra nuisance amazing at mechanical design I don't know anything about laser covers and CNC machines just come down a Monday night chapter Andrew that he's done all the mechanicals I don't know why almost like a little PlayStation 12 it's all made out of laser cutter wardens that mark off is done the electronics designs ability to copy of electronics and and basically that's all code using the expensive IDF and it's all Bluetooth based so mark knows that you know yes I see look that's a book from scratch all right buttons and things and joysticks and blue so if you want to find out more from people who they're talking about that's guys and I'm sorry often we don't hit pretty much every every so day there's a much bigger market the mock prison visit again mothers who are very much into NQ DT so they're going to do home automation are things basically you cook lots of a species together so let's think you trying to get a gradual est 32 running surfaces in space so one of the first ones that Peter and Cooper together you know sign above the gorge that red bin means it's Wednesday night worship it means out the white hacker space and goes green and then once a day mornings if I was reading in my dreams maybe because we're clearly hopeless but that's that's I think I believe is an ESB futu and that some blue polluted ble beacons doing that so there's a lot going on so you want to offer this if they keep coming down the webpage hack number org their chassis look calendar on right hand slide there's um Twitter which I think's once again which one of these things happen things hacker moment is a facebook facebook page so all these ways always are just funny how long off meetup pages and so yes this space is really just exists for people out there who sauce so basically do what you will get so yeah so don't feel like you need to wait for smiles to organize stuff if you can please make it happen you can use here to help you community basically say it's something she okay some do you say that set things on fire tour group thank you for that it's not this invitation to come yeah I'm gonna keep this going and cleaning other people will help you up there's lots of cool gear here because you do these p32 is that designed to actually talk to stuff so yeah I'm sick of laser cutter movement bosses and packaging I'm sorry play ball the peripherals are to super force reports but I would displace on soon to see on he basically did the tiny Pico project was the world's smallest ESP 32 module the gossip reports on us at was kick start as crowd-funded to be strictly honesty I'm just basically did all on his own recognizance and you went to across to the Shenzhen to put together by béla Georgia but he he comes down here every about when he came comes down on the micro park and I saw that so there's a really a wealth of experience here I'm some really nice sharing don't feel like you chat mix with people it's not like that at all so yeah cool to say it looking like what people deployables will stop so Socrates do cool stop these divinities great this in terms of so next next month okay so yeah discounting what you said absolutely but when the next ESP 30 to me temps coming just does anybody have any ideas as to okay so first thing how was the session tonight was it to the two low levels and two high level was getting a mic mark what was your low level can be good but it can be overwhelming so what did you think yeah alright and everybody to it was good so yeah I mean it wasn't too complicated you didn't which is good alright cool so that's correct so next time would you like to sort of do something similar or do you want to sort of get your hands on there and do want to do a workshop maybe do it like a drunk dice with of all the things I've created for the first time that's essentially a little so led dice press two buttons you press it new basic it does a random number and it comes up with the random dice display and you can basically toggle one dice off you can have two dice and since they're juggling and solar basically comes to a number you can do something like that so you know do we want to do sort of a lab or do we want or is there sort of as you said ble which is something I'm still trying to get my head I've got I've got bluetooth sorted out and I can actually communicate to my computer via bluetooth to a ship which is kind of cool we can also do something like that like a lab like that just to get something going cuz everyone got the idea can stop going there - you're a player who hasn't anyone you hasn't broken the news to be fair - yet oh cool well maybe that's the things basically do Vega has it got started but let's get one get there everybody's working and lushing LaVista hello what's that so it's pretty good thing yeah there's everyone there was anything anyone who you said what the local slaughter basically it was ready I see run a task or pinged opinions basically now Kampala firm under these people into our best to be taken some poetry flashing like in sample some people I see they're using the Arduino IDE so you so you're not change okay so whose something going with the idea yes yeah audio did you wanna get through the audio I guess there's like three people with anything so maybe we can do that next time I'll basically there are hands-on getting getting you're getting your environment set up so to bring your computers alright we'll get to sort of that so that you can have what I've got which is the sensitive es code intellisense full-blown compiled and flash directly within your environments and then I can show you this little guy as well this guy is probably one of the coolest guys out there on the planet this little guy yeah Joey have you ever seen this before what is it this is a $10 $10 JTAG okay huh and this allows me to do in line just like want to see that yeah yeah yeah no no I do wanna see it now yes if you can okay too much of it you can make mistakes hopefully not okay I'm just developing your energy monitor okay so I'm just I'm just glad to be in space with all the debugger this will take me and this will take me ten seconds to set up so I'll show you very quickly what I'm doing I'm just just gonna set this up very real fast this one second okay all right so I've just set up so I'm good I've got some configurations that I that I usually set as boilerplate okay what I'm going to do is I'm going to go through to my main function over here I'm going to go to the side over here where I'm starting the code there's a plane over here and it's going to put a breakpoint there like that very straightforward okay you'll see in a moment okay I'll put another one over there okay all right so now what I'm gonna do is okay firstly I just need to make sure that I'm actually on this directory so I'll just open this in the terminal okay now I need to get a command very quickly just one second is PhD course let's just go back here startup template go to the readme which is over here I'm just gonna get the command I need which is this guy here okay and then go ahead and run that guy in the device found huh I need to plug it in for us otherwise that's here so yeah so I mean this is something that I could probably talk for hours about but in essence what you've got is you've got two inputs one going through to your JTAG which is little trip over here your JTAG then talks to your chip so you need to comport so you'll see a bunch of little green lights coming on there all right now let's just basically control exit start that guy ah okay all right that's not going to work right now well basically just I just need to do something here very quickly it's this one site I know what's wrong actually what I'm gonna do is I'm just going to make sure that I don't have anything else running on these ports this is gonna take me five minutes just give me a second Charles okay so that is failing canvas can that can I correct Jenny that is failing good let's go to my directory and set the driver Vance's nice driver one of the biggest problems with these things is the driver on on windows that keeps on getting replaced by one that I can't use yeah it's real pain in the ass okay but now that I've done that I should be able to get this guy started and it's working excellent so now what I do is I come into debug and go to my main and open that up a little bit and press play sorry now you got a yeah this I've got the wrong file view it yes it is the part of the it's called open OCD the debugger yeah it's part of the open OCD is this make sure I'm in the right place yeah yeah why for your toes okay so I've got the wrong file I just need to get that and it's gonna go to the bill this isn't seamless unfortunately I'd be nice if it can make it seamless but I haven't quite figured out how to make it completely seen Mac OS Linux okay so make sure mix Travis yes yes so so officials Jo Senegal moment is that all PS code is available everywhere okay let's give that a try let's save that time what am i doing though I got the wrong files up I mean the hurry yes I'm making mistakes okay close close all there we go close all let's try this one more time so I'm gonna go in here into launch that's the wrong file that's the right file ctrl D D D D a forward slash control s try that one more time come on why is it looking oh I know why ah sorry um that's why okay control see I know why you gotta actually start it okay because I'm not in the right directory not a template read me I'm gonna get it any second now just bear with me I'm sorry it's taking so long ctrl C close that face that we've got the debugger working stopped us yes there goes all right and it's coming patient in fact that hasn't their doubt just means that we're in good shape just give it a second it's coming the first time the first time it takes a bit of time it's and then it it sort of kicks in and everything is then fine and it actually speeds up after that so yeah this is going to work just give it a second this is $10 oh yeah and there's there's different versions you can do get cheaper ones as well I'll stop it and start again see if we can actually get it to I do find that the first time it always is a bit slow and then after that it it works quite well you see I've got to show you you can't you can't you have to experience unfortunately no there isn't here comes here comes here comes at the so the thread stack starting to call it first time I dunno why but you need to put a breakpoint in a setup routine because look at the declaration I mean it's it's starting here okay yeah so that'll be the first line that actually runs that target halters why oh I know I said I've don't have the right program installed ha ha ha yeah you're gonna have the right application in going in there so that's just my flash 1 so obviously it's not going to break on a different application which is what it's currently earning let's just actually stop that okay so now it's compiled this is flash shirt I haven't tested that actually I don't see why not [Music] there we go lost Jesus ikuo ever alright good so now what's happening right is I've actually got an inline debugger so what can have actually happen is I can press let's say for example to step down alright and then so it's just stepped over I can go ahead and have a look at of the consumer variables in runtime okay now what I can do so if we sort of step over hey what is this doing in English yeah it's halted the application and it's actually running on my on my chip one line at a time and I can actually yeah that's right and I can step into this function so I press 11 and it'll go straight into that one okay and I can have a look I can hover over and I can say all right GPI you know what is LED one LED one is is 2 I can come in here and I can say alright let's go ahead and see what is led1 and it'll basically tell me oh it's it's a variable which is not very helpful in this particular case this is step out of there now this one over here right LED params I can go to my debug console I can say all right what is LED params since they'll basically give me the fact that it's two things LEDs for and time is 100 and what I can do is I can also do something like this ad dot time while this is running without having to recompile it is equal to 600 and it's going to actually update that so I can change values directly in runtime okay so if I come in here and just add that to the watch all right you can see now that it's now 600 okay so now it'll basically blink a little bit slower than it did before not so just gonna hook up there it's just that's right and now you can see also like this particular one has been hit right so I can put these on the beginning of the tasks and I can see when the tasks are gonna be sort of it's a it doesn't matter it's just appointed to reference so it doesn't matter it'll be it's an end it knows it's an integer it'll basically allow me to change it anyway there's other things I can do like for wrong no yeah but you wouldn't you yeah constant constant variables you can change what JTAG is it's not just somethings about the ESP food - it's actually stands to be around for some advanced microprocessor because I hope people Rose what these things are getting more - complexin - basically tests and so they suppose if I suppose Eliezer to stand and face tomorrow sublime stop the stopping processor and read and why didn't eat any part of memory effectively so when you compose program you end up with a memory map and the program they're talking to the JTAG interface know is basically a few buddy when you somebody put up the bogus they can say stop at that line it knows what process what processes are just to stop the program you know when you're talking about for whoever will be there on the step wherever it's knows what memory location that's using that jtech really starts all the process of read and write memory yeah softly laptop makes it all apart magic just a spotless is fixed in Palestine because you typically have shared memory between the course I still just reading writing from sharing therefore this share memory and you spicy Saudis week right yeah when it hits that line of code a little bit about it either course it hits a else no stop this is very ordinary in most programming languages these exciting is because it's on a embedded chip but would really you know it's really cool as you know specifically for debugging to us you can come in here and you can say edit this breakpoints and you can say actually only break on an expression let's say when l time let's say for example is equal to 1000 okay now if you've got let's say for example a piece of code that conditional break on what that why that's good is because if you could let's say for example that sauce the twenty several hundred times a second or several thousand times a second you don't have to certain something crashes what is going on right now you can essentially go and then you can say only break at that point and there's a line you guys if you highlight that point through see the variables and you know for ten dollars or highly recommend you get one setting it up to be a real challenge but I've kind of got that figured out Express just get the cheapest one you can find so it's any jtech reader yeah so this is an f250 two to three - okay that's isn't that just a USB to so yeah it's this thing here I'll show you here yeah I just one second just open our CD it's this guy here ft 2 2 3 2 so that's the actual chunk that I'm using and it's essentially a JTAG chip so that little chip on there is this guy over here it comes in different form factors this was just a bracket a breakout board and you know that I need trouble is you get a little tricky to get the drivers working on Windows but once you actually understand you get this capability and when you're writing applications and specifically if you've got lots of our toss toss talking to each other you know and you don't know wind up in thousands of print statement sometimes it's just these yet breakpoints look that's fine you know oh yeah that's where I'm cluttering the memories oh yeah that's what I've got a wild pointer oh yeah this is where you know it makes it really easy to see what's going on yeah so you can see what's actually being cold over here so it'll take you through what what actually what the process flow was now just out of interest sex right if you ever heard of Sager you can see the various difference right so they'll actually show you what's right you're on as well so if you have multiple threads which you'll have two of you'll have a different idea that'll tell you what hit it you know which thread hits it okay what's really cool is that you can actually configure this guy to give you an output dump okay and then from there you can basically plug that output into something called sigur that'll give you and this is something I've just started to sort of look at it'll give you a graphical interface I think it's this guy here no sorry one second this it'll give you a graphical interface a free application that you can download you plug that in you and what it'll this will give you this guy where it'll actually tell you all the various different tasks and when they're fired and you can actually see you know you actually get a full process map as to how this thing actually looks and works so you can actually see no no that's so yeah so you get a dump from the jtech you can basically don't forget to do that and you can plug it in and then give you you can optimize it none or so what happens is you yes it's generic enough so yeah so what happens is you going to the IDF config and you you tell it that when you tell it that you want to basically dump a file and when you play it plug in the JTAG it's talking to a service and your machine and what will happen is that will actually create a dump the file then you plug that dump into this application and it'll tell you what happened so yeah we go extra bonus believe me yeah go yeah feat free artists yeah and this is this particular tool is called second I posted in the slack also the link [Music] [Music] oh that's something I forgot to mention actually just a that was a good question sorry for cutting off their just if you if you're wondering about sort of this I'll just show you this quickly right so that if you have a look at three artists that the the a lying down that we here right it's essentially supported three artists as a system is supported for all of these chips it takes this instruments the arm the risk five the thick microchip alright so all of these things actually use our I'm sorry free on target it's in millions of devices and chances are you've probably interacted with it too sometime today yes that's right and you can actually dump that into your trip as well so you can actually get free art oh sorry an AWS free art sauce yeah there's on the free on sauce in your shop yeah and then you'll be able to use seems like you'll be able to run lambda function start to finding the stupid to it gets wild yeah yeah I haven't looked at that I mean I the whole aw Estes ecosystems is pretty other one yeah I don't get it a year ago three ounces you could probably run it within the Linux kernel itself so essentially it's three files that see files you can compile them into agency season so yeah I think softer yes it's a couple of kilobytes it's tiny I think from what I recall right so I think the actual free auto sperm that's actually running every it's using two hundred voice it's tiny and I think that the entire code is about I think it's in flash no I don't think you can but you need a 32-bit system don't think it will work on the nightgood system and you do need look at me for as simple simple ideas and stuff like that the event Clips gonna work you know you don't need it's just what you want to scale stuff they got that point there's a new chip that I'm really really interested in the Paducah you guys have it yeah okay it's an 8-bit microcontroller okay the thing about this particular I put the microcontroller it's about to go open-source so we're glad to be able to create programmers and it has built-in debuggers and it basically is gonna be open source and what-have-you right this is special it's a tiny little microchip it's got like nose memory it's got black four pins whatever but what makes this thing so appealing is it cost three cents you have at that customers more it's like 50 cents this thing that's really since by you know the shipping is gonna cost you more in the natural history the padu k so there's a guy as you ever heard of Evie look yeah this is a guy Scott he's basically doing this whole initiative the puppy dog you know if you have a look at his YouTube channel you look for the cheapest microcontroller he's got like two hours of content in there and he's actually reversed engineered it's not he's actually coming up with a program basically just say everybody go ahead and marry and you know you have to spend like 3 dollars for shipping but then you basically spend 10 dollars buying like 3,000 of these chips literally yeah seriously you know so and apparently you can also get services there can pre-program them so yeah by the denis if you got like if you're trying to drive thousands of LEDs it might be a great solution for us yeah yeah it's pretty exciting alright so guys anything else you'd like to know guys thank you for your attendance and thank you I hope you guys found it interesting I'm glad you liked it yeah stop this guy
Info
Channel: Mair Swartz
Views: 30,503
Rating: undefined out of 5
Keywords:
Id: E9FY-IOvC3Q
Channel Id: undefined
Length: 137min 21sec (8241 seconds)
Published: Thu Sep 12 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.