Skip to main content


Showing posts from May, 2013

Debugging on Linux

"Where can I look in my file system that shows errors and problems?" Watch the log files! On Ubuntu:  $ sudo tail -f /var/log/syslog or on Fedora: $ sudo tail -f /var/log/messages or $ sudo tail -f /var/log/dmesg The nice thing about Linux is that you can always see what is going on.  You need not poke around in the dark when looking for the cause of a problem.

UAE Vehicle Test

As an expat in the UAE, it doesn't make economic sense to buy a fancy new car if you have no idea how long you are going to be here.  My own vehicle is a young and sprightly 2004 Dodge Durango 5.7 litre V8, which does 0 to 100km/h in about 7s,  uses only 14 litres per 100km in fuel and cruises at 120km/h at slightly more than idle speed. The Al Ain Traffic Department has a large test centre, driving school and registry, which is always overcrowded and getting a vehicle processed there can take half a day if all the Dust Devils are smiling kindly upon you.  This year, I went to a small test centre in Al Foah, a village on the outskirts of the city instead. They open at 8am and I was first in line.  I had my car serviced at the dealer the week before, so I left the service papers on the front seat.  The test then took only a few minutes. For the exhaust test, the vehicle is put on a dynamometer, but since the big Dodge is all wheel drive it always just climbs off the machine,

Scanner SMB Access

The company has a networked scanner which is configured to save scanned PDF documents on a MS Windows SMB share. Hooking up from a Linux machine requires a domain name, user name, password and mount operation.   I need to scan things maybe once a month, so I don't want to bother with a permanent connection. Here is a simple little script to handle this share on Fedora.  The script uses Zenity and Beesu to make it a little more user friendly.  You should replace the IP address of the scanner,  YOURDOMAIN and myusername with your credentials.  You should also create the mount point /mnt/scan . #! /bin/bash pass=$(zenity --entry --title="Add an Entry" --text="WindowsPassword:" --entry-text "password" --hide-text) beesu - mount -t cifs -o domain=YOURDOMAIN,username=myusername,password=$pass,rw,file_mode=0777,dir_mode=0777 // /mnt/scan nautilus /mnt/scan beesu - umount /mnt/scan The rw, file_mode and dir_mode para

Virtualbox with Ubuntu and Xubuntu

It has been a few years since I last used Ubuntu Linux and since some of my students are using it, I decided to install it on Virtualbox and see what the fuss is all about.  Ubuntu used to be quite a nice system, but it seems to have regressed terribly and is now almost unusably slow and clunky due to the Unity/Gnome desktop. My favourite desktop system is KDE.  I like my rotating desktop cube and wobbly windows, but on slower systems, I use the simpler XFCE or LXDE.  Gnome/Unity however, is the Win8 of Linux at this stage of its development and is much unloved. Security Problems The Ubuntu desktop also presents a serious security risk in its default configuration, since the Lens sends all your local and remote search activities to various third parties.   Ubuntu now is really a spyware system just like that other legacy system when it is infected with viruses and junkware . The only difference is that in Ubuntu, the spyware is deliberately installed , though it can be deactivat

Compile a Moxa Serial Widget Device Driver on Ubuntu Linux

We needed a Linux serial device driver for the Moxa U1250 series multi-port USB to Serial adaptors.  The released driver on the Moxa web site only works with Ubuntu Linux up to version 11 and with Fedora Linux up to version 16, so you need a Virtual Machine of the right version for it.   Otherwise, ask Moxa support for a Beta version of their driver for the newer kernels. Ubuntu Software Installer There are basically three Linux development streams: Slackware Debian  Red Hat The Ubuntu distribution is part of the Debian family. The Fedora distribution is part of the Red Hat family. Each of these families has their own incompatible code packaging systems.  Each distribution has its own set of file servers and when you install a system, it will be configured to look at those servers for updates.  These servers are distributed all over the world at universities and large corporations.  Because they are perfect copies of each other, the servers are also known as 'mir

USB Serial Device With Unknown IDs

I got a new USB serial widget, but although it uses a regular FTDI chip, the manufacturer thought it wise to change the IDs, so that the Linux system doesn't recognize it.   Yes, I am glaring at you SerialComm... One can work around that by forcing the vendor and device IDs when the driver is loaded. For example: Plug the offending USB serial adaptor in. $ dmesg Note the Vendor and Device IDs: [452076.573062] usb 2-1.2: New USB device found, idVendor=0403, idProduct=6001 Now load the module: # modprobe usbserial vendor=0x0403 product=0x6001 and now it should show up in /dev: $ ls /dev/ttyU* ttyUSB0 Turn that into a little script in /usr/local/bin for next time and la voila!

ArduPlane Smoke Test

Where are we? The first step is just to be sure everything runs. Mission Planner test Plug the computer into the USB port of the AP.  Enable the FTDI USB device in the Windows VM.  The AP should power up like a Yuletide tree.  Let it go online and download the latest AP firmware. If you carry your whole setup (minus the main wing) into your garden and if you have WiFi access out there, then the GPS, magnetometer and gyros should activate and after a while you should see your location on the map and wherever you went, that is where you are. If you live in a desert like me, then you may not want to stay out there too long, but most people could carry on doing the rest of the tests on a patio table - all you need is power, WiFi and coffee. So now you can see where that is going - either you need to pair a smart phone with your laptop PC or get a cell phone data modem of sorts for use out at the airfield.  This isn't a cheap hobby. Manual Override Initially, you need

ArduPlane Mission Planner Installation

I love it when a plane comes together... Getting the ArduPlane autopilot installed in a plane is quite intricate and getting the Mission Planner software to work is also an adventure all by itself, hence this little guide. Virtualbox The Mission Planner software is a legacy 'Java' application created with the Microsoft DotNet toolkit. Assuming that you have a real computer - Linux or Mac - you would need a virtualizer to run some version of Windows.  I always use Windows XP for virtual machines, since I own about a dozen useless licenses for it and it is light and fast on a VM. First get Virtualbox from Oracle for your machine . Make a VM and install your favourite least hated version of Windows, then select Guest Additions from the Devices menu and install it in Windows, then restart the VM.  Your screen should now resize and the mouse and copy/paste buffer should work transparently with UNIX. DotNet Getting DotNet inst

RC Electric Glider Autopilot Conversion

Scope This document provides a brief description of the conversion of a RC plane to autonomous control with an Ardupilot ( system. I started this project about 1 1/2 years ago and worked on it off and on.  My main problem was keeping track of the details, hence this guide.  If you have the time or inclination, then you can finish it off in a week! ­ I chose a large, positively stable RC Electric Glider from Sussex Model Centre ( ) in the UK. The plane has a 2 meter wingspan with 3 degrees of dihedral and swept up wing tips. A positively stable glider will fly on its own even when the electronics are dead and it will eventually land all by itself too.  It will simply glide into the ground and ground effect will make it flair.  So if you can find it and there are not too many trees about, then you should always be able to recover your plane intact.  I prefer h

Using dd on a Mac to copy an ISO file

I downloaded a Fedora ISO file and needed to copy it to a USB memory stick to install on another machine, but the Mac user interface is just enough different from Linux to be annoying: Hermans-MacBook-Pro:Downloads herman$ sudo dd if=Fedora-18-i686-Live-LXDE.iso of=/dev/disk2 Password: dd: /dev/disk2: Resource busy Now what?  Some googling later... Hermans-MacBook-Pro:Downloads herman$ sudo diskutil umountDisk /dev/disk2 Unmount of all volumes on disk2 was successful Of course, you can also use Disk Utility to unmount the thing. Hermans-MacBook-Pro:Downloads herman$ sudo dd if=Fedora-18-i686-Live-LXDE.iso of=/dev/disk2 Even Data Definition is different and Ctrl-T will show the dd progress as records in/out. Raspberry Pi SD Card Images After copying a RPi image to a SD card, it may be necessary to edit the /etc/rc.local  or  wpa_supplicant.conf file on the SD card.  To do that, you need to mount the SD card in a Linux virtual machine, since a Mac cannot

Virtualbox file share permission problem

Virtualbox (by Oracle) is my favourite virtualizer and was the first thing I installed on my new Mac, so that I can run Fedora Linux on it.  A Mac is great for common users and I would advise anyone to buy a Mac instead of that other sad legacy system that always gets riddled with viruses and malware. However, I am an engineer and need to be able to test and debug things and write low level programs - I am always rooting around in the weeds and need Linux for that. So I wanted to share my Mac Documents directory.  After some sleuthing I found that it gets mounted as /media/sf_Documents , but I then got a permission problem when I tried to access it. The solution is to add yourself to the vboxsf group and then reboot the virtual machine: $ su - password # usermod -a -G vboxsf herman Just logging out and loggin in again is not sufficient.

Macbook Pro file browser replacement

My little Lenovo netbook died of old age, so I picked up one of the new Apple Macbooks with a so called retina display.  The high resolution screen is absolutely worth the money. My main gripe with a Mac is the horrid excuse for a file browser called Finder .  A file browser that doesn't allow you to browse all files, is really not a terribly bright idea - it doesn't do much of anything really and is quite useless.  Even Microsoft Windows Explorer works better than Finder . Fortunately some kind souls have coded up a few alternatives including one called Macintosh Explorer (by Rage).  You can get it here: Mac Explorer is free and it works - a good combination of features - although I like the Linux file browsers such as Dolphin and Thunar better. Another well kept secret, is to extend the Finder with a plug-in called Xtrafinder (by Tran Ky Nam), which makes Finder a whole lot more useful:

SSH Brute Force Attacks

Years ago, some vagrant made a SSH password brute forcer and my servers got around 10,000 SSH login attempts per hour. I fixed it with an iptables rate limit rule: iptables -A INPUT -p tcp --dport 22 -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m limit --limit 3/min --limit-burst 3 -j ACCEPT iptables -A INPUT -p tcp --dport 22 -j DROP

Airport Web Browser Security

Contrary to the popular perception, the world is not round - it is a giant polygon and my work has taken me to many a strange corner. Travelling with a laptop computer is a risky business.  They are easily stolen and the financial cost pales into insignificance compared to the inconvenience of having to set up a new one again after having lost all your contacts and other keyboard kreature komforts. On a Linux system, you absolutely must use 'f ull disk encryption '.  This is so easy to set up, that there is no excuse not to.  It only protects your data when at rest - when the machine is turned off, but your ordinary perp will try to log in, won't get past your 16 character password, then reboot and promptly get stuck at your 20 character encryption password (OK not everyone is as paranoid as me, but you should use at least 12 characters for a password).  After a few days, the machine will be re-installed with Windows XP and sold on Ebay, while your personal and financi

No more printing woes

Linux uses the CUPS printing system (provided by Apple). Usually, one can just plug a printer into a Linux machine and it will be instantly recognized.  This is so much easier than downloading and installing drivers on a legacy system. On the odd occasion that something is amiss, printing a document from the command line can pinpoint the issue. When you execute a command manually, you can see the error messages and then google them, or look for a solution on . Use lp or lpr to send a document to the default printer: $ lp filename or to print to a specific printer: $  lp -d printer filename Sometimes it is easier to send a file directly to a printer than to launch an editor just to open and print a file, for example: $ lp -o landscape -o fit-to-page -o media=Letter filename.jpg CUPS understands many file types directly, such as PDF, postscript, text, or pictures! Sometimes, when you are busy installing a new machine, you may wish to print

RS422 to RS485 Adaptor

I got a radio with a RS422 port and got to hook up a camera with a RS485 port.  Electrically, the two are much the same, but RS422 is four wire, full duplex and RS485 is two wire half duplex. On the RS485 side, the transmitter only drives the bus while sending a byte.  It is enabled at the start bit and disabled after the stop bit, allowing another device to send.  (BTW, Maxim makes nice little devices that will do this automatically). On the RS422 side, the transmitter is permanently enabled.  Therefore, I cannot simply hook the Tx+ to Rx+ and Tx- to Rx-, since then the transmitter will permanently clash with the RS485 transmitter. I need to somehow disable the RS422 transmitter when it is idle, to relinquish the bus and allow the other side to respond. Looking at it a little more carefully, the RS422 transmitter uses a push-pull output stage, so one transistor is always on and the Tx+ line idles high, while the Tx- line idles low. The trick therefore is to use two series d