zmcontrol.pm daemon not stopping

Forum for questions and support relating to the 1.24.x releases only.
Locked
bokusouchi
Posts: 13
Joined: Sat Jan 31, 2009 10:36 pm

zmcontrol.pm daemon not stopping

Post by bokusouchi »

I am in the process of writing a PTZ control module for the quickcam orbit/sphere . (with uvcdynctrl from the libwebcam library)
http://www.quickcamteam.net/software/libwebcam

I have a couple of questions concerning the new version of zmcontrol (daemon):

1) how is zmcontrol supposed to stop ? ; it is started at the first use of a control by the user . It then stays there . It is not stopped when stopping zoneminder (either via the web interface ,or via the /etc/init.d/zm script)

2) what is the purpose of the socket that zmcontrol opens ?

3) how in the control module ,do i get the values of max-pan-range and max-tilt-range ? (those value are entered in the web interface and are in the database )

The behaviour i have so far is :
zmcontrol not stopping when zoneminder stops (have to kill it manually).
If apache it stopped when zmcontrol is still running , it cannot restart because zmcontrol is hogging the ports 80 and 443 .

many thanks
newvisionantenna
Posts: 381
Joined: Sat Jan 17, 2009 7:49 pm
Location: Germany

Post by newvisionantenna »

I've already got one that was made by another forum user for 1.24. I currently use it on remote devices and have not tested it by using it on the actual computer running Zoneminder.

Would love if you could expand on it. If you want I'll send you a pm link to see it in action.
bokusouchi
Posts: 13
Joined: Sat Jan 31, 2009 10:36 pm

Post by bokusouchi »

hello

Mine is for local devices (no uvcstreamer) . it doesn't use the sysfs entries (they are not present for local devices ) but uses uvcdynctrl from libwebcam . I had already written one for version 1.22 that was working quite fine . Unfortunately (for me ) , the author of ZoneMinder changed quite
a lot ,the way zmcontrol works and rewrote it the "object programming way"
(gosh , how i hate doing object programming! :)
as 1.24 has (sort of) v4l2 support , I decided to rewrite "the new way"
my old control script .
I am ATM quite struggling with the "object way" , I have a very rough script
that does relative move (up-down-left-right) (this "works" ATM).
I plan to add focus control , home reset/preset , and diagonal moves later on .
If you send me a PM link , I can send you the code (you will need to get and compile uvcdynctrl)
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Re: zmcontrol.pm daemon not stopping

Post by zoneminder »

bokusouchi wrote:1) how is zmcontrol supposed to stop ? ; it is started at the first use of a control by the user . It then stays there . It is not stopped when stopping zoneminder (either via the web interface ,or via the /etc/init.d/zm script)
It will stop after not having received any input for 30 minutes (MAX_COMMAND_WAIT in the script). This is to enable a faster response to commands as there is not the overhead of starting up the script.
bokusouchi wrote:2) what is the purpose of the socket that zmcontrol opens ?
They are used by the web interface to talk directly with the script with minimal delays. If the web interface cannot talk on those sockets then it will fall back to direct script execution per command which is much slower.
bokusouchi wrote:3) how in the control module ,do i get the values of max-pan-range and max-tilt-range ? (those value are entered in the web interface and are in the database )
These, and the other values, are specific to your camera.
Phil
bokusouchi
Posts: 13
Joined: Sat Jan 31, 2009 10:36 pm

Post by bokusouchi »

bokusouchi wrote:
>3) how in the control module ,do i get the values of max-pan-range and >max-tilt-range ? (those value are entered in the web interface and are in >the database )


>These, and the other values, are specific to your camera.
_________________
yes , i know that those values are specific to my camera .
I entered them in the database through the web admin interface .

What i would like to do , is access those values in a custom control script .
I meant , given that those values are in the database , are they accessible through some data structure or object like "monitor-->{.....}" .
the same way that device-name or device-port is accessible ?

otherwise , i will have to hardcode them in the script .


thanks
ris2t
Posts: 43
Joined: Thu Jan 22, 2009 8:44 am

Re: zmcontrol.pm daemon not stopping

Post by ris2t »

bokusouchi wrote:I am in the process of writing a PTZ control module for the quickcam orbit/sphere . (with uvcdynctrl from the libwebcam library)
http://www.quickcamteam.net/software/libwebcam

2) what is the purpose of the socket that zmcontrol opens ?
Excellent, I was just embarking on a similar task. Would you mind sharing what you have to-date? I presume you have a *.pm module?

Currently I'm struggling with the socket stuff and the "Control Device" values. Does your orbit/sphere generate a /sys/class/video4linux/video1/pan_tilt path, mines missing which makes me suspect a more fundamental udev issue?

Code: Select all

video1   UVC Camera (046d:0994) 
Bus 006 Device 002: ID 046d:0994 Logitech, Inc. QuickCam Orbit/Sphere AF 
/sys/class/video4linux/video1$ ls -l 
 total 0 
 -rw-rw-rw- 1 root root 4096 2009-02-08 19:36 dev 
 lrwxrwxrwx 1 root root    0 2009-02-08 19:47 device -> ../../../6-2:1.0 
 -rw-rw-rw- 1 root root 4096 2009-02-08 19:47 index 
 -rw-rw-rw- 1 root root 4096 2009-02-08 19:47 name 
 drwxrwxrwx 2 root root    0 2009-02-08 19:47 power 
 lrwxrwxrwx 1 root root    0 2009-02-08 19:36 subsystem -> ../../../../../../../../class/video4linux 
 -rw-rw-rw- 1 root root 4096 2009-02-08 19:36 uevent 
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

bokusouchi wrote:
bokusouchi wrote:
>3) how in the control module ,do i get the values of max-pan-range and >max-tilt-range ? (those value are entered in the web interface and are in >the database )


>These, and the other values, are specific to your camera.
_________________
yes , i know that those values are specific to my camera .
I entered them in the database through the web admin interface .

What i would like to do , is access those values in a custom control script .
I meant , given that those values are in the database , are they accessible through some data structure or object like "monitor-->{.....}" .
the same way that device-name or device-port is accessible ?

otherwise , i will have to hardcode them in the script .


thanks
The max/min values etc are used in the web interface to calculate the amount of movement or speed to apply to the control script. So if it went from 0-100 then clicking on the point of the arrow (or near the edge of the image) will generate movement with a 100 step or speed. Half way along will be 50 etc. The zmcontrol script itself just gets passed the actual values to be move etc, the limits are just for the web pages to generate ratios.
Phil
bokusouchi
Posts: 13
Joined: Sat Jan 31, 2009 10:36 pm

Re: zmcontrol.pm daemon not stopping

Post by bokusouchi »

ris2t wrote:
bokusouchi wrote:I am in the process of writing a PTZ control module for the quickcam orbit/sphere . (with uvcdynctrl from the libwebcam library)
http://www.quickcamteam.net/software/libwebcam

2) what is the purpose of the socket that zmcontrol opens ?
Excellent, I was just embarking on a similar task. Would you mind sharing what you have to-date? I presume you have a *.pm module?

Currently I'm struggling with the socket stuff and the "Control Device" values. Does your orbit/sphere generate a /sys/class/video4linux/video1/pan_tilt path, mines missing which makes me suspect a more fundamental udev issue?

Code: Select all

video1   UVC Camera (046d:0994) 
Bus 006 Device 002: ID 046d:0994 Logitech, Inc. QuickCam Orbit/Sphere AF 
/sys/class/video4linux/video1$ ls -l 
 total 0 
 -rw-rw-rw- 1 root root 4096 2009-02-08 19:36 dev 
 lrwxrwxrwx 1 root root    0 2009-02-08 19:47 device -> ../../../6-2:1.0 
 -rw-rw-rw- 1 root root 4096 2009-02-08 19:47 index 
 -rw-rw-rw- 1 root root 4096 2009-02-08 19:47 name 
 drwxrwxrwx 2 root root    0 2009-02-08 19:47 power 
 lrwxrwxrwx 1 root root    0 2009-02-08 19:36 subsystem -> ../../../../../../../../class/video4linux 
 -rw-rw-rw- 1 root root 4096 2009-02-08 19:36 uevent 
hello

No I don't have /sys/class/video4linux/video1/pan_tilt . I suspect some
old version of the UVC driver had this at some point . but it does not exist with the current driver . the pan/tilt control are "custom controls" that
are accessible with some special v4l2 ioct calls ,they are created dynamically by a udev script . all this is handled by a library called libwebcam and a small utility program called uvcdynctrl . you can find all the explanations and documentation , and download this utility at the address i mentioned in my first post .
http://www.quickcamteam.net/software/libwebcam

you need this "uvcdynctrl" to use my script

another different option is to use the remote mjpeg_streamer to control
the ptz of the camera . some other people have gone that way .

with my script it is possible to control a local camera .




Code: Select all

# ==========================================================================
#
# ZoneMinder QuickcamSphere Control Protocol Module, $Date: 2009-02-08 
# Copyright (C) 2009  Bokusouchi
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# ==========================================================================
#
# This module contains the implementation of the QuickcamSphere camera control
# protocol
#
package ZoneMinder::Control::QuickcamSphere;

use 5.006;
use strict;
use warnings;
use IO::Handle;
use File::Basename;
use File::Find;

#==========================================================================
#
# These are the elements you can edit to suit your installation
#
# ==========================================================================

use constant DBG_ID => "QuickcamSphere"; # Tag that appears in debug to identify source
use constant DBG_LEVEL => 1; # 0 is errors, warnings and info only, > 0 for debug

# ==========================================================================



require ZoneMinder::Base;
require ZoneMinder::Control;

our @ISA = qw(ZoneMinder::Control);

our $VERSION = $ZoneMinder::Base::VERSION;

# ==========================================================================
#
# QuickcamSphere Control Protocol
#
# ==========================================================================

use ZoneMinder::Debug qw(:all);

use Time::HiRes qw( usleep );

use constant SYNC => 0xff;
use constant COMMAND_GAP => 100000; # In ms



sub new
{
    my $class = shift;
    my $id = shift;
    my $self = ZoneMinder::Control->new( $id );
    bless( $self, $class );
    srand( time() );
    $self->loadMonitor();
    $self->where_am_i();
    return $self;
}

our $AUTOLOAD;

sub AUTOLOAD
{
    my $self = shift;
    my $class = ref($self) || croak( "$self not object" );
    my $name = $AUTOLOAD;
    $name =~ s/.*://;
    if ( exists($self->{$name}) )
    {
        return( $self->{$name} );
    }
    Fatal( "Can't access $name member of object of class $class" );
}


sub open
{
    my $self = shift;

    $self->loadMonitor();

    $self->{state} = 'open';
}

sub close
{
    my $self = shift;
    $self->{state} = 'closed';
}

sub printMsg
{
    if ( zmDbgLevel() > 0 )
    {
        my $self = shift;
        my $msg = shift;
        my $prefix = shift || "";
        $prefix = $prefix.": " if ( $prefix );

        my $line_length = 16;
        my $msg_len = int(@$msg);

        my $msg_str = $prefix;
        for ( my $i = 0; $i <msg_len> 0) && ($i%$line_length == 0) && ($i != ($msg_len-1)) )
            {
                $msg_str .= sprintf( "\n%*s", length($prefix), "" );
            }
            $msg_str .= sprintf( "%02x ", $msg->[$i] );
        }
        $msg_str .= "[".$msg_len."]";
        Debug( $msg_str );
    }
}



sub moveRelUp
{
    my $self = shift;
    my $params = shift;
    $self->loadMonitor();
    my $tiltstep = $self->getParam( $params, 'tiltstep' );
    Debug( "Step Up" );
    my $pan_min=$self->{Monitor}->{MinPanRange};
    my $pan_max=$self->{Monitor}->{MaxPanRange};
    my $tilt_min=$self->{Monitor}->{MinTiltRange};
    my $tilt_max=$self->{Monitor}->{MaxTiltRange};
    my $pan_cur=$self->{Monitor}->{pan_cur};
    my $tilt_cur=$self->{Monitor}->{tilt_cur};
    my $focus_cur=$self->{Monitor}->{focus_cur};
    my $panstep=0;
    $tiltstep = - $tiltstep ;                                               
    if ($tilt_cur + $tiltstep <tilt_min>{Monitor}->{uvcdynctrl_device}=~ /^([\w.</Debug>{Monitor}->{pan_cur}=$pan_cur;
    	$tilt_cur=$self->{Monitor}->{tilt_cur}=$tilt_cur;
	my $device_temp_file=$self->{Monitor}->{device_temp_file};
        my $fh=IO::Handle->new();
	Debug( "device_temp_file=$device_temp_file");
	CORE::open($fh,">","$device_temp_file") || die("Cannot open $device_temp_file");
	CORE::print($fh "$pan_cur:$tilt_cur:$focus_cur");
	CORE::close($fh);
        Debug( "Moving to $pan_cur,$tilt_cur \n" );
	$tiltstep = $tiltstep * 64 ;
	$panstep = $panstep  * 64 ;
        Debug( "real_panstep = $panstep reial_tiltstep = $tiltstep\n" );
	if ( $tiltstep == 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d", $untainted_device ,"-s","Tilt (relative)" ,"--","$tiltstep") ;
	}
	if ( $panstep == 0 )
	{

		CORE:system("/usr/bin/uvcdynctrl" ,"-d",$untainted_device ,"-s","Pan (relative)" ,"--","$panstep") ;
	}

	if ( $tiltstep != 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d", $untainted_device ,"-s","Tilt (relative)" ,"--","$tiltstep") ;
		CORE:usleep (400);
        }
	if ( $panstep != 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d",$untainted_device ,"-s","Pan (relative)" ,"--","$panstep") ;
		CORE:usleep (400);
        }
}

sub moveRelDown
{
    my $self = shift;
    my $params = shift;
    $self->loadMonitor();
    my $tiltstep = $self->getParam( $params, 'tiltstep' );
    Debug( "Step Down" );
    my $pan_min=$self->{Monitor}->{MinPanRange};
    my $pan_max=$self->{Monitor}->{MaxPanRange};
    my $tilt_min=$self->{Monitor}->{MinTiltRange};
    my $tilt_max=$self->{Monitor}->{MaxTiltRange};
    my $pan_cur=$self->{Monitor}->{pan_cur};
    my $tilt_cur=$self->{Monitor}->{tilt_cur};
    my $focus_cur=$self->{Monitor}->{focus_cur};
    my $panstep=0;
     if ($tilt_cur + $tiltstep >  $tilt_max) {
           $tiltstep = $tilt_max - $tilt_cur;
      }
	Debug( "panstep=$panstep tiltstep=$tiltstep ,before untaint" );
	my $untaint1="0";
	my $untaint2="0";
	($untaint1)="$panstep"=~ /^(-?[0-9]+)$/;
	Debug ("untaint1= $untaint1");
	($untaint2)="$tiltstep"=~ /^(-?[0-9]+)$/;
	Debug ("untaint2= $untaint2");
	$panstep=$untaint1;
	$tiltstep=$untaint2;
	my $untainted_device="grr";
	($untainted_device) =$self->{Monitor}->{uvcdynctrl_device}=~ /^([\w.</Debug>{Monitor}->{pan_cur}=$pan_cur;
    	$tilt_cur=$self->{Monitor}->{tilt_cur}=$tilt_cur;
	my $device_temp_file=$self->{Monitor}->{device_temp_file};
        my $fh=IO::Handle->new();
	Debug( "device_temp_file=$device_temp_file");
	CORE::open($fh,">","$device_temp_file") || die("Cannot open $device_temp_file");
	CORE::print($fh "$pan_cur:$tilt_cur:$focus_cur");
	CORE::close($fh);
        Debug( "Moving to $pan_cur,$tilt_cur \n" );
	$tiltstep = $tiltstep * 64 ;
	$panstep = $panstep  * 64 ;
        Debug( "real_panstep = $panstep real_tiltstep = $tiltstep\n" );
	if ( $tiltstep == 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d", $untainted_device ,"-s","Tilt (relative)" ,"--","$tiltstep") ;
	}
	if ( $panstep == 0 )
	{

		CORE:system("/usr/bin/uvcdynctrl" ,"-d",$untainted_device ,"-s","Pan (relative)" ,"--","$panstep") ;
	}

	if ( $tiltstep != 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d", $untainted_device ,"-s","Tilt (relative)" ,"--","$tiltstep") ;
		CORE:usleep (400);
        }
	if ( $panstep != 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d",$untainted_device ,"-s","Pan (relative)" ,"--","$panstep") ;
		CORE:usleep (400);
	}
}

sub moveRelLeft
{
    my $self = shift;
    my $params = shift;
    $self->loadMonitor();
    my $tiltstep=0;
    my $panstep =  $self->getParam( $params, 'panstep' );
    Debug( "panstep=$panstep" );
    Debug( "Step Left" );
    my $pan_max=$self->{Monitor}->{MaxPanRange};
    Debug("pan_max=$pan_max");
    my $pan_min=$self->{Monitor}->{MinPanRange};
    Debug("pan_min=$pan_min");
    my $tilt_min=$self->{Monitor}->{MinTiltRange};
    my $tilt_max=$self->{Monitor}->{MaxTiltRange};
    my $pan_cur=$self->{Monitor}->{pan_cur};
    my $tilt_cur=$self->{Monitor}->{tilt_cur};
    my $focus_cur=$self->{Monitor}->{focus_cur};
    if ($pan_cur + $panstep >  $pan_max) {
         $panstep = $pan_max - $pan_cur;
    	Debug( "Hitting the limite --> recalculating panstep" );
    }   
	Debug( "panstep=$panstep tiltstep=$tiltstep ,before untaint" );
	my $untaint1="0";
	my $untaint2="0";
	($untaint1)="$panstep"=~ /^(-?[0-9]+)$/;
	Debug ("untaint1= $untaint1");
	($untaint2)="$tiltstep"=~ /^(-?[0-9]+)$/;
	Debug ("untaint2= $untaint2");
	$panstep=$untaint1;
	$tiltstep=$untaint2;
	my $untainted_device="grr";
	($untainted_device) =$self->{Monitor}->{uvcdynctrl_device}=~ /^([\w.</Debug>{Monitor}->{pan_cur}=$pan_cur;
    	$tilt_cur=$self->{Monitor}->{tilt_cur}=$tilt_cur;
	my $device_temp_file=$self->{Monitor}->{device_temp_file};
        my $fh=IO::Handle->new();
	Debug( "device_temp_file=$device_temp_file");
	CORE::open($fh,">","$device_temp_file") || die("Cannot open $device_temp_file");
	CORE::print($fh "$pan_cur:$tilt_cur:$focus_cur");
	CORE::close($fh);
        Debug( "Moving to $pan_cur,$tilt_cur \n" );
	$tiltstep = $tiltstep * 64 ;
	$panstep = $panstep  * 64 ;
        Debug( "real_panstep = $panstep reial_tiltstep = $tiltstep\n" );
	if ( $tiltstep == 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d", $untainted_device ,"-s","Tilt (relative)" ,"--","$tiltstep") ;
	}
	if ( $panstep == 0 )
	{

		CORE:system("/usr/bin/uvcdynctrl" ,"-d",$untainted_device ,"-s","Pan (relative)" ,"--","$panstep") ;
	}

	if ( $tiltstep != 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d", $untainted_device ,"-s","Tilt (relative)" ,"--","$tiltstep") ;
		CORE:usleep (400);
        }
	if ( $panstep != 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d",$untainted_device ,"-s","Pan (relative)" ,"--","$panstep") ;
		CORE:usleep (400);
        }
}

sub moveRelRight
{
    my $self = shift;
    my $params = shift;
    $self->loadMonitor();
    my $tiltstep=0;
    my $panstep = - $self->getParam( $params, 'panstep' );
    Debug( "panstep=$panstep" );
    Debug( "Step Right" );
    my $pan_min=$self->{Monitor}->{MinPanRange};
    my $pan_max=$self->{Monitor}->{MaxPanRange};
    my $tilt_min=$self->{Monitor}->{MinTiltRange};
    my $tilt_max=$self->{Monitor}->{MaxTiltRange};
    my $pan_cur=$self->{Monitor}->{pan_cur};
    my $tilt_cur=$self->{Monitor}->{tilt_cur};
    my $focus_cur=$self->{Monitor}->{focus_cur};
    if ($pan_cur + $panstep <pan_min>{Monitor}->{uvcdynctrl_device}=~ /^([\w.</Debug>{Monitor}->{device_temp_file};
        my $fh=IO::Handle->new();
	Debug( "device_temp_file=$device_temp_file");
	CORE::open($fh,">","$device_temp_file") || die("Cannot open $device_temp_file");
	CORE::print($fh "$pan_cur:$tilt_cur:$focus_cur");
	CORE::close($fh);
        Debug( "Moving to $pan_cur,$tilt_cur \n" );
    	$pan_cur=$self->{Monitor}->{pan_cur}=$pan_cur;
    	$tilt_cur=$self->{Monitor}->{tilt_cur}=$tilt_cur;
	$tiltstep = $tiltstep * 64 ;
	$panstep = $panstep  * 64 ;
        Debug( "real_panstep = $panstep reial_tiltstep = $tiltstep\n" );
	if ( $tiltstep == 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d", $untainted_device ,"-s","Tilt (relative)" ,"--","$tiltstep") ;
	}
	if ( $panstep == 0 )
	{

		CORE:system("/usr/bin/uvcdynctrl" ,"-d",$untainted_device ,"-s","Pan (relative)" ,"--","$panstep") ;
	}

	if ( $tiltstep != 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d", $untainted_device ,"-s","Tilt (relative)" ,"--","$tiltstep") ;
		CORE:usleep (400);
        }
	if ( $panstep != 0 )
	{
		CORE:system("/usr/bin/uvcdynctrl" ,"-d",$untainted_device ,"-s","Pan (relative)" ,"--","$panstep") ;
		CORE:usleep (400);
        }

}

sub moveRelUpLeft
{
    my $self = shift;
    my $params = shift;
}

sub moveRelUpRight
{
    my $self = shift;
    my $params = shift;
}

sub moveRelDownLeft
{
    my $self = shift;
    my $params = shift;
}

sub moveRelDownRight
{
    my $self = shift;
    my $params = shift;
}

sub focusConNear
{
    my $self = shift;
    my $params = shift;
    Debug( "Focus Near" );
}

sub focusConFar
{
    my $self = shift;
    my $params = shift;
    Debug( "Focus Far" );
}



sub presetClear
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset', 1 );
    Debug( "Clear Preset $preset" );
}

sub presetSet
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset', 1 );
}

sub presetGoto
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset', 1 );
    Debug( "Goto Preset $preset" );
}

sub presetHome
{
    my $self = shift;
    my $params = shift;
#    Debug("device=    $self->{Monitor}->{ControlDevice}");
#    Debug("device=    $self->{Monitor}->{ControlDevice}");
#    Debug("device=    $self->{Monitor}->{ControlDevice}");
#    Debug("device=    $self->{Monitor}->{ControlDevice}");
#    Debug("device=    $self->{Monitor}->{ControlDevice}");
#    Debug("device=    $self->{Monitor}->{ControlDevice}");
#    $self->where_am_i();
#    my @msg = ( 0x80|$self->{Monitor}->{ControlAddress}, 0x01, 0x06, 0x04, SYNC );
#    $self->sendCmd( \@msg );
}


sub where_am_i
{
my $self = shift;
my $params = shift;
# We have a device ... where is it now?
Debug("n ::where_am_i:: ");
$self->loadMonitor();
Debug("device=    $self->{Monitor}->{ControlDevice}");
$self->{Monitor}->{MinPanRange}=-55,
$self->{Monitor}->{MaxPanRange}= 55,
$self->{Monitor}->{MinTiltRange}=-28,
$self->{Monitor}->{MaxTiltRange}= 24,
Debug("MinPanRange=    $self->{Monitor}->{MinPanRange}");
Debug("MaxPanRange=    $self->{Monitor}->{MaxPanRange}");
Debug("MinTiltRange=    $self->{Monitor}->{MinTiltRange}");
Debug("MaxTiltRange=    $self->{Monitor}->{MaxTiltRange}");
my $sym_device_basename=File::Basename::basename($self->{Monitor}->{ControlDevice});
Debug("sym_device_basename= $sym_device_basename");
my $device_temp_file="/tmp/"."$sym_device_basename".".current";
Debug ( "grrr   device_temp_file= $device_temp_file \n" );
$self->{Monitor}->{device_temp_file}=$device_temp_file;
my $fh=IO::Handle->new();
CORE::open($fh, "$device_temp_file") || Debug ("Could not open $device_temp_file");
my $diamond_handle=<fh>;
my ($pan_cur,$tilt_cur,$focus_cur)=CORE::split(/:/,$diamond_handle);
CORE::close($fh);
Debug ( "Currently at $pan_cur,$tilt_cur,$focus_cur" );
$self->{Monitor}->{pan_cur}=$pan_cur;
$self->{Monitor}->{tilt_cur}=$tilt_cur;
$self->{Monitor}->{focus_cur}=$focus_cur;
Debug ( "Currently(monitor object) at $self->{Monitor}->{pan_cur}, $self->{Monitor}->{tilt_cur},$self->{Monitor}->{focus_cur}" );
#first we deduce the real device name 
my $real_device="glop";
#$real_device=File::find::readlink("$sym_device");
$real_device=CORE::readlink("$self->{Monitor}->{ControlDevice}");
Debug ( "real_device= $real_device" );
my $tainted_device=File::Basename::basename($real_device);
Debug ( "tainted_device= $tainted_device" );
$self->{Monitor}->{uvcdynctrl_device}=$tainted_device ;
#my uvcdynctrl_device="glop";
#$uvcdynctrl_device) = $tainted_device=~ /^([\w.<>\/,"=]+)$/;
#Debug ( "uvcdynctrl_device= $uvcdynctrl_device \n" );
#srand( time() );
}




1;
__END__
# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

ZoneMinder::Database - Perl extension for blah blah blah

=head1 SYNOPSIS

  use ZoneMinder::Database;
  blah blah blah

=head1 DESCRIPTION

Stub documentation for ZoneMinder, created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.

Blah blah blah.

=head2 EXPORT

None by default.



=head1 SEE ALSO

Mention other useful documentation such as the documentation of
related modules or operating system documentation (such as man pages
in UNIX), or any relevant external documentation such as RFCs or
standards.

If you have a mailing list set up for your module, mention it here.

If you have a web site set up for your module, mention it here.

=head1 AUTHOR

Bokusouchi

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2009  bokusouchi

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.3 or,
at your option, any later version of Perl 5 you may have available.


=cut
ris2t
Posts: 43
Joined: Thu Jan 22, 2009 8:44 am

Re: zmcontrol.pm daemon not stopping

Post by ris2t »

Hi, a couple of lines seem to be throwing compile errors. I suspect a forum cut and paste issue with some characters being changed.

Would appreciate a check and correction of the lines below.

printMsg for seems to be missing a ";$i++" and has "<msg_len> 0", also missing a }

moveRelUp has "<tilt_min>{Monitor}->{" which i'm still trying to figure out.
bokusouchi wrote:

Code: Select all

...
sub printMsg
{
... 
        for ( my $i = 0; $i <msg_len> 0) && ($i%$line_length == 0) && ($i != ($msg_len-1)) )
            {
                $msg_str .= sprintf( "\n%*s", length($prefix), "" );
            }
            $msg_str .= sprintf( "%02x ", $msg->[$i] );
        }
}

sub moveRelUp
{
....
    if ($tilt_cur + $tiltstep <tilt_min>{Monitor}->{uvcdynctrl_device}=~ /^([\w.</Debug>{Monitor}->{pan_cur}=$pan_cur;
....
}

ssalerno
Posts: 2
Joined: Mon Feb 15, 2010 6:44 pm

uvcdynctrl Control

Post by ssalerno »

Ok I have got the command uvcdynctrl to work in a shell so I know it works, but I can not get it to work in ZoneMinder.

What do you put in the Control Device ?

/sys/class/video4linux/videoX/pan_tilt Does not exists.

when I try the bokusouchi script I keep getting these errors in my zmcontrol.log.

02/18/10 05:38:29.516659 zmcontrol[10214].INF [Control server 9/uvctrl starting at 10/02/18 05:38:29]02/18/10 05:38:39.517519 zmcontrol[10213].FAT [Can't connect: No such file or directory

Any Help would be appreciated.

P.S here is the link to the shell uvcdynctrl commands for anyone who wants them.

http://forums.quickcamteam.net/showthread.php?tid=212

Steve
ris2t
Posts: 43
Joined: Thu Jan 22, 2009 8:44 am

Re: uvcdynctrl Control

Post by ris2t »

ssalerno wrote:02/18/10 05:38:29.516659 zmcontrol[10214].INF [Control server 9/uvctrl starting at 10/02/18 05:38:29]02/18/10 05:38:39.517519 zmcontrol[10213].FAT [Can't connect: No such file or directory
Just been reworking through getting my QuickcamSphere up and running with controls again. ZM version 1.24.2.

I've found in my case the "Can't connect: No such file or directory" arose because I didn't set the Control Type EXACTLY as "QuickcamSphere".

If you dig into the perl you'll see that the control type name is a verbatim match requirement for the perl modules names (without the extension).

To track all this down I had to resort to tweaking the /usr/bin/zmcontrol.pl.

Code: Select all

     elsif ( defined($cpid) )
    159     {
    160       #  close( STDOUT );
    161       # close( STDERR );
Commenting out the above two lines help give some temporary visbility to hidden errors.

Tested with

Code: Select all

zmcontrol.pl --id=2 --command=moveRelRight.
christophe_y2k
Posts: 102
Joined: Mon Oct 12, 2009 8:47 am
Location: EUROPE-FRANCE-MANDELIEU

Re: zmcontrol.pm daemon not stopping

Post by christophe_y2k »

Thanks you !!!
with your method i found the probleme with my Foscam PT Script and now that move
;)
Locked