1 00:00:00,000 --> 00:00:02,940 So, yeah, I guess we'll get started. It's about five minutes 2 00:00:02,940 --> 00:00:06,300 after time. So as you guys probably saw from the previous 3 00:00:06,300 --> 00:00:09,420 talk about the game, et cetera, I recognize a lot of faces here. 4 00:00:10,240 --> 00:00:14,580 This is a more in depth look at the badge and, you know, how you 5 00:00:14,580 --> 00:00:17,900 script it and, you know, kind of what the APIs are that are 6 00:00:17,900 --> 00:00:23,520 there, et cetera. So, you know, we saw this slide in my last 7 00:00:23,520 --> 00:00:27,240 presentation, right? I mean, not much to it, but the 8 00:00:27,240 --> 00:00:30,040 jumpers, where the score, the seven segment display and then 9 00:00:30,040 --> 00:00:37,380 the OBD2 port. That's of interest. And, you know, you 10 00:00:37,860 --> 00:00:40,660 guys don't have to memorize this by any means. I mean, on 11 00:00:41,320 --> 00:00:48,840 carhackingvillage.com, all these presentations, the SDK, PON help 12 00:00:48,840 --> 00:00:52,240 documentation, everything is available there for download. But 13 00:00:52,820 --> 00:00:56,240 I did want to just kind of run through, you know, as far as 14 00:00:56,240 --> 00:00:57,220 what the jumpers are. 15 00:00:57,220 --> 00:00:59,900 Just so you can kind of get a scope of what the badge 16 00:01:00,980 --> 00:01:04,180 capabilities might be. So, you know, I guess starting in the 17 00:01:04,180 --> 00:01:10,880 upper left hand corner, that's the UART interface. All of 18 00:01:10,880 --> 00:01:14,220 these different positions on the jumper as well, you can see in 19 00:01:14,220 --> 00:01:17,280 the silk screen on the badge kind of guides where all these 20 00:01:17,280 --> 00:01:22,680 things are as well. So the FTDI connector, which is just the 21 00:01:22,680 --> 00:01:27,200 standard USP to TTL UART connector. So you can see all 22 00:01:27,200 --> 00:01:30,340 the different things that you can buy basically anywhere, you 23 00:01:30,340 --> 00:01:33,520 know, goes up there. That's for the host port, which we'll talk 24 00:01:33,520 --> 00:01:38,060 about a little bit later. Down from that is the first output 25 00:01:38,640 --> 00:01:42,600 that you can control through the scripting language. Below that 26 00:01:42,600 --> 00:01:47,980 are the four inputs that can also be read and trigger events 27 00:01:48,640 --> 00:01:52,200 in the scripting language. So just some general purpose inputs 28 00:01:52,200 --> 00:01:56,520 outputs to whatever you want to interface to. But the last four 29 00:01:57,200 --> 00:02:02,660 inputs are basically how you select what OBD2 interface pins 30 00:02:02,660 --> 00:02:07,480 you want to use. So by default, the badge is populated such that 31 00:02:07,480 --> 00:02:11,180 you're using high speed CAN. The micro only has one CAN 32 00:02:11,180 --> 00:02:14,620 controller, but we support three different CAN interfaces on the 33 00:02:14,620 --> 00:02:18,760 OBD2. So the jumpers are the way to basically tell the badge 34 00:02:18,760 --> 00:02:24,640 which CAN channel you want to listen to, right? So the first 35 00:02:24,640 --> 00:02:27,180 two, you could have either, you know, if you want to listen to 36 00:02:27,180 --> 00:02:32,000 the purple or the light blue, it's one or the other. So if 37 00:02:32,000 --> 00:02:34,800 they're up on the purple one, you're going to use a single 38 00:02:34,800 --> 00:02:39,420 wire CAN transceiver. So that comes out I believe on pin one 39 00:02:40,020 --> 00:02:44,420 and now you can talk over the GM stuff. If it's in the blue 40 00:02:44,420 --> 00:02:47,740 position, then you're using dual wire CAN. So what that's going 41 00:02:47,740 --> 00:02:51,900 to do is that's going to route, you know, the CAN channels or 42 00:02:51,900 --> 00:02:56,020 the CAN lines from the micro out to the dual wire CAN transceiver. 43 00:02:57,180 --> 00:03:01,180 The bottom jumpers basically select which dual wire CAN 44 00:03:01,180 --> 00:03:06,000 interface do you want to use on the OBD2 connector. By default, 45 00:03:06,040 --> 00:03:08,460 the bottom ones are populated because we're using HS CAN on 46 00:03:08,460 --> 00:03:12,080 pin 6 and 14. But if you're on a forward and you want to look 47 00:03:12,080 --> 00:03:16,200 at like the medium speed body bus and see things going on in 48 00:03:16,200 --> 00:03:18,680 there or do other things, you can, you know, instead of 49 00:03:18,680 --> 00:03:21,540 populating on position D, you can populate on position C, 50 00:03:21,620 --> 00:03:26,220 right? So it's flexible. I mean, you can't, obviously you can't 51 00:03:27,180 --> 00:03:31,060 do hardware. But as somebody pointed out, you know, with a 52 00:03:31,060 --> 00:03:36,280 little bit extra hardware and using the GP outputs, you could 53 00:03:36,280 --> 00:03:39,800 easily do some sort of mux, demux thing there to switch 54 00:03:39,800 --> 00:03:46,620 this dynamically, right, with the script. So this is basically 55 00:03:46,620 --> 00:03:50,400 what I just talked about, right? But I put it in here just for 56 00:03:50,400 --> 00:03:54,620 reference when you go back through these slides later. So 57 00:03:55,000 --> 00:03:57,160 what is PON? So PON is the scripting language. It's a 58 00:03:57,180 --> 00:04:02,620 language that I chose to put on the badge. And these are kind of 59 00:04:02,620 --> 00:04:06,020 like the highlights from it, right? So it is C-like, which 60 00:04:06,020 --> 00:04:12,260 we'll see. And it's compiled, but it's interpreted on the 61 00:04:12,260 --> 00:04:17,480 device. The language is really designed for scripting embedded 62 00:04:17,480 --> 00:04:21,060 targets. However, you know, I have heard things it is used in 63 00:04:21,060 --> 00:04:25,200 the desktop world as well. I think it's used as part of like 64 00:04:25,200 --> 00:04:27,160 the half life 2 engine. I don't know if you guys have heard 65 00:04:27,160 --> 00:04:29,240 of the half life engine, the half life engine to do scripting 66 00:04:29,240 --> 00:04:33,540 for mods, et cetera. So as you search the Internet for PON, 67 00:04:33,660 --> 00:04:36,520 you'll come across IDEs that are out there. Those are kind of 68 00:04:36,520 --> 00:04:39,280 really set up for like Team Fortress and stuff like that. So 69 00:04:39,280 --> 00:04:42,240 they kind of have their hooks in there. But, you know, some of 70 00:04:42,240 --> 00:04:46,260 those IDEs, I mean, you could use to do this with as well, 71 00:04:46,400 --> 00:04:50,300 right? You just have to know the APIs that are, you know, 72 00:04:51,020 --> 00:04:56,200 specific to this badge, which we'll talk about. You know, I 73 00:04:56,200 --> 00:04:57,140 think interpreted language is a little bit more complicated than 74 00:04:57,160 --> 00:04:57,460 PON is. But, you know, I think interpreted language is allowed 75 00:04:57,460 --> 00:05:02,060 for safe, PON is very fast and efficient updates to the embedded 76 00:05:02,060 --> 00:05:05,080 system. Safe in the sense that, you know, there really aren't 77 00:05:05,080 --> 00:05:07,700 any types, right? So you don't have to worry about stuff like 78 00:05:07,700 --> 00:05:12,060 that. All the details as far as like how to set up the can 79 00:05:12,060 --> 00:05:15,540 controller and send messages in and out and handle interrupts. 80 00:05:15,560 --> 00:05:19,400 All that is taken care of for you. So what you get in this PON 81 00:05:19,400 --> 00:05:24,360 environment is a very high level mechanism for sending, 82 00:05:24,480 --> 00:05:27,140 receiving messages and doing other things that embed them. So 83 00:05:27,140 --> 00:05:31,560 that's what embedded systems typically do. I think it's 84 00:05:31,560 --> 00:05:33,680 easier to write than traditional, but a programming 85 00:05:33,680 --> 00:05:38,560 paradigm for the reasons I just talked about, right? So as you'll 86 00:05:38,560 --> 00:05:42,280 see, some of these scripts that do, you know, some meaningful 87 00:05:42,280 --> 00:05:45,680 things are usually about six lines, ten lines long, right? 88 00:05:45,800 --> 00:05:49,300 And you can get a lot done. PON is open source. It was created 89 00:05:49,300 --> 00:05:51,300 by this gentleman, which I'm sure I'll pronounce his name 90 00:05:51,300 --> 00:05:57,060 wrong, Theadmir. And, you know, I have the link here as well for 91 00:05:57,140 --> 00:05:59,700 future reference. If you go to this website, you'll see all of 92 00:05:59,700 --> 00:06:04,200 his documentation, which is excellent. He did a great job 93 00:06:04,860 --> 00:06:08,080 documenting his creation, talking about how to use it, 94 00:06:08,880 --> 00:06:13,040 examples. The documentation is absolutely great. It's more 95 00:06:13,040 --> 00:06:16,780 than just like an API document would read. He gives a lot of 96 00:06:16,780 --> 00:06:21,060 motivations for the choices he made and he talks about, you 97 00:06:21,060 --> 00:06:24,280 know, compromises that he made when he designed this language. 98 00:06:24,460 --> 00:06:27,120 So I think the documentation is absolutely great. And I think, 99 00:06:27,140 --> 00:06:31,620 you know, it's perfect. Just some high level differences. And 100 00:06:31,620 --> 00:06:35,300 as you guys and gals dive into PON, you know, this is just 101 00:06:35,300 --> 00:06:38,960 stuff that I listed here off the top of my head. But, I mean, one 102 00:06:38,960 --> 00:06:41,200 of the big things, semicolons are optional at the end of 103 00:06:41,200 --> 00:06:44,840 statements in PON. If you put them there just out of habit, 104 00:06:45,060 --> 00:06:48,420 which I do, it doesn't hurt anything. You don't have to have 105 00:06:48,420 --> 00:06:53,920 them there. So there's really only one type, and that's kind 106 00:06:53,920 --> 00:06:56,960 of referred to as a cell. On this target, it's a 107 00:06:57,140 --> 00:07:02,620 32-bit quantity, right? So if you make an array, you know, 108 00:07:02,660 --> 00:07:08,600 every element in the array is 32 bits long. The tag itself, you 109 00:07:08,600 --> 00:07:14,780 know, has the capability to, I'll look back through here, but 110 00:07:14,780 --> 00:07:18,380 it's about 20K worth of RAM that's allocated towards the 111 00:07:19,120 --> 00:07:23,060 PON side of things. And I felt like with that, I mean, you can 112 00:07:23,060 --> 00:07:25,920 do a lot with that. I mean, even though they're four bytes in 113 00:07:25,920 --> 00:07:27,120 size and you might have a lot of RAM, you can do a lot with that. 114 00:07:27,140 --> 00:07:30,080 Big arrays. You should still be able to get a lot of stuff done. 115 00:07:30,940 --> 00:07:34,700 There are some new keywords, which we'll touch upon. It does 116 00:07:34,700 --> 00:07:37,100 support structured data, but not in the traditional, like, 117 00:07:37,120 --> 00:07:42,260 struct fashion that C does it. It basically uses, like, named 118 00:07:42,260 --> 00:07:46,020 elements in arrays. So you can assign, like, tags to array 119 00:07:46,020 --> 00:07:51,320 positions. So when you look at the code, it does kind of look 120 00:07:51,320 --> 00:07:56,740 like how you would get at C structure elements, but it's a 121 00:07:57,140 --> 00:08:00,180 little different how you have to set it up. There's no linking 122 00:08:00,180 --> 00:08:04,760 phase with the PON compiler. So if you have a script that spans 123 00:08:04,760 --> 00:08:07,920 multiple files, you have to pull them all together using 124 00:08:07,920 --> 00:08:16,000 includes. No function prototypes. And in this 125 00:08:16,000 --> 00:08:19,900 implementation, the badge implementation, there's no 126 00:08:19,900 --> 00:08:24,400 dynamic memory. So, you know, if globally allocated array, if 127 00:08:24,400 --> 00:08:27,120 you're going to use it across functions, right, if you're 128 00:08:27,140 --> 00:08:29,620 going to use it, if can messages are coming in, you know, 129 00:08:29,660 --> 00:08:33,020 you can use that data there, but once that function returns, that 130 00:08:33,020 --> 00:08:35,800 data is gone unless you copied it someplace else, et cetera, 131 00:08:35,860 --> 00:08:46,060 et cetera. So when we look at what PON is with the badge, you 132 00:08:46,060 --> 00:08:49,680 know, by its PON by itself, it's basically the language, the 133 00:08:49,680 --> 00:08:53,740 interpreter, the compiler, and some standard libraries that 134 00:08:53,740 --> 00:08:57,120 support core operations. That's part of the PON package. It's a 135 00:08:57,140 --> 00:09:01,180 language that you can download. It's freeware, et cetera. But 136 00:09:02,900 --> 00:09:08,800 really where PON shines is you can easily extend PON with these 137 00:09:08,800 --> 00:09:12,420 native extensions. So and this is what's been added for the 138 00:09:12,420 --> 00:09:15,760 badge. So there's things, there are extensions that you can get 139 00:09:15,760 --> 00:09:21,040 to that look just like function calls for the most part that 140 00:09:21,040 --> 00:09:24,100 allow you to do things like sending canned messages and 141 00:09:24,100 --> 00:09:27,120 setting timers and doing stuff like that. So, you know, it's a 142 00:09:27,120 --> 00:09:31,160 lot of fun. You know, the way I like to think of it is, you 143 00:09:31,160 --> 00:09:36,600 know, the badge provides this library of things you can do and 144 00:09:36,600 --> 00:09:38,900 PON is the thing that glues the application, you know, it's the 145 00:09:38,900 --> 00:09:46,480 application. It glues it all together. So QCM is, it's, I put 146 00:09:46,480 --> 00:09:50,120 this in here because you'll see references to QCM, you know, on 147 00:09:50,120 --> 00:09:53,080 the badge itself. There's like a rev and there's a part number, 148 00:09:53,160 --> 00:09:57,100 stuff like that. For lack of a better terminology, a wide 149 00:09:57,120 --> 00:09:58,080 variety of things. You know, a while ago I just came up with 150 00:09:58,080 --> 00:10:02,320 this idea like these quick canned module, which is kind of, I 151 00:10:02,320 --> 00:10:05,160 don't really like it too much, I guess, but it's, you know, it 152 00:10:05,160 --> 00:10:09,900 works, you know. It's just an acronym. And this badge is 153 00:10:09,900 --> 00:10:15,460 actually a mini version of this product suite that I have. You 154 00:10:15,460 --> 00:10:19,620 know, the more advanced versions of these things, and you can 155 00:10:19,620 --> 00:10:22,000 talk to me about them if you're interested in them. You know, add 156 00:10:22,000 --> 00:10:24,960 things like Wi-Fi and multiple can interfaces so you can do, 157 00:10:25,020 --> 00:10:27,100 like, easily canned gateway functionality. You know, you can, 158 00:10:27,100 --> 00:10:30,040 it runs three times faster. So if you're gatewaying canned 159 00:10:30,040 --> 00:10:33,180 messages, like, it's literally microseconds of delay between 160 00:10:33,180 --> 00:10:38,480 messages passing through back and forth. The badge, you know, 161 00:10:38,500 --> 00:10:41,900 you could, you could use two badges to kind of do that, but 162 00:10:41,900 --> 00:10:44,740 it won't be as fast and it won't be as feature rich as some of 163 00:10:44,740 --> 00:10:49,320 these other things. So the classic place that everybody 164 00:10:49,320 --> 00:10:56,400 starts, Hello World. So this is a fully compilable Hello World 165 00:10:57,100 --> 00:11:01,460 thing. And basically you can see that it looks like C, right? 166 00:11:01,540 --> 00:11:07,880 There's a main. And they use, you know, brackets to denote 167 00:11:07,880 --> 00:11:11,460 blocks. And they have a built-in function that's called 168 00:11:11,460 --> 00:11:17,000 printf that's just like C. No semicolons. And basically what 169 00:11:17,000 --> 00:11:21,720 this does is it calls this native extension called QCM 170 00:11:21,720 --> 00:11:24,920 console enable. What that does is that, and I'll talk about it 171 00:11:24,920 --> 00:11:27,080 here in the next slide a little bit more, but it basically, you 172 00:11:27,100 --> 00:11:29,700 know, allows the script to output through the UART port, 173 00:11:29,900 --> 00:11:33,280 right? Because by default the UART port is set to reprogram 174 00:11:33,280 --> 00:11:36,060 scripts. Well, you've got to tell the engine I want to take 175 00:11:36,060 --> 00:11:39,960 control of it so the scripts can do that. And then just to clean 176 00:11:39,960 --> 00:11:47,700 up at the end, we disable it. That's optional. So as I 177 00:11:47,700 --> 00:11:51,920 mentioned, scripts control the port's destiny. So if you want 178 00:11:51,920 --> 00:11:56,800 to do UART-based I.O. with the scripts, you've got to tell the 179 00:11:57,100 --> 00:12:00,460 system, I'm going to use the UART port. And that's how you do it 180 00:12:00,460 --> 00:12:05,880 with the QCM console enable. But the big thing is once you call 181 00:12:05,880 --> 00:12:09,420 that enable call, it's not going to pay attention. The badge is 182 00:12:09,420 --> 00:12:12,200 not going to pay attention to scripts trying to be loaded on 183 00:12:12,200 --> 00:12:15,780 to it anymore. Because the script itself has control of the 184 00:12:15,780 --> 00:12:20,720 UART port. So what happens if you call enable but you never 185 00:12:20,720 --> 00:12:24,240 call disable? Can you never program the badge again? Not 186 00:12:24,240 --> 00:12:27,080 the case. So there's up in the top corner, you've got the UART 187 00:12:27,080 --> 00:12:33,760 port of the badge. There's a jumper that up in the top right 188 00:12:33,760 --> 00:12:36,780 hand corner selects script clear when present which is also 189 00:12:36,780 --> 00:12:41,020 switch input. So when that jumper is closed and the module, you 190 00:12:41,020 --> 00:12:45,040 know, if you just like tweak the battery so it resets, it will 191 00:12:45,040 --> 00:12:48,780 not run the script and stay in loading mode. So if you have like 192 00:12:48,780 --> 00:12:52,280 a script that's blocking access to be able to reload it, this is 193 00:12:52,280 --> 00:12:55,900 the way to recover it. It's just an easy way. The rest of QCM 194 00:12:55,900 --> 00:12:57,060 modules have a switch on them. So if you have a script that's 195 00:12:57,080 --> 00:12:58,920 blocking access, it's a little bit more convenient because you 196 00:12:58,920 --> 00:13:01,800 just apply power while you're holding the switch and then it 197 00:13:01,800 --> 00:13:09,400 will just default into the loader mode. So I mentioned 198 00:13:09,400 --> 00:13:13,140 before and I've mentioned it to several of you guys, you know, 199 00:13:13,160 --> 00:13:20,720 the SDK is out there. Basically the SDK in itself consists of 200 00:13:20,720 --> 00:13:26,500 two utilities. This compiler, the PON compiler and this loader, 201 00:13:27,080 --> 00:13:30,920 it's something that allows you to load scripts onto the badge. It 202 00:13:30,920 --> 00:13:36,520 has some PON include files which are where all of these QCM 203 00:13:36,520 --> 00:13:43,360 extensions live, right? It has several examples which will go 204 00:13:43,360 --> 00:13:48,980 through some excerpts from those. And there is some 205 00:13:48,980 --> 00:13:52,740 documentation that's in there as well from the PON website that 206 00:13:52,740 --> 00:13:56,100 talks about, there's a great getting started guide for PON and 207 00:13:56,100 --> 00:13:57,060 then there's like the language guide. There's a lot of stuff 208 00:13:57,080 --> 00:13:59,760 about language reference guide. They're both really good to come 209 00:13:59,760 --> 00:14:05,120 up to speed quickly on the language. You know, there's no 210 00:14:05,120 --> 00:14:08,500 fancy IDE right now besides the ones that, you know, might be 211 00:14:08,500 --> 00:14:13,380 for some other implementation of PON. So, you know, use your 212 00:14:13,380 --> 00:14:17,420 favorite text editor, create scripts. You know, maybe someday 213 00:14:17,420 --> 00:14:22,040 there will be a specific IDE for it. But for now it's just a 214 00:14:22,040 --> 00:14:26,080 simple on a command line and I can give demos of this back at 215 00:14:26,080 --> 00:14:26,440 the village. 216 00:14:27,080 --> 00:14:32,020 I didn't bring my stuff here to do it. But, you know, in the 217 00:14:32,020 --> 00:14:36,080 SDK I'm going to invoke this thing called PONCC and I'm going 218 00:14:36,080 --> 00:14:39,800 to pass it a script that's hello world dot P. All the PON stuff 219 00:14:39,800 --> 00:14:42,240 ends with a dot P. At least that's the extension that I've 220 00:14:42,240 --> 00:14:47,180 always used. And when you run that, now you result, the 221 00:14:47,180 --> 00:14:50,600 resulting file that comes out is this hello world dot AMX. Which 222 00:14:50,600 --> 00:14:56,380 that is the compiled PON binary that's going to be sent to the 223 00:14:56,380 --> 00:14:57,060 module. So, you know, it's going to be a little bit more of a 224 00:14:57,960 --> 00:15:02,340 test. So, once you have this AMX thing, there's the second 225 00:15:02,340 --> 00:15:06,100 utility. This QCM loader utility which you'll see in the SDK and 226 00:15:06,100 --> 00:15:10,660 as I mentioned, we'll give examples of it. Where we call 227 00:15:10,660 --> 00:15:15,500 it and we basically give it the hello world dot AMX and you run 228 00:15:15,500 --> 00:15:18,680 that. You'll see output that says it loaded it to the badge 229 00:15:18,680 --> 00:15:23,240 and kaboom. You're good. There is one option. It's this dash 230 00:15:23,240 --> 00:15:27,040 C option. It's mainly there for convenience. So, when you have 231 00:15:27,060 --> 00:15:29,780 the dash C option there, basically what that does, it 232 00:15:29,780 --> 00:15:33,620 keeps the, in the QCM loader utility, it keeps the port open 233 00:15:33,620 --> 00:15:36,460 so that if you're using print Fs, it just is there. That way 234 00:15:36,460 --> 00:15:40,640 you don't have to like load the script and then, you know, once 235 00:15:40,640 --> 00:15:43,300 that's done, open up a different program like TerraTerm or some 236 00:15:43,300 --> 00:15:47,100 other serial, you know, terminal program to CIO. It will just do 237 00:15:47,100 --> 00:15:54,400 it right there. So, it's kind of convenient. So, we'll get a 238 00:15:54,400 --> 00:15:57,040 little bit further into like PON fundamentals. We're going to 239 00:15:57,040 --> 00:16:01,300 talk about PON fundamentals here. I really like how PON 240 00:16:01,300 --> 00:16:06,480 handles this concept of event handling. Basically, you know, 241 00:16:06,480 --> 00:16:10,260 when you look at an embedded system, you know, you have 242 00:16:10,260 --> 00:16:12,300 interrupt handlers, you have things that are always, the 243 00:16:12,300 --> 00:16:15,040 application is always responding to stimulus. The user pressed a 244 00:16:15,040 --> 00:16:18,260 button, a message received, something changed, a timer 245 00:16:18,260 --> 00:16:22,960 expired, et cetera, et cetera. You know, traditionally, I mean, 246 00:16:22,980 --> 00:16:25,020 you could either poll for them or you can set up, you know, 247 00:16:25,020 --> 00:16:27,020 interrupt handlers and you can have all this log in and log out 248 00:16:27,040 --> 00:16:30,800 of your project to do this stuff. The nice thing about PON is it 249 00:16:30,800 --> 00:16:34,600 has this built in concept of these event handlers. Things 250 00:16:34,600 --> 00:16:40,440 that will seemingly be called asynchronously when these types 251 00:16:40,440 --> 00:16:45,140 of events occur. They look a lot like functions. But they 252 00:16:45,140 --> 00:16:49,020 just have a special name. And we'll see here what they look 253 00:16:49,020 --> 00:16:54,740 like. So, just keep this event handler thing in the back of 254 00:16:54,740 --> 00:16:56,640 your mind. You're going to see some here coming up in these 255 00:16:57,040 --> 00:17:01,240 examples, this next one. So, you know, there are basically, you 256 00:17:01,240 --> 00:17:06,400 know, a core set of functionality that is exposed to PON. You 257 00:17:06,400 --> 00:17:09,600 know, the first one, the first fundamental one is timers. 258 00:17:10,020 --> 00:17:12,340 Embedded system, you got to have a timer, right? I got to 259 00:17:12,340 --> 00:17:14,420 send a message every 250 milliseconds. I have to change a 260 00:17:14,420 --> 00:17:17,660 GPIO port pin every 500 milliseconds. I got to get an 261 00:17:17,660 --> 00:17:21,740 event, wait one second and do something else, right? So, the 262 00:17:21,740 --> 00:17:26,640 badge supports five timers. Two modes. You can either be a one 263 00:17:26,640 --> 00:17:33,040 time timer or it can repeat over and over again. And the way the 264 00:17:33,040 --> 00:17:35,660 code looks, again, you'll see the main. But you see this other 265 00:17:35,660 --> 00:17:38,540 function up here now. It's called timer zero. And the SDK 266 00:17:38,540 --> 00:17:40,980 talks about, you know, the special names for these things. 267 00:17:41,160 --> 00:17:45,840 But what this says is, if we look at the main first, we call 268 00:17:45,840 --> 00:17:49,260 this function called timer start. We tell it we want to 269 00:17:49,260 --> 00:17:54,100 start timer zero. We tell it the number of milliseconds. And 270 00:17:54,100 --> 00:17:56,620 then the last, the last thing is, is the number of milliseconds. 271 00:17:56,640 --> 00:17:59,260 Do you want it to just be a one time timer or do you want it to 272 00:17:59,260 --> 00:18:03,080 go off all the time? You know, so when 250 milliseconds goes by, 273 00:18:03,160 --> 00:18:05,420 it restarts itself and you'll get an event, you'll get an 274 00:18:05,420 --> 00:18:09,200 event, you'll get an event. So, what this says and how this is 275 00:18:09,200 --> 00:18:12,560 going to work is, you know, the second you call QCM timer start, 276 00:18:12,700 --> 00:18:16,080 that timer is going to start and that event handler at timer zero 277 00:18:16,080 --> 00:18:21,020 is going to run when that timer expires, right? So, think of 278 00:18:21,020 --> 00:18:25,120 them as like event handlers are, they're your functions that 279 00:18:25,120 --> 00:18:26,620 have a specific name. And they're going to run when that 280 00:18:27,380 --> 00:18:31,760 seemingly get called somehow, right? The system calls them 281 00:18:31,760 --> 00:18:35,240 when these events occur. So, very simply, when the timer 282 00:18:35,240 --> 00:18:38,000 expires, you have, you know, inside of timer zero, it 283 00:18:38,000 --> 00:18:42,120 prints timer expired, right? Very, very straightforward, I 284 00:18:42,120 --> 00:18:46,560 think. When we start looking at GPIO, this is the other core 285 00:18:46,560 --> 00:18:48,720 functionality, right? So, we're going to have timers, we're 286 00:18:48,720 --> 00:18:54,060 going to have GPIO, we're going to have CAN, right? GPIO, the 287 00:18:54,060 --> 00:18:57,180 badge has four output channels and it has six input channels. 288 00:18:59,060 --> 00:19:01,400 When we look at like output functionality, they can be 289 00:19:01,400 --> 00:19:06,260 driven high or low from the scripts. Inputs, there are two 290 00:19:06,260 --> 00:19:08,780 ways you can read inputs. You can either pull for them, right, 291 00:19:08,900 --> 00:19:11,540 through a function to say, hey, give me the state of this input 292 00:19:12,100 --> 00:19:15,360 or you can set up those event handlers that I was talking 293 00:19:15,360 --> 00:19:20,680 about to where you specify, hey, I want to be, I want an 294 00:19:20,680 --> 00:19:23,540 event every time this GPIO goes from low to high or do you want 295 00:19:23,540 --> 00:19:26,620 an event every time it goes from high to low or any time it 296 00:19:26,620 --> 00:19:29,700 changes, right? You can call these event handlers or the event 297 00:19:29,700 --> 00:19:34,680 handler be called. They aren't debounced, so if you're trying 298 00:19:34,680 --> 00:19:37,780 to do stuff, you know, with your hand, right, you're going to see 299 00:19:37,780 --> 00:19:40,520 a lot of events come out, right? But that's kind of 300 00:19:40,520 --> 00:19:43,900 intentional because I want the GPIOs to respond as fast as 301 00:19:43,900 --> 00:19:49,880 possible, to be as flexible as possible. So, if we look at 302 00:19:49,880 --> 00:19:52,660 another quick example here, again, you know, I always start 303 00:19:52,660 --> 00:19:53,520 with these scripts. I just look at, you know, I always start 304 00:19:53,540 --> 00:19:56,940 with the main first because main is going to run and once main 305 00:19:56,940 --> 00:20:00,840 falls off the end, pawn is kind of in this idle state waiting 306 00:20:00,840 --> 00:20:05,080 for events, right? So typically a lot of the example scripts 307 00:20:05,080 --> 00:20:09,560 you'll see in the SDK, all main does is it sets up what you want 308 00:20:09,560 --> 00:20:12,440 set up and then everything else is handled by event handlers. 309 00:20:13,100 --> 00:20:17,560 Now, main can stick around. You can call a built-in routine 310 00:20:17,560 --> 00:20:21,060 called sleep inside of like a while loop or something like 311 00:20:21,060 --> 00:20:23,520 that so that it allows the other stuff to, you know, get 312 00:20:23,540 --> 00:20:27,360 to do what it needs to do. But what's happening here is, you 313 00:20:27,360 --> 00:20:29,740 know, there's this call way at the bottom to say, you know, 314 00:20:29,780 --> 00:20:35,060 let's configure this GPIO handler and what handler do we want to 315 00:20:35,060 --> 00:20:37,740 configure? Well, we want to configure this input OBD2, 316 00:20:38,200 --> 00:20:42,960 right? And we just want to know any time we get an event. So 317 00:20:42,960 --> 00:20:45,520 event all means any time it goes from low to high or any time it 318 00:20:45,520 --> 00:20:50,300 goes from high to low, right? And what we'll see here is every 319 00:20:50,300 --> 00:20:53,180 time you plug in the OBD2 connector, that event is going to 320 00:20:53,180 --> 00:20:56,040 be called. When you unplug the OBD2 connector, that event is 321 00:20:56,040 --> 00:21:00,680 going to be called, right? And all this event handler does up 322 00:21:00,680 --> 00:21:05,860 here, this at GPIO input OBD2 is it does the pull mechanism, 323 00:21:06,300 --> 00:21:10,780 right? So if let's get the input OBD2, if that's high, well, we 324 00:21:10,780 --> 00:21:13,440 know there's voltage there and it's plugged in. If it's low, 325 00:21:13,580 --> 00:21:17,040 well, we know somebody unplugged it, right? So, you know, all 326 00:21:17,040 --> 00:21:19,560 the inputs you can set up this way, right? So like if you 327 00:21:19,560 --> 00:21:22,880 wanted to watch, you know, all six inputs that are available, 328 00:21:23,180 --> 00:21:26,180 you'd have six input, you know, the six handlers up here to do 329 00:21:26,180 --> 00:21:30,740 what you need and you'd have six GPIO configure handler calls down 330 00:21:30,740 --> 00:21:35,820 there to set them up the way you want to set them up. So when 331 00:21:35,820 --> 00:21:38,820 we talk about the UART that the script can do, we've already 332 00:21:38,820 --> 00:21:43,140 seen printf, right? That output stuff. But there's also an event 333 00:21:43,140 --> 00:21:48,100 handler there to process data received on UART. So it is 334 00:21:48,100 --> 00:21:52,340 buffered and basically the way that it works is you basically 335 00:21:53,180 --> 00:21:57,560 define in your script, you just have this at host RX event 336 00:21:57,560 --> 00:22:01,360 handler. The native stuff will see that and it will just say 337 00:22:01,360 --> 00:22:06,260 anything I receive on UART, I'm going to direct to this. So you 338 00:22:06,820 --> 00:22:10,520 domain, we enable the console because we have to. And then 339 00:22:10,520 --> 00:22:13,660 this routine here basically we get past the data that we got 340 00:22:13,660 --> 00:22:18,560 and we get past the size, right? The data is an array up to 16 341 00:22:18,560 --> 00:22:22,640 bytes and data size, of course, tells us how many bytes we got. 342 00:22:23,180 --> 00:22:27,080 And all this does is it just prints out what we received in 343 00:22:27,080 --> 00:22:36,240 hexadecimal format. Excuse me. So we get into CAN interfaces. 344 00:22:38,260 --> 00:22:43,860 Three ways to get CAN messages. So we can tell the system we're 345 00:22:43,860 --> 00:22:49,080 interested in specific CAN ID. Excuse me. That's the 346 00:22:49,080 --> 00:22:52,600 recommended approach because it filters out a lot of messages. 347 00:22:53,300 --> 00:22:59,900 Like if you look at a high speed HS CAN bus over OBD2, you might 348 00:22:59,900 --> 00:23:06,340 see a flood of messages. So that leads me to the next one. You 349 00:23:06,340 --> 00:23:11,600 can also set this up to receive all the messages. On some 350 00:23:11,600 --> 00:23:14,260 vehicles that might be a problem for the reason I just mentioned. 351 00:23:14,500 --> 00:23:18,040 Other vehicles have a gateway between the OBD2 connector and 352 00:23:18,040 --> 00:23:22,840 the actual, you know, internal bus. In that case, it wouldn't 353 00:23:22,840 --> 00:23:25,620 be a problem turning on all received messages because you 354 00:23:25,620 --> 00:23:27,200 really aren't going to be getting that much stuff back. 355 00:23:28,500 --> 00:23:30,900 And, of course, you can use both. That's the third way. You 356 00:23:30,900 --> 00:23:33,880 know, you could have some that are specific IDs and you could 357 00:23:33,880 --> 00:23:36,820 have some that you can have the catch all handler that catches 358 00:23:36,820 --> 00:23:44,060 everything else, right? So when we look at this, again, starting 359 00:23:44,060 --> 00:23:47,560 with main, there's a function. When you look in the SDK, you'll 360 00:23:47,560 --> 00:23:51,200 see it. It's called QCM CANINIT. We tell it the baud 361 00:23:51,200 --> 00:23:52,820 rate. Okay. Well, we want to open up the system. We want to 362 00:23:52,840 --> 00:23:56,820 have the CAN channel at 500 kilobits per second. And then 363 00:23:56,820 --> 00:23:59,360 just like what we saw with the GPIOs, there's another call 364 00:23:59,360 --> 00:24:04,900 that's CAN configure RX handler. It looks like the GPIO configure 365 00:24:04,900 --> 00:24:10,340 handler. We tell it what handler we want to use. In this 366 00:24:10,340 --> 00:24:13,380 case, it's handler number zero. Hence why we have the event 367 00:24:13,380 --> 00:24:19,600 handler up there that ends with zero, CAN RX zero. There are, I 368 00:24:19,600 --> 00:24:22,820 believe there are eight. You can have up to eight. You can have 369 00:24:22,840 --> 00:24:27,740 eight handlers, eight or ten, to look at the documentation. But 370 00:24:27,740 --> 00:24:29,960 what this is saying is okay, well, let's set up this CAN 371 00:24:30,520 --> 00:24:37,940 handler for handler zero. We're interested in ID hex 70 zero. And 372 00:24:37,940 --> 00:24:42,460 the last false means it's 11 bit. Is it extended is the last 373 00:24:42,460 --> 00:24:47,700 parameter. So as soon as main falls off the end, the system 374 00:24:47,700 --> 00:24:50,840 is configured and it's just sitting around waiting for the 375 00:24:52,580 --> 00:24:52,820 add const, for the const of the system. And then you can tell, 376 00:24:52,840 --> 00:24:57,400 can RX0 event handler be called? And as soon as we receive a 70 377 00:24:57,400 --> 00:25:01,880 zero, kaboom, this gets called and my test code inside of here 378 00:25:01,880 --> 00:25:04,800 basically just prints out the fields and this is what I was 379 00:25:04,800 --> 00:25:08,300 talking about structured data. So there's this thing that looks 380 00:25:08,300 --> 00:25:12,520 like an array, this RX message, but it has this capital QCM CAN 381 00:25:12,520 --> 00:25:15,820 message inside of it. If you look in the SDK include 382 00:25:15,820 --> 00:25:19,780 directory, you will see the definition for this QCM CAN 383 00:25:19,780 --> 00:25:24,700 message that sets up the structured data for this RX 384 00:25:24,700 --> 00:25:28,540 message. And you can see in the prunef when we actually get into 385 00:25:28,540 --> 00:25:32,040 that structured data, it looks a lot like C, how we would do it. 386 00:25:32,120 --> 00:25:36,820 So it's RX message.ID, RX message is extended, RX message 387 00:25:36,820 --> 00:25:41,600 TLC, which is the length of the message on the CAN bus. We loop 388 00:25:41,600 --> 00:25:44,620 through the data because that's an embed, there's a member 389 00:25:44,620 --> 00:25:48,520 inside of QCM CAN message inside of the RX message that 390 00:25:49,060 --> 00:25:49,760 basically is the data that we're going to be sending to the 391 00:25:49,780 --> 00:25:51,760 QCM CAN. This is an array of all the data that came in the 392 00:25:51,760 --> 00:25:56,240 message and we print it out. And then just as part of this test, 393 00:25:56,440 --> 00:25:59,700 we change the ID to 78 and we just transmit the message back 394 00:25:59,700 --> 00:26:03,540 out. So that's what the QCM CAN TX. As soon as you call QCM CAN 395 00:26:03,540 --> 00:26:08,820 TX, it sends it, right? So, you know, you could see it's pretty 396 00:26:08,820 --> 00:26:12,660 easy if you wanted to just set something up that, let's say we 397 00:26:12,660 --> 00:26:18,340 wanted to reverse this where we make a diagnostic request to 70 398 00:26:19,780 --> 00:26:24,020 and we're interested in the response, say, on address 78. 399 00:26:24,680 --> 00:26:27,960 Well, the way that we would modify this is we would set up 400 00:26:27,960 --> 00:26:32,540 our RX handler for 78 because we're interested on, you know, 401 00:26:32,560 --> 00:26:35,460 that message coming back. And then we would just transmit the 402 00:26:35,460 --> 00:26:38,620 message that we want. As soon as the engine responds, we would 403 00:26:38,620 --> 00:26:41,700 get it and we would process it, right? To reverse this example. 404 00:26:42,260 --> 00:26:45,400 This is kind of like from the perspective of the other side. 405 00:26:48,240 --> 00:26:49,760 So one of the last things I wanted to talk about is the 406 00:26:49,780 --> 00:26:54,220 extension that to see, I think, is pretty important to talk 407 00:26:54,220 --> 00:26:57,360 about in regards to Pawn. Because Pawn is basically 408 00:26:58,280 --> 00:27:03,200 designed for embedded systems. It has this concept of built-in 409 00:27:03,200 --> 00:27:08,240 state machine automation. And the way that it works is, you 410 00:27:08,240 --> 00:27:11,900 know, we saw these event handlers up here like CAN RX0 411 00:27:11,900 --> 00:27:17,320 and stuff like that. The way it works is you can define several 412 00:27:17,320 --> 00:27:19,760 of the same event handlers. And then you can set up that 413 00:27:19,780 --> 00:27:24,300 server, but tell it in what state you want that event to be 414 00:27:24,300 --> 00:27:32,220 handled. So you could have here's an example where let's 415 00:27:32,220 --> 00:27:38,040 just do a PWM signal on a GPIO. So we start a timer, timer zero, 416 00:27:38,320 --> 00:27:41,740 250 milliseconds, only this time we pass it true because we want 417 00:27:41,740 --> 00:27:45,540 it to just run all the time. And then we use this Pawn built 418 00:27:45,540 --> 00:27:49,760 in keyword called state, which means set the state to the state 419 00:27:49,780 --> 00:27:52,820 I'm going to tell you. So we're going to initialize the state to 420 00:27:52,820 --> 00:27:56,540 the state called PWM low. And then you'll see in the event 421 00:27:56,540 --> 00:28:00,100 handlers above for timer zero, there are two of them. And the 422 00:28:00,100 --> 00:28:06,320 first one has this construct after it that says PWM low. And 423 00:28:06,320 --> 00:28:09,660 the next timer zero one has this other construct for PWM high. 424 00:28:10,600 --> 00:28:16,280 What that means is if the internal state machine is in the 425 00:28:16,280 --> 00:28:19,600 state PWM low and you get a timer zero event, it's going to 426 00:28:19,600 --> 00:28:22,780 call that top one. If the state, if the internal state 427 00:28:22,780 --> 00:28:25,680 machine was in the state called PWM high, which you can just make 428 00:28:25,680 --> 00:28:29,240 these state machine names up, I mean, the state names on the fly, 429 00:28:29,400 --> 00:28:32,760 right? The compiler knows how to deal with them. It will call the 430 00:28:32,760 --> 00:28:36,560 PWM high one if you're in that state. So you can kind of see 431 00:28:36,560 --> 00:28:39,340 here what's going to happen is timer zero is going to get 432 00:28:39,340 --> 00:28:43,820 called first because when that timer expires, it's going to set 433 00:28:43,820 --> 00:28:46,300 the output to false and then it's going to set the state to 434 00:28:46,300 --> 00:28:49,580 PWM high. And because the timer is repeated, it's going to call 435 00:28:50,280 --> 00:28:52,040 the PWM high. And then the timer is going to go off again in 436 00:28:52,040 --> 00:28:56,040 250 milliseconds. Well, only now we're in the PWM high state so 437 00:28:56,040 --> 00:29:00,440 the PWM high timer zero handler is going to get called. So on. 438 00:29:00,520 --> 00:29:03,800 And then it sets low, so on and so forth. That's basically how, 439 00:29:03,980 --> 00:29:06,400 you know, you've seen how I have the scrolling stuff coming 440 00:29:06,400 --> 00:29:11,980 across here. I just have a lot of timer zero events set up at a 441 00:29:11,980 --> 00:29:15,920 certain interval and every, and with states and it basically 442 00:29:15,920 --> 00:29:19,580 just walks through and sets the LCD accordingly. Right? And then 443 00:29:19,600 --> 00:29:24,100 every time that expires. So it's kind of a good thing, like 444 00:29:24,100 --> 00:29:27,020 if you wanted to handle, you know, like message sequencing, 445 00:29:27,380 --> 00:29:31,640 right? So like, you know, you send a CAN message and you're 446 00:29:31,640 --> 00:29:35,780 going to get back, you send a CAN message and you set the 447 00:29:35,780 --> 00:29:40,100 state. You're going to get back a response that you're going to 448 00:29:40,100 --> 00:29:43,160 want to process in a certain way. Let's say it's, you know, 449 00:29:43,160 --> 00:29:46,840 on a specific ID. You're going to send something else back out 450 00:29:46,840 --> 00:29:49,460 and you're going to get a, you're going to get different 451 00:29:49,600 --> 00:29:52,380 data, but with like the same ID. Well, you could just have 452 00:29:52,380 --> 00:29:55,720 different states for that CAN handler, so on and so forth. So 453 00:29:56,300 --> 00:30:03,240 it's just kind of a way to automate that. I want to see 454 00:30:03,240 --> 00:30:19,080 something here. Okay. So I was actually going to open up, I was 455 00:30:19,600 --> 00:30:25,260 going to open that up here real quick. Maybe. 456 00:30:57,380 --> 00:31:00,520 And I was just going to show you the example that, you know, 457 00:31:00,540 --> 00:31:08,540 this badge is using to show that data. So basically what you'll 458 00:31:08,540 --> 00:31:13,000 see in here is, and this, again, is in the SDK, how to 459 00:31:13,000 --> 00:31:17,400 control this LCD. I copied it here for my reference. But there 460 00:31:17,400 --> 00:31:19,580 are several of these at timer, timer, timer, timer, timer, 461 00:31:20,220 --> 00:31:23,540 event handlers for every single state. And by far, this isn't 462 00:31:23,540 --> 00:31:25,800 like the most efficient way to do it at all. Like you could set 463 00:31:25,800 --> 00:31:27,900 up an array that has the characters in it and walk 464 00:31:27,900 --> 00:31:33,160 through, et cetera, et cetera. But this, this was, was fast to 465 00:31:33,160 --> 00:31:38,160 do. So, you know, first state is CAR. Those binary things, if 466 00:31:38,160 --> 00:31:40,280 you look at the SDK, that's controlling the individual 467 00:31:40,860 --> 00:31:45,500 segments so the car shows up. The next one comes in. It shifts 468 00:31:45,500 --> 00:31:49,240 it one over. It says AR and X I use for space. And then I set the 469 00:31:49,240 --> 00:31:49,580 next state. And then I set the next state. And then I set the 470 00:31:49,600 --> 00:31:55,340 state. Next state is R space H. The next state is space HA. 471 00:31:55,640 --> 00:31:59,920 The next space is, or the next state is HAC. So on and so forth. 472 00:32:00,740 --> 00:32:03,420 Just to achieve this scrolling effect. So there's a lot of 473 00:32:03,420 --> 00:32:07,100 these timer zero event handlers. One for every state. And way 474 00:32:07,100 --> 00:32:10,660 down here in Maine, I initialize the state to the first one where 475 00:32:10,660 --> 00:32:14,460 it starts with the word CAR or the letter CAR. And then I set 476 00:32:14,460 --> 00:32:18,260 up the timer to run every 250 milliseconds. It just walks 477 00:32:18,260 --> 00:32:18,980 through. So. 478 00:32:19,600 --> 00:32:20,440 It's kind of like the. 479 00:32:30,660 --> 00:32:35,280 So as you learn more about PON and dig into it, you'll see 480 00:32:35,280 --> 00:32:38,640 that, you know, there are things that can be turned on or off 481 00:32:38,640 --> 00:32:43,280 depending upon how PON is being used in the system. And these 482 00:32:43,280 --> 00:32:46,940 are choices that I've made. I have enabled floating point. So 483 00:32:46,940 --> 00:32:49,580 because I thought that that was pretty important. You know, if 484 00:32:49,580 --> 00:32:50,000 you have a bus, you can just give it a little bit of time to 485 00:32:50,000 --> 00:32:54,460 of data that comes over CAN. You know, might be expressed in a 486 00:32:54,460 --> 00:32:58,380 certain unit. That you might have to multiply by some factor 487 00:32:58,380 --> 00:33:03,100 in order to get what you actually need. So like miles per 488 00:33:03,100 --> 00:33:06,080 hour might be expressed in kilometers an hour. But it's, 489 00:33:06,080 --> 00:33:08,520 you know, offset by a certain number of bits so that they can 490 00:33:08,520 --> 00:33:12,000 do fractional values over the bus. If you have floating point 491 00:33:12,000 --> 00:33:14,240 built into the script it's very easy to do that. You don't have 492 00:33:14,240 --> 00:33:16,440 to do any integer mass shifting, all that other stuff. 493 00:33:16,520 --> 00:33:19,240 You can just multiply it by a factor and just be done with it. 494 00:33:20,980 --> 00:33:26,020 As I mentioned, there's no dynamic memory allocation. Almost 495 00:33:26,020 --> 00:33:28,660 all the core pawn stuff is there. So as you read through 496 00:33:28,660 --> 00:33:31,900 pawn, you'll see a lot of these native routines that ship with 497 00:33:31,900 --> 00:33:36,700 stock. They're almost all there except like a couple of string 498 00:33:36,700 --> 00:33:39,160 routines. I didn't think it would be useful to have like the 499 00:33:39,160 --> 00:33:43,060 UU encode, UU decode routines in the target. So they're just 500 00:33:43,060 --> 00:33:48,500 taking up space, got rid of them. Unix time stamping, stuff 501 00:33:48,500 --> 00:33:51,680 like that. They also have some socket stuff where you can send 502 00:33:51,680 --> 00:33:55,140 UDP and like the core example obviously doesn't apply to this 503 00:33:55,140 --> 00:34:01,440 at this point. When I mentioned the sleep, you know, there is a 504 00:34:01,440 --> 00:34:04,680 sleep routine that can be called in the main routine to kind of 505 00:34:04,680 --> 00:34:11,680 like allow event handlers to run. And, you know, the ‑‑ I'm 506 00:34:11,680 --> 00:34:14,560 basically using the latest version of pawn that you can 507 00:34:14,560 --> 00:34:18,480 find out there. And it's actually a little bit more than 508 00:34:18,480 --> 00:34:22,180 that because I have other contributions that have not been 509 00:34:22,180 --> 00:34:25,880 accepted back into the core edition to work around some bugs 510 00:34:25,880 --> 00:34:29,660 that I've come across when using it. So it really is kind of 511 00:34:29,660 --> 00:34:32,700 like the bleeding edge of a pawn that's inside of here. I 512 00:34:32,700 --> 00:34:36,120 mean, pawn isn't used in a lot of places. But there were some 513 00:34:36,120 --> 00:34:38,840 real show stopper bugs that would not make some of those 514 00:34:38,840 --> 00:34:46,920 examples even possible, right, without these fixes. So as I 515 00:34:46,920 --> 00:34:48,460 mentioned, look in the SDK. I'm going to go ahead and show you 516 00:34:48,480 --> 00:34:52,180 that. Download it. Carhackingvillage.com. You will 517 00:34:52,180 --> 00:34:55,680 see ‑‑ it's structured very well. You will be able to go and 518 00:34:55,680 --> 00:34:59,220 find your way. I will be available at all times 519 00:34:59,220 --> 00:35:02,860 throughout the con back at the Carhacking Village. Come and talk 520 00:35:02,860 --> 00:35:06,360 to me. We can write scripts. I'll show you how to load them. 521 00:35:06,540 --> 00:35:12,320 We can go through all of that stuff. I basically listed a 522 00:35:12,320 --> 00:35:14,480 couple of ideas because some of you might be like, okay, well, 523 00:35:14,500 --> 00:35:17,120 this is great. We can script this thing. What are we going to 524 00:35:17,120 --> 00:35:18,460 do? Right? So I'm going to go ahead and show you a couple of 525 00:35:18,460 --> 00:35:21,900 ideas. You know, we saw a script that waits for OBD2 to be 526 00:35:21,900 --> 00:35:25,960 connected. So, you know, let's use that to our advantage. So 527 00:35:25,960 --> 00:35:30,640 like maybe let's use a script that waits for the OBD2 to be 528 00:35:30,640 --> 00:35:34,220 connected, then listens for some particular CAN message and shows 529 00:35:34,220 --> 00:35:37,140 it on the display. So like let's say we wanted to show 530 00:35:37,140 --> 00:35:41,240 vehicle speed on the display. Would be very easy to do on a 531 00:35:41,240 --> 00:35:46,760 lot of vehicles. Right? You can make a simple CAN diagnostic 532 00:35:50,320 --> 00:35:56,320 stuff. That basically just dumps over the UART CAN messages of 533 00:35:56,320 --> 00:36:00,140 interest. Right? So it's a way to just, you know, make like a 534 00:36:00,140 --> 00:36:04,480 CAN sniffer. Because the scripts are persistent. And, you know, 535 00:36:04,600 --> 00:36:08,400 they're stored when you remove power, of course. I mean, you 536 00:36:08,400 --> 00:36:12,500 could program this thing to as you plug it into vehicles, you 537 00:36:12,500 --> 00:36:17,420 know, do some diagnostic stuff. Query something and send it over UART. 538 00:36:18,860 --> 00:36:22,500 Figure out something to set and set it on a lot of things or, 539 00:36:22,620 --> 00:36:31,120 you know, things like that. You could wait for data on the CAN 540 00:36:31,120 --> 00:36:34,920 bus and then resend that data, but format it a little bit 541 00:36:34,920 --> 00:36:37,640 differently. And depending upon your timing there, you might 542 00:36:37,640 --> 00:36:41,500 cause the vehicle to do things that you want it to do, not what 543 00:36:41,500 --> 00:36:45,720 it's going to do. Example of this might be, you know, you 544 00:36:45,720 --> 00:36:48,440 just saw the speed message come over. You know, you just saw the 545 00:36:48,460 --> 00:36:52,560 CAN bus. Change the speed and send it out immediately. I mean, 546 00:36:52,580 --> 00:36:55,580 it's going to be sent within, you know, under a millisecond. So 547 00:36:56,020 --> 00:36:58,620 the things that are paying attention to speed are going to 548 00:36:58,620 --> 00:37:01,040 see that first message, but they're also going to see your 549 00:37:01,040 --> 00:37:03,120 message. And they're probably going to take your message over 550 00:37:03,120 --> 00:37:05,720 the one because they always take the latest data. So if you're 551 00:37:05,720 --> 00:37:08,400 always triggering off of a CAN message and you're always 552 00:37:08,400 --> 00:37:13,120 resending it immediately afterwards, you can alter what 553 00:37:13,120 --> 00:37:17,780 the vehicle might display or do. An interesting one would be, you 554 00:37:17,780 --> 00:37:18,440 know, let's link two different things. One is, you know, the 555 00:37:18,460 --> 00:37:22,440 two badges together and make a crude gateway where you could 556 00:37:22,440 --> 00:37:27,580 actually interrupt, you can cut the CAN bus, put one listener 557 00:37:27,580 --> 00:37:31,000 here and a transmitter over here, maybe make it 558 00:37:31,000 --> 00:37:34,520 bidirectional so you can actually, for the nodes that you 559 00:37:34,520 --> 00:37:38,020 can't just repeat data, you want to intercept something that's 560 00:37:38,020 --> 00:37:41,840 being sent and you want to modify it so that something else, 561 00:37:41,900 --> 00:37:46,520 you know, believes what's not really true. Two badges could be 562 00:37:46,520 --> 00:37:48,440 used to do that. You know, a potential example might be, you 563 00:37:48,460 --> 00:37:54,320 know, a lot of OEM head units won't, that could play DVDs, 564 00:37:54,320 --> 00:37:57,020 won't play them if the vehicle is moving. Well, they're paying 565 00:37:57,020 --> 00:37:59,900 attention to the speed message and maybe it's not enough to 566 00:37:59,900 --> 00:38:03,100 just retransmit it. Maybe you actually have to intercept the 567 00:38:03,100 --> 00:38:06,180 speed message, modify it and retransmit it. But let 568 00:38:06,180 --> 00:38:09,540 everything else go through. You know, you could use two badges 569 00:38:09,540 --> 00:38:12,180 to do that. You know, link them together over UART, couple 570 00:38:12,180 --> 00:38:18,440 scripts on each side, bang, it's done. And, you know, you can 571 00:38:18,460 --> 00:38:21,780 of course, you don't have to use the OBD2 interface on the 572 00:38:21,780 --> 00:38:25,400 badge. I mean, you have some IOs, you got UART, you have a 573 00:38:25,400 --> 00:38:29,120 display. Interface it to something else and, you know, 574 00:38:29,120 --> 00:38:37,180 use PON to your advantage there as well. So, you know, as I 575 00:38:37,180 --> 00:38:40,740 mentioned, feel free to grab me any time. I put my e-mail 576 00:38:40,740 --> 00:38:43,000 address in here. You know, if you guys want to spam me with 577 00:38:43,000 --> 00:38:48,440 stuff, it's easy to set up filters. And, you know, you can 578 00:38:48,460 --> 00:38:50,800 just, you know, I'm curious to know about your badge 579 00:38:50,800 --> 00:38:55,020 experiences. So come and tell me or, you know, feel free to post 580 00:38:55,020 --> 00:38:58,840 stuff to Twitter, you know, to CHV badge and share your 581 00:38:58,840 --> 00:39:01,640 experiences. But I guess I'll just open up for questions. I 582 00:39:01,640 --> 00:39:04,760 mean, I just kind of wanted to give a high-level overview as far 583 00:39:04,760 --> 00:39:08,520 as, you know, what the system is, what it can kind of do. You 584 00:39:08,520 --> 00:39:10,300 know, until you get in and actually play with it a little 585 00:39:10,300 --> 00:39:12,760 bit, it will probably become a little bit more concrete. But 586 00:39:14,220 --> 00:39:14,940 any questions? 587 00:39:18,580 --> 00:39:24,280 How do you get it? Carhackingvillage.com, which I 588 00:39:24,280 --> 00:39:27,940 think I mentioned in here. You can download the SDK there. 589 00:39:28,220 --> 00:39:35,660 That's where it lives. And the badges, if everybody doesn't 590 00:39:35,660 --> 00:39:39,560 have them, we sold out this morning. We will have at least 591 00:39:39,560 --> 00:39:44,160 80 more for sale tomorrow starting at 10. So you'll have 592 00:39:44,160 --> 00:39:45,020 another chance to get them. 593 00:39:52,940 --> 00:40:12,060 They are 50. Yes? Say again? I would attend some of the other 594 00:40:12,860 --> 00:40:15,900 TurboTalks that we're doing back in the village. There are 595 00:40:15,900 --> 00:40:18,440 some talks that address exactly what you're talking about. So if 596 00:40:18,440 --> 00:40:21,500 you have a question, you can go to the chat. We go through some 597 00:40:21,500 --> 00:40:26,460 CAN bus examples. We talk about, you know, the types of things 598 00:40:26,460 --> 00:40:29,720 that you can do over OBD and what that looks like and what 599 00:40:29,720 --> 00:40:32,520 CAN messaging looks like. You know, the whole concept. Right? 600 00:40:32,760 --> 00:40:36,660 If you're familiar with like, you know, traditional 601 00:40:36,660 --> 00:40:41,700 networking, depending upon your level of familiarity with it, 602 00:40:41,780 --> 00:40:46,300 you'll probably find CAN bus to be about 20 years behind that. 603 00:40:47,600 --> 00:40:48,420 It's very, very different than, you know, the other things that 604 00:40:48,440 --> 00:40:52,180 we do. It's a very simplistic messaging paradigm. And, you 605 00:40:52,180 --> 00:40:56,100 know, you'll catch on to it very fast. Because there are some 606 00:40:56,980 --> 00:40:59,480 methodologies that all the manufacturers use to transmit 607 00:40:59,480 --> 00:41:02,040 data back and forth. And there are some standards in place. 608 00:41:02,220 --> 00:41:05,320 But when it all boils down, you know, I like to think of CAN, 609 00:41:05,440 --> 00:41:10,480 it's kind of like UDP to a certain extent where it's a fire 610 00:41:10,480 --> 00:41:14,940 and forget type bus and there's a fixed payload and the 611 00:41:14,940 --> 00:41:18,420 receivers get it. And that's how it goes. So it's kind of like a 612 00:41:18,440 --> 00:41:23,000 reverse. Right? I mean, it's pretty simplistic. But, yeah, 613 00:41:23,060 --> 00:41:26,560 grab us. Come to more TurboTalks. We'll bring you up to 614 00:41:26,560 --> 00:41:31,900 speed. Yes? Yes. When you download the SDK, they're in 615 00:41:31,900 --> 00:41:43,400 there. Everything's there. Oh, no. Okay. Well, we're 616 00:41:43,940 --> 00:41:48,220 repeating stuff tomorrow as well. I think all the talks 617 00:41:48,440 --> 00:41:53,400 get repeated tomorrow. And all the slides should be available 618 00:41:53,400 --> 00:41:56,160 some place as well for that. And if you're really interested, 619 00:41:56,320 --> 00:41:58,640 just come by and grab us. I mean, we'll just go through it 620 00:41:58,640 --> 00:42:01,920 with you. I mean, we want awareness. We want people to be 621 00:42:01,920 --> 00:42:04,640 able to learn. We want to show people. I mean, we really like 622 00:42:04,640 --> 00:42:07,640 this stuff. Everybody involved with the village. And we're more 623 00:42:07,640 --> 00:42:10,160 than happy to share with you the knowledge. Bring you up to 624 00:42:10,160 --> 00:42:16,300 speed. I mean, that's the whole goal here. Right? So. Yes? 625 00:42:16,920 --> 00:42:17,280 . 626 00:42:21,120 --> 00:42:25,040 There is. When you come back to the village, there's a company 627 00:42:25,040 --> 00:42:28,020 there called Intrepid Control Systems. They make what I think 628 00:42:28,020 --> 00:42:32,440 is pretty much the flag. I mean, it's a really good program 629 00:42:32,440 --> 00:42:37,440 to do this. The problem with it is, you know, it is a high-end 630 00:42:37,440 --> 00:42:41,140 engineering tool. So I think they have options to get lower 631 00:42:41,140 --> 00:42:45,260 cost versions of that. Perhaps even free versions of it that 632 00:42:45,260 --> 00:42:48,420 are limited. But we can show you those things. So we're 633 00:42:48,440 --> 00:42:50,200 going to show you those tools back there and how they work. 634 00:42:50,360 --> 00:42:54,240 It's really a feature-rich program that allows you to do a 635 00:42:54,240 --> 00:42:59,340 lot of stuff. You know, you can find, you can find, you know, 636 00:42:59,360 --> 00:43:04,020 can dongles out there that just dump stuff. You know, this badge, 637 00:43:04,320 --> 00:43:08,060 you could turn it into something like that, as I mentioned. I 638 00:43:08,060 --> 00:43:16,380 mean, it has a U.R. port on it. But as far as, like, cheap, I've 639 00:43:18,520 --> 00:43:20,880 never seen anything like that. Not expensive. Now, you aren't 640 00:43:20,880 --> 00:43:22,640 going to get a lot with them. But... 641 00:43:29,200 --> 00:43:31,980 Yeah, exactly. That's where VehicleSpy excels, of course. 642 00:43:32,580 --> 00:43:36,900 But other ones, we'll have to talk to the guys back there to see 643 00:43:36,900 --> 00:43:41,460 what their experiences are, too. I always use VehicleSpy, 644 00:43:41,580 --> 00:43:42,800 personally. But... 645 00:43:44,040 --> 00:43:44,480 . 646 00:43:45,860 --> 00:43:46,300 . 647 00:43:46,940 --> 00:43:47,380 . 648 00:43:47,980 --> 00:43:48,420 . 649 00:43:48,840 --> 00:43:51,180 You have to use one of their dongles, though, in 650 00:43:51,180 --> 00:43:54,160 order to utilize it. I mean, the badge doesn't work with their 651 00:43:54,160 --> 00:43:58,360 software, of course. But I think you can get in. I'm not sure 652 00:43:58,360 --> 00:44:00,980 what the value cans run now. They have, like, a value can 653 00:44:00,980 --> 00:44:05,060 limited. It might be, and don't quote me on this, it's probably 654 00:44:05,060 --> 00:44:09,660 on the order of a few hundred dollars. 200, 300, something 655 00:44:09,660 --> 00:44:09,920 like that. 656 00:44:12,500 --> 00:44:12,860 . 657 00:44:31,860 --> 00:44:32,120 . 658 00:44:35,820 --> 00:44:36,080 . 659 00:44:36,080 --> 00:44:36,360 . 660 00:44:36,360 --> 00:44:36,480 . 661 00:44:36,480 --> 00:44:36,980 . 662 00:44:36,980 --> 00:44:37,280 . 663 00:44:37,280 --> 00:44:37,300 . 664 00:44:38,460 --> 00:44:38,720 . 665 00:44:38,720 --> 00:44:38,860 . 666 00:44:38,860 --> 00:44:38,880 . 667 00:44:38,880 --> 00:44:38,900 . 668 00:44:38,900 --> 00:44:38,920 . 669 00:44:38,920 --> 00:44:38,940 . 670 00:44:38,940 --> 00:44:38,960 . 671 00:44:48,540 --> 00:44:48,680 . 672 00:44:55,100 --> 00:44:55,240 . 673 00:45:03,460 --> 00:45:03,600 . 674 00:45:03,600 --> 00:45:03,620 . 675 00:45:03,620 --> 00:45:03,660 . 676 00:45:03,660 --> 00:45:03,780 . 677 00:45:03,780 --> 00:45:03,860 . 678 00:45:03,860 --> 00:45:03,920 . 679 00:45:03,920 --> 00:45:03,960 . 680 00:45:03,960 --> 00:45:03,980 . 681 00:45:03,980 --> 00:45:04,000 . 682 00:45:05,840 --> 00:45:05,980 . 683 00:45:05,980 --> 00:45:06,000 . 684 00:45:12,620 --> 00:45:12,760 . 685 00:45:18,440 --> 00:45:19,180 . 686 00:45:22,180 --> 00:45:23,300 . 687 00:45:26,280 --> 00:45:26,840 . 688 00:45:26,840 --> 00:45:27,380 . 689 00:45:27,380 --> 00:45:27,940 . 690 00:45:27,940 --> 00:45:28,040 . 691 00:45:28,040 --> 00:45:28,400 . 692 00:45:28,400 --> 00:45:28,640 . 693 00:45:30,460 --> 00:45:31,580 . 694 00:45:31,580 --> 00:45:31,680 . 695 00:45:35,420 --> 00:45:36,540 . 696 00:45:36,540 --> 00:45:36,700 . 697 00:45:37,320 --> 00:45:37,600 . 698 00:45:38,180 --> 00:45:38,460 . 699 00:45:38,460 --> 00:45:38,600 . 700 00:45:38,600 --> 00:45:38,740 . 701 00:45:38,740 --> 00:45:38,780 . 702 00:45:38,780 --> 00:45:38,900 . 703 00:45:38,900 --> 00:45:38,920 . 704 00:45:38,920 --> 00:45:38,940 . 705 00:45:38,940 --> 00:45:38,960 . 706 00:45:41,580 --> 00:45:41,860 . 707 00:45:41,860 --> 00:45:41,880 . 708 00:45:42,480 --> 00:45:42,760 . 709 00:45:42,760 --> 00:45:44,100 . . . 710 00:45:44,100 --> 00:45:44,220 . .