Sniff is a "Scratch-like" programming language that's designed to help Scratchers move gently from Scratch to more conventional languages. They can start writing programs, without having to learn a new language because Sniff is based on Scratch. They learn a little more about variables, compiling, syntax errors (!), and they can have fun controlling real hardware while they're doing it.

Friday, 5 September 2014

ev3dude: programming the Lego EV3 without WIFI

To get access to the Unix shell on the EV3 you need a WiFi adapter. That's sort of OK, but only 1 adapter is supported, and its quite large. If you don't have one, you don't have access to a WiFi network or perhaps you've simply put the EV3 somewhere a the adapter isn't going to fit, then you can't get a shell, you can't use SSH and you can't transfer files.

However the EV3 has USB and Bluetooth built in. The problem is that they only supports the proprietary protocol used by the Lego Software. A couple of people have built tools to work with it, buts what's needed is a generic, and simple command line tool that lets you transfer files to the EV3. Well here it is and its called ev3dude!

Firstly you need to pair your computer to the EV3 over Bluetooth. As my only bluetooth machine is a Mac, I've built and tested on that, and when you pair it creates a file called /dev/cu.EV3-SerialPort. The name will change if you've renamed your brick to something other than EV3, but it'll be something like that.

Now get the source to ev3dude, and compile it by typing:
make ev3dude

now test it by running
ev3dude /dev/cu.EV3-SerialPort

(or whatever your device is called).

Now you can get a directory listing of your SD card by typing:
ev3dude /dev/cu.EV3-SerialPort -l /media/card

The formatting is a bit funny, as the EV3 sends md5 hashes of the files, along with their size and name, but the info is pretty clear.

To write a file
ev3dude /dev/cu.EV3-SerialPort -w myLocalFile /media/card/filenameOnBrick

and if you change your mind you can delete it again:
ev3dude /dev/cu.EV3-SerialPort -d /media/card/filenameOnBrick

That's it! Simple and clean EV3 file transfer. It should compile without any serious issues on any Unix (let me know if it doesn't!). You're free to use and modify the code as you see fit, but please send back any changes/improvements/bug fixes so we can make this a better tool.

Combined with the Sniff menu system described in the last post we've got a mechanism for installing and running Sniff code on the Brick without WiFi. It'll be fully integrated into Sniff in the next release, but for now you can use ev3-sniff to generate the binary, and transfer it manually with ev3dude.

No comments:

Post a comment