This is upside down. Great. Can we take it from the start please? Sure: How about we take do it step-by-step, HowTo-like? Just navigate to my new NXT::USB tutorial!
Once you've gathered the necessary info, that's all you'll need to enjoy your NXT brick doing very clever things in NBC or NXC on your linux box.
For this, all that you shall need is Kate, the over-powerful, Mighty Text Editor from the KDE family.
No, it doesn't mean you'll need to get a fully functional KDE system on board if you are a gnome addict. or fluxbox, whatever: the screen above shows my desktop which runs Enlightenment DR16, and it's just gorgeous this way, on top of being very neat.
Let's look at Kate: as of now, on the left, you'll see the list of my currently opened text files; instead, I could switch to a Filebrowser in one click (on leftmost bar) in case I'd like quick access to another one. The actual Text job is obviously in the upper-right part, and it's just plain that. start writing in Perl or something, it will even give you colored tags to help. The lower Part is what/where KDE makes the difference: it's a terminal window. Tell me: isn't it obvious that with your Code Editor, you may want to run some operations? Hmm? well, yes it was obvious to those KDE devs too, and so whenever you are writing code you may as well complie it and run it from the same window! How neat is that! Not near enough: the Terminal can be replaced by a search panel. That ought to be enough, even for the most demanding Nerd. But, then, the Nerd being what it is (a nerd), he could think of further features, and discover that yes, they are implemented: comparing two files by splitting your Text window in two (or more) panels, keep bookmarks of places, expand and collapse your code tree; decide what Color Code you want to use to highlight your hard work (in the Tools menu) or even open several tabs to literally expand the wealth of code you manage to a third dimension (since there's already the leftmost list of current opened files for quick access). You sure can save all or one file, save your Session as well, and even export it as html (?). Most everything is though about mouseless, there's keyboard shortcuts to most actions. And yes, you can display Line Numbers too!
But that was for the Framework, now, what's inside the toolbox when it comes to speaking to my NXT brick? Well, it's fairly simple actually. All you'll gonna need is as follow:
- A text editor, of which I think I made clear I recommend Kate. Didn't I?
- the nbc compiler from John C Hansen. John is becoming a legend among the dev-for-mindstorms community.
- the NexTTools utility, to write to / get info from, your brick. full-featured but not as quick as:
- t2n which is the easiest/fastest way to put stuff on the brick. You don't need it for real if you have NexTTool, but it's just faster, leaner.
OK THEN WHAT NOW?
Well, say you start with John's NXC tutorial, OK? All the following understand you are working from a single folder, USB wire plugged, NXT switched on, UDEV rules done, CHMOD & Symlinks done. (see below about that. I told you I was going upside down!)
- Start writing your snippet,
- Save it under your choice of (wise) name, with an .nxc at the end, or the nbc compiler will puke.
- run a command like: nbc yoursnippetname.nxc -O=yoursnippedcompiledname.rxe // in this case, - means option, O is a Block Letter O like not a ZERO, then the = sign connects it to the desired output name. It doesn't matter you work in nbc or nxc language, as long as you name it properly; both will be compiled by nbc. this little piece of software even debug your scripts by shortstopping over any compilation error!
- use t2n -put yourcompiledsnippet.rxe to upload your code to the NXT.
- If you feel to tired after that to press the orange button on the Brick, then do NexTTool /COM=USB -run=yoursnippedcompiled.rxe and voila, it should run.
Well it does here, definitely, with USB and not BT & Not Python but that shall do right now.
Yeah, great. Can we take it from the start please?
Sure: How about we take do it step-by-step, HowTo-like? Well, yeah, just navigate to my new NXT::USB tutorial!
Stuff You'll Need is, I believe, amptly layed down above
Now, Speak to The Brick
Well then, that's simple now: all you have to do is read again this post from the beginning...
Just for the sake of testing, go to your nexttool folder, and try
./NexTTool /COM=USB -deviceinfo
So that you know if everything went right. And if it did, then it's all thanks to John --deadlink see here instead, not me. I am just spreading the word, that's my contribution to it. NXT::USB tutorial
Some personal tips though: Clean Up the Mess
You really don't need much to start programming the next NXT-based MarsRover: you do not need a powerful machine or that much of ram, you can do it with a text editor, a decent usb stack and the above mentionned nbc, Nexttool and t2n; and if you feel like going Python or whatever, you won't need more anyway. One tho,g tough that started to annoy me was the sheer number of micro-apps that I had to keep in one single place & start with ./ + the need to have the not-yet-compiled candidate there too if I did not wanted to change folders all the time; so:
- NexTTool is a completely anti-Linux name, I renamed it to nexttool;
- All these are to be chmod'ed +x to be able to execute;
- Of the three programs that you'll use, nbc, nxttool & t2n, I made them part of the wheel group (that my user belongs to too) and moved/linked them to /usr/bin so that I can really type t2n -put ... or nbc this.nxc -O=that.rxe... like they are just normal executables, part of my system. Which they are, after all.
Now i am working from a neat ~/mindstorms/compile/ folder where the only non-nxc/nbc/rxe thingie is a subminimal script as follow:
#!/bin/bash nbc x1.nxc -O=output.rxe t2n -put output.rxe nexttool /COM=USB -run=output.rxe nexttool /COM=USB -runningprogram
This script assumes you are working on the x1 project, and that you want to put it & start it on the brick as output.rxe; I do this with every "draft" snippet, and then I name them properly and compile them with the appropriate output name for archival/sharing when I am happy with the result.
Lola 15:05, 1 July 2008 (UTC)
Sample Snippets are here.