Marc's Public Blog - Linux Hacking


All | Aquariums | Arduino | Btrfs | Cars | Cats | Clubbing | Computers | Dining | Diving | Electronics | Exercising | Festivals | Flying | Halloween | Hiking | Linux | Linuxha | Monuments | Museums | Outings | Public | Rc | Sciencemuseums | Solar | Tfsf | Trips

This page has a few of my blog entries about linux, but my main linux page is here
Picture of Linus


Table of Content for linux:

More pages: April 2023 March 2023 September 2021 May 2020 January 2020 January 2019 December 2018 March 2018 January 2018 September 2017 January 2017 October 2016 August 2016 July 2016 June 2016 March 2016 February 2016 January 2016 May 2015 March 2015 January 2015 October 2014 May 2014 April 2014 March 2014 January 2014 November 2013 September 2013 May 2013 March 2013 January 2013 December 2012 August 2012 May 2012 March 2012 January 2012 December 2011 August 2011 July 2011 January 2011 October 2010 August 2010 June 2010 April 2010 March 2010 January 2010 December 2009 November 2009 September 2009 August 2009 July 2009 May 2009 January 2009 December 2008 November 2008 October 2008 January 2008 November 2007 August 2007 July 2006 January 2006 August 2005 April 2005 November 2004 March 2004 February 2004



2013/11/16 Mythtv + Denon-AVR-3808CI 2 Way Communication
π 2013-11-16 01:01 in Linux, Linuxha
Recent Denon AV Receivers, like at least the 3806, 3807, 3808, 3809, 3810, 3811, 3812, 3813, as well as 4806, 4807, 4808, 4809, 4810, 4811, 4812, 4813 have a TCP/IP connection you can use to control the receiver via telnet.

But the important thing is that the telnet connection 2-way, so it will also tell you whathe receiver is doing. I use this to know when the receiver turns on or off, and more importantly when it tunes into my mythtv input. When that happens, I have my controlling PC (the one that's always on) know that the AV receiver switched to mythtv, and it will send a wake on lan (WOL) packet to my mythtv to wake it up from S3 sleep, as well as restart X because for my video card X doesn't resume properly over HDMI.

At the same time, as explained in an earlier post on how to mute and change volume on a Denon receiver using a mythtv remote, I already have my mythtv send commands to my Denon AV receiver to change the volume or mute it.

Given the above, I now had the problem that both my hacks didn't work at the same time because denon receivers only accept one telnet connection. Thankfully the connection is 2-way, but you need the code that can receive status from it independently from writing to the telnet socket.

So, I found denon.pl from bradfitz and quickly adapted my code into it. My new code reads commands from a FIFO and passes them on ot the socket. With my diffs, it's not super pretty code, but I stopped caring when it worked :)

So now, I have my denon to trigger a WOL packet to wake up my mythtv PC from S3 ACPI sleep when it's selected in the receiver.
In turn, when my denon is told to sleep, my code receives the state change over the telnet connection and my controlling PC uses the info to make mythfrontend exist back to mythwelcome, which in turn will cause the mythtv to go to S3 sleep if it's not doing anything else.
This can all be done by only reading from the telnet connection (which I used to do), but now I also use mythtv to control the sound on the receiver and this is done by sending commands asynchronously from the status updates being received.

This is how the mute script works:

 
#!/bin/bash

FILE=/tmp/denonmute

test -f $FILE || touch $FILE

# prevent bounces [ $(( $(date "+%s") - $(stat -c "%Z" $FILE) )) -lt 2 ] && exit

if grep -q MUON $FILE 2>/dev/null; then CMD=MUOFF else CMD=MUON fi

# Used to be: #echo -ne "$CMD\r" | nc -q0 denon 23 #echo $CMD > $FILE

echo $CMD | tee $FILE > /var/run/denon.fifo

Here is the code that interacts with my Denon AVR:

  • denon
  • denoncmd
  • denonmute
  • On the mythtv side, these are some of my scripts:

  • myth_can_shutdown
  •  
    #!/bin/bash

    # See http://www.mythtv.org/wiki/ACPI_Wakeup # Time wakeup format was hh:mm yyyy-MM-dd and changed to time_t

    DATE=$(date "+%Y:%m:%d-%H:%M:%S") LOG=/var/log/mythtv/myth_acpi

    exec >>$LOG exec 2>>$LOG

    # This will shutdown if I pause too long without turning off denon. #for mplayer in $(pgrep mplayer) #do # # See if mplayer is currently playing. # before=$(grep pos /proc/$mplayer/fdinfo/*) # sleep 2 # after=$(grep pos /proc/$mplayer/fdinfo/*) # # if [ "$before" != "$after" ]; then # echo "$DATE: $0 found running mplayer, cancel sleep" # ps auxww |grep "[ ]$mplayer" # exit 1 # fi #done

    # mplayer is killed in myth_frontend_shutdown. if pgrep mplayer; then echo "$DATE: $0 found mplayer, cancel sleep" ps auxww |grep "[mM]player" exit 1 fi

    if pgrep xbmc.bin >/dev/null; then echo "$DATE: $0 xbmc running, cancel sleep" exit 1 fi

    if who | grep -qv mythtv; then echo "$DATE: $0 root logged in, cancel sleep" who exit 1 fi

    echo "$DATE: $0 called, and nothing blocking shutdown"

  • myth-fmr_wol
  •  
    #!/bin/bash

    etherwake -i eth1 00:22:15:8c:66:e9 etherwake -i wlan0 00:22:15:8c:66:e9 &>/dev/null

  • myth_frontend_shutdown is the script 'denon' calls via telnet to shut down mythfrontend/xmbc/mplayer and let the machine go to S3 sleep
  •  
    #!/bin/bash LOG=/var/log/mythtv/myth_acpi exec >>$LOG exec 2>>$LOG

    if pgrep xbmc.bin >/dev/null; then echo "$(date "+%Y:%m:%d-%H:%M"): Asking XBMC to shut down" /var/local/scr/alarm 5 wget --quiet -O /dev/null 'http://localhost:8080/xbmcCmds/xbmcHttp?command=exit' sleep 5 ps auxww | grep '[xX]bmc' if pgrep xbmc.bin || pgrep xmbc; then echo "$(date "+%Y:%m:%d-%H:%M"): XBMC DID NOT DIE, FORCIBLY KILLING." killall xbmc.bin xbmc sleep 1 killall -9 xbmc.bin xbmc fi fi

    # stop mplayer so that myth_can_shutdown can detect and shutdown. killall mplayer

    # killing xbmc can restart mythfrontend. sleep 1

    if pgrep -f mythfrontend.real >/dev/null; then echo "$(date "+%Y:%m:%d-%H:%M"): Asking mythfrontend pid $(pgrep -f mythfrontend.real) to shut down" # http://www.mythtv.org/wiki/Keybindings #for key in space f1 escape escape down enter #do #nc -q0 localhost 6546 <<< "key $key" #sleep 1 #done for cmd in 'jump mainmenu' 'key escape' 'key down' 'key enter' do echo "sending $cmd" nc -q0 localhost 6546 <<< "$cmd" sleep 1 done # Key enter takes a long time to exit mythfrontend. sleep 10 if pgrep -f mythfrontend.real; then echo "$(date "+%Y:%m:%d-%H:%M"): MYTHFRONTEND DID NOT DIE, FORCIBLY KILLING." /usr/bin/killall mythfrontend.real sleep 1 /usr/bin/killall -9 mythfrontend.real else echo "$(date "+%Y:%m:%d-%H:%M"): mythfrontend has shut down." fi fi

  • myth_reset_xorg is the other script 'denon' calls via telnet to restart X and mythwelcome after S3 sleep restore. This is necessary on my system because X doesn't always come back ok from sleep.
  •  
    #!/bin/bash

    export PATH=/var/local/scr:$PATH

    while : do # I shouldn't have to kill mythfrontend because it shouldn't be running # but this is just for completeness. # I have also had one case like below where I had to kill Xorg. # |-login(6160)---startx(6184,mythtv)---xinit(6307)-+-Xorg(6308,root) # | `-xinit(6318) killall mythwelcome xinit mythfrontend.real mythfrontend Xorg

    sleep 6 X_TTY=$(ps auxww | grep '/usr/bin/[X]' | sed -e "s/.* tty//" -e "s/[^0-9].*//")

    /var/local/scr/alarm 3 sudo chvt 2 sleep 1 /var/local/scr/alarm 3 sudo chvt $X_TTY

    sleep 2 # This doesn't actually check that X is talking to a screen, it works # when waking up from RTC and no screen is connected :( #if grep 'intel(0): EDID vendor "DON"' /var/log/Xorg.0.log; then if grep 'Resuming AIGLX clients after VT switch' /var/log/Xorg.0.log; then echo "X seems be running and displaying" break else echo ">>>>>>>>>>>> X isn't displaying, trying restart loop <<<<<<<<<<<<<<<<" fi done

    For indexing purposes, here is a snapshot of the main denon code

     
    #!/usr/bin/perl

    # Originally from bradfitz (denon.pl on github).

    use strict; use IO::Socket::INET; use Time::HiRes qw (sleep); use POSIX qw(mkfifo); use Carp qw(croak); use FileHandle;

    my $host = "denon"; my $fifo = "/var/run/denon.fifo"; my $port = 23;

    STDOUT->autoflush(1); STDERR->autoflush(1);

    ("\xff\xfd\x03" eq fromhex("ff fd", " 03 ")) or die "Unittest failed";

    # ----------------

    my $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port) or die "Failed to connect to $host:$port";

    sub expect_from_denon { my $expected = shift; my $got = ""; my $buf; print "Waiting on ", printable($expected), "..."; while (length($got) < length($expected) && sysread($sock, $buf, length($expected) - length($got))) { $got .= $buf; } croak "Didn't get expected input." unless $got eq $expected; print "Got it.\n"; return 1; }

    sub fromhex { my $in = join(', @_); $in =~ s/\s*(..)\s*/chr(hex($1))/eg; return $in; }

    sub send_to_denon { my $str = shift; syswrite($sock, $str) = length($str) or die; # We don't sync with the reader, but blind sleep for each line sent. sleep 0.2; }

    sub printable { my $str = shift; $str =~ s/[^[:print:]]/sprintf("x%02x", ord($&))/eg; return $str; }

    sub turn_off_myth { # for key in 'key space' 'jump mainmenu' 'key escape' 'key down' 'key enter'; do # echo "$key" | nc myth 6546; echo "$key"; sleep 3; done system("date; /var/local/scr/alarm 10 telnet myth 10221; date"); }

    sub wakeup_activate_myth { if (not system("fping -c3 -p1 -q myth")) { print "myth is already up, toggle X screen to wake X up\n"; system("date; /var/local/scr/alarm 20 telnet myth 10222; date"); } else { # If we start myth too quickly and the display isn't ready, it becomes # unable to talk to it until it goes through another suspend/resume. # Mmmh, actually it doesn't look like sleeping here is useful. but let's sleep 1; print "myth is down, wake it up and restart X\n"; # 5 Seconds is a bit aggressive for the machine to wake up and # be ready to flip Xorg, but it seems to work. system("date; sudo /var/local/scr/myth-fmr_wol; fping -r 5 myth && date && " "echo 'sleep 5 wait for X to restart safely' && sleep 5 && /var/local/scr/alarm 20 telnet myth 10222; date"); } }

    sub printlog { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); my $mesg = $_[0]; $year+=1900; $mon++;

    chomp($mesg); printf LOG ("%.4d/%.2d/%.2d %.2d:%.2d:%.2d - $mesg\n", $year, $mon, $mday, $hour, $min, $sec); }

    # --------------------------------------------------------------------------------

    my $hello = fromhex("ff fd 03", # Do Suppress Go ahead "ff fb 18", # Will Terminal Type "ff fb 1f", # Will Negotiate About Window Size "ff fb 20", # Will Terminal Speed "ff fb 21", # Will Remote Flow Control "ff fb 22", # Will Linemode "ff fb 27", # Will New Environment Option "ff fd 05", # Do Status );

    send_to_denon($hello);

    expect_from_denon(fromhex("ff fb 03")); # Will Suppress Go Ahead expect_from_denon(fromhex("ff fa 18 01 ff f0")); # Send your terminal type

    print "send terminal.\n"; send_to_denon(fromhex("ff fa 18 00", "rxvt", "ff f0", # suboption end ));

    expect_from_denon("BridgeCo AG Telnet server\x0a\x0d");

    my $child = fork; defined($child) or die "Fork failure.";

    if ($child) # we're the parent process. accept input. { if ($#ARGV eq -1) { while (1) { print "DENON> "; my $line = <STDIN>; chomp $line; next if (!$line); exit if ($line eq "quit" or $line eq "q" or $line eq "exit"); send_to_denon($line . "\x0d"); } } elsif ($#ARGV eq 0) { my $arg = $ARGV[0];

    if ($arg eq "--server") { -p $fifo or mkfifo($fifo, 0700) or die "mkfifo($fifo) failed: $!";

    print "Will read from fifo $fifo until ^C\n"; my $logfile = "/var/log/denon-send.log"; open(LOG, ">>$logfile") or die "Can't write to $logfile"; LOG->autoflush(1);

    open(FIFO, "<$fifo") or die "Can't read from $fifo: $!"; while (1) { sleep 0.1; my $arg = <FIFO>; next if (not $arg);

    chomp $arg; printlog("sending $arg"); send_to_denon($arg . "\x0d"); } } else { print "Will send $arg to $host\n"; send_to_denon($arg . "\x0d"); } } elsif ($#ARGV eq 1) { my ($arg, $repeat) = @ARGV; print "Will send $arg to $host $repeat times\n"; foreach $_ (1 .. $repeat) { send_to_denon($ARGV[0] . "\x0d"); } } else { die "Too many args: ".join(" ", @ARGV); } } else # Child process, { my $logfile = "/var/log/denon.log"; open(LOG, ">>$logfile") or die "Can't write to $logfile"; LOG->autoflush(1);

    # Init state machine for keeping track of whether receiver is on or off # and on which output. By default, we'll pretend the last output was DVR my $input = "SIDVR";

    # Sometimes, the connection to denon dies when denon starts up. # When this happens, we missed the first PWON, so we assume that # we're at stage one already (first PWON seen) when we start. my $denon_state = "on_stage1";

    # Turning back on to mythtv when it was off, we need to wait for the 2nd PWON # 2011/11/09 05:50:17 - PSROOM EQ:AUDYSSEY # 2011/11/09 05:50:17 - PWON # 2011/11/09 05:50:17 - ZMON # 2011/11/09 05:50:20 - PSROOM EQ:AUDYSSEY # 2011/11/09 05:50:21 - PSROOM EQ:AUDYSSEY # 2011/11/09 05:50:24 - PSROOM EQ:AUDYSSEY # 2011/11/09 05:50:24 - PSROOM EQ:AUDYSSEY # 2011/11/09 05:50:25 - PSROOM EQ:AUDYSSEY # look for 2nd PWON vvvvvvvv # 2011/11/09 05:50:25 - PWON # 2011/11/09 05:50:42 - PSROOM EQ:AUDYSSEY # 2011/11/09 05:50:44 - PSROOM EQ:AUDYSSEY # 2011/11/09 05:50:44 - PSROOM EQ:AUDYSSEY # # Turning on when mythtv was the last input to DVD # 2011/11/09 05:48:22 - ZMOFF # 2011/11/09 05:48:38 - PSROOM EQ:AUDYSSEY # 2011/11/09 05:48:38 - PWON # 2011/11/09 05:48:39 - ZMON # 2011/11/09 05:48:41 - PSROOM EQ:AUDYSSEY # 2011/11/09 05:48:43 - SIDVD # 2011/11/09 05:48:43 - Denon switched input to SIDVD # 2011/11/09 05:48:43 - SDHDMI # 2011/11/09 05:48:43 - SVSAT # 2011/11/09 05:48:43 - DCAUTO # 2011/11/09 05:48:43 - CVFL 495 # 2011/11/09 05:48:43 - CVFR 505 # 2011/11/09 05:48:43 - CVC 495 # 2011/11/09 05:48:43 - CVSW 52 # 2011/11/09 05:48:43 - CVSL 495 # 2011/11/09 05:48:43 - CVSR 52 # 2011/11/09 05:48:43 - CVSBL 50 # 2011/11/09 05:48:43 - CVSBR 50 # 2011/11/09 05:48:43 - CVSB 50 # 2011/11/09 05:48:43 - MVMAX 98 # 2011/11/09 05:48:43 - PSROOM EQ:AUDYSSEY # look for 2nd PWON vvvvvvvv # 2011/11/09 05:48:47 - PWON # 2011/11/09 05:49:19 - SIDVR # 2011/11/09 05:49:19 - SDAUTO # 2011/11/09 05:49:19 - SVDVR # 2011/11/09 05:49:19 - DCAUTO

    # Show any read data, and depending on some commands read, wake up # or put mythtv to sleep. my $data; while (sysread($sock, $data, 300)) { $data =~ s/\015/\n/g; foreach my $line (split(/\n/, $data)) { printlog("Read: ".printable($line));

    if ($line =~ /SIDVR/) { printlog("Denon switched to MythTV (denon state $denon_state), waking up myth"); wakeup_activate_myth(); $input = $line; } elsif ($line =~ /^SI/) { printlog("Denon switched input to $line"); $input = $line; if ($denon_state eq "on") { printlog("Denon on (state $denon_state), but switched to $input. Turn off mythtv"); turn_off_myth(); } } elsif ($line =~ /PWON/) { if ($denon_state eq "off") { $denon_state = "on_stage1"; printlog("Denon being turned on, switching to stage1 on"); # Between now and the second 'ON', we'll have gotten a new # input line if input got switched at power on, or we use # the last one we've seen in the past. } else { printlog("Got another PWON (was $denon_state)"); $denon_state = "on"; if ($input =~ /SIDVR/) { printlog("Denon turned on and was last on MythTV, waking up myth"); wakeup_activate_myth(); } else { printlog("Denon turned on but input is $input, doing nothing"); } } } elsif ($line =~ /PWSTANDBY/) { $denon_state = "off"; if ($input =~ /SIDVR/) { printlog("Denon turned off and was last on MythTV, turning off"); turn_off_myth(); } else { printlog("Denon turned off but last input was $input, not doing anything"); } } } } }

    sub END { #print "Killing child\n"; kill(9, $child); }

    exit; ___END___ #!/bin/bash

    # $0 cmd [repeat]

    for i in `seq 1 ${2-1}` do echo -ne "$1\r" | nc -q0 denon 23 sleep 0.2 done

    exit

    PWON", "xon" PWSTANDBY PW?", "power-status" MVUP", "volplus" MVDOWN", "volminus" MV62", "vol-18" MV80", "vol+0" MV98", "vol+18" MUON", "mute-on" MUOFF", "mute-off" SIPHONO", "input-phono" SICD", "input-cd" SITUNER", "input-tuner" SIDVD", "input-dvd" SIVDP", "input-vdp" SITV", "input-tv" SIDBS", "input-dbs" SIVCR-1", "input-vcr1" SIVCR-2", "input-vcr2" SIV.AUX", "input-vaux" SICDR/TAPE", "input-cdr" SI?", "input-status" SDAUTO", "digital-in-auto" SDPCM", "digital-in-pcm" SDDTS", "digital-in-dts" SDANALOG", "digital-in-analog" SDEXT.IN-1", "digital-in-ext-in" SVDVD", "video-select-dvd" SVVDP", "video-select-vdp" SVTV", "video-select-tv" SVDBS", "video-select-dbs" SVVCR-1", "video-select-vcr1" SVVCR-2", "video-select-vcr2" SVV.AUX", "video-select-vaux" SVSOURCE", "video-select-source" MSDIRECT", "surround-mode-direct" MSPURE DIRECT", "surround-mode-pure-direct" MSSTEREO", "surround-mode-stereo" MSMULTI CH IN", "surround-mode-multi-ch-in" MSMULTI CH DIRECT", "surround-mode-multi-ch-direct" MSMULTI CH PURE D", "surround-mode-multi-ch-pure-direct" MSDOLBY PRO LOGIC", "surround-mode-dolby-pro-logic" MSDOLBY PL2", "surround-mode-dolby-pl2" MSDOLBY PL2x", "surround-mode-dolby-pl2x" MSDOLBY DIGITAL", "surround-mode-dolby-digital" MSDOLBY D EX", "surround-mode-dolby-d-ex" MSDTS NEO:6", "surround-mode-dts-neo6" MSDTS SURROUND", "surround-mode-dts-surround" MSDTS ES DSCRT6.1", "surround-mode-dts-es-dscrt61" MSDTS ES MTRX6.1", "surround-mode-dts-es-mtrx61" MSWIDE SCREEN", "surround-mode-wide-screen" MS5CH STEREO", "surround-mode-5ch-stereo" MS7CH STEREO", "surround-mode-7ch-stereo" MSSUPER STADIUM", "surround-mode-super-stadium" MSROCK ARENA", "surround-mode-rock-arena" MSJAZZ CLUB", "surround-mode-jazz-club" MSCLASSIC CONCERT", "surround-mode-classic-concert" MSMONO MOVIE", "surround-mode-mono-movie" MSMATRIX", "surround-mode-matrix" MSVIDEO GAME", "surround-mode-video-game" MSVIRTUAL", "surround-mode-virtual" MS?", "surround-mode-status" MSUSER1", "surround-mode-user1" MSUSER2", "surround-mode-user2" MSUSER3", "surround-mode-user3" SSCUP", "cursor-up" SSCDN", "cursor-down" SSCLT", "cursor-left" SSCRT", "cursor-right" SSENT", "cursor-enter" SSMEN ON", "system-setup-menu-on" SSMEN OFF", "system-setup-menu-off" PSMEN ON", "surround-parameter-menu-on" PSMEN OFF", "surround-parameter-menu-off"

    2013/11/10 Reviewing IP Webcams for Linux and Zoneminder:Dlink DCS900, Ubnt Aircam, Foscam FI8904W FI8910W, FFI9820W, FI9821W, Wansview NCB541W, and Zavio F3210
    π 2013-11-10 00:00 in Computers, Linux, Linuxha
    Links to cameras:
  • DCS900
  • FI8904W
  • NCB541W
  • FI8910W
  • FI8920W
  • FI8921W
  • Aircam
  • Edimax3115w
  • F3210
  • FI9826PB
  • FI9805P
  • FI9900P
  • NCM625GA (aka Wansview Q1)
  • NCM751GA (aka Wansview W1)
  • Wansview K1
  • Wansview W2
  • Wansview Q2
  • Reolink RLC-410
  • Wansview K2
  • I hearby want to thank Wansview for giving me some of the above cameras for review (I bought some of them on my own, and after seeing my reviews, they asked me to test and review a few more). Note that while wansview cameras do not offer the sharpest 1080p pictures I've seen (Zavio and FI9900 win, even I hate foscam), the nice things I've written on wansview are not based on the free cameras, but the fact that they have always answered my support queries, including the technical ones showing issues with the firmware, and fixed the firmware after that (including making it work on linux and other other operating systems), while Foscam tells people that they're running the wrong version of windows, and that's it.
    zavio truly sells good cameras, but sadly they cost more than double, which may be a bit out of reach for many people.

    Zoneminder

    I have tried a bunch of IP cameras with linux and zoneminder. Here is a short review of them below if that helps others.

    One good page to know about is ispyconnect, which gives all the entrypoints for many cameras:

  • http://www.ispyconnect.com/man.aspx?n=foscam
  • http://www.ispyconnect.com/man.aspx?n=wansview
  • http://www.ispyconnect.com/man.aspx?n=zavio
  • Camera in 2009

    Dlink DCS900

    My first IP Cam was a Dlink DCS900. Today, it's utter crap, the picture is bad, the camera is slow, but back in the day it was cheap-ish and there weren't many other ones:






    Cameras in 2013/11

    Foscam FI8904W

    This is an outdoors camera. It's not wide angle at all, which I don't like, and it's low res (640x480), but the picture is decent enough for that resolution:




    Wansview NCB541W

    It's a clone of the FI8904N. The firmware isn't great, but it works well enough for image capture and it's the cheapest you'll find for 480p with a motorized base _and_ night view.



    Foscam FI8910W

    Similarly the FI8910W is ok enough for 640x480, but don't expect miracles:






    Because it wasn't wide angle enough, I got a 3rd party (cheap) wide angle F2.0 lens for it. It blurs the picture around the edges quite a bit, but gives me the shot I wanted:



    Foscam FI8920W

    It's supposed to be an HD camera (720p), but the picture is horrible and the web interface too (does not work with linux). It's not even wide angle. DO NOT BUY:




    Foscam FI8921W

    It's the not as bad version of the FI8921W. To be honest, the 720p HD picture is still blurry, but it's better than 480p. You get what you pay for. The web interface does not work with linux but you can capture screenshots from it with zoneminder on linux after you've set it up. It also has an RTSP stream, but I found it often gave me frames where the picture was aborted half way (actually I found out later that reducing the frame rate seems to fix this), so I use image capture instead of RTSP for zoneminder.



    I also changed the F2.8 lens to a wider dealextreme F2.0 lens that's blurry around the edges:



    Ubnt Aircam

    It wins for the very wide angle and cheap price for 720p, but that's because the sensor is not 720p, only the output is. If you take a 480p shot and you blow it up to 720p, it looks almost the same. Sad... The newer firmware offers image capture if you turn off authentication, but I didn't get it to work well with zoneminder (it's too slow), so I use RTSP. I would not really recommend this camera unless you want the very wide angle. Note that some cameras ship blurry because the lens (very very hard to turn, it's stuck with glue I think), is not focussed. At times, it'll also show you wrong colors.

    out of focus out of the box, this is kind of sad
    out of focus out of the box, this is kind of sad

    this is only barely better than the 480p version but great wide angle
    this is only barely better than the 480p version but great wide angle

    480p picture blown up to 720p to compare with 720p 'native'
    480p picture blown up to 720p to compare with 720p 'native'

    Edimax 3115w

    This is a nice cheap camera with an honest resolution of 960p. The caveats are that it's not motorized, and it does not have night/IR vision, but otherwise the picture and resolution are good and you can't beat them for the price (assuming you can still find it for sale anywhere)



    Zavio F3210

    It's more expensive ($260), but the picture is fantastic, even in 1080p (reduced here for the web page). Too bad it does not come motorized, and for Wifi you'll need the F3215 which is not motorized either ($280).
    The web interface and protocol support are fantastic. This is a camera that all other manufacturers should inspire themselves from. You can fully configure it in any browser (including from linux of course), and see the live view without any special plugin.






    Cameras in 2015/08

    My old Foscam fi8904w died (it was my only outdoor camera), so I looked at replacements. Sadly foscam only got worse software/firmware-wise, sometimes even making cameras that work with virtually no OS (including new versions of windows in some cases), and they continued to have lots of fake 5 star reviews on amazon, which is enough of a reason not to by from them anymore.
    A few cameras I looked at first though:

    Foscam FI9826PB

    Don't buy this, get the cheaper Wansview NCM625GA/Q1 (or Q2) which comes with higher resolution and no cheating fake reviews on amazon.

    Foscam FI9805P

    This one might have worked, again if you forget all the fake amazon reviews, but it's superseeded by the FI9900P.

    Foscam FI9900P

    The amazon reviews are saying: good camera quality, and questionable firmware with bugs, a foscam specialty still... I ordered one out of morbid curiosity and to replace my outdoors Foscam FI8904W which just died, but really I (or you) shouldn't be giving any money to Foscam anymore...
    If you don't mind spending more ($300), the Zavio B6210 seems like a good serious replacement.

    Anyway, here's what I found on the Foscam 9900:

  • The firmware is even more horrible than it was before. I could not even get it to display a picture in windows with MSIE and their stupid windows only plugin that I shouldn't even have to trust to see a picture. I was able to change video settings on windows, but not see the picture.
  • With the android software, I can see the picture/video, but not change the video settings
  • And get this, if I try to login on linux, I cannot even login. Yes, login denied without the stupid windows plugin (i.e. I cannot even access settings and non video related stuff).
  • If you guessed that I think Foscam sucks by now, you guessed right. First to me, they look like liars and cheaters by what really looks like buying fake reviews on amazon, and then in the last 2 years, they actually made their web interface worse since the FI8921W where you could at least login on linux and change settings.

    While I'll repeat that life is too short to deal with this crap and give money to that company, I used jpeg URL ( /cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=user&pwd=pwd1 ) to make it work with zoneminder, and it works well enough. As other reviews have said, the optics are actually quite good, I do like the very wide angle picture without barrel effect:






    Too bad that Foscam's firmware sucks so much, the optics are good now. If you need an outdoor camera, and value your time and sanity a few dollars, I'd recommend the Zavio B6210. If an indoor camera used outdoors with light weather proofing is good enough, try the cheaper and somewhat better Wansview NCM625GA/Q1 below (although its picture isn't as wide and show barrel effect):

    Wansview NCM625GA (aka Wansview Q1)

    I ended up continuing with an indoor camera that I'm going to use outdoors. A Zavio F3215 would have been very good, but this new Wansview is half the price and is motorized. It's much much better than the old NCB541W I have (and actually that was a very good camera for the price too). The Wansview NCM625GA is sold on amazon as Wansview 1080P 2.0MP WiFi Wireless IP Security Camera, Full HD.
    Note that there is new firmware for this camera. The original firmware was mostly windows only, but the new one has a flash interface that works on linux and most operating systems.

    Cons:

  • It used to require a windows plugin, but now it works with flash too on most operating systems (including linux)
  • Pros:

  • Price/features is unbeatable ($80), video quality is good
  • Nice wide lens (maybe not what you needed, but that's what I wanted)
  • the motorized mount almost has 360 travel
  • relay outputs if you care about that
  • Updates:

  • If you install firmware 0.40 and this firmware patch I got from Wansview (both can be installed in the web upload interface), http://ipaddr/mjpeg/snap.cgi?chn=0 now returns a proper Content-Type: image/jpeg header and will work with Zoneminder and other software that expects a jpeg. You can also get official firmware updates from this site: http://www.wansview.com/Service/download/25.html
  • Info:

  • Turns out you can get simple jpegs from that camera without a plugin. The magic URL is http://ipaddr/mjpeg/snap.cgi?chn=0 . Note that the firmware did not return a proper "Content-Type: image/jpeg" header, so the jpeg URL does not work with zoneminder and may not work with other software. This is now fixed with a firmware patch_.
  • I installed the recommended iSmartViewPro on android, scanned the QR code on the back of the camera, and had it working instantly.
  • The video works fine on linux with ( vlc rtsp://ipaddr/live/ch0 , vlc rtsp://ipaddr/live/ch2 , vlc rtsp://ipaddr/live/ch3 ).
  • PTZ can be controlled with GET ipaddr/hy-cgi/ptz.cgi?cmd=ptzctrl&act=left|right|up|down|stop|home|hscan|vscan (you can also add &speed=1-4 for a slower/faster scan speed).
  • Move to a preset: GET ipaddr/hy-cgi/ptz.cgi?cmd=preset&number=1&act=goto (I gathered those by dumping strings in the npHYPlayer.dll they provide for windows).
  • From the command line, try wget -q -O - --user=admin --password=pwd 'http://ipaddr/hy-cgi/ptz.cgi?cmd=preset&number=2&act=goto'
  • To move the camera just a bit to the left, try this: wget -q -O - --user=admin --password=pwd 'http://ipaddr/hy-cgi/ptz.cgi?cmd=ptzctrl&act=left&speed=2'; sleep 1; wget -q -O - --user=admin --password=pwd 'http://ipaddr/hy-cgi/ptz.cgi?cmd=ptzctrl&act=stop&speed=2'
  • It works fine with zoneminder 1.28 although I have to configure the 1080p stream on the camera to only be 3fps, or my zoneminder backend cannot process it quickly enough and the picture gets truncated (also there is up to a 5 second delay, but that seems to be true for zoneminder with many RTSP streams). If this does not work well for you, you can also simply configure zoneminder to pull the jpeg without using RTSP.
  • With the newer firmware, you can now do jpeg image capture too like you would with any basic webcam:
  • http://wansview-ncm625ga-1/mjpeg/snap.cgi?chn=0 gives you a single jpeg snapshot (which on newer firmware like 48 is 1920x1072 instead of 1920x1080, beware!)
  • http://wansview-ncm625ga-1/mjpeg/stream.cgi?chn=0 gives you an mjpeg stream that works with zoneminder but for me it gives a lower frame rate (1fps while I can do about 5fps on jpeg pulls from snap.cgi).

  • The 1920x1080 shots are truncated to 1280 for display on this page
    The 1920x1080 shots are truncated to 1280 for display on this page





    Wansview NCM751GA (aka Wansview W1)

    Wansview just came out with a competitor to the Foscam 9900, it's priced at the same $150 (now $100-ish 2016/12). If you need a cheap 1080p outdoors camera, and you hate foscam like I do (as explained above: bad firmware, and dishonest fake reviews on amazon), it's a decent option. However, the optics/video capture are inferior to both the foscam 9900 and the Wansview NCM625GA. For some reason, the 1080p picture looks like a blown up burry 720p or maybe 480p picture (this turned out to be due to my lens being out of focus, it's better after I fixed that). Also this camera is big and heavy compared to the Foscam 9900 (try the W2 instead).
    Please read the Wansview Q1 review for details on magic URLs to use, and firmware updates.

    This camera was superseeded by the Wansview W2 which is both much smaller and cheaper. Honestly, the only advantage of the W1 is the onboard storage if you care about that. For remote capture support, the W2 will be a much better bet (and almost half the price).

    The viewing anble is pretty narrow. That's either a good or a bad thing depending on your needs, but if you need wide, prever the NCM625GA if you can put it outdoors safely, or consider the foscam or a higher priced camera. The night vision is decent though:

    The 1920x1080 shots are truncated to 1280 for display on this page
    The 1920x1080 shots are truncated to 1280 for display on this page





    My camera was giving blurry pictures because the lens was mis-adjusted. I had to open it up and readjust the lens for the picture to a bit more clear.

    Like the NCM625GA, it now comes with firmware that works fine with linux and any operating system, and the android app gets the camera working in no time after you scan the QR code.

    Wansview K1

    This is wansview's smaller version of the NCM625GA that adds temperature and humidity monitoring while removing the motorized base.
    Please read the Wansview Q1 review for details on magic URLs to use, and firmware updates.

    It's a great little camera. Just like its big brother, I installed the recommended iSmartViewPro on android, scanned the QR code on the back of the camera, and had it working instantly. The picture quality is very good and this is the widest picture of any camera I've reviewed so far (even if it comes at the price of barrel effect).
    Please refer to my Wanview NCM625GA review for configuration details. The only real downside is the placement of the ethernet jack, making it hard to fit some ethernet cables unless you remove the flexible sleeve, but that's a manageable problem :)

    If you have firmware 0.39 or 0.40 and install this firmware patch I got from Wansview (via the web upload interface), http://ipaddr/mjpeg/snap.cgi?chn=0 now returns a proper Content-Type: image/jpeg header and will work with Zoneminder and other software that expects a jpeg. If your firmware is 0.41 or later, it should just work without the patch.

    It is the best 1080p camera you can get for that price, I'm quite impressed with it.

    The 1920x1080 shots are truncated to 1280 for display on this page
    The 1920x1080 shots are truncated to 1280 for display on this page





    Wansview W2

    This is wansview's smaller version of the Wansview W1 (NCM751GA). It's much smaller, cheaper, and otherwise short of onboard storage, it's really identical in functionality, including the narrow 6mm lens, which may or may not be good depending on your application.
    Please read the Wansview Q1 review for details on magic URLs to use, and firmware updates.

    My camera shipped with firmware 0.42 which supports http://ipaddr/mjpeg/snap.cgi?chn=0 out of the box with a proper Content-Type: image/jpeg header and will work with Zoneminder and other software that expects a jpeg.

    This is definitely a good alternative to the Foscam FI9900 if you are ok with a narrow lens in exchange for better firmware froma better company. However I'm not going to lie, the picture is not ultra sharp. It doens't look blurry but it feels like the sensor is not truly 1080p, or something is robbing a bit of resolution or sharpness.

    The 1920x1080 shots are truncated to 1280 for display on this page
    The 1920x1080 shots are truncated to 1280 for display on this page





    Wansview Q2

    I really liked my Wansview Q1, it was a great motorized camera with good wide lens, for a good price. The Q2 is a similar camera that's just a bit smaller, and offers similar performance. At the time I'm writing this, they are similarly priced. The Q1 is tiny bit bigger and offers a it more I/O. The Q2 is smaller and white if you prefer that over white, but the more important difference is that the Q2 has a lens that is a bit wider, so you will see a little bit more of your room with it than with a Q1. On the minus side, I found the picture less sharp on the Q2 than the Q1. You can compare the screenshots for yourself.
    Please read the Wansview Q1 review for details on magic URLs to use, and firmware updates.

    My camera shipped with firmware 0.42 which supports http://ipaddr/mjpeg/snap.cgi?chn=0 out of the box with a proper Content-Type: image/jpeg header and will work with Zoneminder and other software that expects a jpeg.

    The Q1 picture is a bit more narrow and looks a bit more sharp
    The Q1 picture is a bit more narrow and looks a bit more sharp

    The Q2 picture is a bit wider and bit less sharp
    The Q2 picture is a bit wider and bit less sharp

    Here are the other Q2 screenshots, they look fairly good at night;






    Reolink RLC-410

    I tried a reolink since it offered 1440p resolution instead of 1080p like the wansview, and despite the low price, the firmware worked pretty well (no problems on linux/chrome), and http jpeg downloads work fine too, although the download URL is weird: http://192.168.205.206/cgi-bin/api.cgi?cmd=Snap&channel=0&user=user&password=pwd . Actually, let me scratch that, jpeg downloads work fine in a browser, but return a content-type chunked that does not work with software that expects a simple image/jpeg in return. As a result, zoneminder does not work with this camera unless you use RTSP which itself is full of problems since it can easily push data faster than zoneminder can process it, yielding broken frames.

    Setup was a breeze, the one downside is because it's a PoE camera, it does support 12V input, but it does not ship with a 12V power supply. Thankfully I have a drawer full of those :)
    The default picture was way too bright (over exposed) and the sharpening was turned up too high, making the picture grainy. On the last picture, I turned the brightness down as well as the sharpening, and the results are better. The lens is about as wide as Wansview Q2. *Update* a firmware update seems to have dramatically improved the picture quality, which to be honest, was pretty poor. The screenshots below are the old picture quality, I have not had the chance to get shots with the new firmware yet since my camera is installed outdoors at the moment.

    Here are screenshots (resized to 1280, but you can click on them to get the full original size). Again, these are very poor quality and a new firmware fixes those:






    Wansview K2

    This is wansview's smaller and cheaper version the K1. It's about as barebones as you can get for an IP camera: $30.
    This camera is about half the size of the K1 (on top of being half the cost), and is wifi only. Setting it up is interesting as it doesn't use the typical methods of acting as an access point that your phone connects to, or having a side channel to configure it via bluetooth (probably for cost reasons). Instead you use the wansview smartphone app to enter your access point details and it'll emit a loud sound that encodes the Wifi name and password, which get picked up by the camera's microphone. That's a pretty cool hack :)
    To be fair, setting up the camera is a bit blind, you only have 2 LEDs close to one another and you need to send the sound sequence at the right time and hope it works, or reboot and try again. Also, don't forget that if you send a 5Ghz network, it won't work since the camera only does 2.4Ghz wifi. It worked for me on my second try, but basically you're working kind of blind. This may get a bit annoying if you're having problems setting it up, and in that case spending more money on the K1 may be a better option.

    So, for that limited price, you still get most of the typical wansview interface without any sdcard or recording support, but you can tell the CPU is slow. It's slow enough that you have to wait for the web page to load, and also slow enough that a reboot takes a while. Last, but not least the picture is only 720p, not 1080p, and when comparing a downsided picture from a K1 and a native 720p picture from the K2, the K2 picture is not as sharp but still very usable
    It's far from a perfect camera, but again, you only paid $30 (my favourites from Wansview are definitely K1 and Q1). If you want a camera that's more capable, the K1 is a very good small camera, so get that one instead. The choice is yours :)

    Here are the screenshots in native 720p:








    Using cameras outdoors

    I'm in California, so we don't have extreme weather. I use indoor cameras outdoors because the choice of good outdoor cameras with wide angles and reasonable pricing, was limited to say the least. This is probably an example of what not to do :) (but it's been working fine for over 2 years, and as luck would have it, my real outdoor camera is the only one that died after 2.5 years of use).

    Foscam FI9821W and Zavio F3210, along with an IR booster for better distance vision at night with the Zavio
    Foscam FI9821W and Zavio F3210, along with an IR booster for better distance vision at night with the Zavio

    we don't exactly have harsh winters here, or really bad rain, so part of my equipment is just outdoors under the gutter
    we don't exactly have harsh winters here, or really bad rain, so part of my equipment is just outdoors under the gutter

    I then have ethernet and power going in my yard to the malibox
    I then have ethernet and power going in my yard to the malibox

    I do use a waterproof box for equipment outside (includes an insteon iolinc to control the mailbox and flood light if you open it)
    I do use a waterproof box for equipment outside (includes an insteon iolinc to control the mailbox and flood light if you open it)

    very tight fit, but I used a 7A 12V power supply to power the gigabit switch, floodlight (12V LEDs), and 4 IP cams
    very tight fit, but I used a 7A 12V power supply to power the gigabit switch, floodlight (12V LEDs), and 4 IP cams

    this should take care of any mailbox thieves :)
    this should take care of any mailbox thieves :)

    2013/11/06 Attending and presenting at Usenix Lisa 2013
    π 2013-11-06 01:01 in Linux
    Usenix was in Washington DC this year, and a coworker got me to present a paper on my work there, so I did and I was accepted.

    A few pictures:



    Bruce Schneider via VC
    Bruce Schneider via VC

    I attended an evening BOF on lock picking
    I attended an evening BOF on lock picking

    I managed to open a few
    I managed to open a few

    Tatu gave a very boring talk about ssh key management and gave his commercial solution which most people seemed to agree was a bad solution, disappointing.
    Tatu gave a very boring talk about ssh key management and gave his commercial solution which most people seemed to agree was a bad solution, disappointing.

    They had a single evening party bowling based:




    My coworker Todd gave a fun end of conference keynote:


    Because I was presenting a paper, I only had a short 30mn timeslot, which is way too short for my talk which needed closer to an hour, so I gave a very fast condensed version. Lisa has posted a video here which does not show me, but shows the slides. I self recorded the talk but it doesn't show the screen (slides clearly), that said, you can play both at the same time if you wish :)

    Here is a link to the full paper in PDF, which gives many more details than my talk: http://marc.merlins.org/linux/talks/ProdNG-LISA/Paper/ProdNG.pdf

    The talk went very well, and hopefully a few people enjoyed the paper, because it sure took a long time to write :)


    More pages: April 2023 March 2023 September 2021 May 2020 January 2020 January 2019 December 2018 March 2018 January 2018 September 2017 January 2017 October 2016 August 2016 July 2016 June 2016 March 2016 February 2016 January 2016 May 2015 March 2015 January 2015 October 2014 May 2014 April 2014 March 2014 January 2014 November 2013 September 2013 May 2013 March 2013 January 2013 December 2012 August 2012 May 2012 March 2012 January 2012 December 2011 August 2011 July 2011 January 2011 October 2010 August 2010 June 2010 April 2010 March 2010 January 2010 December 2009 November 2009 September 2009 August 2009 July 2009 May 2009 January 2009 December 2008 November 2008 October 2008 January 2008 November 2007 August 2007 July 2006 January 2006 August 2005 April 2005 November 2004 March 2004 February 2004

    Contact Email