Embedded - 391: The Lesser of Two Weevils

Episode Date: October 28, 2021

Chris and Elecia chat about their current projects and ideas. Elecia is teaching Making Embedded Systems at Classpert. The course is based on her book with lectures to extend the information, quizzes,... homework, mentors, synchronous classes, and a final project. Starting Nov 13th, the first cohort is full but you can join the waiting list. The second cohort starts in February. Elecia is also giving a keynote at Hackaday’s Remoticon! It is Friday Nov 19 and Saturday Nov 20. Tickets are free, get yours now! Jeremy Fielding will be the keynote speaker on Saturday. Hopefully, she’ll have figured out how to use spaghetti sharing as a metaphor for stacks and heaps by then.  The EP for Chris’ 12AX7 album is coming out soon: #ihateeverything. The cover art is generated with a GAN from this Reddit post. Terrible Halloween jokes are collected on Twitter under the tag #EmboodedSystems. If you’d like to support Embedded, check out our Patreon. If you’d like to sponsor a show, click the Sponsor link.

Transcript
Discussion (0)
Starting point is 00:00:00 Welcome to Embedded. I am Alicia White. This week, it's just going to be Christopher and I talking with each other. Hello. How you doing? I'm okay. That means you're not okay.
Starting point is 00:00:20 I've heard that phrase before. Do you want me to ask or should I just... I don't think we want to discuss my mental state on the podcast. It's not that kind of show. Okay. Do you want some candy? I don't think that would help. Also, I had some. It didn't help. I mean, unless you count really good chocolate as not candy. Is it a different category of thing? Is it like one of those nutraceutical things?
Starting point is 00:00:48 Yes. Okay. The chocolate I buy for us is definitely nutraceutical. Okay. Well, I had a nutraceutical 70% dark mint chocolate, and it helped for a minute. Well, secretly inside, I feel exactly the same way. But I have so many things going on that I can't. That's because you keep signing up for things.
Starting point is 00:01:12 The little dialogue box comes up and says, would you like to do this? And you hit the checkbox and you check it. And they just keep coming up and you check them. I don't. I don't. I don't mean to. I think there may be something wrong with my mouse.
Starting point is 00:01:25 Oh. You know, I can ask what I have going on in order to help me. Oh, I'm sorry. What's going on? Why are you so busy all the time? Why are you working all the time? Why are you so overburdened? Okay, so I have my usual clients, deep sea, underwater science platforms, and large autonomous trucks. Yeah, I mean, the large autonomous truck, the size doesn't really matter. Well, it kind of indicates what happens when things go bad.
Starting point is 00:01:55 Gas, sure. But the software and everything would run on a radio-controlled car. So I just think it's unnecessary. Anyway, go on. And then last spring, a company called Classbert said they were getting into the MOOC audience. Last spring? It was late spring. Was it?
Starting point is 00:02:20 Yeah. I feel like, okay. We didn't actually sign anything until July, so I only started then. Yep. Did I want to do a class based on my book? And we went back and forth about what they would do, which is video editing and some educational assistance and setting it all up. And what I would do, which is create a dozen lectures. And I was still, you know, kind of happy with my memory map talk.
Starting point is 00:02:55 That was a mistake. Yeah, that was the problem. And so I said yes. And now the class is open for waitlist, and it's going to start on November 13th and go through the holidays to February. And that's going to be the Alpha cohort, and then there will be another group that starts in February. How big is the alpha cohort? 50 people. 50 people.
Starting point is 00:03:30 And November 13th, this is the real date. This is it. I'm not going back and editing in you saying, November 27th. I hope it's the real date. I really do. Okay. Well, in case it's not, why don't you say every number from 1 to 30.
Starting point is 00:03:47 1 to 31. Well, I can always do 31. So 1 to 30. And then if I need to clip in a day that's different, actually, you better do the month too. It has slipped a bit. Just sing the month song. January, February, March, April, May, June, July, August, and September. Remember that... No, I skipped some. But remember that December is the end. January, February, March, April, May, June, July, August, and September.
Starting point is 00:04:09 Remember that, no, I skipped some, but remember that December is the end. And when I was in first grade, when we sang that song, and remember that December is the end, I got very upset. You were afraid that that was the end? The end. That was the end of the world. December was it. And this is the song telling me, remember, December is the end.
Starting point is 00:04:35 Yeah. Okay. So the class will run a couple times. Maybe it will run indefinitely. It depends on the response. So far, the response has been good. Definitely, we're doing the two. And I should have coupon codes before you have to pay for it. Okay. But right now, at this moment, I don't know how much it costs or what my coupon codes will be worth. Definitely the coupon code will not be worth more than it costs. No. There will be scholarships in the future, but don't ask me about them for the Alpha cohort. So have we talked at all about how the class works? Like, what are they going to, if somebody
Starting point is 00:05:10 signs up for this class, what are they going to do every week? And how are they going to interact with the instructor, presumably you, and is there homework? Okay, so every week there will be at least one lecture. There are a couple weeks where there are optional lectures. And those are about an hour with the quizzes and all the other stuff that goes with them. And then there will be a synchronous class. And I don't know what time it will be. It will probably be on Saturday.
Starting point is 00:05:48 And that's when I think half of the students each get to— there'll be two slots of synchronous classes so that the mentors and I can talk to people kind of individually but also leading discussions. So there'll be the synchronous element. There'll be a Discord channel. There will be homework, and there will be reading. And really, if you don't do the reading,
Starting point is 00:06:13 I have no sympathy for you. So, you know, there's that. And then there'll be a final project that is right now very loosely defined. I went through a lot of back and forth on it, whether or not to do embed boards, which really aren't that great, but the compiler is easy and then I don't have to fight with it, or to do ST discovery boards, which are pretty cool and can compile for everything, but can be intimidating to some. I don't want people to use Arduino.
Starting point is 00:06:49 Definitely want them to use Cortex-M. Anyway. Okay. Well, and the other challenge is getting boards. I don't know how available eval boards are. Probably more available than getting hundreds of chips for a product but so i have a half dozen or more discovery boards that are in stock at digikey and i am basically going to show them all the boards they can use which is anything that is a cortex m0 based
Starting point is 00:07:21 that isn't an Arduino interface. Okay. And then what are they going to build? They're going to get a lot of freedom in that. There are some requirements about buttons and interrupts and state machines and peripherals. But overall, they get to choose what they're going to build, including whatever they're working on for work. It is intended to be a very professional course and to get a portfolio-worthy project.
Starting point is 00:07:46 So that's the projects, the homework, the reading, the mentors, some of whom have been guests on the show, so that will be interesting, maybe. I actually don't know who the mentors are yet. But there will be mentors. And then there'll be the lectures and the quizzes. Okay. So, and is it, are you going to go into more depth in some of the things that were in the book?
Starting point is 00:08:13 Or do you just have time to cover what's in the book? I am assuming that the students have read the chapter. Oh, okay. And if they haven't, then what I'm about to do is going to just be confusing as heck. So you're building on it. Yeah, for like the state machine chapter. In the book, I go through green light, red light,
Starting point is 00:08:36 stop light sort of thing and flow charts and building up state tables and some RTOS and scheduling stuff. And in the lecture, I take an actual device and I create a state machine based on that device while I play with it in front of the camera and do this picture-in-a-picture thing. And we can build up a real state machine, not a simple one,
Starting point is 00:09:01 and talk about how all that works and then do the table version. Oh, nice. Okay. Let's see. What's another one? For the input-output timer chapter, output-input timer, I don't know. For that chapter, instead of talking about all the things in the book, I actually go through a HAL, where it actually starts at the very top level of PWM out 25% sort of instruction and goes through the embed library, the targets library, the STM library,
Starting point is 00:09:43 the HAL for the STM, and then the registers. And by the end, I'm just exhausted because it was so hard to figure all that out. So stuff like that. It's not what's in the book. It's some of what I wish was in the book. Like when we talked to Tyler last week, a lot of the stuff about IoT management
Starting point is 00:10:04 is something I want to add to the book. So the chapter about updating firmware gets some of that, gets a lot more security information, but I don't really talk about the basics of what is a bootloader, because I assume you've read the chapter. Okay. So I've started recording the videos. There's a commercial. It's terrifying. And I have been working on the lectures for a while. I haven't done all of them.
Starting point is 00:10:36 And then it goes from my slides and voiceover and some talking head and demos and whatever our screen shares to the classpert folks who do the video editing and will do a little bit of animation make my slides prettier they've been pretty good um and and i did get that fantastic octopus playing with leds on a on a board uh as my icon, which is just hilarious. I think it'll be good. Yeah, I hope so. And after you go through one, you know, you'll learn a few things. And then that's why you're doing a small group first, right? Yeah, oh yeah.
Starting point is 00:11:22 And, you know, the alpha people, I had to give the cohorts names. And I chose them in rainbow order. And then I wanted sea creatures. So the first cohort are red jellies. Because they're going to have to be very flexible. I've never written quizzes before. And so my quiz questions may be trivially easy or completely impossible. That reminds me of every quiz I've ever taken.
Starting point is 00:11:52 Sometimes from question to question. It's hard to design those things. It's really hard to make tests. Do you remember how often? You probably don't. But there were tests in school, in college, and in graduate school where the professor just completely miscalibrated. Yeah. Like, and everyone's sitting, like, I remember somewhere it was like, it should be done in an hour. And at an hour and a half, everybody, and this is a class of smart people, is still there trying to finish. And the professor was like, take it home just take it home bring it back
Starting point is 00:12:25 tomorrow finish it finish it overnight it's like it's really hard yeah because you don't once you get to an advanced enough level it's not just here's your multiplication table right it's stuff that you're asking professional level questions about that are things that you understand and they just heard about it. And I try to keep that, what does a beginner need to know mindset. But with this, I have been doing so much. The lecture preparation gives me one aspect of the beginner mindset. And then the quizzes are our beginner mindset I've never really had to deal with. Yeah. And you can't really put yourself in the beginner mindset.
Starting point is 00:13:12 You can try. No, not anymore. Not on this. There is one thing that I've been having trouble with trying to figure out how to teach. So I kind of wanted to talk about that. Do you want to talk about other stuff first? No, no.
Starting point is 00:13:26 We're on the topic. Okay. So this is related. Actually, this is related to Hackaday. I'm keynoting Remoticon. It's free. It's on Friday. Friday the what?
Starting point is 00:13:38 Friday the 19th of November 2021. But you can just say all the numbers and I can adjust the years. Right, right, right. And actually, Jeremy Fielding will be keynoting the other day. It's the first time I've ever keynoted something.
Starting point is 00:13:54 I'm very excited. I don't know that I have to do anything different other than show up and talk. I guess I get a key and a note or I have to provide a key and a note? I think you have to use Keynote from Apple. They don't let you use PowerPoint.
Starting point is 00:14:08 That's my understanding. Otherwise, it's called a PowerPoint. Nice. I don't know. Do you need special? I think they might require special visual effects or something, right? I don't know how this works. Do you want to do it in front of a green screen and have, like...
Starting point is 00:14:22 It's live. I'm giving it live. Wild animals. You can still do it with obs they can do it yeah i'm learning to use obs the video software so am i yeah we we're kind of like leapfrogging i don't understand this and then he'll come help me and then i'll use it for an hour and then you're way ahead of me now and then now now i'm ahead and then he'll be ahead you're using it for uh music stuff i don't know yet mostly well this is not interesting
Starting point is 00:14:48 mostly i i started because um i am practicing a lot and there's a lot of things with um with like guitar or piano you can kind of usually have a teacher of course but if you don't have a teacher and you're somewhat advanced but you're still working on technique issues, you can at least look at your hands if you're playing guitar. And you can look at your hands when you're playing piano and see if your wrist's in the right position, if you're doing the right things. With drums, it's a little harder. I mean, there's a lot of stuff happening with hands that you can watch, but since it's the whole body, there's posture issues, there's arm issues, there's leg issues, there's all kinds of things that you cannot see unless you record yourself and play back or have a teacher yell at you. And I don't have one right now. So I thought, okay, I've got a bunch of stupid old cameras and things and let's fire up OBS. Can it record multiple cameras at once?
Starting point is 00:15:41 Yes. Yes, it can. Okay, that's very cool. So I did that and set it up. And then I went a little overboard and got it so that I got a MIDI plug-in for it. So I can use a MIDI pad on my drums to change the scene. That's pretty cool. To switch cameras.
Starting point is 00:15:56 So I can record myself and say, okay, this section, I'm working on more foot stuff. So I can just hit the thing I want and it switches the camera and the recording. And then you play it back and you look at it and you go, wow, I hate everything about myself and want to burn the instrument and the cameras so that this will never happen again. Yeah, yeah. So anyway. See note about commercial. vague notion that maybe I'd want to live stream some stuff at some point. Not for any reason other than to make me really, really nervous because I haven't been really,
Starting point is 00:16:33 really nervous playing music since playing live, which I haven't done in a long time. So it would be useful exercise. But yeah, it's super, super easy to use. For a free program, it sure has a lot of features. Yeah, I was worried it was going to be like blender level of complexity but i was able to get basic stuff working without even reading anything about it it's like oh okay add this sure fine okay i was able to get basic stuff working and then i broke it well yes i broke some too. And then working and then sort of working and I'll be fine.
Starting point is 00:17:06 Okay, so. But you're using it for the class. But so back to the keynote for Hackaday, it will be in part based on my memory map talk. Right, I don't think we mentioned that at all. But I didn't want it to be the same memory map talk. Yeah. Because people have heard that before. So one of the things that Mike Stish asked about was
Starting point is 00:17:32 heap memory and stack memory and figuring out when you're out of memory. And I didn't do a very good job of explaining heaps and stacks. I seem to recall, especially the GCC section, I did a particularly poor job of heaps and stacks. I seem to recall, especially the GCC section, I did a particularly poor job of heaps and stacks on that. And so I wanted to make a graphic that explained heaps and stacks. And there were a couple of things I thought of. There are armies approaching each other, each going forward and backwards like you do for freeze and stack pops and possibly clashing and they get little people fighting. Or Lady and the Tramp style spaghetti.
Starting point is 00:18:15 Or, and hear me out here, stalactites and stalagmites. Stalactites are on the top, stalagmites are on the bottom, and they crash in the middle, which actually doesn't sound very good at all. I don't know. You could combine the army thing and have them fighting up and down a tower, a wizard's tower, climbing the circular staircase and fighting each other up and down. And I've been trying to think about— Skip right over that.
Starting point is 00:18:39 No, I— I mean, yes. The tower— I have heard your note. I have heard your note. I've heard your note. But I was trying to figure out both the imagery to use, the metaphor, but how to show what they do. And so I have a heap pointer after all of the pre-allocated globals and statics and BSS and data. And then I have the heap pointer and I have a minimum heap size.
Starting point is 00:19:11 And then I have the stack pointer, which is at the other end of memory, and I have a minimum stack size. And so every time I allocate something with malloc, I use the heap. And every time I call a function, I use the stack both to do for the whole stack frame, for the return function, for the registers, for the locals. There's a lot of stuff that goes on the stack. And so the stack builds up and it goes down and builds up as you go deeper into the functions. And then it frees itself. That's not quite the right word. It jumps back to a previous function. And the heap goes up, and then you free memory,
Starting point is 00:19:50 and ideally it goes back down, but sometimes it fragments, so it just keeps going up. Well, now you have to talk about malloc. Well, I mean, I just want to say malloc. I don't want to talk about it. If you said fragmentation, you you got to talk about malloc. So the heap continues to go down and the stack continues to go up. And in a bad situation, they crash.
Starting point is 00:20:14 And I wanted to create such a bad situation. The only thing I could come up with, maybe this part will help with the whole metaphor, is a recursive function that has a malloc in it. That would work. I mean, I haven't seen them crash that much. I mean, usually don't you set a maximum stack size and then the runtime tells you no more when you go over? No.
Starting point is 00:20:41 That's how I've used RTOSs. Well, I mean, if you have an RTOS, yes. Okay. Bare metal. If you don't, there's nothing checking that you're going beyond the heap. There's nothing checking you're going beyond the stack. Well, that's an important thing to talk about, too. Yeah. I mean, that's why you end up in this. Okay.
Starting point is 00:21:00 And this is one of the reasons we don't always use heaps in embedded systems. You use static memory, and then everything after the preallocated variables is stack space. And you can, although I've never done it or haven't done it in many years, calculate how many stack frames you can put on, how many functions you can call not counting the local variables. And then you say, I can only call 100 functions deep, which is a lot. Not if you're using a UI library. And a how. Don't forget the how. Yeah, the how is a real problem.
Starting point is 00:21:39 Or even, you know, you can call 20 functions deep, and that doesn't sound like much until you get to the hows and the UI libraries. Yeah. And then you end up bumping up against some variable that you have, as opposed to the heap where you don't quite know where you'd bump up against. Bumping up some. This is a light word for destroying. Crashing into something. Yeah.
Starting point is 00:22:06 Well, I mean, yeah, I guess that's why the lady in the tramp spaghetti thing doesn't work. Because at the end, they smooch. And let's face it, the heap and the stack are more like fighting than smooching. We've never asked them. I'm pretty sure. Okay. Pretty sure. Just a guess.
Starting point is 00:22:23 Okay, so are there other metaphors? Preferably oceanic deep sea creature metaphors? I mean, there's a lot of gross sea creatures. We can probably come up with something. Are we going to go back to the Zee Franks video with the nudibronk eating the nudibronk? Hmm. So you have to have things growing into it. Yeah, I don't have anything offhand, sorry. Molds, fungus?
Starting point is 00:22:49 Worms, undersea worms. Sponges and corals? Yeah, it doesn't really work. Because you have to kill them off because they have to die back. I mean, you have armies. It's no better. Spaghetti, you can kill them with spaghetti. Well, the armies can retreat, so they don't have to fight.
Starting point is 00:23:07 Just like the heap and stack don't have to collide and cause your system to crash. But they're not thinking about it. The stack doesn't get close to the heap and say, oh, no, I'm too close to the heap. I better turn around. That's true. It'd be cool if it did. Well, that's why you're in an toss it just yells at you and you crash anyway it just crashes with a message saying hey you idiot you blew your stack well it crashes with a you did something wrong and so i'm not going to allow
Starting point is 00:23:38 you to destroy your system by accidentally calling code that says yeah light on fire and then you go in and you configure a bigger stack and it says you don't have enough room for that. And then you spend a week trying to figure out how to fit all your code in and the stacks you need. Yeah, I don't feel like we've made any progress on this metaphor.
Starting point is 00:23:58 I liked what you had. Why don't you do something better? You think the armies is the way to go? That's pretty good. I mean, you can fire it up in like one of those hilarious army simulators. Oh, I was
Starting point is 00:24:10 thinking about going back to the Encarta map thing, but maybe an army simulator would be kind of funny.
Starting point is 00:24:17 Yeah, I don't know offhand. Maybe I can just instantiate a few million people in Blender and have them
Starting point is 00:24:21 running each other. I need them to go forward and back. Yeah, yeah. I'm not each other. I need them to go forward and back. I'm not doing that. I'm not signing up for that. And then in a heap
Starting point is 00:24:30 we'll get memory fragmentation by having one guy sit down and have lunch. A food truck coming by and taking up a bunch of space. Okay, so that's me. I've been doing a lot of things.
Starting point is 00:24:48 I feel like you've been doing a lot of things. Shortly after all of this, I will be hiding under the bed. No, somebody will say, hey, Alicia, can you, you want to do this? Do you want to do the second version on your book? Do you want to, I have a contract for you to do this thing that's interesting. No, don't take it. I'm not taking any CES contracts. I'm saying that right now in public.
Starting point is 00:25:11 Have you ever in the past? Oh, yeah. When? They come in December. They come in December? Some company comes to you with an Arduino and says, we want to show this at CES. And you've taken these contracts?
Starting point is 00:25:24 Yeah. When? Which one? Tell me, tell me. The statute of limitations is long past. Well, there were a couple of sports ones. You remember the sports ones, right? Those were CES? One of them was, yeah.
Starting point is 00:25:39 It started at CES? You were already working for them and they... No, they emailed in November, December and said, we want this for ces i like them they're kind of fun because it's really just hacking a prototype together from a worse prototype you just said you didn't want to do it i know and then you said you know you like them and they're fun this is how you get in trouble and you click the checkbox but i should not add anything in this calendar year until the class is over. And actually, at the end of this year, my other two projects are over, too.
Starting point is 00:26:11 It's going to be January 1st, and I'm going to be like, oh, my, what am I doing? And then you're going to be really unhappy. I know. Because you don't have anything to do. You have two states. Unhappy because you have too much to do, and unhappy because you don't have anything to do i suggest you average those two positions and just have just enough to do did that pretty well last year okay well and class could take up an infinite amount of time. Because there's always a slightly better way to explain things.
Starting point is 00:26:46 I guess with code, there's always a better method to do it or whatever. With my code, there's always a better method. Your code, can, is doing better. Can. Can. We talked about can problems. Can, can, can, can. Oh, last time we talked? Yeah.
Starting point is 00:27:02 Yes, and people tried to help me, but I'd already solved it once they suggested their help. And did your solution come from anywhere else? No, I can't remember anyone suggesting anything. I can't remember anyone suggesting the exact specific thing I did. The word I ended up using did not come up in the conversation with the person who claims they told me how to do it. Yes, you gave me a pretty big hint for how to look at how to do it. So what was happening, just to back up and recap for people, what was happening was I'm gathering data from a radar over CAN, which comes in at about once every 50 milliseconds.
Starting point is 00:27:46 It hands me 64-ish CAN messages, which correspond to radar tracks. And I'm also streaming an IP camera, 4K images from an IP camera, and using GStreamer to save those off to disk as JPEGs, also at 20 frames per second. And what I was doing at the time was getting the image from GStreamer to save those off to disk as JPEGs, also at 20 frames per second. And what I was doing at the time was getting the image from GStreamer. It gives me a signal and says, hey, I got a new image. And then I was talking to the CAN code
Starting point is 00:28:16 to go ahead and grab the latest set. The next set. The next set of radar things. And then write those both to the RAM database that I'm acquiring stuff into. And what was happening was once in a while, way too often, but once in a while, the radar just would get interrupted
Starting point is 00:28:36 or go out to lunch or not, that portion of the code would not keep up and it would say, hey, I got track three when I was expecting track zero which meant it had wrapped around and it had missed a bunch and i couldn't figure out how to get this to to solve to solve this problem tried various things ultimately what i think the issue was was i was doing this all in line and doing this all in in python with g streamer trying to use g streamers callbacks and things to to do everything g streamer behind the scenes creates a whole bunch of threads and
Starting point is 00:29:13 you don't know what they are and you know what they're doing and every time you add a q to your pipeline it adds a new thread so i probably had two or three or four 15 threads running for g streamer but you don't know what they are. You don't have any control over them. And threads in Python are not really that great because of the... Gil. The Gil? I don't know. Would you say Jill? The Gile. The Global Interpreter Lock,
Starting point is 00:29:46 which is the single top-level lock in the Python interpreter, which basically says you can only have one thread running at a time. So you can have as many threads as you want in Python, but it's not going to put them on different CPUs or do any useful things for you. It's just like your old threads on your Windows computer in 1997 when you had one CPU. You can have as many threads as you want,
Starting point is 00:30:10 but they're just cooperative multitasking, bouncing back and forth. So if something's busy, you can get held up. But GStreamer has true threads. I agree, but it's also probably getting priority over me. I don't know the actual... I'm speculating as to what was going on. Okay. But clearly putting all this in one Python process was not working. If you have a better idea for what was going on, I'm open to hearing, but.
Starting point is 00:30:39 No, I mean, for some of my stuff, I have GStreamer with a couple of threads. And then those threads are separate from my Python, quote, threads, which I have with Ross. And Ross uses Python threads, so those are all running cooperatively. But my GStreamer threads run on different processors. But you're not connecting your GStreamer. You're not doing things in the other threads in a timely manner based on GStreamer. No, everything stays very asynchronous. There's no waiting.
Starting point is 00:31:15 Waiting is bad. Well, not waiting, but I was signaling from GStreamer. Anyway, I was doing something different and probably worse. What I ended up doing was Python has a wonderful module called multiprocessing. And multiprocessing allows you to spawn new processes. And it works much the same as threading would work. A lot of the calls are the same. A lot of the communication methods are the same between threads, message queues, and things.
Starting point is 00:31:55 And they look the same, and they have the same APIs. And so you can just spawn a new process and communicate with it over queues. And the new process is an actual process that shows up in PS or top. And it goes on a different CPU. If you've got them, the OS can move it around and it runs independently.
Starting point is 00:32:11 You can choose to have it inherit your entire Python context in terms of a copy or just start from fresh without a copy. You can do all kinds of things. You can get in trouble with some of that, but you can do all kinds of things. And so what I ended up doing is creating a new process. And this is all in the same Python file.
Starting point is 00:32:30 I don't have multiple Python files. Creating a new process that just free runs with the radar. And so it just sits there and gathers new tracks all the time. And it gets a message from GStreamer, which is in a different process that says hey i got an image here's the image file location and it's timestamp and it sends that to that to the other the radar process and the radar process says oh i got an image fine what's my latest radar tracks boom this and this go together put it in in the database, out, never had a problem again.
Starting point is 00:33:11 So that's what fixed it. But multiprocessing is super cool because you can do, that's sort of a by hand kind of approach to doing it, create this process, create this process, link them up with communications and stuff. If you have to do something that complicated, it's more of an architecture. But it's also useful for tackling big data problems. So I've used it in the past a whole bunch of times when I'm processing a huge list of images that I need to do something to. So let's say I need to mark them up with some, I have data in a database, and I have a set of images, and I need to take that data and I need to paste it on the images in some fashion. Maybe highlight something, maybe put some objects in. Normally, you just go through that one by one, right?
Starting point is 00:33:53 You grab the image, you look at the data, you do your thing, you'd save it out. And if you do that in Python the normal way, it would run just fine, but it would run on one CPU and beginning to end. But what you can do, which is a few lines of code with multiprocessing
Starting point is 00:34:10 and the multiprocessed, a thing called the multiprocess pool, is you can say, I have eight CPUs. Create a pool with eight CPUs. Here is my data set. Divide this up however you feel like. Here's the function I want you to run on it.
Starting point is 00:34:27 And multiprocess, please go do this. And it divides it up into these sections. It feeds each of those sections to a different copy of the function you gave it, and then runs them all on how many CPUs you've got, and now it's whatever, eight times faster than it was. And it's like six lines of code to do that. So super cool.
Starting point is 00:34:54 And I use that all the time. So hopefully that helps somebody who's suffering through. But yeah, Python doesn't work well with multithreading. If you really want to do anything concurrently, multiprocessing is the way to go. And you can get threads from other places, but there are other big libraries. I mean, like matplotlib and numpy
Starting point is 00:35:17 will spawn new true threads as opposed to the global interpreter lock thread. But you really have to be careful about that global interpreter lock. It will bite you. There is a rumor in the last week or so that they are getting rid of the global interpreter lock. I mean, it's been such a pain for so many people. And it's a hidden pain because you can call something a thread
Starting point is 00:35:43 which you believe will run concurrently on a different processor, but actually it doesn't. And unless you're vigilant about checking top and looking at things, you just wonder why this program that is supposed to be efficiently written takes forever to run on your 32-core processor. How many cores does... Oh, that's not that computer. What, my new one?
Starting point is 00:36:13 Yeah. That's 10. Oh, that's nice. Anyway, there was another Python topic, if you want me to continue blathering about that. Bit twiddling in Python. Yeah, so this is more of a rant and a complaint. I never have found bit twiddling that bad in Python.
Starting point is 00:36:29 You're not doing what I was doing. Of course. I mean, bit twiddling is fine. It says here, talk about bit twiddling in Python. Maybe someone has better ways. Yeah. But you asked me how to do something, and I told you how to do it without having to depend on the size of the variable.
Starting point is 00:36:48 I know. It's great. But it was still a big function that you had to do a bunch of stuff with. Like four lines. Let me explain the problem. Why? Before you get offended at your solution, which was wonderful and worked, and I used it.
Starting point is 00:37:02 But it would be nice if there was a kind of a native way to do this sort of thing that didn't require knowledge of number formats. Okay. Sorry. No, I mean, I have that knowledge too, but it just, it's, if you find yourself doing a bunch of where is the sign bit and how do I sign extend this,
Starting point is 00:37:21 you're probably off in the weeds somewhere. Start at the beginning. You had a 10-minute signed number. Anyway, can. Some of the messages that I get, some of the messages that I get from can have numbers in them. Weird, right?
Starting point is 00:37:38 Docker. Right. Some of them are split. So I will get the lower five bits of the number, and then I'll get eight bits of a completely different thing, and then the upper five bits of the number previous. In C, this is not such a big deal. And certainly combining those is not such a big deal,
Starting point is 00:38:02 except these were signed. So what I've got is a 10-bit signed integer split into five, well, a 9-bit signed integer with a signed bit split into two 5-bit chunks. In twos complement. Right. Well, when you said signed bit, that actually doesn't make it to's complement. Yes, maybe it doesn't have a sign. I don't remember the specifics of what we did, but that was last week. I can't be expected to remember anything.
Starting point is 00:38:36 It's a sign thing. So normally in C, it's 10 bits. Okay, you've got a sign extend it to a short. Right. You've got to take that 10 bits and you've got to fill out the 5 bits to make it as if it were assigned 16 bit instead of a 10 bit. Because if you just stick it in the 10 bits in the short, you're going to have a bad time. Yeah. You're going to have radar tracks which is flying all over the place and they're all on the sides and everybody's upset
Starting point is 00:39:05 because it's not working right. How do you know that? Because I had radar tracks and they were all messed up and they were all on two sides and everyone wasn't happy. Okay, so in C that's not as big a deal because you can manipulate things with different type links. In Python, it's a little trickier because an int is just kind of an int. They don't really go for
Starting point is 00:39:28 telling you how many bits are in it. There's no int32. There's no real int32 or int16. Now, yes, people are yelling, oh, you could use NumPy. NumPy has those. This is true. I could have done that. But it seemed kind of weird. And so, yeah, so we had to find a way to sign extend this into a Python int.
Starting point is 00:39:50 And you had a nice way of doing it, and I ended up using that. But it still was too... Gross? Yeah. Because it looked like it was bit twiddling? It was bit twiddling with a bunch of conditionals and things. It was one conditional whether or not you were an assigned or not. I'm not complaining about your solution.
Starting point is 00:40:10 This is not an attack on your solution, which I'm currently using. I'm just wondering if I'm missing something about Python integers that would have made this more straightforward. So he asked me about this, and I gave him some suggestions, and then he walked away. And then I, instead of doing what I was supposed to be doing, wrote the function for him, because bit twiddling is really fun, and it's a solvable problem.
Starting point is 00:40:37 Twiddling wasn't the fun part. I did the twiddling. The whole problem of I don't know how big my integer is, and I need it to be negative. So how do I make sure? I wrote a whole CPU emulator that did all of the signed arithmetic for the thing. I'm not saying you couldn't have done it. I know what I'm doing. You just didn't want to take the time to do it,
Starting point is 00:40:55 and I treated it like a game. This is one of those areas where Python, being nice and easy, made something harder. The solution that I did for you is probably the one I would do in C. I think there's a... Yeah, maybe. I think there's an easier way to do it in C. But, sure.
Starting point is 00:41:14 But you could do it in... I could have done it into a short. I have the solution in C. It's in the example code they gave me. It was much shorter than that function. It was just a couple of things. They just amped it with something magic because they knew it was a short. code they gave me. It was much shorter than that function. It was just a couple of things. They just amped it with something magic.
Starting point is 00:41:27 Because they knew it was a short. Anyway. Anyway, if you have any bit twiddling problems, please send them to me. That's not... Fine. I'm going to stop using Python. It's time to switch to Rust. Except I don't think I can use
Starting point is 00:41:43 OpenCV and Rust. And GStreamer and Rust and OpenCV would probably break me. I'd have to learn too many things. Also, my client would kill me. Yeah, probably not. Okay, I heard a rumor. Yeah?
Starting point is 00:42:01 I heard a rumor that the chip shortage... I heard one rumor that the chip shortage is going to be cleared up by Q1 2022. That's Elon Musk. I hear a lot of rumors from him. He just says what the voices tell him. Yes, and full self-driving will be done next month. Full self-driving was done three years ago, according to four years ago. Anyway, for those not reading between the sarcasm lines, I believe the chip shortage will be going through 2023. So continue your hoarding.
Starting point is 00:42:39 No, wait, sorry, don't hoard them. That's rude. Continue pre-buying your chips for a little while longer. And if you're thinking about starting a company... Make a software company. Make it a software company. Yeah, I mean, where are you hearing this rumor? What little birdie is telling you this?
Starting point is 00:42:58 I can't divulge my informants. But you have a birdie. Oh, yeah, I have a birdie. And your birdie works at a birdie. I'm going to divulge my informants. But you have a birdie. Oh, yeah. I have a birdie. And your birdie works at a chip company. I'm not going to divulge my sources. We're not talking kettle. We're talking like an electronic chip company. What do robots like to eat for lunch?
Starting point is 00:43:21 Raw Maine lettuce. Microchips. Yeah. raw main lettuce microchips uh yeah so if you haven't been following me on twitter this whole month has been full of really terrible jokes so if you are following me on twitter i have no idea why the jokes just get worse but they will end on halloween the jokes will continue until morale improves no oh the jokes will continue until the month? No. Oh. The jokes will continue until the month ends? Until the month ends. Maybe morale will improve. After I stop them?
Starting point is 00:43:51 Probably. They're really bad. Mm-hmm. Okay, so the other thing I wanted to ask you about was your album. Which album? Specifically, the new EP album art. The extended play record? Well, that's EP album art. The extended play record? Well, that's not released yet.
Starting point is 00:44:09 It was only sent to find Kickstarter backers who bought it as a bonus. But isn't everybody going to be able to see it? On November 12th. Okay. When it releases. Yes. Yes. We have a new five-song record that we released to the Kickstarter people who ordered it. It was one of the Kickstarter options. And yeah, it has some songs on it. It's got five of them. And there's artwork.
Starting point is 00:44:35 The music is cool. You don't care about the music. I want to talk about the artwork. Yeah, yeah, yeah, yeah. Generated adversarial networks? Generative adversarial networks. Yes, that is the name of the record no i hate everything is the name of the hashtag i hate everything is the name of the record that's the important part yes uh so tell me about this this network that you have and where you got it from and why the waves have teeth?
Starting point is 00:45:09 Where do you get anything? I got it from Twitter. People have been playing around with these for a while. It's a neural network. There's types of networks called generative adversarial networks. And I don't remember the architecture exactly, but there's something where it has kind of targets
Starting point is 00:45:25 it's been trained on, certain styles of images and things, and then it feeds back and tries to, there's a feedback portion. So it tries to generate things that are like that stuff. And the one I was using has another portion of the model that has text as part of it. So it's got text associated with the images. So you can put in a text prompt and it will attempt to
Starting point is 00:45:50 create an image that's something to do with the texts you gave it. And it takes several long steps to get anywhere. And you can watch it kind of think about things, dream about things. It's like watching something dream. They're very strange images. They're very dreamlike, nightmarish sometimes. And Janelle Shane's been doing a bunch of them and some other people. You see them on Twitter.
Starting point is 00:46:16 And I was very lazy for the album art for this after spending so much time on the other one. I didn't really want to. Well, you had an idea. I had a couple ideas. It just didn't quite work out. They were okay. There were some photo
Starting point is 00:46:25 stuff that I was working on. I'll probably use it in some context later, but I just got annoyed one afternoon and started and loaded this up. So the model I'm using is called Clip plus VQGAN. And those
Starting point is 00:46:42 are the two portions. And there's various places you can get it if you just type that in Google and then you load it up in Google Collab notebooks, which are very cool. It's basically a Jupyter notebook that gives you a GPU backend. Not a great GPU, not a terrible GPU.
Starting point is 00:46:59 You can pay them 10 bucks a month to get a better GPU. And it loads right up there in your browser, and you can go through the things, set it up, and put in the text prompt, and it just goes. So I didn't do anything. I didn't design this or write the code or anything. Just paint by numbers. And so I got annoyed and started putting increasingly strange prompts in,
Starting point is 00:47:21 and one of them was ocean monster monster monster wave teeth something and that's what ended up uh being me art for the ep and i'm gonna start generating my code this way i don't know about that letter but you did get some pretty weird but cool yeah and i lost the one with the scary scary girls on the beach with the haunted sandcastle. That was okay. That was scary. Yeah, but I still wanted to show it at some point. But yeah, it's weird. It's weird to see a computer kind of...
Starting point is 00:47:54 It's not intelligence. It's not dreaming, really, but a bunch of stuff kind of randomly putting together strange images. And part of it is putting together the strange images. If you just typed in cat, you'd probably get a normal-looking cat. I don't know. I haven't tried that. It probably depends on the model.
Starting point is 00:48:13 I think there's better ones for that kind of thing. I know there's the ones that generate people that don't exist and things, and those tend to be better. Although they still make weird mistakes with those. Like people will have the wrong number of teeth or just subtle stuff. Like you'll see they have three incisors or something. So you got one that looked Japanese woodcut style. Yes.
Starting point is 00:48:35 And it was big waves. Yes. And then they had sharp teeth. And those were really cool. Yeah. But you didn't use that one. That one wasn't as good as the other one. But you also got
Starting point is 00:48:45 waves with teeth and instead of being sharp monster teeth they were human teeth yeah i don't remember that was terrifying well i think there was one time i asked for wood cut and it gave me like wood wood which wasn't what i asked for so it's not it's not there's no intelligence here the interesting thing is the more usable stuff tends to be the earlier more abstract more the longer it goes the closer it gets to kind of a photo quality instead of a painting quality um and so i had some that were good after the first hundred steps and then a thousand steps later i was like i don't know what it's doing it's it's made this into a photo photo quality waves with sharp needle teeth was... Yeah, but it's a good way to make some abstract stuff.
Starting point is 00:49:29 Now, you can't use some of the models for commercial purposes. So there's two. There's a, I think it's a Flickr-based one called S-Flickr, and there's another one I forget the name of that you can use for commercial purposes. But most of the other big models are not for commercial purposes. So you can get different styles of images and things, depending on what your source model is.
Starting point is 00:49:52 But I was limited to those two. Because you weren't using it on an album that people would pay for. Yeah. Anyway, I didn't spend a whole ton of GPU time doing it, so it wasn't a big deal, but sort of interesting distraction. It was fun to watch. I think we've talked about it a little bit before, because you've played with it before. Yeah, I'm sure. I think we have. But I was once again kind of bogg-aroundable with the thing that I used.
Starting point is 00:50:26 The image size is 512x512, which is way not enough for using for art purposes, photo art purposes. So I ended up taking that image, putting that in Photoshop and doing some stuff, and then using another neural network-based photo enlarger thing to get it up to a really high resolution that didn't look bad. Do you think neural networks are going to take over the world? No. I'm sure there was somebody after they invented the screwdriver who said, do you think the screwdriver is going to take over the world?
Starting point is 00:50:59 I think of them as kind of annoying screwdrivers at this point. Like I said on Twitter a few weeks ago, call me when it has the intelligence of a Weevil. Although, I've never seen a Weevil paint. I think a Weevil's visual processing system is probably more sophisticated than whatever made my album art. Do you think if the Weevil painted a self-portrait on a smaller canvas, it would be the lesser of two weevils.
Starting point is 00:51:29 I'm sorry. It's really been a month full of bad, bad jokes. And I don't know why, but every October I'm kind of drawn to the... I did that joke. I know, you were like 10. 30 years ago on a whiteboard in the CS department lab, we drew two weevils and then pointed to the lesser of two weevils. I was really proud of that.
Starting point is 00:51:53 That was my biggest accomplishment in college. Well, I think this show, of course, will be our biggest accomplishment today, this particular episode. So if you're ready to put a cap on it, I can... Do we have anything else to talk about? I mean, we can talk about Patreon and how those people are nice.
Starting point is 00:52:15 They are nice, very nice people. About how we've had guests who, when we ask them about sponsorship on their YouTubes or whatever, they say, oh, I didn't think you had sponsorship because you had that message that said, you don't have commercials. And I'm like, yeah, that was like a year ago. We do have it on some of the repeats because I'm too lazy to cut it. Anyway, we're taking sponsorships. Please sponsor us.
Starting point is 00:52:45 It's pathetic. Okay, so... You can finish the podcast. Thank you to Christopher for producing and co-hosting and chatting with me. You're welcome. Oh, God, I probably wasn't supposed to say that. No, it's okay. Oh, God, I probably wasn't supposed to say that. No, it's okay. Thank you to our Patreon supporters for supporting
Starting point is 00:53:12 us and buying mics for our guests, as well as helping us get the word out about the show. If you like the show, please tell somebody about it. What else? Oh, thank you for listening. You can always contact us at show at embedded.fm or hit the contact link on embedded.fm. Where can they find out about this class that you're teaching? Gosh, I should put it on embedded.fm, shouldn't I?
Starting point is 00:53:40 You should make a blog post or something. Yeah, you probably should make a blog post and some links and stuff. Maybe a little banner across the top. In the meantime. A little pop-up that flashes at you. Act now. I was reading about writing call to actions today. I've learned that I am terrible at marketing.
Starting point is 00:53:59 Just give us your email. Yeah, okay. I'll put a link. There'll be a blog post i guess and um worst comes to worst search classpert and my name and you can even misspell it and it will find it or classpert and making embedded systems although that one you have to spell correctly is it time for winnie the pooh? Yes. Or did I forget stuff? I'm sure you forgot something. Okay.
Starting point is 00:54:28 Winnie the Pooh has agreed to find Eeyore's tail. It was a fine spring morning in the forest as he started out. Little soft clouds played happily in the blue sky, skipping from time to time in front of the sun, as if they had come to put it out, then sliding away suddenly so that the next might have his turn. Through them and between them the sun shone bravely. A copse which had worn its furs all year round seemed old and dowdy now beside the new green lace which the beaches had put on so prettily. Through copse and spinny marched Bear, down open slopes of gorse and
Starting point is 00:55:08 heather, over rocky beds of streams, up steep banks of sandstone into the heather again, and so at last, tired and hungry, to the hundred-acre wood, for it was in the hundred-acre wood that Owl lived. And if anyone knows anything about anything, said Bear to himself, it's Owl who knows something about something, he said. Well, my name's not Winnie the Pooh, he said, which it is, he added. So there you are.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.