Wednesday, 25 August 2010

ALSA drivers not working for Cirrus Logic CS46xx soundcard

If you are using OSS emulation for ALSA on a laptop with a CS46xx card, and are getting no sound, then read on.

I use a really old laptop (Ascentia M-Series dating from 1998) that I carry about in places where I think anything nicer would get stolen/drowned in spilled tea/rolled over by a forklift. One thing that has long annoyed me about this laptop though, is that the sound doesn't work. Things would appear to be working, mplayer would claim it was playing .mp3 files, but no sound would come out.

The sound card is a cirrus logic CS4624B, and everyone says that these are a pig to get working, requiring lots of meddling with old-style Plug-and-Pray settings because, in these old laptops, the soundcard is on an isa bus.

Funny thing is though, that back in the day when I used OSS for sound, rather than ALSA, the soundcard worked fine. Why would ALSA suddenly have irq or resource issues that require me to mess with isapnp, when OSS didn't?

In the end, the problem turned out to have nothing to do with irq's, io-ports or plug-and-play. Basically there is a bug in ALSA. For these cards, ALSA sets everything to 'Mute' by default. This doesn't mean it sets the sound level to zero, it seems to be more than that, it actually does some magic 'mute' thing to the card that you have to unlock. Unfortunately, the OSS compatibility module that makes the sound-card visible to programs that use the old OSS interface, doesn't know how to mute/unmute, so the card stays muted no matter what you do.
Or it might not be the mute, it might be the fact that one of the volume controls 'Master' doesn't appear to be exported to the OSS emulation, under ALSA volume control programs you see the 'Master' setting, but under OSS volume controls, you don't.

The only solution I've found is to install the alsa libraries, and use 'alsamixer' to initially set up the card and volume levels. Suddenly BINGO! It works! No need to meddle with irq's and isapnp.conf.

However, I didn't really want to install the ALSA libraries, that's why I'm using OSS emulation. But, more and more these days Linux is becoming another O.S. of you-will-do-as-we-say. IF you want to use software X, you will install lots of libraries and now you're going to have to upgrade your computer. If I have to upgrade my computer, then why not just put windows on it or get a mac and be done with it, hmmm??

Wednesday, 2 June 2010

M. T. Urself

So, I had a server that was misbehaving in a truely weird way. I was accessing this server via and ADSL line, connecting into it using Secure Shell. Any large amount of data pulled from it caused the network connection to drop. But I could push as much data to it as I liked. Huge uploads worked fine, but downloads would get me disconnected instantly. Logging in and typing 'ps ax' would normally only get me half the page of output before the connection froze up. Also, anything that posted information to websites, like logging into googlemail for instance, seemed to freeze as well.

I tried altering the firewall, the router, the routing table on the server, recompiling the kernel, etc, etc, all to no avail. After each new attempt the problem would seem to go away, cruely making me think I'd fixed it, before returning again.

Now, often in the past when there's been network problems, some old unix-hacker with open-toed sandals and a grateful-dead t-shirt has been around to say; "You know man, could it be, like, the MTU?"

The MTU. That thing they had on modems, remember? No, I don't suppose you would.

Friday, 16 April 2010

Quick and Dirty Webcam monitoring

Just thought I'd mention a very quick and dirty way to get 'webcam monitoring' going. I've done this with axis webcams, but it should work with any webcam that allows you to fetch a jpeg image from a url.

This will, of course, be working under linux. It's only using the standard 'Borne' shell and a program called 'links' so it should work under FreeBSD and Mac OSX too.

The command-line webbrowser, 'links' has an option called -'-source'. This has the effect that a webpage or item fetched using http with links is written in raw format to stdout. So

links -source http://media.libsyn.com/media/djsteveboy/the_swing_set.mp3 > TheSwingSet.mp3

Will download the example .mp3 file.

Most axis webcams allow you to download an image from http://<webcamip>/axis-cgi/jpg/image.cgi, so we can use links to Grab an image thusly:

links -source http://192.168.5.4:1000/axis-cgi/jpg/image.cgi > snapshot.jpg

Of course, what's best is to get images every couple of seconds and put them into a date/timestamped file. Here's the script I've been using, it creates directories for each hour of a day, and puts timestamped .jpg files in them.


#! /bin/sh

cd /home/Public/AxisWebcam

while [ 1 = 1 ]
do

DIR=`date "+%d_%m_%Y_Hour-%H"`
FILE=`date "+%H_%M_%S.jpg"`

mkdir $DIR
links -source http://192.168.5.4:1000/axis-cgi/jpg/image.cgi > $DIR/$FILE

sleep 2

done


One issue is that links doesn't have any way (that I know of) of expressing a username/password to access a website. Fortunately, Axis cameras have a setup option under 'Setup->Users' called 'Enable anonymous viewer login'. This allows access to the image without having to supply a username and password.


If you're going to leave this script running, you may want to periodically run a command like:

find -mtime +7 -exec rm -f {} \;

This command will delete any files older than a week.

And that's it!

Tuesday, 9 March 2010

Slow boot due to libata problems with mwdma2

I use a lot of old kit. Recent linux kernels are starting to have problems with old kit. An old laptop harddrive suddenly started to 'freeze' during bootup. The kernel was trying to access it with various DMA modes, none of which seemed to work. Finally it would fall back to PIO, and work, but this was annoying, because it meant the laptop took ages to boot.

I'm attaching a dump of what the kernel spewed out while it was trying to talk to the hard-drive. The main thing to look for if you have the same problem is:

[ 23.107017] ata2: soft resetting link
[ 23.259250] ata2.00: configured for MWDMA1

Thursday, 17 December 2009

Linux Tips: Vim autoconfigure for different filetypes

Thanks to Ajay Somani, over at http://ajayfromiiit.wordpress.com/ for this post that finally helped me solve a long term gripe with vim.

When I'm in 'programmer' mode, I use vim with syntax highlight turned on.
When I'm in 'wannabe fiction writer' mode, I use it with spell check turned on.

And these two personas keep fighting like Jekyll and Hyde. Because I have both of these turned on, vim insists on syntax highlighting my fiction, interpreting apostrophes as quotes and then coloring everything after them. Worse still, it spell-checks my C-code. It'll highlight some text in red, and then spell-check it, and decide it's mis-spelt, and thus surround it in a background colored.... red. This results in large blocks of red-on-red text that cannot be... uh... read.

The solution, it turns out, is to add this magic line to my vimrc:

autocmd BufEnter *.txt set spell

Wednesday, 16 December 2009

HTTPS: No one uses it

I spent a whole night battling to get secure http working in 'Movgrab', only to discover that no-one uses it. I couldn't find a single proxyserver that supported 'straight' https (some of them might support use of the 'upgrade' header, but as of right now, I don't understand that). So then I switched to using https to connect directly to video-sharing websites. Any google website (youtube, videos.google.com) bounces me straight to www.google.com if I try to use https. Many other sites let you use it for the initial connection, but insist on redirecting you to http: when you try to get video. The rest don't support https at all.

I don't know, I would have thought that in these days of 'Web 2.0' secure browsing would have been the norm by now.

Tuesday, 15 December 2009

Hey, movgrab people!

So, I posted movgrab to www.freshmeat.net on Sunday. Since then, I've not heard anything, but through my advanced psychic superpowers I happen to know that visits to my new technical blog have jumped dramatically. The only explanation for this, I believe, is that people are downloading movgrab, and seeing the mention of my blogs on the help-page (or the website they download it from).

So, if you're coming here having used movgrab, leave a comment. Did it compile on your system? Does it work as advertised? Will it change your life? Did using it open a portal to the dungeon dimensions (if it did, and you're thinking of suing, you're out of luck, I included a disclaimer covering exactly this eventuality).

Come on people, I needs to know!


Sunday, 13 December 2009

My first code release up on freshmeat!

Big day for me today. I've been writing software projects for simply years, maybe even decades, and every one of them has grown and grown, but it's never finished, it's never ready for release. Finally I've gotten my first project completed!

Okay, it's a fairly trival app. Movgrab is a command-line app for downloading flash/mp4/mp3 movies and audio from websites that offer that kind of thing. This is useful to we linux luddites who are still using machines that most people wouldn't even use for email these days (for instance, I've got a bunch of pentium-1 laptops that I use as 'holiday' or 'travel' laptops, because no one is likely to bother stealing them, and if they get smashed or something, then I've not lost very much). On weedy machines like the one I'm typing this blog-post on, web-browsers like firefox don't run well. Unfortunately light-weight webbrowsers don't support flash. The solution? Download the movies and watch them with a command line player, rather than in a web-browser.

There are other downloader applications out there of course, but few of them are command-line 'C' programs like movgrab. Most of them require you to install scripting languages and libraries, which can be a headache, I find. Also, few of them support as many download types as movgrab does (including BBC iplayer, youtube, metacafe, dailymotion, crazymotion, uchannel, various university webcasts etc, etc).

More important than the app is the underlying library ('libUseful') that allowed it to be written. Writing movgrab meant adding a lot of code to the library to support HTTP transfers, and this is being used in a lot of other projets too.

So, there is a new website over at http://sites.google.com/site/columscode, where one can download this first of my masterpieces.

Sunday, 29 November 2009

Linux tips: Recovering lost text data from disk, or EVEN MEMORY

Okay, first new post for the new 'technical' blog. The topic is "Holy ****!!! I just had my browser/text editor crash, and I've lost all that work! What do I do now?"

Well, so long as the editor you were using stores it's data in some form of plain text, and so long as you are using linux, freebsd, or some other unix, (or possibly Mac OSX), I may be able to help.


WARNING: These techniques, like any secret powers, come with a degree of risk. I take no responsibility for any accidents where you wipe your hard-disk, explode your computer, or accidentally sell your soul to the devil. In fact I take no responsiblity for anything at all. You have been warned.


I christen this blog...

So, I'm starting up a second blog. Why? Well, my first blog was about my efforts to be a writer, my sundry opinions on the state of Science Fiction and the political issues within it, and technical linux hackery. These things did not play well together. People who knew me from my 'writerly' efforts were completely bamboozled by posts full of 'grep | cut -c 1-10 | sed "s/apple/pear/" | tr ':' ' ''

And can you blame them?

But, on the other hand, my rare 'technical' posts got the most satisfying feedback, when people said "Hey! This really helped me to do something!", so I'm starting up this 'Linux techy' blog to turn alongside my main blog over at thesingularitysucks.blogspot.com

First I'll be transfering over my old 'linux' posts, and then I'll come up with something new to say.