Wednesday, 19 September 2007

Can Black Rod Prevent Tasered Students?

International websites, and American TV news have all covered the incident where a student was tasered by American police while resisting officers who tried to prevent him asking a long rambling political question, even after John Kerry being asked the question said he would answer.

Whatever your take on this particular situation, this is the continuation of bad trend that started before designation "safe protest zones" well away from the political figuring being protested to.

So how can Black Rod save the day? The answer lies in the power of political ritual and ceremony to keep certain ideas alive.
Purloining freely from Wikipedia:

State Opening of Parliament


Black Rod is best known for his part in the ceremonies surrounding the State Opening of Parliament and the Throne speech. He summons the Commons to attend the speech and leads them to the Lords. As part of the ritual, as Black Rod approaches the doors to the chamber of the House of Commons to make his summons, they are slammed in his face. This is to symbolise the Commons’ independence of the Sovereign. Black Rod then strikes the door three times with his staff, and in reply to the challenge "Who is there?" answers "Black Rod". He is then admitted and issues the summons of the monarch to attend. This ritual is derived from the attempt by Charles I of England to arrest five members in 1642, in what was seen as a breach of privilege, though strictly the King was entitled to enter the chamber. After that incident, the House of Commons has maintained its right to question the right of the monarch’s representative to enter their chamber, though they can not bar him from entering with lawful authority.

The ceremony maintains the right.

From this day forth, a new tradition (like the famous Slashdot "first post") must begin.

The first question asked at any political rally, or convention must be a ceremonial question:"The police aren’t going to arrest or taser us if we ask unpopular questions, are they?"

Let the asking of this ceremonial question be offered to distinguished guests as a token of politeness, or to student body presidents, or the rotary club president, or the mayor.

And then the police, or the host will give the ceremonial answer: "No, not even if you are courteous or impolite, but we respectfully ask you to be courteous and polite to our guests and others present".

Maybe the questions need improvement, but the main thing is that it happens.

Make it happen, have the suggestion posted in every student handbook and newspaper, have it asked every time.

The maintenance of your liberty depends on the regular performance of this new ceremony.

New Lyrics


Lyrics to "He’s not Heavy. He’s my brother", anyone want to make a recording?

To the tune of "He ain’t heavy"

I may be wrong
with many a foolish thought
that leads me to who
  knows where
who knows where
If I’m wrong
show me that you care
please don’t taze me, please my brother

I hope you know
I welcome your point of view
don’t have to agree
to hear
or to share

for I know
the law preserves our liberty
please don’t taze me, please me brother

If I’m learning
  at all
I’m learning
  with sadness
that every tyrants heart
is-a filled with the badness
and hate
for free opinion

it’s a long long road
I fear there is no return
and we’re on the way
to hell
were nearly there

and the law
shouldn’t weigh us down at all
please don’t taze me, please me brother

( please my brother

  please don’t taze me

  please my brother
)

Wednesday, 18 July 2007

UPDATE: Fix status timeout: status=0xd0 { Busy }

I got a nice Acer laptop for not much from PC World, but it has a sucky TSSTcorpCD/DVDW TS-L632D, ATAPI  CD/DVD-ROM drive. The manufacturers have released a firmware update, but not for my OEM. Bah!

Gareth and Gareth have explained how to do a firmware update which (as it works for me) is a better solution:

See https://bugs.launchpad.net/ubuntu/+source/linux-source-2.6.20/+bug/75295

My own solution below is buggy and prone to calling the atapi reset TWICE (hanging the machine). I have a fix (not with me as I edit this now) which prevents the atapi reset being called twice in one minute, but I think the better solution is the firmware update.

As a consequence if the moon shakes a bit too much or one of the electrons gets a bit too hot, the CDROM drive stops responding. For windows users it disappears from My Computer altogether and they have to reboot.

Linux users are both better and worse off. Worse because the system hangs 4 seconds out of 5 and the syslog fills up with messages like "/dev/hdc: status timeout: status=0xd0 { Busy }"

If you can bear to slowly get a command window, a bit of "sudo hdparm -w /dev/hdc" will fix it, but thats too painful.

So, this script will fix it. You need to modify /etc/syslog.conf to add this line "kern.* /var/log/kern.fifo" to log kernel messages to a named pipe from which the script will read.

Install the script in /usr/local/sbin/fixhdc, and run it from /etc/rc.local with: "setsid /usr/local/sbin/fixhdc &"

#! /bin/bash
# /usr/local/sbin/fixhdc
# by Sam Liddicott
# Monitor kernel messages to see if the cdrom is jiggered
# If so do an atapi reset
# First add this line to /etc/syslog.conf
# kern.* /var/log/kern.fifo
# Then run this script from /etc/rc.local with:
# setsid /usr/local/sbin/fixhdc &

KERNFIFO=/var/log/kern.fifo
CDROM=hdc

CDROM_NODE="/dev/$CDROM"

daemon() {
  while read logline
  do
    case "$logline" in
      *"$CDROM: status timeout: status=0xd0 { Busy }"*)
        hdparm -w "$CDROM_NODE"
        logger -t ‘kern.crit’ — "$0 reset $CDROM"
      ;;
      *) echo "Ignore $logline";;
    esac
  done
}

while :
do
  if test -p "$KERNFIFO" || mkfifo "$KERNFIFO"
  then daemon < "$KERNFIFO" &
       # restart syslog now we have the pipe open
       /etc/init.d/sysklogd reload
       # it probably won’t finish till syslog does
       wait
       logger — "Restarting $0"
  else echo "Can’t make fifo $KERNFIFO"
       exit 1
  fi
done

Thursday, 12 July 2007

Windows-only IP camera on linux

I got a nice panning VGA camera for £69.00, but it’s one of those cameras from hell that only supports internet explorer on windows and crashes windows a lot.

As far as I can tell generically it is an SQ IP Cam or a GP-280 IP Camera.

I want to use it on linux, so out comes ethereal to do some packet sniffing and here is what I get:

I can get a video stream (special header and concatenated JPEG’s) with this URL:

http://192.168.1.69/cgi-bin/Stream?Video?Acc=USERNAME?Pwd=PASSWORD?webcamPWD=RookCookies00000

Possibly the RootCookies bit is important, perhaps related to a login that occurred earlier.

I can move the camera wth:
http://192.168.1.69/motor_control_right?webcamPWD=RootCookie00000

http://192.168.1.69/motor_control_left?webcamPWD=RootCookie00000

http://192.168.1.69/motor_control_up?webcamPWD=RootCookie00000

http://192.168.1.69/motor_control_down?webcamPWD=RootCookie00000

For horizontal and vertical centre

http://192.168.1.69/motor_control_auto_h?webcamPWD=RootCookie00000

http://192.168.1.69/motor_control_auto_v?webcamPWD=RootCookie00000

Full centre

http://192.168.1.69/motor_control_center?webcamPWD=RootCookie00000

To stop

http://192.168.1.69/motor_control_stop?webcamPWD=RootCookie00000

The special header on the video stream is a 40 byte header. I’m expecting certain values so they were easy to find:

Stream Header
Offset Format Data
0×16-0×17 16 bit integer LSB size of jpeg in bytes, or in other words, the number of bytes to read after this header before the start of the next header
0×1a-0×1b 16 bit integer LSB jpeg width in pixels
0×1c-0×1d 16 bit integer LSB jpeg height in pixels
0×28- Start of JPEG header

So stripping off the first 40 byte with
dd if=stream of=1.jpeg bs=1 skip=40

leaves me a jpeg (with loads more jpegs on the end, ech prefixed by the same 28 byte header).

So I can control the camera and rip video from it, now to make it like zoneminder.

UPDATE:

I can watch a video stream with VLC using:

wget -O /dev/stdout http://192.168.1.69/cgi-bin/Stream?Video?Acc=USERNAME?Pwd=PASSWORD?webcamPWD=RookCookies00000 |dd  skip=40 bs=1 | vlc -

I modified axmjpeg so it can split images from my camera too.

Update: 20 Sept 2007
This patch has been reworked applied to the standard axmjpeg project. (a while ago!)

This script can be used to control the camera from zoneminder:

#! /bin/bash
preset=home
presets="nothing motor_control_auto_h motor_control_auto_v motor_control_stop motor_control_center"

while test -n "$1"
do
  case "$1" in
    --address=*) address="${1##--address=}";;
    --address)   address="$2"; shift;;
    --command=*) command="${1##--command=}";;
    --command)   command="$2"; shift;;
    --preset=*)  preset="${1##--command=}";;
    --preset)    preset="$2"; shift;;
  esac
  shift;
done

url_base="http://$address/"
url_tail="?webcamPWD=RootCookie00000"

case "$command" in
  # home goto
  preset_home) url_command="motor_control_center";;
  preset_goto) set $presets; shift "$preset"; url_command="$1";;
  # right left down up
  move_rel_*) url_command="motor_control_${command##move_rel_}" ;;
esac

url="$url_base$url_command$url_tail"
wget -O /dev/null "$url" 2>/dev/null


UPDATE snapshot

I found a URL that can be used for a single snapshot (based on this http://ultradigital.freshdesk.com/support/solutions/articles/77478-comment-acc-der-au-flux-vid-o-d-une-cam-ra-ip-9060-i-9060-o-ou-9060a-mp):

http://192.168.1.69/snapshot.jpg?account=admin&password=password

Also related source code here: http://read.pudn.com/downloads65/sourcecode/internet/webserver/235705/Net_apps/httpd/api/HttpFileSystem.c__.htm

UPDATE streaming

I can play the stream like this:

ffplay -f mjpeg -probesize 40 -i 'http://192.168.1.69/cgi-bin/Stream?Video?Acc=admin?Pwd=password?webcamPWD=RookCookies00000&f=file.mjpg'

tip from http://www.lavrsen.dk/foswiki/bin/view/Motion/MplayerMjpegStreamViewing

but it seems more reliable to use axmjpeg to remove the extra data and output just a concatenation of jpegs:

axmjpeg -N -o /dev/stdout  'http://192.168.1.69/cgi-bin/Stream?Video?Acc=admin?Pwd=password?webcamPWD=RookCookies00000' | ffplay -f mjpeg /dev/stdin

Wednesday, 27 June 2007

$150 Bounty: 0402:5602 m560x webcam driver

I bought a fancy refurbished Acer laptop at a nice price. Ubuntu Feisty Fawn likes it all except the webcam, which is identified as 0402:5602, also known as m560x.

Well, I want it to work. I also want to improve the linux kernel, but I won’t be the one writing the driver, so instead I’ll use some of what I saved on this laptop to offer a bounty to the chap who does it.

I’ll pay by paypal $150 when Greg Kroah-Hartman of the usb-devel mailing list, or one of his deputies (e.g. Jiri Kosina) accepts working patches for this webcam and commits them for the upstream kernel; and where with the said patches I can get xawtv, ekiga and the like to enjoy the video source. like any other standard video source. The patches must be licensed under the GPL2, or GPL2 or later. The author retains copyright (naturally) or assigns it to the FSF.

To qualify, the patch, and earlier patch candidates (yes, they will make you tweak it and re-submit) must be submitted on the usb-devel mailing list, and excepting complications, the paypal payment will be to the email address comprising the Signed-off line in the patch submitted on said mailing list. I’ll split the bounty as joint contributors can agree or failing that, at my discretion. I expect one developer will leave a clear trail on the mailing list, terminating with the accepted patch, making recognition of the deserving author and subsequent payment easy.

The bounty offer will end after a valid claim has been made.

In any case it’s my intent to pay up to $150 to encourage development of such a driver and to pay it to those who write it and release it for kernel.

(It’s been suggested that this may involve working on sane-devel as well as usb-devel, in which case patches may need to be accepted for upstream submission by maintainers of both projects to qualify).

Information for starters:

Of course I’ll post the bounty notice in some of these places too.

UPDATE
I’m advised by one of the developers that more likely two drivers, m5602 and m5603 will hit the kernel; unknown timescales.
As long as the 5602 is supported I don’t mind splitting the bounty fairly between contributors of both drivers; in my view it is a common work that is now more conveniently expressed as two modules instead of one.
I expect other contributors will feel the same was as long as their device is supported.

Wednesday, 20 June 2007

Terminal Servers

I recently bought a Chase IOLAN RACK+ on ebay, only to find the built in switched mode PSU was clicking away like a broken thing.

The vendor generously offered a refund and let me keep it to repair or dipose of.

I then bought what I thought was another Chase IOLAN RACK+, but it fact it was the non-rack DB25 version with external PSU.

I decided they probably had the same voltages, so I could swap the PSU around, and with a bit of metal bending get things working for the RACK model.

While prodding the RACK+ PSU with my voltmeter to work out how to splice in the new PSU it suddenly started working; I guess the problem is most likely dry joints.

Next I find that my RJ45-DB9 cisco console cables don’t work. I find the Cisco pinout at http://www.technick.net/public/code/cp_dpage.php?aiocp_dp=pincabser_cisco_9 and by conferring with the Chase manual, come up with this  colour mapping.

IOLAN / Cisco Cable mappings
IOLAN CISCO RJ45 Names RJ45 DB9 DB9 Names
2 Black RTS 1 8 CST
8 Brown DTR 2 6 DSR
4 Red TXD 3 2 RXD
6 Orange GND 4 5 GND
  Yellow GND 5 5 GND
5 Green RXD 6 3 TXD
3 Blue DSR 7 4 DTR
7 White/Grey CTS 8 7 RTS

I cut off the RJ45 from the Cisco cables and make my own, which work fine!

So, as I crimp on a new RJ45, my colour mapping is:
NONE, BLACK, BLUE RED GREEN ORANGE WHITE BROWN
with yellow dangling/

Hurrah! I can now control 16 devices at once using debian’s cylcades-serial-client; all much more satisfactory that USB com ports which have given me no end of trouble.

Monday, 14 May 2007

Signing Jars with pvk

I had a little fun signing Jar files recently. I was using Comodo for my code signing certificate, which generates the CSR and private key using MSIE and xenroll - which suits me, (I once briefly ran a CA before, based on ssleay and xenroll). I exported the private key as a pvk file during the generation process.

The difficulty was getting the java keytool  to import a private key. The other difficulty was getting the secret proprietary microsoft .pvk format into a form that anything else knew about.

I got it working using pvktool to convert from pvk to pem format:

wine pvk.exe -in mykey.pvk -nocrypt -out mykey.pem 

I then used openssl to combine the key pem file with the cer file I had exported from MSIE to make a pkcs12 file:

openssl pkcs12 -export -chain -name FRIENDLYNAME -inkey mykey.pem -in mycert.cer -out all.pkcs12


The final clue was to give up using keytool to import the pkcs12 into the java keystore, but just use the pkcs12 file directly:

jarsigner -storetype pkcs12 -keystore all.pkcs12 JARFILE.JAR "FRIENDLYNAME"

For completeness I note that a pfx export from MS Windows is close enough a PKCS12 file, as is an export from Mozilla Firefox; however I wasn’t able to import the openssl generated pkcs12 file into MS IE, unless I imported it and exported through Firefox first. It may be something else I had done wrong at the same time that stopped it working otherwise/

And I’m not sure where the certificate chain came from, openssl’s root CA’s no doubt.

Sunday, 1 April 2007

BYU-TV on linux

This weekend I was watching the General Conference of the Church of Jesus Christ of Latter-day Saints (the Mormons).

The church itself no longer provides windows media streams of the video during the event, but audio only. This allows them to use their resources to provide audio streams to a wider range of users and in more languages.

Users wanting video are instead directed to www.byu.tv. Alas, whereas before I was able to use my linux video player of favour (totem or mplayer) to watch video, BYU TV streams video using a proprietary video format and requires a proprietary video player which seems to require the purchase and licensed use of certain proprietary operating systems. (Windows or MacOS). I may have mentioned that I’m using Ubuntu Linux.

Fortunately, as I have an x86 platform, I was able to watch all of conference on Linux by using windows firefox running under WINE with the Move Networks plugin. It was a simpel matter of making sure I had WINE installed and then installing Firefox for windows and then browsing to www.byu.tv where I was prompted to load the Move Networks plugin.

Sadly the move-networks plugin thought it was running in 256 colour mode, and so rendered the 24 bit colour into 8 bit hatching. (I took a screen-grab I can send to demonstrate this if you like). This required the combined processing power of 2 3GHz CPU’s to show video at full screen.

Fortunately move networks plugin WOULD play even when it thought it was in 256 colour mode, and fortunately I did have 2 3GHz CPU so I COULD watch in full screen.

Implications are that move networks could do an x86 linux plugin without too much hard work, if they would link with winelib.

It would still be a horrible proprietary video format and player, btu at least i would be able to choose my operating system.