|
|||
|
Firefox and Internet Explorer bookmarks September 7, 2005 Recently I saw this old geezer walking around downtown Quebec City with a Firefox Take Back the Web T-Shirt. That's where I'm at too. I just finished consolidating all my Internet Explorer and Firefox bookmarks. It's pretty remarkable how seamlessly you can export bookmarks from IE then import to Firefox, and then export from Firefox and import into IE and preserve folder structures both ways. Firefox is truly an IE killer. My latest programming bookmarks are available to all here. Swing Java Audio Recorder February 28, 2005 I'm helping out David with his robotics project and he needs to record a voice sample to be sent off elsewhere for speech recognition. For the audio part, I swiped some command line code from jsresources.org which wasn't working right, and hacked this nifty Swing Java Audio Recorder (source code included). It uses Java Sound rather than JMF. Basically it will do the same as your Windows Sound Recorder, except it will automatically save a uniquely named WAV file (i.e., the number of seconds since 1970). And it should work as is on all operating systems with a Java runtime. So I did that for fun. On the other hand, for work, I did this. You gotta love Firefox. Oh and did you see my implementation of FreeTTS using the MBROLA text-to-speech binary on Windows? It's got a ready to play with ANT build.xml file! Video streaming using a Labtec Webcam from a Linux Redhat 9 INTEL (2.4 kernel) box to Microsoft Windows Media Player January 9, 2005 Somehow I am the "volunteered" techie helping out an artistic project which involves putting webcams in different locations and viewing the sounds and images 500 kms away. Since my estimates fogured a bunch of computers will be needed, I have been looking into used and refurbished PCs running Linux to keep costs low. I already figured out how to use Icecast and Darkice to do the streaming audio, Darkice grabs the line in from the audio sound card so it's pretty darn flexible. Whatever you want to plug in there, mixer, cassette deck, it will be streamed. For a Linux compatible webcam, I found a pawn shop which had a stack of brand new Labtecs webcams still in the box for about $30 US each. Bought one to fool around with, then I found the same thing for 10 bucks less in a regular computer store a week later. I didn't want to do web phone calls, I want to simply stream the video on to a port so it can be viewed on a web page. Tomas Groth is the guru who came up with the Linux driver for this camera (mirror here). After (hot) plugging my Labtec Webcam, I used the following Linux command: /sbin/lsusb Which displayed: Bus 002 Device 002: ID 046d:0921 Logitech Inc. Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 255 Vendor Specific Class bDeviceSubClass 255 Vendor Specific Subclass bDeviceProtocol 255 Vendor Specific Protocol bMaxPacketSize0 8 idVendor 0x046d Logitech Inc. idProduct 0x0921 bcdDevice 0.01 iManufacturer 0 iProduct 0 iSerial 0 bNumConfigurations 1 The vend/proc: 046d/0921 combination confirms that this matches Tomas' driver. Next I downloaded the driver. Had to add the following line for Redhat to the top of include file spca50x.h: #define RH9_REMAP 1 Then I simply compiled with: make and did a: make install Next, I tested the camera using mplayer with the commands: modprobe spca50x modprobe videodev mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=/dev/video0 I am using ffmpeg version 0.4.8 (not the latest 0.4.9 RC1 which is broken for ffserver) on Redhat 9 using KDE, which I compiled after first changing one line in grab.c from "/dev/video" to "/dev/video0" with: ./configure make make install I found I could grab the video from the webcam and save it to a file with the 3 commands: modprobe spca50x modprobe videodev ffmpeg -an -s cif /root/bertrand.mpeg (or ffmpeg -an -s cif /root/bertrand.asf) But those files play back a bit speeded up, have not figured out the fps hack yet in the previous command line. Here is a 200K asf file of me that plays back way too fast. Anyway, no way no how would this setup stream video for me! My issue was the particular flavor of mpeg used by the webcam (YUV or yv12). I struggled and struggled, finally I found some useful help. It turns out all I had to do was ignore mpeg and go with asf. Helpful Nick at the Alfie cam website lent me their alfiecam.conf, which I modified to use port 9000 and left pretty much untouched except for port and screen size. I used two separate terminal windows to launch the video server and client grabbing the webcam input (I get more verbose printouts). The first terminal I run the command to launch ffserver: ffserver -f /root/reference/software/ffmpeg-0.4.8/alfiecam.conf The second terminal window I run the commands: modprobe spca50x modprobe videodev ffmpeg -s cif -an -vd /dev/video0 -y http://localhost:9000/feed1.ffm Then on another computer running Windows, I type: http://192.168.1.100:9000/alfiecamhi.asf or http://192.168.1.100:9000/alfiecam.asf and in each case I get a nice video stream going. Tested on Windows 2000 Server and Windows ME both running Windows Media Player 9. The mpeg streams do not work using either Windows Media Player, or Quicktime Player 5, or Foobar 2000 version 0.8.3 on Windows or Kaboodle running on Redhat. Mplayer on Redhat caches the file in increments of a percentage point and eventually is unable to load the stream with: mplayer http://192.168.1.100:9000/alfiecam.mpg It looks like a yv12 issue the ffmpeg team is working on right now. Nick the Alfiecam person also lent me his file webcammpg.html to test out the kutttpech player applet which displays JPEG snapshots. On the resulting web page, I look like a cockateel! C programming with MinGW September 18, 2004 Recently a nameless company building cool devices was advertising a C developer position with the novel approach of requiring candidates to code 2 programs and submit them with their cv. Impossible to resist, so I coded the things and compiled each of them for Windows on Intel, Linux on Intel, Linux on PowerPC and Linux on StrongARM. The whole exercise was quite useful as it helped me discover the cool compiler Minimalist GNU for Windows (MinGW) which is a lot more convenient than Visual Studio .NET to do C programming. The first program displays all instances of the use of a particular word in a text file including "n" words to the right and left. The second program displays an alphabetic list of words used in a text file with their number of occurences.
I proudly emailed the source code, binaries, and a couple of screen shots of the running programs to the company and waited for a response from them. A week later, I wrote them again to inquire if they received the email and 6 weeks later still received no sign of life from them. Anyway, here are the programs along with binaries all wrapped up in a convenient zip file. Hope this will help out the next candidate for the job... Modifying a Compaq (HP) iPaq palm device into an Embedded Linux development platform July 12, 2004 I recently purchased an eye-opening book which I like a lot, called "Embedded Linux: Hardware, Software and Interfacing" by Dr. Craig Hollabaugh (website at: http://embeddedlinuxinterfacing.com/overview.shtml). The book explains how to set up a Linux development environment for electronic boards, using inexpensive off-the-shelf hardware. Love that book. I had a spare computer I didn't know what to do with so I got it all set up just for the fun of it. Then I started shopping for the embedded hardware and balked a bit, the average board was $795 in US dollars, the price of an excellent desktop computer. So I emailed the author and asked about alternatives for a novice in electronics. Craig's speedy response from the Colorado mountains was, "You gotta get an iPaq!" So I did. The device I got was a 3 year old iPaq 3765 handheld which I found on E-Bay, along with a "PC serial port to iPaq" cable and a PC Card / Extra Battery expansion slot. This is a truly beautiful toy. The iPaq 3765 uses a 206 megahertz StrongARM processor, which coupled with a regular PC running Debian Linux provides a cross-compiling development platform for embedded devices (running an ARM processor). The Operating System that came on the iPaq is an older version of Windows CE, which I replaced with Familiar Linux from handhelds.org. Rationale: in 1995, I used a $10000 cd burner at work running on a Pentium 90 with the Windows 95 operating system. It is logical to assume that a processor twice as fast running a tuned version of Linux will be able to accomplish a lot of useful things. Hardware used:
(Following section borrows extensively from various referenced documents, on the handhelds.org web site and elsewhere) Steps followed to set up the Debian Linux PC1- Getting ready for cross-compilingTo set up the desktop Debian Linux PC which will be the development environment for cross-compiling, follow the instructions in Craig Hollabaugh's book "Embedded Linux Hardware, Software and Interfacing" up to the end of Chapter 3. Worked for me: using only the "NONUS cd 1" of Debian Linux version 3.0 R2 "Woody" along with the corrections for the book available at the web site URL: http://embeddedlinuxinterfacing.com/corrections.shtml The steps in the book demonstrate the building of the PowerPC cross-compiler. Repeat the step for the ARM processor and build the ARM toolchain. Compile the "Hello World" program that comes with the book (I called my Hello World program "bello"). Next, you need to install the serial program 'minicom', and for xmodem upload functionality you need 'lrzsz'. On the Debian Linux box do the command: apt-get install minicom lrzsz The following steps describe how to configure minicom to use the Debian serial port correctly (this digresses from page 95 of Hollabaugh book)... At the command prompt on the Debian machine type: minicom Type: CtrL-a o Select "Serial port setup" and then change your settings to match these: A - Serial Device: /dev/ttyS0 B - Lockfile Location: /var/lock/ C - Callin Program: D - Callout Program: E - Bps/Par/Bits: 115200 8N1 F - Hardware Flow Control: No G - Software Flow Control: No Exit from this screen, select "Save setup as df1", and then exit from this screen. Exit from minicom by typing: CtrL-a q NOTE: The minicom step was the major hurdle of the installation procedure, as it refused to recognize the CONtrOL key of my keyboard. The workaround is to accept “alternate keys” when prompted during the install, which substitutes ALT for CONtrOL for all the commands. If you get stuck here, don’t worry, read the manual: man minicom and try the workaround. Getting the software:I selected the options "stable, v0.7.2"/"h3700"/"Opie" on the web page:http://familiar.handhelds.org/releases/v0.7.2/install/download.html and clicked the "Download" button. Save the file "bootopie-v0.7.2-h3600.tar" to your hard drive. There are actually two other choices besides OPIE. Each choice installs Familiar Linux and whatever else you select as a front end on top. I picked OPIE because it was developed in large part by trolltech using QT Embedded. I like QT a lot, and want to program with it, so this is why I chose this option. The OPIE interface is gorgeous, by the way. So much so that you lose all Linux coolness credibility by showing off the device once you have Linux running on it. There were two other drawbacks to choosing OPIE which I want to mention before going further: 1) The IPKG installer utility on Familiar 0.72 required patching after install. I will describe the steps later in this text; 2) The DHCP client is flaky when using auto-detect of the DHCP server: it works for 5 minutes, then loses connection. The workaround is to set a fixed IP address. This is a big annoyance, big enough to avoid OPIE as an option altogether if what you want to do is do wireless Web surfing and email. Setting up the iPAQ:Decompress the downloaded tar archive and you will have the following files:BootBlaster_1.19.exe bootldr-sa-2.21.12.bin bootldr-sa-2.21.12.bin.gz bootldr-sa-2.21.12.bin.md5sum bootopie-v0.7.2-h3600.jffs2 md5sums reflash.ctl (from reference 1) The initial installation of Linux on the iPAQ requires the use of a Windows desktop platform. This is because we need to install a loader program, which bootstraps the process. This loader program will be transferred to the unit by using Microsoft's ActiveSync tool. The loader program can also create WinCE backup images, which are also transferred back to the Windows box using ActiveSync. Once the loader program is installed and running, a dialog is established through the serial port between the Debian computer and the palm device. Installing or upgrading Linux simply involves entering a command and sending the appropriate file to the device via xmodem. (from reference 2 and reference 3) Installing bootloader using ActiveSync transfer BootBlaster and bootldr to your iPAQ using ActiveSync: if ActiveSync isn't already installed on your Windows PC, install it by inserting the iPAQ Pocket PC Companion CD-ROM into the PC's drive and following the ensuing instructions. Copy the BootBlaster and bootldr files that came with your Familiar Linux distribution to your Windows PC if they're not already there. The files are named BootBlaster_1.19.exe and bootldr-sa-2.21.12.bin. Plug the iPAQ cradle into an AC power outlet. Connect the USB connector from the cradle to the Windows PC. Slide the iPAQ into its cradle. If a "Set Up a Partnership" screen appears on the PC, choose "No" and then click Next. Copy BootBlaster_1.19.exe or BootBlaster3900-2.6.exe to the default folder on the iPAQ by clicking Explore in ActiveSync and dragging their icons there. Ignore any "may need to convert" messages. Do the same thing for bootldr-sa-2.21.12.bin or bootldr-pxa-2.21.12.bin. Start BootBlaster: Start -> Programs on the iPAQ touch screen. Tap on File Explorer. Tap on BootBlaster. Save your PocketPC image for later restoration, if desired: Execute "Flash -> Save Bootldr .gz Format" in BootBlaster to save the bootloader in file "\My Documents\saved_bootldr.gz" on the iPAQ.
Note that the Linux Bootloader will also boot PocketPC, so restoration of this file is not generally required. Right at the moment, there is a bug in the Linux Bootloader, which causes PocketPC to reinitialize itself every few boots. You may indeed wish to keep and restore this bootloader if you restore PocketPC.
Execute "Flash -> Save Wince .gz Format" in BootBlaster to save the PocketPC image in file "\My Documents\wince_image.gz" on the iPAQ. This takes two to three minutes.
If no backup of Pocket PC is desired, you can skip this step entirely. Note that this procedure saves your bootloader and Pocket PC executable image: it does not preserve any data you may have entered in your iPAQ under Pocket PC. So also synchronize your iPAQ to your host to preserve this data. Note that Familiar does not *yet* have any way to resynchronize this data to Linux (we hope/expect to have Linux<->Host synchronization in a near future release). Copy saved_bootldr.gz and wince_image.gz to your Windows PC. Select "View -> Refresh" in the ActiveSync Explore window on the PC. Icons for the saved_bootldr.gz and wince_image.gz files should appear. Drag the saved_bootldr.gz and wince_image.gz icons from the ActiveSync Explore window to a local folder on your PC. As with any backup files, please store saved_bootldr.gz and wince_image.gz in a safe place. We highly recommend verifying the built-in gzip checksum in both files before presuming your backup is safe (see the gzip man page for details). Install the bootloader Before continuing, be sure that the iPAQ is plugged into external power, and that the battery is charged, to protect against the small chance of power failure during the very limited period the iPAQ is reprogramming the bootloader flash. Do NOT touch the power button or reset button on your iPAQ until you have performed the "Verify" step below. From the "Flash" menu on BootBlaster, select "Program".
A file dialog will open allowing you to select the bootloader to use. Select bootldr.bin.gz, which may have a version number embedded in it. We use a gzip file because it has an internal checksum. Wait patiently. It takes about 15 seconds to program the bootloader. Do not interrupt this process, or the iPAQ may be left in an unusable state. From the "Flash" menu on BootBlaster, select "Verify". If it does not say that you have a valid bootloader, do NOT reset your iPAQ, do NOT turn off your iPAQ. Instead, try programming the flash again. If that doesn't work, program your flash with your saved bootloader. If that doesn't work, send e-mail to bootldr@handhelds.org and/or get on the IRC and ask for help. Leave the iPAQ plugged in and do NOT reset it or turn it off. If everything has gone well, you have successfully installed the CRL bootldr program, which can run either Linux or PocketPC. As yet, your PocketPC image is intact and should restart normally; the next step actually installs Linux (overwriting Pocket PC). Installing Familiar 0.7.2 with a serial lineYou will need a serial sync cable or serial sync cradle. You will need to use a terminal program such as minicom, kermit, or Hyperterminal. If you use minicom or kermit, you will need to use an external ymodem program such as sb, which is available in the Linux lrzsz package.1. Hold down the joy pad and push the reset button on the iPAQ. You will need to remove it from the cradle to access the reset button. When the bootloader splash screen appears, release the joy pad.
2. Press the calendar button on the iPAQ. This is the leftmost action button, labelled "Serial Bootldr Console" on the screen. 3. Make sure the terminal emulator is up and running, and is properly interacting with the bootloader. Proper interaction consists of being able to issue commands, and get responses (e.g. the help command should return the bootloader usage). Your terminal emulator must be set to 115200 8N1 serial configuration, no flow control, no hardware handshaking. Failing to use these settings will lead to trouble, so double and triple check all settings. If you cannot interact with the bootloader, make sure your terminal settings are correct, the iPAQ is properly connected to the host computer, and the iPAQ is actually on. If everything seems fine, try restarting the host terminal emulator and resetting the iPAQ again. . Hyperterminal is particularly ill-behaved. Sometimes it uses 100% of the CPU without allowing any interaction with the iPAQ. In that case, you will need to use the task manager to terminate Hyperterminal before you can restart it. At the "boot>" prompt, issue the following command: load root Proceed to send or "upload" the jffs2 file (from the tarball that you downloaded earlier) with ymodem: With minicom, use the key sequence: ctrl-A-z-s Then select ymodem and the name of the file to send. transfer->>Send File to activate the Send File dialog. With this dialog, select the name of the file to send, choose the Xmodem protocol, and then Send. Reference here Be patient and wait until all is complete! At the "boot>" prompt, issue the following command: boot Linux should now start booting. After the install, update(Basically you list 'feeds' in the /etc/ipkgdirectory, then when you run ipkg to install something, ipkg uses the information in feed files to know where to get the package.)The default root password for bootstrap and OPIE is rootme. Setup Internet connectivityFamiliar supports many 802.11b Wireless cards and 10Mbps or 100Mbps Ethernet LAN PC cards. Both should "just work" when you plug them in.Not much there, you plug the iPaq into the Expanion pack, you plug the network cable into the PC LAN card and slip the card into the Expansion slot, and the iPaq will blink that it successfully recognized the card. Done, you’re online. Once you have Internet connectivity, you should run these commands: ntpdate -b time.handhelds.org ipkg upgrade At this point, if you get an error message citing SIGSEGV, then you need to patch the IPKG utility (the meaning of the message is explained at: http://www.wlug.org.nz/SIGSEGV). The steps: #Get ready. mkdir /tmp/newipk cd /tmp/newipk #Retrieve libipkg wget -O libipkg.ipk http://familiar.handhelds.org/familiar/feeds/unstable/packages/armv4l/libipkg_0.99.126_arm.ipk #Unpack the ipk wrapper. ar -x libipkg.ipk #In general, when manually installing an ipk, you should probably check the contents of control.tar.gz. For the version used as an example, there are no scripts that had to be run for the library portion, but there's always the possibility this will change. If there are scripts (preinst or postinst), be sure you know the appropriate actions to take before and after the next step. #Unroll the tarball in the root directory. tar -zxvC / -f data.tar.gz #Clean up - this isn't strictly necessary, but if you are checking out the files as you extract them (as you probably should) this makes the things easier. Type this command carefully. rm -R /tmp/newipk/* #Now, get the latest ipkg.ipk. (If you skipped the above steps because you are installing an older version, do the initial "Get Ready" mkdir and cd commands first). wget -O ipkg.ipk http://familiar.handhelds.org/familiar/feeds/unstable/packages/armv4l/ipkg_0.99.126_arm.ipk #Unpack the ipk wrapper. ar -x ipkg.ipk #Check the control file. tar zxvf control.tar.gz #Look for scripts such as preinst and postinst. I will only cover the postinst here, but if a preinst exists you should probably run that before unpacking the tarball (i.e. ./preinst) ls -l #When upgrading from a version older than 0.99.110 #[Not sure of version this changed], you will likely have to remove the ipkg executable because it is not included in the data.tar (it becomes a link to ipkg-cl instead during postinst). If this file is already a link, just leave it alone ![I think - you might have to run the prerm for the current version first]. rm /usr/bin/ipkg #Unroll the tarball. tar -zxvC / -f data.tar.gz #Run the postinst script. If you get an error regarding linking on this step, be sure you removed the original binary ipkg and then try again. ./postinst #To cleanup the temporary files, you can reboot or: cd / rm -R /tmp/newipk #Check your version ipkg --version Hopefully it matches what you downloaded. Running Helloworld program on the iPaq:On the Debian PC: cd /root/cross/builds/Then: arm-linux-gcc -g -o helloworld-arm-linux helloworld.c Then move the following file through ymodem to the palm: /root/cross/builds/helloworld-arm-linux On the iPaq, open the prompt program ash and run the executable: helloworld-arm-linux You should get the following:
Final word:It works. Be patient and read everything before going down this path.Packages marked as "unstable" do work, but unit testing varies wildly from one package developer to the next. I found the "ubrowser" package particularly bad, for example. Read the newsgroup at handhelds.org (subscribe, even!) and ask for opinions before installing something new. Java Server Pages with MySQL May 24, 2004 The hard part is over. Assuming you have installed the Tomcat web server on the Linux box, and have started it with the command: /usr/local/jakarta-tomcat-5.0.24/bin/startup.sh And with the ConnectorJ JAR file still in the same place (no classpath modification necessary), I created two files: mysql.jsp and error.jsp and placed them (on my system) in the directory: /usr/local/jakarta-tomcat-5.0.24/webapps/ROOT I simply open a browser at: http://localhost:8080/mysql.jsp And get the desired result: Connecting Java to MySQL
This is basically the same as building an Active Server Pages or PHP web site. There is no real advantage to doing a database-enabled web site with Java as opposed to PHP or ASP if this is the method you are going to use, because Java is interpreted while PHP and ASP are compiled and optimized with native code. The Java web site will be several times slower. Java has the additional disadvantage of not being supported well by Internet hosts, so a JSP web site on a shared server will be much more expensive than PHP or ASP. On the other hand, if among your database needs it is critical that you be able to either commit or roll back a global transaction which consists of several database operations, you are down to only two real choices: Microsoft .NET and Java J2EE with Entity beans. And at this point, Java is definitely the most secure and reliable of the two, offering direct support for a much wider range of databases and operating systems besides Windows. So the next level is JBoss with Linux and Java and messing around with Container Managed Persistence. But that's a story for another day. Fun with MySQL, Redhat 9, Java and ConnectorJ May 22, 2004 MySQL is the classic Linux database, yet when you install Linux Redhat 9 and select the Developer Tools and SQL database, it's not selected by default. So it's not installed by default. After looking for MySQL on my new Linux Dev box (2 gigs CPU and 80 gigs of hard drive) for a while, I realized this and explored the Gnome menu System Settings > Add/Remove Applications and all became clear. I installed it (requiring install cd number 2), and after a reboot for good measure, Redhat spotted that I needed to update a bunch of MySQL stuff. The Redhat Network Alert Notification Tool is very close to the Windows Update, with the exception that on weekdays, most of the time it is too busy to get through to it if you are cheap and don't want to encourage Redhat by actually paying them something for all their wonderful work. In that case, if have an emergency software patch to apply, try after 23:00 or on weekends! After installing MySQL, patching and rebooting, you can start the database using System Settings > Server Settings > Tools. Test the database using the the quick start tutorial at: http://www.informit.com/articles/article.asp?p=31474&seqNum=2 First, create the database in MySQL by command prompting: mysql -u root Then: CREATE DATABASE BabyTalkWebLibrary; Note that on Linux Redhat 9, the database and table names are case sensitive (by default perhaps). I created a SQL script to populate the database with what we will need for the BabyTalkWeb Library web application. The script is called SetupBabyTalkWebLibrary.sql. To use the above script, you need to do the command prompt line: mysql BabyTalkWebLibrary < /root/SetupBabyTalkLibrary.sql Next, for Java database connectivity, you have to get the Java SDK and a JDBC driver, in our case ConnectorJ. The ConnectorJ download is at: http://dev.mysql.com/downloads/connector/j/3.0.html The install consists in unzipping and copying the JAR file into (in my case): /usr/java/j2sdk1.4.2_04/jre/lib/ext Then using the "not dumbed down enough" tutorial at: http://dev.mysql.com/doc/connector/j/en/index.html#id2754449 I crafted a .Java file to test my connectivity, LoadDriver.java... On my computer, I used the following command to compile LoadDriver class: /usr/java/j2sdk1.4.2_04/bin/javac LoadDriver.java This compiled fine, the class was created. Next I tried running the Java program with: /usr/java/j2sdk1.4.2_04/bin/java LoadDriver And got the nasty error: "Host 'localhost.localdomain' is not allowed to connect to this MYSQL server" Messed around to double-check everything, then hit Google, went to bed frustrated. Next morning first thing I find the answer at: http://www.netbeans.org/servlets/ReadMsg?listName=nbusers&msgId=744245 You need to go edit the file: /etc/hosts Changing the line: 127.0.0.1 localhost.localdomain localhost To: 127.0.0.1 localhost localhost.localdomain And rebooting! Resolved the issue. The program now displays (as expected): [root@localhost root]# /usr/java/j2sdk1.4.2_04/bin/java LoadDriver connected! submitted pending review rejected approved [root@localhost root]# Anyway, not so obvious! Next up, Tomcat, MySQL and Java oh my! |