Thursday, January 23, 2014

No monitor device on USB sound card? No problem.

My USB sound card doesn't have a "monitor" mixer device. In other words, in order to listen to audio that is being recorded through my speakers or headphones, I need to record and play back that audio.

PulseAudio makes this somewhat easy using module-loopback, although the method is esoteric, so here are the applicable commands.

In order to figure out what input and output devices to use,
pactl list | grep -1 State
You should see a number of sources and sinks. The key piece of information is the Name: field, which allows us to specify which device to use in the loopback chain.

In my case, my source device is oss_input.dsp2, and my sink device is oss_output.dsp2. Therefore, I can load the appropriate module:

pactl load-module module-loopback source="oss_input.dsp2" sink="oss_output.dsp2" latency_msec=1
An ID number, corresponding to the module ID, is returned on the command line. When you want to unload the loopback module, supply this argument to This is the argument to pactl unload-module

There is a bit of latency using this method, but at least I don't have to involve a hardware mixer in my set-up.

Saturday, January 18, 2014

Specifying name servers with resolvconf

I finally figured out how I can tell resolvconf to preferentially add my favorite DNS servers before it adds name servers supplied by DHCP servers.

Create the file /etc/resolvconf.conf. If you use IPv6 and OpenDNS, the file should contain the following (all on one line):

name_servers="2620:0:ccc::2 2620:0:ccd::2 208.67.222.222 208.67.220.220"

Monday, December 9, 2013

Creating USB disk images from .iso images in order to update firmware on old devices

I recently needed to update the firmware on an older Seagate hard drive. Seagate only offered a .iso image for me; however, I don't have a CD-ROM available.

Upon examination of the contents of the files stored inside of the .iso disk image, I didn't find anything that looked like a DOS executable; however, I did find an .ima file -- several megabytes in size.

This .ima file turned out to be another disk image that Seagate loaded using a tool called "Bootable CD Wizard" (or BCDW). I deduced that the El Torito bootable image in the .iso was using BCDW to load the .ima file into memory and "chain-load" the .ima file.

In order to make my bootable flash disk, I downloaded a FreeDos 1.1 image, and copied it directly to my USB device using the Unix dd command (note that my USB flash device is /dev/sdb). Don't accidentally overwrite something important by making a typo!
dd if=FreeDOS-1.1-memstick-2-256M.img of=/dev/sdb bs=1M
I then unplugged and plugged in the USB disk, and extracted the contents of the .iso file into my USB stick's FreeDOS partition with the Gnome Archive Manager (aka file-roller). This left the .ima file on the root directory of my USB stick's filesystem.

The trick was to figure out how to "chain-load" the .ima file, and I accomplished that by editing FreeDOS' syslinux.cfg file. Here's a snippet from the configuration file with the apropos section highlighted:

say Press ENTER to boot FreeDOS, or choose from these alternatives:
say ---------------------------------------------------------------
say :    fdos :: FreeDOS 1.1
say :    odin :: Boot ODIN 0.6 floppy disk image (tiny FreeDOS)
say : memtest :: Run Memtest86+ 4.20
say :      di :: Upgrade
say ---------------------------------------------------------------
say Example: To boot Memtest86+, type "memtest" and hit Enter.



label di
    menu label di upgrade
    linux /img/memdisk
    initrd /HE-CC35.ima


label fdos
    menu label fdos - Load FreeDOS 1.1 from USB flash drive
    com32 /fdos/bin/chain.c32
    append freedos=/fdos/bin/kernel.sys
In the boldfaced "di" (short for disk image, you can choose any word as the label) entry above, I instructed syslinux to load memdisk, which is a utility for booting floppy images. The initrd command tells syslinux to load a disk image into RAM.

Saving my work, I plugged the flash drive into the system that needed the firmware upgrade, and typed in di at the syslinux prompt in order to execute the corresponding menu entry.

Hopefully this is enough to help those of us with Seagate drives to get things working!

Wednesday, May 22, 2013

RTSP / Streaming Video with Foscam FI9821W pan/tilt camera under Linux (or any other operating system)

I purchased Foscam's 720P pan/tilt IP camera to use as a baby monitor, but was somewhat dismayed to discover that the camera didn't work well under FreeBSD... until I found the instructions at the following post.
rtsp://username:pwd@ip:port/videoMain  -- Main streaming
rtsp://username:pwd@ip:port/videoSub -- Sub streaming
rtsp://username:pwd@ip:port/audio -- Audio streaming
The camera works beautifully with VLC (VideoLan client)!

This feature very likely requires the latest firmware.

Now, I'm very pleased with this camera.

Friday, November 16, 2012

Automatic connection to VPN server in Ubuntu Precise 12.04

Ubuntu Precise 12.04's NetworkManager service can be used to access VPN connections, and can be configured to connect at boot-time without having to add any additional packages to the system. Using the following script, I access my FreeBSD OpenVPN server (configuration was covered in a previous post) at boot time.

Save the following script to /etc/NetworkManager/dispatcher.d/02vpn :
#! /bin/bash

REQUIRED_CONNECTION_NAME="virt0"
VPN_CONNECTION_NAME="baitis vpn"


activ_con=$(nmcli con status | grep "${REQUIRED_CONNECTION_NAME}")
activ_vpn=$(nmcli con status | grep "${VPN_CONNECTION_NAME}")
if [ "${activ_con}" -a ! "${activ_vpn}" ];
then
    nmcli con up id "${VPN_CONNECTION_NAME}"
fi
Don't forget to mark the script as executable with chmod: 
chmod +x /etc/NetworkManager/dispatcher.d/02vpn

VPN_CONNECTION_NAME should correspond to whatever VPN connection you have configured using Network Manager. If, for some reason, you can't configure VPN connections in Network Manager, you may need to install the appropriate plug-in:
apt-get install network-manager-openvpn network-manager-openvpn-gnome

Sunday, November 11, 2012

"Life-changing" VIM plugin: "Screen"

Eric Van Dewoestine's Screen plugin for VIM is terrific. Not only is the plugin "life-changing," but it's also an exceptionally easy to install, and should serve as an example for other VIM plugin developers.

If you use VIM and enjoy the command line, make sure you check it out. I think this plugin is much better and far more intuitive than 'conque shell.'

Special hint: try pressing control-A control-A when the embedded shell is displayed.


If you don't use VIM, here's why you might want to try it:
  • You are a touch typist
  • You want to move around extremely rapidly in files without taking your fingers off of the keyboard
  • You want to do incredibly powerful bulk edits

Sunday, October 21, 2012

Google Voice Poetry

The coolest feature about the Android is its excellent voice recognition capabilities. I like to send it difficult or unintelligible syntax, and I appreciate how the software seems to understand part-of-speech and grammar so well that it makes complete sentences out of what I dictate:

You'll have to wait for the Apes to happen
They keep some noise
The evening has no eyes
Nothing undoing the drawers in the middle of this s*** shoe box

I think that, somewhere on the Internet, a microcontroller is crying.