1 00:00:00,000 --> 00:00:06,240 So my name is Eric Evanczyk. I work on cars. I work for a company now called Faraday Future. 2 00:00:06,460 --> 00:00:12,400 We're making a new electric vehicle. I get to say that we're hiring, which is something I've never got to say in my life before. 3 00:00:12,920 --> 00:00:19,180 So if you're someone who's into cars, wants to do like firmware kind of stuff on cars, reach out after. We can chat about that. 4 00:00:19,740 --> 00:00:23,880 The other thing that I've done is build this little open source can tool called Cantact. 5 00:00:25,020 --> 00:00:31,960 Basically, the way that this came along is I was giving a talk on CAN bus just sort of in general at TourCon, 6 00:00:32,200 --> 00:00:34,600 which is a great conference that happens in San Diego every year. 7 00:00:36,020 --> 00:00:40,980 And I was like, yeah, there's a bunch of tools available. Most of them are kind of a couple hundred bucks or whatever. 8 00:00:41,480 --> 00:00:44,880 There's some open source ones, but no one really makes them anymore. 9 00:00:45,580 --> 00:00:47,960 And someone was like, oh, well, you should build one. And so I did. 10 00:00:49,580 --> 00:00:52,020 This talk isn't really about this tool. It kind of is. 11 00:00:52,160 --> 00:00:53,860 But it's more about something called SanDisk. 12 00:00:53,880 --> 00:00:54,340 It's called Socket CAN. 13 00:00:54,980 --> 00:00:59,880 And we'll talk about Socket CAN, which applies to a lot of different tools, both commercial and open source. 14 00:01:00,860 --> 00:01:07,600 What it is, how it works, and how you can use it to develop CAN bus applications for, you know, whatever you want to do with cars. 15 00:01:09,580 --> 00:01:11,820 So what is Socket CAN? 16 00:01:13,240 --> 00:01:15,600 Basically, if you've ever dealt with... 17 00:01:15,600 --> 00:01:18,600 Is anyone here like a Linux user in general? 18 00:01:19,180 --> 00:01:20,460 Or are you mostly Windows? 19 00:01:20,540 --> 00:01:23,140 Okay, so like we got, you know, a good amount of Linux users. 20 00:01:24,160 --> 00:01:25,060 OSX, anybody? 21 00:01:26,140 --> 00:01:26,960 Couple, okay. 22 00:01:27,280 --> 00:01:29,320 You guys might know what's going on a little bit. 23 00:01:29,580 --> 00:01:31,380 And then Windows, you have no idea what's going on. 24 00:01:31,500 --> 00:01:32,920 But, well, I'm sorry. 25 00:01:33,140 --> 00:01:34,620 You can run a VM. You can run a VM. 26 00:01:35,240 --> 00:01:38,980 So what happens with this is, if you've ever used Linux network devices before, 27 00:01:39,900 --> 00:01:46,540 you know, you have the network driver, which is sitting real low in the kernel, deals with the actual hardware. 28 00:01:46,760 --> 00:01:48,800 In this case, that's replaced with the CAN controller. 29 00:01:49,580 --> 00:01:51,540 Then on the left, we have the Socket CAN version. 30 00:01:51,620 --> 00:01:53,400 On the right, we have the traditional version. 31 00:01:53,880 --> 00:01:55,020 We'll start with the traditional way of doing it. 32 00:01:55,500 --> 00:01:58,400 So CAN controller, you stick a driver on top of that, 33 00:01:58,540 --> 00:02:02,520 such as a character device driver for the SL CAN devices we'll talk about. 34 00:02:02,820 --> 00:02:05,760 Then on top of that, you can stick a protocol interface. 35 00:02:05,900 --> 00:02:09,100 And then the application that you actually write goes in the very, very end. 36 00:02:09,680 --> 00:02:12,900 You can take a picture of this or literally go to Wikipedia, which I ripped it off of. 37 00:02:14,500 --> 00:02:15,180 Yeah, sorry. 38 00:02:15,380 --> 00:02:18,840 But on the left-hand side, you have the Socket CAN version. 39 00:02:19,200 --> 00:02:21,180 The way this works is your Ethernet hardware 40 00:02:21,180 --> 00:02:26,080 or whatever Wi-Fi card, whatever it is, replaced with a CAN controller. 41 00:02:26,580 --> 00:02:33,500 And then Socket CAN kind of jumps in and takes over from the network device driver level up. 42 00:02:34,200 --> 00:02:39,560 And it actually merges back with how you'd normally deal with sockets in Linux at the socket layer, 43 00:02:40,120 --> 00:02:43,620 which means that we can write code that looks a lot like network socket code, 44 00:02:43,820 --> 00:02:45,900 but it's actually going to talk CAN. 45 00:02:46,180 --> 00:02:50,120 And then in your application, you make those calls just like you would with any other socket. 46 00:02:51,180 --> 00:02:53,880 And, you know, you're probably familiar with something like this 47 00:02:53,880 --> 00:02:59,640 if you've ever dealt with sockets ever or devices on Linux at all. 48 00:03:00,300 --> 00:03:02,940 This is kind of washed out, I'm sorry, 49 00:03:03,080 --> 00:03:06,580 but this is me running ifconfig for a vCAN device, 50 00:03:06,860 --> 00:03:08,820 which is a virtual CAN bus device we'll talk about. 51 00:03:09,220 --> 00:03:13,040 And it shows up just like any other network device you'd see. 52 00:03:13,320 --> 00:03:17,260 It has the one weird thing with it is the hardware address comes up 53 00:03:17,260 --> 00:03:19,880 as like just a whole bunch of zeros for some weird reason. 54 00:03:21,180 --> 00:03:22,660 And it has everything you'd expect. 55 00:03:22,780 --> 00:03:24,720 Some of those numbers don't work, but a lot of them do. 56 00:03:24,860 --> 00:03:27,820 Receipt packets, transmitted packets, all that kind of stuff. 57 00:03:28,380 --> 00:03:31,380 So once you have this device and, you know, you've set it up, 58 00:03:31,380 --> 00:03:32,520 and it's actually a network device, 59 00:03:33,140 --> 00:03:37,020 in C you literally do everything you'd expect to do with sockets. 60 00:03:37,100 --> 00:03:39,200 Has anyone done socket code in C before? 61 00:03:39,620 --> 00:03:40,620 Got a couple hands. 62 00:03:41,080 --> 00:03:45,420 So, like, you know, you call the function, you get a file descriptor back. 63 00:03:45,740 --> 00:03:48,760 The difference being where normally you would specify, like, 64 00:03:48,760 --> 00:03:53,560 I want an INET socket, and I want it to be, or UDP datagram, 65 00:03:53,820 --> 00:03:54,540 and I want these flags. 66 00:03:55,400 --> 00:03:59,500 This will get you a CAN socket that is a raw CAN socket, 67 00:03:59,640 --> 00:04:00,780 which means you get direct access. 68 00:04:01,320 --> 00:04:05,120 There's also a mode called BCM, which is meant to deal with queuing, 69 00:04:05,240 --> 00:04:10,420 and it's meant to take the work off of the user space application 70 00:04:10,420 --> 00:04:12,200 and do more of it in the kernel space. 71 00:04:12,880 --> 00:04:14,220 I haven't worked with it too much. 72 00:04:14,480 --> 00:04:18,260 It supports kind of odd, it seems, but it's getting there. 73 00:04:18,760 --> 00:04:21,720 So once you have that socket, you can do everything you'd expect. 74 00:04:21,960 --> 00:04:26,460 You can call IOControl to set up, you know, in some cases bit rates, 75 00:04:26,620 --> 00:04:28,560 but at the very least set the address of it. 76 00:04:28,840 --> 00:04:31,520 You can bind to it, and then you can do reads and writes, 77 00:04:31,660 --> 00:04:35,440 and you can set socket options to block or not block or time out, 78 00:04:35,560 --> 00:04:36,720 all those things. 79 00:04:37,280 --> 00:04:41,920 You can also do all of this from Python, but specifically Python 3. 80 00:04:42,120 --> 00:04:47,480 For whatever reason, socket.pfcan and sock.raw, or socket.sockraw, 81 00:04:47,480 --> 00:04:49,500 are not defined in Python 2. 82 00:04:49,920 --> 00:04:51,300 I'm not quite sure why. 83 00:04:51,540 --> 00:04:53,640 But in Python 3, it works great. 84 00:04:53,740 --> 00:04:57,140 You can create a new socket and call all the same functions. 85 00:04:57,260 --> 00:04:58,180 It's just an interface. 86 00:04:59,980 --> 00:05:03,660 So this is, you know, that's how you go from CAN to sockets, 87 00:05:03,720 --> 00:05:05,420 is you're just working with them. 88 00:05:05,480 --> 00:05:06,340 You fill up a buffer. 89 00:05:06,600 --> 00:05:11,740 Rather than sending a normal IP, like a TCP IP or UDP buffer, 90 00:05:12,000 --> 00:05:16,280 you populate a CAN frame struct, and you say, 91 00:05:16,280 --> 00:05:19,420 hey, send this CAN frame struct, or read me in a CAN frame struct, 92 00:05:19,940 --> 00:05:23,120 just like you would with TCP or UDP. 93 00:05:24,860 --> 00:05:27,160 Now, if you don't have any CAN devices, 94 00:05:27,340 --> 00:05:29,860 though a lot of you will have one of these sweet things now, 95 00:05:30,920 --> 00:05:32,600 but it doesn't plug into your computer. 96 00:05:32,720 --> 00:05:34,920 So let's say you want to play around with CAN on your computer 97 00:05:34,920 --> 00:05:38,680 and, you know, create a device that's not a real device, 98 00:05:38,900 --> 00:05:40,940 but it'll let you send and receive messages 99 00:05:40,940 --> 00:05:43,500 and play around with all the tools with no hardware. 100 00:05:43,780 --> 00:05:45,240 So it's free. 101 00:05:45,240 --> 00:05:46,920 That's the biggest benefit. 102 00:05:47,700 --> 00:05:49,640 It's also useful for, like, simulating stuff 103 00:05:49,640 --> 00:05:51,440 and just testing out tools. 104 00:05:52,240 --> 00:05:57,760 You can actually do this sudo ip link add vcan 0 of type vcan. 105 00:05:57,940 --> 00:06:00,020 That will create you a new virtual CAN device. 106 00:06:01,080 --> 00:06:04,340 Once you have the device, you can just do ifconfig vcan up, 107 00:06:04,460 --> 00:06:07,180 and sure enough, you get a CAN device. 108 00:06:07,680 --> 00:06:10,180 Again, it's not going to send any frames out on the wire. 109 00:06:10,360 --> 00:06:11,440 It's just virtual. 110 00:06:11,620 --> 00:06:13,600 But you can use all the tools. 111 00:06:13,600 --> 00:06:14,640 You can send stuff around. 112 00:06:14,920 --> 00:06:15,960 You can write. 113 00:06:16,060 --> 00:06:17,980 It's quite useful for developing tools 114 00:06:17,980 --> 00:06:20,240 because let's say you have a client and a server. 115 00:06:20,600 --> 00:06:23,960 You can develop both of them to use socket CAN, 116 00:06:24,520 --> 00:06:27,360 use this to test it without actually having to deal with hardware, 117 00:06:27,580 --> 00:06:30,140 and then write whatever you need to deal with the hardware later. 118 00:06:31,060 --> 00:06:34,120 I may have done that once or twice, so it's kind of handy. 119 00:06:34,860 --> 00:06:37,680 Now, if you want a real device, there's a few things you can do. 120 00:06:38,780 --> 00:06:40,240 One is this SL CAN. 121 00:06:40,500 --> 00:06:42,880 So this stands for serial line CAN. 122 00:06:43,600 --> 00:06:46,080 And it supports this pretty old protocol 123 00:06:46,600 --> 00:06:48,780 that some company came up with a while ago 124 00:06:48,780 --> 00:06:54,320 that basically takes CAN frames and encodes them over serial data 125 00:06:54,320 --> 00:06:56,020 like UART or RS-232. 126 00:06:56,260 --> 00:07:00,140 You can actually buy something that does this from, for example, 127 00:07:00,360 --> 00:07:01,680 Peak or GridConnect. 128 00:07:01,880 --> 00:07:04,920 They sell a tool that is CAN to RS-232, 129 00:07:05,340 --> 00:07:06,500 and it spits out ASCII. 130 00:07:06,600 --> 00:07:10,060 So it's really not that efficient because, for example, 131 00:07:10,160 --> 00:07:12,500 the byte FF becomes the two bytes, 132 00:07:12,500 --> 00:07:14,640 the character F and the character F again. 133 00:07:15,060 --> 00:07:18,160 But it's well supported, and it works out of the box. 134 00:07:18,340 --> 00:07:22,100 So that's why this CANTAC thing ended up using this protocol 135 00:07:22,100 --> 00:07:23,760 rather than something more efficient. 136 00:07:24,060 --> 00:07:25,160 It's just, it works. 137 00:07:25,760 --> 00:07:29,460 The bad news is that serial is very slow. 138 00:07:29,880 --> 00:07:34,040 You know, typical baud rates you're going to get off of a RS-232 or UART, 139 00:07:34,120 --> 00:07:37,060 it's going to be 115, 200 bits per second. 140 00:07:37,380 --> 00:07:39,800 CAN can go up to 1 megabit per second, 141 00:07:39,900 --> 00:07:42,140 though we usually see it used at 500, 142 00:07:42,500 --> 00:07:43,000 or KBPS. 143 00:07:43,460 --> 00:07:46,580 CAN FD is another thing that I'm not going to talk about, 144 00:07:46,720 --> 00:07:49,740 but there actually is starting to be Linux support for it. 145 00:07:51,220 --> 00:07:52,680 So yeah, that's a problem, right? 146 00:07:52,700 --> 00:07:54,360 We have one order of magnitude of a jump. 147 00:07:54,620 --> 00:07:58,320 The good news is that it turns out that the bit rate 148 00:07:58,320 --> 00:08:01,980 doesn't actually matter when you're dealing with a USB to serial device. 149 00:08:02,960 --> 00:08:06,820 That bit rate that you set is only to tell the device, 150 00:08:07,040 --> 00:08:10,080 okay, please talk serial at whatever rate. 151 00:08:10,440 --> 00:08:11,820 So in the case of the CANTAC, 152 00:08:12,500 --> 00:08:14,740 if I do this thing, I want to do 9600 baud, 153 00:08:14,960 --> 00:08:18,400 it will ignore you and instead just continue talking 154 00:08:18,400 --> 00:08:20,260 as fast as it possibly can over USB. 155 00:08:21,360 --> 00:08:23,000 It's kind of a common misconception. 156 00:08:23,380 --> 00:08:26,420 People figure, oh, well, USB serial devices must be limited 157 00:08:26,420 --> 00:08:30,900 to whatever, 115, 200, but no, they can go a lot faster. 158 00:08:32,160 --> 00:08:33,920 Specifically, if you're interested in it, 159 00:08:33,960 --> 00:08:35,960 it's a 64-byte endpoint for USB, 160 00:08:36,140 --> 00:08:38,620 so you can basically do really fast transfers 161 00:08:38,620 --> 00:08:40,280 as long as they're 64 bytes or less. 162 00:08:41,400 --> 00:08:43,100 So you can use this. 163 00:08:43,640 --> 00:08:44,880 There's a typo on this slide, 164 00:08:45,000 --> 00:08:48,400 but you can use this command to bring up a serial line device. 165 00:08:48,600 --> 00:08:51,100 So anything that speaks this standard protocol 166 00:08:51,960 --> 00:08:54,060 will interface by running this command. 167 00:08:54,420 --> 00:08:58,140 So it's SLCAND, which is the serial line CAN daemon. 168 00:08:58,960 --> 00:09:01,880 Dash O tells it that when you start it up, 169 00:09:01,900 --> 00:09:03,200 you want to send the open command, 170 00:09:03,400 --> 00:09:06,320 which is just capital O and a carriage. 171 00:09:06,480 --> 00:09:09,700 It actually all uses a carriage return rather than a new line. 172 00:09:10,280 --> 00:09:12,820 Yeah, carriage return rather than new line for whatever reason. 173 00:09:13,520 --> 00:09:17,140 Dash C tells it whenever you close SLCAND, 174 00:09:17,160 --> 00:09:18,480 you want to send the close command. 175 00:09:18,920 --> 00:09:20,960 You give it the path to your device, 176 00:09:21,180 --> 00:09:23,340 dev, TTY, ACM, whatever, 177 00:09:23,800 --> 00:09:26,080 then the name of the device that you want to actually create. 178 00:09:26,660 --> 00:09:28,800 So in this case, it would connect to something like this 179 00:09:28,800 --> 00:09:30,920 and create a CAN0 device. 180 00:09:31,820 --> 00:09:32,780 Here's the typo. 181 00:09:32,840 --> 00:09:37,260 You would then call ifconfig can, not vcan, 0 up, 182 00:09:37,380 --> 00:09:38,880 and that would bring the device up, 183 00:09:38,880 --> 00:09:42,860 and now you have access to it over a socket interface. 184 00:09:44,140 --> 00:09:47,060 Now, if you're a developer who deals with Unix sockets, 185 00:09:47,120 --> 00:09:48,500 that might be of interest to you. 186 00:09:48,560 --> 00:09:50,160 You might be like, great, I can do CAN now. 187 00:09:50,280 --> 00:09:51,120 That's cool. 188 00:09:51,600 --> 00:09:53,120 If you're not, you're probably thinking, 189 00:09:53,320 --> 00:09:54,520 well, okay, what's the point? 190 00:09:54,680 --> 00:09:56,860 Like, I don't write code for that anyway. 191 00:09:57,580 --> 00:10:00,000 And the main reason you'd want to do this is 192 00:10:00,000 --> 00:10:01,960 there's a whole bunch of tools you get for free. 193 00:10:02,920 --> 00:10:04,440 This is a list of some of them, 194 00:10:04,500 --> 00:10:07,920 and we'll show them now because I don't have that many slides. 195 00:10:07,920 --> 00:10:10,300 I figured it would be better to actually show you this working 196 00:10:10,300 --> 00:10:12,140 and, you know, how it works. 197 00:10:12,760 --> 00:10:14,680 So if I switch to VM mode, 198 00:10:15,500 --> 00:10:16,620 and if it actually works, 199 00:10:16,840 --> 00:10:18,920 oh, that is interesting. 200 00:10:19,080 --> 00:10:20,760 That is not what I want at all. 201 00:10:21,500 --> 00:10:23,480 I have no idea what that is. 202 00:10:24,660 --> 00:10:26,300 That's pretty much the same thing. 203 00:10:27,700 --> 00:10:28,220 Displays. 204 00:10:28,220 --> 00:10:30,580 The thermostat was an example of an RTU. 205 00:10:32,060 --> 00:10:34,320 RTUs are obviously designed to be remote, 206 00:10:34,460 --> 00:10:36,580 so they are in remote locations. 207 00:10:36,580 --> 00:10:38,160 This is why you test out the projector 208 00:10:38,160 --> 00:10:39,680 before you start your talk, 209 00:10:39,880 --> 00:10:41,960 just for future reference. 210 00:10:43,880 --> 00:10:45,580 Really harsh conditions sometimes. 211 00:10:46,000 --> 00:10:48,500 I mean, imagine how many PLCs we had on top. 212 00:10:48,660 --> 00:10:50,800 Nope, that's me changing my screensaver now. 213 00:10:51,600 --> 00:10:53,340 And then compare that with the ones 214 00:10:53,480 --> 00:10:54,380 I took that picture. 215 00:10:54,440 --> 00:10:54,880 It's a good one. 216 00:10:56,200 --> 00:10:56,720 Thank you. 217 00:10:57,480 --> 00:10:58,200 Here we are. 218 00:10:58,540 --> 00:10:58,900 Arrangement. 219 00:10:59,860 --> 00:11:00,340 Let's see. 220 00:11:00,420 --> 00:11:00,880 Where is mirror? 221 00:11:03,020 --> 00:11:04,120 It's not going to let me mirror. 222 00:11:04,520 --> 00:11:04,880 Awesome. 223 00:11:06,680 --> 00:11:09,160 What we're going to do then is we're just going to take my VM 224 00:11:10,380 --> 00:11:12,340 because you guys are probably bored of me 225 00:11:12,340 --> 00:11:13,620 playing around with display settings. 226 00:11:15,220 --> 00:11:17,580 And where is that? 227 00:11:17,900 --> 00:11:19,140 Oh, there it is. 228 00:11:19,920 --> 00:11:21,560 Apparently it's off to the left of my screen. 229 00:11:22,800 --> 00:11:23,160 Hey. 230 00:11:23,860 --> 00:11:25,380 Please don't be terrible resolution. 231 00:11:26,520 --> 00:11:27,120 All right. 232 00:11:27,420 --> 00:11:28,520 Now I have to look this way. 233 00:11:30,440 --> 00:11:32,120 So, first thing we're going to talk about, 234 00:11:32,300 --> 00:11:34,040 and I'm going to do this all on VCAN devices, 235 00:11:34,700 --> 00:11:36,900 just because this is all stuff you can try at home 236 00:11:36,900 --> 00:11:38,380 with no hardware, which is kind of fun. 237 00:11:39,680 --> 00:11:42,880 First thing we'll do is actually, 238 00:11:43,140 --> 00:11:44,160 let's do TMUX. 239 00:11:44,720 --> 00:11:46,760 Let's do equals. 240 00:11:47,980 --> 00:11:48,400 Cool. 241 00:11:48,540 --> 00:11:50,540 So I have two terminals here. 242 00:11:51,920 --> 00:11:53,460 Hopefully it comes out later. 243 00:11:53,460 --> 00:11:53,620 I don't know if this is legible. 244 00:11:54,460 --> 00:11:56,940 Projectors and VMs are always trying. 245 00:12:00,100 --> 00:12:02,880 So, first thing you're probably going to want to do if you're 246 00:12:02,880 --> 00:12:04,820 ever on a CAN system is dump a whole bunch of stuff. 247 00:12:05,040 --> 00:12:06,320 So let's do that. 248 00:12:06,800 --> 00:12:08,620 So CAN DUMP VCAN 0. 249 00:12:08,960 --> 00:12:10,820 What this is going to do is start dumping messages. 250 00:12:11,040 --> 00:12:13,380 And there actually are active messages right now flying around. 251 00:12:14,220 --> 00:12:15,440 We'll look at them more later. 252 00:12:16,340 --> 00:12:18,700 But, you know, it's going to give you a trace of the CAN bus. 253 00:12:18,920 --> 00:12:21,240 It's just going to give you every message printed out with a 254 00:12:22,400 --> 00:12:23,440 few different options. 255 00:12:23,440 --> 00:12:24,140 There are a lot of options that are quite useful. 256 00:12:24,380 --> 00:12:28,140 So if you want time stamps, you can do TA for absolute time 257 00:12:28,140 --> 00:12:28,420 stamps. 258 00:12:29,680 --> 00:12:33,140 That's the number of seconds since the Unix epoch that your 259 00:12:33,140 --> 00:12:36,200 CAN message arrived, which is probably not the most useful 260 00:12:36,200 --> 00:12:36,420 number. 261 00:12:37,080 --> 00:12:39,060 But TD is a very useful one. 262 00:12:39,160 --> 00:12:41,780 It will tell you the delta time, so time in between messages. 263 00:12:44,500 --> 00:12:46,140 And that would be CAN DUMP. 264 00:12:46,200 --> 00:12:46,740 Pretty simple. 265 00:12:46,860 --> 00:12:48,020 But let's keep CAN DUMP running. 266 00:12:49,580 --> 00:12:51,380 We'll kill off that stuff running in the background. 267 00:12:51,380 --> 00:12:51,980 Cool. 268 00:12:52,440 --> 00:12:53,200 So it stopped. 269 00:12:53,400 --> 00:12:54,420 We'll start it again so you can see. 270 00:12:55,200 --> 00:12:56,940 You want to send some arbitrary CAN frames. 271 00:12:57,220 --> 00:12:58,920 That's another useful thing to do. 272 00:12:59,420 --> 00:13:01,280 We can use CAN SEND. 273 00:13:02,160 --> 00:13:05,980 Format for this is CAN SEND, CAN ID, number sign, and some bytes. 274 00:13:07,500 --> 00:13:08,260 11AABBCC, whatever. 275 00:13:09,060 --> 00:13:11,520 And that, oh, no, it's not. 276 00:13:11,880 --> 00:13:13,480 VCAN 0 for the device. 277 00:13:15,020 --> 00:13:16,760 And that will let us send CAN frames. 278 00:13:16,960 --> 00:13:19,400 So if we're connected to a real car right now, we're literally 279 00:13:19,400 --> 00:13:20,640 sending CAN frames on the bus. 280 00:13:22,020 --> 00:13:23,200 It's pretty simple. 281 00:13:23,360 --> 00:13:26,380 If you want to just fuzz out some frames and see what happens. 282 00:13:28,240 --> 00:13:30,780 Another pretty useful thing you can do is logging. 283 00:13:30,980 --> 00:13:36,200 So I actually took a log by using CAN DUMP with the dash L flag, 284 00:13:36,320 --> 00:13:37,300 which will log to a file. 285 00:13:38,100 --> 00:13:40,560 And the nice thing about this is I can now play it back. 286 00:13:40,800 --> 00:13:42,320 So this might be a little hard to read. 287 00:13:42,500 --> 00:13:46,160 What I'm doing here is using CAN Player, which is a playback tool. 288 00:13:46,520 --> 00:13:50,520 And I'm saying send the messages that were on CAN. 289 00:13:50,640 --> 00:13:52,280 Can 1, whenever you received them. 290 00:13:53,000 --> 00:13:54,440 To the device CAN 0. 291 00:13:55,060 --> 00:13:57,900 And repeat this infinitely using this log file. 292 00:13:58,480 --> 00:14:01,420 And so that's what lets us, you know, just generate a whole boatload 293 00:14:01,420 --> 00:14:02,900 of frames that are kind of useful. 294 00:14:03,460 --> 00:14:06,440 There's another tool if you want to generate useless frames called 295 00:14:06,440 --> 00:14:07,200 CAN GEN. 296 00:14:07,800 --> 00:14:11,220 And that will literally just spit out random data. 297 00:14:11,480 --> 00:14:13,960 There's a whole bunch of different flags you can set for different 298 00:14:13,960 --> 00:14:14,920 types of data. 299 00:14:15,080 --> 00:14:16,940 But VCAN 0. 300 00:14:16,940 --> 00:14:19,380 You can use this. 301 00:14:19,720 --> 00:14:23,340 Very useful if you want to load up a bus to like 90% and see what 302 00:14:23,340 --> 00:14:23,640 happens. 303 00:14:24,040 --> 00:14:28,260 You can say I want message 0 to be going on at really, really fast 304 00:14:28,260 --> 00:14:31,360 speed so that I can test to see if my diagnostic stuff that's on 305 00:14:31,360 --> 00:14:32,960 really high IDs still work. 306 00:14:33,960 --> 00:14:35,280 One example of using it. 307 00:14:35,440 --> 00:14:37,100 But here it's just spitting out crap. 308 00:14:40,080 --> 00:14:43,260 So these are all like, you know, simple CAN interfacing tools. 309 00:14:43,640 --> 00:14:46,040 Now we'll talk about some actually pretty useful ones. 310 00:14:46,040 --> 00:14:49,160 The first one is CAN sniffer. 311 00:14:49,380 --> 00:14:53,720 And CAN sniffer is sort of unlike any other tool that I've 312 00:14:53,720 --> 00:14:54,540 really seen for CAN. 313 00:14:55,460 --> 00:14:57,180 It basically lets you. 314 00:14:58,640 --> 00:14:59,300 VCAN 0. 315 00:15:00,400 --> 00:15:02,500 Basically lets you just take a look at what's going on. 316 00:15:03,760 --> 00:15:05,320 I've killed off all of my messages. 317 00:15:05,440 --> 00:15:05,760 One sec. 318 00:15:06,440 --> 00:15:07,940 We'll start that log up again. 319 00:15:08,380 --> 00:15:11,640 And we will do over here. 320 00:15:13,320 --> 00:15:15,260 CAN sniffer VCAN 0. 321 00:15:15,380 --> 00:15:15,560 Okay. 322 00:15:17,060 --> 00:15:19,280 This is going to show you everything going on in the bus. 323 00:15:19,800 --> 00:15:21,660 You see a bunch of messages at the top. 324 00:15:22,880 --> 00:15:25,020 After a couple seconds, a lot of them go away. 325 00:15:25,220 --> 00:15:26,240 And we only have one left. 326 00:15:26,500 --> 00:15:29,180 And the reason being this is the only frame where anything is 327 00:15:29,180 --> 00:15:29,620 changing. 328 00:15:30,640 --> 00:15:32,940 Everything else, it's just we're getting the same frame, the same 329 00:15:32,940 --> 00:15:34,360 data over and over and over again. 330 00:15:34,780 --> 00:15:36,480 And that's not exciting because who cares. 331 00:15:37,720 --> 00:15:39,900 When you're reverse engineering CAN buses, though, it's quite 332 00:15:39,900 --> 00:15:41,440 useful to be able to see what's changing. 333 00:15:41,580 --> 00:15:44,760 For example, you want to know where the pedal position signal 334 00:15:44,760 --> 00:15:45,340 is on the bus. 335 00:15:45,340 --> 00:15:46,540 So you plug in. 336 00:15:46,800 --> 00:15:48,640 And you start pushing the pedal. 337 00:15:48,820 --> 00:15:50,120 And you want to see that value change. 338 00:15:51,460 --> 00:15:55,940 This gets even better if you do use the what's the flag? 339 00:15:56,540 --> 00:15:58,300 It's definitely not dash dash help for it. 340 00:15:59,480 --> 00:16:01,200 There is a flag for color. 341 00:16:01,660 --> 00:16:02,940 It's dash C. Great. 342 00:16:03,060 --> 00:16:04,840 So now we can actually see what's changing. 343 00:16:05,100 --> 00:16:07,860 And it shows you exactly what byte is changing. 344 00:16:08,040 --> 00:16:09,260 It shows you it in ASCII as well. 345 00:16:09,500 --> 00:16:10,780 And increments like that. 346 00:16:11,560 --> 00:16:15,160 If you plug this into real systems, it's quite useful because all the 347 00:16:15,160 --> 00:16:18,400 cruft that just repeats itself over and over and over again goes 348 00:16:18,400 --> 00:16:18,660 away. 349 00:16:18,860 --> 00:16:20,340 And you actually get to see the live data. 350 00:16:21,940 --> 00:16:23,300 So that's CAN sniffer. 351 00:16:23,400 --> 00:16:25,040 It has a whole bunch of other options. 352 00:16:25,260 --> 00:16:26,540 This is a quick demo. 353 00:16:26,960 --> 00:16:29,900 Depending on what you're trying to do, CAN sniffer might have 354 00:16:29,900 --> 00:16:30,880 something useful. 355 00:16:31,700 --> 00:16:34,620 The last thing I really want to demo, and then, you know, this is 356 00:16:34,620 --> 00:16:36,820 basically just about showing you tools and having you ask 357 00:16:36,820 --> 00:16:37,540 questions about them. 358 00:16:38,080 --> 00:16:42,960 But the last tool I'll show off is Wireshark, which some of you 359 00:16:42,960 --> 00:16:44,660 have probably used for not CAN purposes. 360 00:16:44,840 --> 00:16:45,140 It's a really good tool. 361 00:16:45,160 --> 00:16:46,100 It's a pretty popular tool. 362 00:16:46,220 --> 00:16:46,840 You may have heard of it. 363 00:16:48,940 --> 00:16:50,040 Wireshark supports CAN. 364 00:16:50,240 --> 00:16:51,360 And most people don't know this. 365 00:16:52,020 --> 00:16:53,560 It supports it out of the box. 366 00:16:53,920 --> 00:16:56,700 It does a pretty good job of it, too. 367 00:16:56,880 --> 00:16:59,640 If you just want to record CAN frames, everything that I've been 368 00:16:59,640 --> 00:17:01,900 doing is now recorded in this Wireshark trace. 369 00:17:02,140 --> 00:17:02,880 I can scroll through. 370 00:17:03,140 --> 00:17:04,200 I can pause it. 371 00:17:04,240 --> 00:17:05,440 I can save a PCAP file. 372 00:17:05,820 --> 00:17:07,780 You can write filters like CAN. 373 00:17:08,000 --> 00:17:10,020 ID is greater than OX100. 374 00:17:10,460 --> 00:17:11,280 It will filter them. 375 00:17:11,780 --> 00:17:14,860 If you're working with CAN open, which is a protocol 376 00:17:15,160 --> 00:17:18,660 mostly used in ICS systems, not so much cars, so industrial 377 00:17:18,660 --> 00:17:19,620 stuff, SCADA. 378 00:17:19,960 --> 00:17:23,020 You can actually do CAN open dot and filter by a lot of 379 00:17:23,020 --> 00:17:24,780 different things that CAN open uses. 380 00:17:25,060 --> 00:17:27,020 I'm not sure if anyone is interested in that part of CAN, 381 00:17:27,180 --> 00:17:28,760 but those options are there. 382 00:17:29,820 --> 00:17:31,980 And it's a useful tool for looking at buses. 383 00:17:32,060 --> 00:17:33,860 It can deal with very large amounts of data. 384 00:17:34,000 --> 00:17:36,820 It's used to dealing with network packets. 385 00:17:37,880 --> 00:17:40,700 And, yeah, it's kind of a nice thing to run in the background 386 00:17:40,700 --> 00:17:43,060 and just be able to save a trace of what you're doing. 387 00:17:43,960 --> 00:17:44,360 So, yeah. 388 00:17:44,360 --> 00:17:44,680 So, yeah. 389 00:17:44,680 --> 00:17:44,700 So, yeah. 390 00:17:44,700 --> 00:17:44,800 So, yeah. 391 00:17:45,160 --> 00:17:47,460 So, all this stuff, it's pretty low-level tools. 392 00:17:47,680 --> 00:17:49,360 It's more meant for the development end. 393 00:17:50,000 --> 00:17:53,880 But it makes it pretty easy to then write your own software 394 00:17:53,880 --> 00:17:54,740 using CAN. 395 00:17:55,000 --> 00:17:57,800 And, you know, if you do C right now and you do network 396 00:17:57,800 --> 00:18:01,780 devices or any kind of socket stuff, extending that to CAN 397 00:18:01,780 --> 00:18:05,520 has just become, okay, I'll call it with the right flags and 398 00:18:05,520 --> 00:18:06,120 that's about it. 399 00:18:06,580 --> 00:18:10,600 So, that's pretty much my really quick tour of socket CAN. 400 00:18:10,960 --> 00:18:14,420 At this point, questions or tool demos that you want to 401 00:18:14,420 --> 00:18:15,140 specifically see, I'll put them in the chat. 402 00:18:15,140 --> 00:18:16,420 I think the ones that you see probably make the most sense 403 00:18:16,420 --> 00:18:19,940 because we should tailor this to what you want and not just 404 00:18:19,940 --> 00:18:21,100 keep talking about random tools. 405 00:18:21,400 --> 00:18:24,280 So, is there any questions from anyone about socket CAN or 406 00:18:24,280 --> 00:18:27,120 devices or really anything CAN related? 407 00:18:27,260 --> 00:18:28,200 I'll try to answer. 408 00:18:31,560 --> 00:18:32,000 Oh. 409 00:18:33,020 --> 00:18:33,840 What is CAN? 410 00:18:34,160 --> 00:18:37,460 I figured people in here, like, knew a bit about cars and CAN 411 00:18:37,460 --> 00:18:37,680 bus. 412 00:18:37,880 --> 00:18:40,620 I may have just, like, gone way the hell over everybody's head. 413 00:18:40,740 --> 00:18:41,300 I hope I didn't. 414 00:18:42,860 --> 00:18:45,740 Has anyone gone to none of the car hacking stuff yet? 415 00:18:48,200 --> 00:18:49,680 Everyone's gone to something, right? 416 00:18:50,040 --> 00:18:50,480 Good. 417 00:18:50,740 --> 00:18:51,780 You scared me. 418 00:18:51,880 --> 00:18:53,020 I didn't realize that. 419 00:18:53,140 --> 00:18:53,580 Okay. 420 00:18:53,600 --> 00:18:53,780 Good. 421 00:18:54,180 --> 00:18:58,180 Are there any other questions about socket CAN or CAN in 422 00:18:58,180 --> 00:18:58,480 general? 423 00:19:01,180 --> 00:19:01,620 Yeah. 424 00:19:01,840 --> 00:19:06,080 So, it's this device that I built. 425 00:19:06,280 --> 00:19:08,260 It's basically I was like, hey, I should build an open source 426 00:19:08,260 --> 00:19:08,760 hardware thing. 427 00:19:08,860 --> 00:19:09,340 So, I did. 428 00:19:09,940 --> 00:19:11,280 This is using the open source hardware. 429 00:19:11,300 --> 00:19:14,860 This is the STM32F0, which is remarkably similar to the 430 00:19:14,860 --> 00:19:16,140 microcontroller on this guy. 431 00:19:17,300 --> 00:19:18,460 Slightly different package. 432 00:19:18,920 --> 00:19:21,700 Cool thing about it is it can do USB and CAN at the same time. 433 00:19:22,180 --> 00:19:24,120 So, this is essentially a USB connector, 434 00:19:25,020 --> 00:19:25,500 microcontroller, 435 00:19:25,720 --> 00:19:26,820 CAN transceiver, 436 00:19:26,940 --> 00:19:28,520 and some jumpers. 437 00:19:28,540 --> 00:19:31,520 Reason being, if you've ever dealt with DB9 cables, 438 00:19:31,680 --> 00:19:33,000 they come in two different formats. 439 00:19:33,320 --> 00:19:35,840 The really expensive ones come with the right pinout. 440 00:19:35,980 --> 00:19:38,380 The cheap ones from China come with the wrong pinout. 441 00:19:38,540 --> 00:19:40,880 So, this lets you select between both those pinouts. 442 00:19:41,020 --> 00:19:41,280 So, this lets you select between both those pinouts. 443 00:19:41,300 --> 00:19:43,300 I say the right pinout because it was actually set by 444 00:19:43,300 --> 00:19:45,140 CAN and automation like 20 years back. 445 00:19:45,460 --> 00:19:47,520 And for some reason, they don't conform to it. 446 00:19:47,960 --> 00:19:49,520 It also has a little termination resistor. 447 00:19:49,840 --> 00:19:51,540 So, if you're just testing like two of these 448 00:19:51,540 --> 00:19:52,900 or this and one other device, 449 00:19:53,060 --> 00:19:53,880 you can terminate the bus. 450 00:19:54,680 --> 00:19:55,860 Otherwise, nothing works. 451 00:19:56,060 --> 00:19:57,860 So, it's useful to be able to jumper select that. 452 00:19:58,380 --> 00:20:00,220 And yeah, DB9 connector on the end. 453 00:20:01,960 --> 00:20:02,900 Yeah, it was 454 00:20:02,900 --> 00:20:04,680 just mostly to say, hey, 455 00:20:04,740 --> 00:20:06,560 I want to put together something, make it open source. 456 00:20:08,540 --> 00:20:09,340 GitHub.com 457 00:20:09,340 --> 00:20:10,300 slash link layer. 458 00:20:11,300 --> 00:20:12,140 Has all the 459 00:20:13,540 --> 00:20:14,760 firmware, hardware design, 460 00:20:15,460 --> 00:20:17,180 everything you would need to put one of these 461 00:20:17,180 --> 00:20:17,780 together yourself. 462 00:20:18,100 --> 00:20:20,220 If you want, you can print your own board and build it. 463 00:20:21,120 --> 00:20:22,000 Cantact.io 464 00:20:22,000 --> 00:20:25,320 C-A-N-T-A-C-T is the actual website. 465 00:20:26,080 --> 00:20:26,980 I'm not allowed to get 466 00:20:26,980 --> 00:20:28,540 so I'm just going to stop right there. 467 00:20:29,500 --> 00:20:31,420 You can go learn more on that website. 468 00:20:32,640 --> 00:20:33,300 But yeah, 469 00:20:33,340 --> 00:20:35,380 the main goal was let's build an open source one. 470 00:20:35,620 --> 00:20:37,300 And the information's 471 00:20:37,300 --> 00:20:39,120 out there now for anybody here to go out 472 00:20:39,120 --> 00:20:41,280 and build a USB to CAN tool that speaks socket language. 473 00:20:41,300 --> 00:20:41,360 Can. 474 00:20:43,760 --> 00:20:45,000 Any other thoughts, 475 00:20:45,260 --> 00:20:46,420 questions, ramblings? 476 00:20:46,760 --> 00:20:47,940 I'll take anything, really. 477 00:20:48,100 --> 00:20:50,620 This was meant to be kind of quick and introductory. 478 00:20:55,720 --> 00:20:56,760 Not after market. 479 00:20:57,000 --> 00:20:58,600 I've worked with some OEMs, but not with this. 480 00:21:00,300 --> 00:21:00,780 It's 481 00:21:01,420 --> 00:21:02,980 a really divided world, 482 00:21:03,080 --> 00:21:03,800 the automotive one. 483 00:21:04,640 --> 00:21:07,000 OEMs, for example, work with the most expensive tools 484 00:21:07,000 --> 00:21:07,880 out there that cost 485 00:21:07,880 --> 00:21:10,980 more than everyone's 486 00:21:11,500 --> 00:21:12,760 You can get this for registration here 487 00:21:12,760 --> 00:21:13,880 combined times 10. 488 00:21:15,200 --> 00:21:16,160 Stuff like that. 489 00:21:16,320 --> 00:21:17,800 You were talking like five figures 490 00:21:17,800 --> 00:21:20,560 before you can get even a single CAN channel 491 00:21:20,560 --> 00:21:22,000 plus the software, plus the support, 492 00:21:22,180 --> 00:21:23,240 plus, plus, plus. 493 00:21:24,340 --> 00:21:26,040 The tuning guys, I'm guessing, 494 00:21:26,100 --> 00:21:28,220 are more into cheaper things 495 00:21:28,220 --> 00:21:29,300 and they need to get that out there. 496 00:21:29,460 --> 00:21:30,700 That could be interesting. 497 00:21:30,960 --> 00:21:33,600 But it's a pretty closed community from what I've seen. 498 00:21:33,780 --> 00:21:35,460 They don't want to talk about much. 499 00:21:35,460 --> 00:21:37,380 I don't know if you work in that. 500 00:21:38,500 --> 00:21:39,240 Yeah, okay. 501 00:21:40,320 --> 00:21:41,620 It would be interesting. 502 00:21:41,860 --> 00:21:43,000 We should talk, yeah. 503 00:21:43,360 --> 00:21:45,640 Because some people figure out secrets 504 00:21:45,640 --> 00:21:48,040 about how to make your car go faster 505 00:21:48,040 --> 00:21:50,160 and they want to not tell you that 506 00:21:50,160 --> 00:21:51,560 because they can make money off of 507 00:21:51,560 --> 00:21:52,820 selling that option. 508 00:21:54,360 --> 00:21:56,040 That's a business model, I guess. 509 00:21:57,100 --> 00:21:58,720 The automotive companies, of course, 510 00:21:58,860 --> 00:22:00,480 they're most interested in making your car 511 00:22:00,480 --> 00:22:02,400 as emissions friendly as possible 512 00:22:02,400 --> 00:22:03,040 nowadays. 513 00:22:03,440 --> 00:22:04,980 So that's why. 514 00:22:05,460 --> 00:22:07,140 The aftermarket guys can have some fun. 515 00:22:07,960 --> 00:22:09,900 We don't care about emissions now, 516 00:22:10,020 --> 00:22:11,060 let's just go for performance. 517 00:22:11,340 --> 00:22:13,600 And then suddenly your car behaves very differently. 518 00:22:16,740 --> 00:22:18,420 Any other stuff? 519 00:22:19,000 --> 00:22:19,500 Yeah. 520 00:22:23,560 --> 00:22:24,120 So, 521 00:22:38,300 --> 00:22:39,060 Oh, okay. 522 00:22:39,200 --> 00:22:40,500 So if you want to figure out 523 00:22:40,500 --> 00:22:41,940 what ECUs are talking to each other, 524 00:22:42,080 --> 00:22:43,480 the question was how do you figure out 525 00:22:43,480 --> 00:22:44,540 interactions between them. 526 00:22:47,500 --> 00:22:49,940 Oh, if you want to simulate an ECU. 527 00:22:50,000 --> 00:22:50,120 Okay. 528 00:22:50,200 --> 00:22:51,920 So it's hard. 529 00:22:52,120 --> 00:22:55,460 CAN is a totally multi-master bus 530 00:22:57,260 --> 00:22:58,940 and everything is sent to everybody. 531 00:22:59,120 --> 00:22:59,460 It's broadcast. 532 00:23:00,300 --> 00:23:02,120 So every message that's sent out 533 00:23:02,120 --> 00:23:03,840 could be received by every controller 534 00:23:03,840 --> 00:23:04,640 for all you know. 535 00:23:05,460 --> 00:23:06,680 You have no idea really how they act. 536 00:23:07,000 --> 00:23:08,680 The way you would find out is 537 00:23:09,180 --> 00:23:11,120 you get the DBC file, 538 00:23:11,380 --> 00:23:13,540 which is a CAN database from the manufacturer, 539 00:23:13,800 --> 00:23:14,820 which actually will say 540 00:23:15,320 --> 00:23:16,980 here are all of the nodes in the network, 541 00:23:17,240 --> 00:23:18,720 here is all the messages that 542 00:23:18,720 --> 00:23:19,960 every single one of them receives. 543 00:23:20,660 --> 00:23:22,760 The only problem is the manufacturer 544 00:23:22,760 --> 00:23:24,380 is not going to give that to you. 545 00:23:27,620 --> 00:23:28,100 Yeah. 546 00:23:28,520 --> 00:23:30,120 They're not going to give it to you. 547 00:23:30,720 --> 00:23:32,640 They'll make it available if you 548 00:23:32,640 --> 00:23:35,000 care to go down that road. 549 00:23:36,560 --> 00:23:37,380 So yeah, 550 00:23:37,460 --> 00:23:38,340 they just don't want you to know 551 00:23:38,340 --> 00:23:40,100 or they figure they can make money off 552 00:23:40,100 --> 00:23:42,100 keeping that information secret and selling it. 553 00:23:43,100 --> 00:23:45,120 So really the best way to figure out 554 00:23:45,120 --> 00:23:46,440 interactions between controllers 555 00:23:46,440 --> 00:23:48,860 is by trial and error nowadays. 556 00:23:49,220 --> 00:23:50,120 It's sort of, 557 00:23:50,140 --> 00:23:52,100 it sounds unfortunate but it's true. 558 00:23:52,300 --> 00:23:53,800 If you disconnect a controller 559 00:23:53,800 --> 00:23:55,320 from a CAN bus, 560 00:23:55,560 --> 00:23:56,880 a whole bunch of messages disappear 561 00:23:56,880 --> 00:23:58,980 so you know where those were coming from at least. 562 00:23:59,940 --> 00:24:02,340 You can also do things like fuzzing the 563 00:24:02,640 --> 00:24:03,120 CAN bus while it's running. 564 00:24:03,120 --> 00:24:05,520 Fuzzing in a real car can be kind of dangerous. 565 00:24:06,680 --> 00:24:08,200 I have a little story. 566 00:24:08,400 --> 00:24:10,960 I was talking about this at another conference. 567 00:24:11,120 --> 00:24:12,780 There was somebody from Continental in the audience 568 00:24:12,780 --> 00:24:13,860 and he was like, 569 00:24:13,940 --> 00:24:15,140 don't tell people to fuzz CAN. 570 00:24:15,740 --> 00:24:17,140 I said, okay, why not? 571 00:24:17,480 --> 00:24:20,140 He said, well, I'm not going to give you any details 572 00:24:20,140 --> 00:24:22,340 but you can actually destroy an engine 573 00:24:22,340 --> 00:24:23,900 by fuzzing the CAN bus while it's running. 574 00:24:24,180 --> 00:24:26,100 I was like, oh, I've seen it happen. 575 00:24:26,220 --> 00:24:27,680 I was like, oh, that sounds really bad. 576 00:24:28,780 --> 00:24:30,300 So you can do fuzzing 577 00:24:30,300 --> 00:24:32,160 but that gets to be somewhat problematic. 578 00:24:32,640 --> 00:24:34,140 You can actually potentially mess things up. 579 00:24:35,760 --> 00:24:36,800 In simulating, 580 00:24:36,980 --> 00:24:38,700 if you're doing V-CAN simulations, 581 00:24:39,540 --> 00:24:41,060 the easiest way to do it 582 00:24:41,060 --> 00:24:42,940 is you treat the V-CAN interface 583 00:24:42,940 --> 00:24:44,300 like a CAN bus 584 00:24:44,300 --> 00:24:46,120 and you just make everybody connect to it. 585 00:24:46,380 --> 00:24:49,120 You can also use it for piping messages around. 586 00:24:49,960 --> 00:24:51,880 I've seen at least one script 587 00:24:51,880 --> 00:24:54,040 that took messages 588 00:24:54,040 --> 00:24:55,400 from a real CAN interface, 589 00:24:55,740 --> 00:24:57,060 moved them to V-CAN 590 00:24:57,060 --> 00:24:58,880 doing some filtering 591 00:24:58,880 --> 00:25:00,920 and some reassignment of IDs 592 00:25:00,920 --> 00:25:02,620 and then moved them back 593 00:25:02,640 --> 00:25:04,160 to a different CAN interface. 594 00:25:04,560 --> 00:25:05,400 So that way, 595 00:25:05,560 --> 00:25:07,760 what often happens 596 00:25:07,760 --> 00:25:09,280 is you buy something from an OEM 597 00:25:09,280 --> 00:25:13,000 it only supports CAN ID 100 and 101 598 00:25:13,000 --> 00:25:14,800 and they want to charge you 599 00:25:14,800 --> 00:25:15,580 like 10 grand 600 00:25:15,580 --> 00:25:18,640 to change it to 102 and 104 or whatever. 601 00:25:18,920 --> 00:25:20,580 So you put a device in the middle 602 00:25:20,580 --> 00:25:22,300 and you make it do that translation for you 603 00:25:22,300 --> 00:25:22,840 because it's cheaper. 604 00:25:23,400 --> 00:25:24,480 For stuff like that, 605 00:25:24,520 --> 00:25:25,580 V-CAN can be pretty useful. 606 00:25:26,980 --> 00:25:28,800 But in terms of actually knowing 607 00:25:28,800 --> 00:25:29,720 who's talking to who, 608 00:25:29,800 --> 00:25:30,160 unfortunately, 609 00:25:30,720 --> 00:25:32,660 CAN is pretty good at hiding that from you. 610 00:25:33,420 --> 00:25:35,020 Makes a lot of other stuff available though. 611 00:25:35,860 --> 00:25:36,340 Yep? 612 00:25:42,520 --> 00:25:43,000 Sure. 613 00:25:47,820 --> 00:25:49,240 So this is raw CAN. 614 00:25:49,540 --> 00:25:50,960 This is just the messages. 615 00:25:51,140 --> 00:25:52,660 This will do anything except CAN FD. 616 00:25:54,300 --> 00:25:55,980 For those higher level protocols, 617 00:25:56,280 --> 00:25:58,460 1939, OBD2, 618 00:25:59,400 --> 00:26:00,700 Unified Diagnostic Services, 619 00:26:01,040 --> 00:26:02,800 which is ISO 14229, 620 00:26:03,600 --> 00:26:03,940 I think. 621 00:26:04,140 --> 00:26:04,620 Somebody? 622 00:26:04,780 --> 00:26:05,440 Yeah, I got it. 623 00:26:06,780 --> 00:26:07,660 For those, 624 00:26:07,840 --> 00:26:09,360 you're going to need some higher level software. 625 00:26:10,060 --> 00:26:12,080 There is support for 626 00:26:12,080 --> 00:26:13,780 all right, 627 00:26:13,780 --> 00:26:14,300 I have to back up. 628 00:26:14,680 --> 00:26:17,180 CAN supports 8 bytes per message. 629 00:26:17,780 --> 00:26:18,800 That's a little limiting 630 00:26:18,800 --> 00:26:19,760 if you're trying to send, 631 00:26:19,920 --> 00:26:21,440 let's say, a firmware update 632 00:26:22,040 --> 00:26:23,240 8 bytes at a time. 633 00:26:29,440 --> 00:26:30,460 15765-2. 634 00:26:31,520 --> 00:26:32,560 15765-2. 635 00:26:32,640 --> 00:26:33,420 I'm bad with numbers. 636 00:26:34,760 --> 00:26:36,900 So that is the protocol that's used 637 00:26:36,900 --> 00:26:37,680 to basically say, 638 00:26:37,820 --> 00:26:40,100 I want to send 10 kilobytes over CAN. 639 00:26:40,440 --> 00:26:41,920 How do I string it all together? 640 00:26:42,420 --> 00:26:42,980 It'll do that. 641 00:26:43,500 --> 00:26:45,000 Then on top of that 642 00:26:45,000 --> 00:26:47,440 are the actual services for UDS. 643 00:26:48,220 --> 00:26:49,500 That middle part, 644 00:26:49,720 --> 00:26:51,180 which is called ISO TP, 645 00:26:51,580 --> 00:26:52,460 if you don't want to remember 646 00:26:52,460 --> 00:26:54,740 that number that Rob yelled out, 647 00:26:56,200 --> 00:26:58,180 that is actually implemented 648 00:26:58,800 --> 00:26:59,240 in the kernel space, 649 00:27:00,180 --> 00:27:02,320 but it's not included with the kernel 650 00:27:02,320 --> 00:27:04,160 and it's really hard to build. 651 00:27:05,280 --> 00:27:06,820 It's a lot of buts, I'm afraid. 652 00:27:07,060 --> 00:27:08,500 It would be really nice if it worked, 653 00:27:08,560 --> 00:27:09,120 but it doesn't. 654 00:27:09,540 --> 00:27:11,640 One thing I'm working on are some new 655 00:27:11,640 --> 00:27:14,040 open source software tools 656 00:27:14,040 --> 00:27:16,080 for doing the higher level protocols, 657 00:27:16,300 --> 00:27:18,900 but socket CAN itself is very raw. 658 00:27:19,300 --> 00:27:20,560 Give it 8 bytes, 659 00:27:20,700 --> 00:27:21,400 a data length code, 660 00:27:21,620 --> 00:27:23,080 and a message ID, 661 00:27:23,240 --> 00:27:24,480 and it will send a frame. 662 00:27:24,700 --> 00:27:25,420 That's about it. 663 00:27:30,920 --> 00:27:31,580 That's the silence. 664 00:27:31,780 --> 00:27:32,360 Are we good? 665 00:27:32,560 --> 00:27:33,580 You can find me after 666 00:27:33,580 --> 00:27:35,240 and ask me about anything, really. 667 00:27:36,380 --> 00:27:37,940 I'll be around here for a little while. 668 00:27:38,080 --> 00:27:39,920 Thanks a lot for listening about socket CAN. 669 00:27:40,120 --> 00:27:41,460 Hopefully it was of some interest 670 00:27:41,460 --> 00:27:42,460 and you can play around with it.