Tag Archive: linux


Ok, let me state up front: Trying to get Processing to read your Arduino on linux (ones that get the /dev/ttyACM0 port) is broken! For all the good work all the devs are doing, this has been the case for far too long.

I spent a whole afternoon trying everything suggested on the RTXT site, Processing site, countless forums, including:

  • The version mismatch is at fault
  • You should be in the uucp group
  • Downgrading/Installing the TXRX package from Ubuntu
  • Throwing your linux machine off the cliff (not really tried)

Nothing of these work. And they shouldn’t be needed, because the Arduino IDE uses RXTX and still manages to work.

Why, you ask? Because our lovely Arduino devs recompiled RTXT doing two essential things:

  • Forget about locking the tty file
  • Have RXTX search ttyACM ports

So, let’s see how we can use their version of RXTX with Processing and forget this nightmare once and for all 😉

First, download the Arduino software for both 32bit and 64bit architectures from here http://www.arduino.cc/en/Main/Software .

Untar those files to some temporary folders, for which I’ll be using the names <arduino-32bit> and <arduino-64bit>

Let’s also name the folder where you have Processing lying around as <processing>.

Do the following:

  • Backup the <processing>/modes/java/libraries/serial/library folder for some good measure.
  • Copy <arduino-32bit>/lib/RXTXcomm.jar overwriting the one in <processing>/modes/java/libraries/serial/library
  • Copy <arduino-32bit>/lib/librxtxSerial.so overwriting the one in <processing>/modes/java/libraries/serial/library/linux32
  • Copy <arduino-64bit>/lib/librxtxSerial.so overwriting the one in <processing>/modes/java/libraries/serial/library/linux64
  • Copy <arduino-64bit>/lib/librxtxSerial64.so to <processing>/modes/java/libraries/serial/library/linux64
  • You’re done! 😉

Or, you could compile them from source to see what works for you, but really, why go through it?

Please, please, if you find this useful, try and locate some of all those forum threads regarding this problem and let them know ^^

So, yesterday NASA published a collection of sounds from historic spaceflights and current missions.
You can check them out here.

Well, I noticed there was no ‘download ALL’ button there, and because most links at a time were hidden by means of javascript my normal tools didn’t really work.

SO! It was time for some scripting!

First, I opened up the FireBug console [link] and tried to see if jQuery was used on the page.
Of course it was, BUT, with a twist. The $ shortcut was assigned to another library. No matter, I can still use jQuery ‘s full name.

So, let’s get a list with all the links to .mp3 files:

jQuery('a[href$=".mp3"]')

which means, get all anchor elements whose href attribute ends with “.mp3”

What should we do to them then?
Keeping it simple, let’s just print the href attribute for each of them on the console. So we go:

jQuery('a[href$=".mp3"]').each(
    function(){
        console.log(jQuery(this).attr('href'));
    })

Pretty straightforward. It’s a one-liner, but I indented here for clarity.

You’ll notice that at the end of the links, we also get an array of all the elements. Well, that’s because our whole statement also returns the collection.
So let’s copy-paste the links to a text file, let’s name it ‘in’.

........
/mp3/590318main_ringtone_135_launch.mp3
445945....min.js (line 30)
/mp3/577774main_STS-135Launchringtone-v2.mp3
445945....min.js (line 30)
/mp3/590196main_ringtone_135_landingCommanderComments.mp3
445945....min.js (line 30)
/mp3/590316main_ringtone_135_landingNaviusComments.mp3
445945....min.js (line 30)
/mp3/581549main_Apollo-8_Merry-Christmas.mp3
........

Oh bummer! We also got a lot of lines like “445945….min.js (line 30)” on them. Not really a problem, let’s crunch it up with python for the geek-out factor:
I ran this:

with open('in') as f:
    lines = f.readlines()
final = [line for line in lines if line.endswith('.mp3\n')]
with open('out', 'w') as f:
    f.writelines(final)
    f.write('\n')

Again, we only keep that lines that end with ‘.mp3’ (and the newline) as relevant.
What should we do with our list file now you ask? But of course use wget.
We want wget to grab all our .mp3s from the list in the file, prepending ‘http://www.nasa.gov&#8217;, as the urls are relative
Here it is:

wget -i b -B http://www.nasa.gov

And voila! Here is our collection of NASA mp3s for our geeky pleasure!

So, here’s a recipe for destruction:

  • Open your Windows VM you have for uni classes to write up a nice little recursive version of a simple algorithm.
  • Put some printf statements there for debugging too. Should look something like this:
int eukleid(int x, int y)
{
    printf("%10d %10d", x, y);
    if(y=0) return x;
    else return eukleid(y, x%y);
}
  • Fail to notice that y=0 instead of y==0 sends your program to endless recursion
  • After 10 minutes of crashing in Windows, decide that, what the hell, I’ll try it in my linux machine.
  • Compile program
  • Instead of running in a shell, double click the executable in nautilus by negligence.
  • Watch your /home partition run out of space in seconds!!!!

Now, what happened is that stdout and stderr of programs started outside a terminal get logged in .xsession-errors. The recursion shouldn’t have gone forever, but, by some strange bad luck, it filled up what was left of my 5GB headspace I had in /home

Not finding the culprit at first glance, I decided to close all programs and restart to single-user to look into it. Unfortunately, closing the VM meant virtualbox trying to update the VM’s xml file. THAT didn’t go well.

So, I was left with an unusable VM which took me a couple of hours to restore to some working condition.

Hey, it could have been worse! All the other programs (firefox, thunderbird to name a couple) handled the problem nicely. And thank Cthulu I had a separate partition for /home. Can’t imagine the mayhem if the root partition had zeroed out.

But everything is swell! I now know a couple tricks more than yesterday and opportunities like this don’t come everyday 😉 Such is the mantra of a troubleshooter soul like me! =)

Nick

Intro

Χαίρετε!

Λίγο background info:

Ονομάζομαι Νίκος και η πρώτη μου επαφή με υπολογιστή ήταν στα 8 μου χρόνια, όταν ένας θείος μου με άφησε να κάτσω στον 8086 του για να με ηρεμήσει επειδή μόλις είχα κλείσει τον αντιχειρά μου ε μία πόρτα αυτοκινήτου. Μπορείτε να πείτε ότι το συγκεκριμένο μου άφησε κουσούρι.

Η πρώτη μου επαφή με προγραμματισμό ήταν στο γυμνάσιο, όταν, ελλείψει υπολογιστή έγραψα σε φύλλο τετραδίου το πρώτο μου ‘Hello World’ σε BASIC. Λίγο μετά πήρα έναν 386 με Windows 95.

Μέχρι πολλά χρόνια μετά, δεν ασχολήθηκα πολύ με τα PC, μάλιστα δεν ανανέωσα τον 386 μέχρι το 2004. Κι όμως, το μικρόβιο υπήρχε και ήταν αρκετές οι φορές που φίλοι μου με τα Pentium τους με έπαιρναν τηλέφωνο να με συμβουλευτούν πως να κάνουν τα format τους.

To 2004 αγόρασα την Αλεξάνδρα, έναν P4 στα 2.66 από την οποία σας γράφω αυτή τη στιγμή. Ναι, έχει γυναικείο όνομα. Αυτό ανήκει σε άλλη συζήτηση όμως.

Πέρυσι, μέσα στην απαλεψιά και την βαρεμάρα του στρατού αγόρασα ένα βιβλίο για HTML και CSS. Μετά ανακάλυψα το Internet στο κινητό μου και άρχισα να διαβάζω C tutorials. Λίγο πριν αρχίσω να τραβάω τα μαλλιά μου με την C, γνώρισα τον αγαπητό μου Κεραμίδα που μου πρότεινε την Python. Αρκετά βιβλία και tutorials και πάμπολλες γραμμές κώδικα μετά δεν ξανακοίταξα πίσω.

Σήμερα ασχολούμαι με Python, παίζω προγραμματίζοντας παιχνιδάκια σε pygame, μαθαίνω σιγά σιγά django, χρησιμοποιώ αρκετά το Mercurial. Είμαι ένας μικρός νεόφυτος wannabe προγραμματιστής αν θέλετε. Με πολλή αγάπη και όρεξη και αρκετό ελεύθερο χρόνο.

Το blog:

Υπήρξα χρήστης Windows αρκετά χρόνια. Οι γνώσεις μου πάνω τους είναι αρκετές ώστε να κάνω μπόλικα “μαγικά” μέχρι και στην υποτυπώδη κονσόλα τους. Και αν δεν υπήρχε το “ανιψάκι” της κάθε σύγχρονης οικογένειας θα μπορούσα να βγάζω το χαρτζιλίκι μου κάνοντας format.

Δεν έχω πρόβλημα με τα Windows. Είναι καλός συμβιβασμός για τον “μέσο χρήστη” που θέλει να κοιτάει το facebook του. Και τα 7 έχουν κάνει πολλά βήματα μπροστά.

Το πρόβλημα είναι πως τα έχω μάθει μέσα έξω και τα βαρέθηκα. Δεν μου καίνε εγκεφαλικά κύτταρα όπως παλιά. Και, όπως σιγά σιγά άρχισα να αντικαθιστώ τα “σπασμένα” προγράμματα μου με εφάμιλλα δωρεάν εργαλεία, ήταν καιρός να κάνω το ίδιο με το λειτουργικό μου:

*ήχο από ρούλο σε ταμπούρο παρακαλώ* Η Αλεξάνδρα πλέον τρέχει Linux Mint. Είναι ένα όμορφο distribution βασισμένο επάνω στο πολυ-διαδεδομένο Ubuntu αλλά λίγο πιο φιλικό σε θέματα proprietary software (τρέχει από μαμά Flash, Java και drivers για την κάρτα γραφικών σας). Και είναι πράσινο αντί για εκείνο το αντιαισθητικό καφέ του πατέρα του. Είμαι σίγουρος ότι οι hardcore linuxάδες θα έχουν μερικά πράγματα να σχολιάσουν, αλλά η πραγματικότητα είναι ότι, όπως και τα Ubuntu, κάνει την δουλειά για την οποία φτιάχτηκε πολύ καλά. Περνάει με τις ελάχιστες σκοτούρες τον χρήστη από τα Windows στον κόσμο των ανοιχτών λειτουργικών ώστε να αρχίσει την περιπέτεια του.

Αυτή την περιπέτεια θα προσπαθήσω να περιγράψω και εγώ από την σκοπιά μου από εδώ.

Τα λέμε για τώρα, και υπόσχομαι, τώρα που έγινε η γνωριμία μας, οι επόμενες αναρτήσεις να έχουν πολύ περισσότερο ενδιαφέρον.

Logging off,

Νίκος