Linux is a fun, frustrating, exciting, head scratching operating system for computers. Unfortunately its not well supported by commercial entities. Most equipment suppliers will provide help or even software drivers for Windows or Apple computers but very little for the Linux user. So we have to search for answers that other Linux users have put on web forums or personal blogs like this one.
When I have a task to accomplish with Linux I can usually find some way to do it and in the process my skill level improves. So lately I've been working on using the ubiquitous little Raspberry Pi for various tasks. Using a version of the Debian Linux system called 'Raspbian' it has some amazing features.
One thing I hadn't tackled with the Raspberry Pi was using a 3G USB modem on it. I've used telephone dial-up modem software on Linux years ago but not a 3G modem. Needing an Internet connection on a remote Science Station it seemed like a natural way to go.
I started with a USB modem from Optus, the Huawei E3131 and looked for articles on how to get it running. When the modem is first plugged in, the USB subsystem in Linux talks to it to find out what device it is. The modem responds with a manufacturer code and hardware code, in this case 12d1:14fe and the Raspberry Pi assigns it as an Optical Disk or CD Drive (run 'dmesg' and you should see a scsi device 'sr0'). Now of course these devices are configured to connect to a Windows PC mostly. So when plugged into a Windows computer it mounts as a CD which contains a startup program which installs the Dial-up program for Windows. Not much good to us.
I found an article on the Raspberry Pi Forum that gave me a lot of answers for this device. Huawei E3131 on Wheezy. So I needed to tell the modem to stop being a CD drive and change to being a modem. By running a line of code I could do this, according to the article. I needed to install a program called sg3-utils so I could talk directly to the modem.
On the command line i ran 'sudo apt-get install sg3-utils'
I could now send the modem a command to change mode. So on the command line again I ran
'sudo /usr/bin/sg_raw /dev/sr0 11 06 20 00 00 00 00 00 01 00'
and a few seconds later the modem responded with its buffer ready. Awesome. Thats step one. So now how do I get it to connect to the Internet?
Once the device had changed mode to a modem, Linux realized it was a serial device and assigned it ttyUSB0, ttyUSB1 and ttyUSB2. I could now talk to it using modem 'AT' commands. The AT command set is an old message and control format used with RS232 serial ports to talk to dial-up modems and was just what I needed.
A Linux program I'd used years ago to talk to modems, WVDial, seemed perfect for the job so I installed it on the Raspberry Pi using
'sudo apt-get install wvdial'
and configured the dialler to talk to the modem. When installed, WVDial has a configuration file that needs to be edited to set up the dialling parameters. The 'pre-paid' settings for Optus Australia turned out to be 'preconnect' for the APN (access point name) and the dialled number is *99#. After setting up the wvdial.conf file I added a shell script to the startup rc.d boot list so the script would execute after everything else during bootup. The script needed to look for a device called 'sr0' since this is the CD Drive the modem first came up as.
So, now I'm at the point where on boot-up, if the USB modem is plugged in it gets mode changed by the script to be a serial device. Sure enough - I had three tty devices. To run the modem dialler I had to type in 'sudo wvdial optus &' (the '&' at the end tells Linux to drop out of the shell script and return to command line). Up came the modem response on the screen as it talked to Optus. The Raspberry Pi was assigned an IP address and also the addresses of two DNS Servers. Great! I was online.
I tried a 'ping' to the outside world. It was working. Now at this point I was still in command line mode. I was itching to try a web browser so I started XWindows on the Raspberry Pi. So I just typed 'startx' and up came the very fetching Pi Desktop. I opened the web browser 'Midori' and of course opened this site first!
The response was quick, only a few seconds and there was my website. All I needed was to run 'sudo wvdial optus &' to connect to the Internet and to run 'sudo pkill -f wvdial' to stop wvdial and hang up. For my task that I needed an Internet connection for I just needed a script to call when I needed the Internet, then hang up afterwards. In this case, a file is getting uploaded using the Ethernet port from elsewhere to the FTP server running on the Raspberry Pi. The script gets called every minute using Cron and looks for the file to upload. If the file exists then wvdial is called, and a few lines in the script starts the Linux FTP client. The file get sent and the modem is then disconnected ready for next time.
Well thats it. There should be enough information for the next person looking for a way to connect their Huawei E3131 to a Raspberry Pi and get on the Internet. Thats what we do. We make something and add to it and write about it for the next person.
I love Linux.
My favorite operating system for computers is Linux. I've been using Ubuntu for many years, probably since Version 6, and for practical do-a-job installations I'll usually install version 10.04 LTS.
It is an old version but runs nicely on older machines and still installs and updates (although not much longer). I currently have several HP desktop P4 boxes crunching on Einstein@home running Ubuntu 10.04 server and they do a nice job.
One thing I hadn't tried was installing the Gnome Desktop on top of Ubuntu Server rather than just using my Ubuntu Desktop install disk. As it turned out, Ubuntu Server core installed takes very little space and dropping the Gnome Desktop on it was quite easy.
The Ubuntu forums contain heaps of useful information so I went looking for some suggested install scripts for Gnome Desktop. The easiest seemed to be:
'sudo apt-get install gnome-core gdm indicator-applet-session'
which installed the gnome core, gnome desktop manager and the indicator applet.
I also needed to install Firefox, Gimp and Gftp plus Network Manager (network-manager-gnome). I decided to also add Banshee for playing music and VLC for video. Firefox needed the FlashPlayer plugin as well (sudo cp libflashplayer.so /usr/lib/mozilla/plugins).
I wanted to try Gnome Desktop and use Epiphany Web Browser. I also needed to then install FlashPlayer through PluginWrapper.
I found this after a bit of googling.
Flash is GTK 2 and Epiphany is GTK 3...that's the problem.
install flash 'sudo apt-get install flashplugin-installer'
install nspluginwrapper 'sudo apt-get install nspluginwrapper'
then 'sudo nspluginwrapper -i /usr/lib/flashplugin-installer/libflashplayer.so'
Lastly 'nspluginwrapper -v -a -n -i'
The above worked nicely and I then had Flash running with Epiphany browser.
I went looking for a theme to use on the desktop and installed 'Ubuntu Sunrise'. It gives a pleasant orange look to the desktop.
So its not hard to install the server version of Ubuntu, put the Gnome Desktop on it and give it a nice look. Job done.
One area of computing that has always fascinated me is the Client-Server networked Thin Client technology. While its been around for a while in the Corporate World where it has its various detractors its not always the 'Cheap Technology' that managers hope it will be.
The Thin Client is a computer, desktop or laptop, that has just enough data-space (often with no Hard Drive at all) to boot up and look for a server on the network. Once a server is found, the Client asks for a Kernel (a piece of 'start-up' software) and begins to set itself up.
All the information that the user would normally store in a local hard drive is instead stored in a users space on the server. The server also has configuration information for the Thin-Client.
So, I've discovered a package, called ThinLinc which is produced by Cendio a Swedish company, which appears to be free for up to ten clients logged in to a server. It installs onto a Linux computer so I guess it needs a hard drive at least. I'm hoping it will be easy to install and get working so I better go try it out.
This should be fun.