Foscam FI8910W control issue with 1.27

Forum for questions and support relating to the 1.27.x releases only.
Post Reply
olsenh
Posts: 3
Joined: Sat Apr 12, 2014 2:11 pm

Foscam FI8910W control issue with 1.27

Post by olsenh » Sat Apr 12, 2014 2:27 pm

Just updated from v1.25 to v1.27 and have lost control ability for Foscam FI8910W camera. Tried to see if I could adjust the code slightly but am having no luck in restoring the ability to control the camera. Tried to use the existing custom .pm file, but got errors, then decided to model off of the FI8908W.pm file (that apparently comes with this version of ZM) and no longer get errors but camera still does not move...streaming and recording is just fine.

Attached is the pm code I am trying to use for the FI8910W camera.
Any help is appreciated...

olsenh
Posts: 3
Joined: Sat Apr 12, 2014 2:11 pm

Re: Foscam FI8910W control issue with 1.27

Post by olsenh » Sat Apr 12, 2014 2:33 pm

# ==========================================================================
#
# ZoneMinder Foscam FI8910W IP Control Protocol Module
#
# primary control script from Troy Will Copyright (C) 2012
# from the Zoneminder PanasonicIP.pm by Philip Coombes, Copyright (C) 2001-2008
#
# 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 an implementation of a Foscam IP FI8910W camera control
# protocol
#
package ZoneMinder::Control::FoscamFI8910W;

use 5.006;
use strict;
use warnings;

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

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

# ==========================================================================
#
# Foscam FI8910W IP Control Protocol
#
# ==========================================================================

use ZoneMinder::Logger qw(:all);
use ZoneMinder::Config qw(:all);

use Time::HiRes qw( usleep );

sub new {
my $class = shift;
my $id = shift;
my $self = ZoneMinder::Control->new($id);
bless( $self, $class );
srand( time() );
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();

use LWP::UserAgent;
$self->{ua} = LWP::UserAgent->new;
$self->{ua}->agent( "ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION );

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

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

sub printMsg {
my $self = shift;
my $msg = shift;
my $msg_len = length($msg);

Debug( $msg."[".$msg_len."]" );
}

sub sendCmd {
my $self = shift;
my $cmd = shift;
my $result = undef;

my ($user, $password) = split /:/, $self->{Monitor}->{ControlDevice};

if ( !defined $password ) {
# If value of "Control device" does not consist of two parts, then only password is given and we fallback to default user:
$password = $user;
$user = 'admin';
}

$cmd .= "user=$user&pwd=$password";

printMsg( $cmd, "Tx" );
### X This forum does not like h t t p here
my $req = HTTP::Request->new( GET=>"X://".$self->{Monitor}->{ControlAddress}."/$cmd" );
my $res = $self->{ua}->request($req);

if ( $res->is_success )
{
$result = !undef;
}
else
{
Error( "Error check failed: '".$res->status_line()."' for URL ".$req->uri() );
}

return( $result );
}

sub reset
{
my $self = shift;
Debug( "Camera Reset" );
$self->sendCmd( 'reboot.cgi?' );
}

sub moveConUp {
my $self = shift;
Debug("Move Up");
#my $cmd = "decoder_control.cgi?command=0"; # original up
my $cmd = "decoder_control.cgi?command=2"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveStop {
my $self = shift;
Debug("Move Stop");
my $cmd = "decoder_control.cgi?command=1";
$self->sendCmd($cmd);
}

sub moveConDown {
my $self = shift;
Debug("Move Down");
#my $cmd = "decoder_control.cgi?command=2"; # original down
my $cmd = "decoder_control.cgi?command=0"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConLeft {
my $self = shift;
Debug("Move Left");
#my $cmd = "decoder_control.cgi?command=6"; # original left
my $cmd = "decoder_control.cgi?command=4"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConRight {
my $self = shift;
Debug("Move Right");
#my $cmd = "decoder_control.cgi?command=4"; # original right
my $cmd = "decoder_control.cgi?command=6"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConUpRight {
my $self = shift;
Debug("Move Diagonally Up Right");
#my $cmd = "decoder_control.cgi?command=90"; # original diagonal up right
my $cmd = "decoder_control.cgi?command=93"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConDownRight {
my $self = shift;
Debug("Move Diagonally Down Right");
#my $cmd = "decoder_control.cgi?command=92"; # original diagonal down right
my $cmd = "decoder_control.cgi?command=91"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConUpLeft {
my $self = shift;
Debug("Move Diagonally Up Left");
#my $cmd = "decoder_control.cgi?command=91"; # original diagonal up left
my $cmd = "decoder_control.cgi?command=92"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConDownLeft {
my $self = shift;
Debug("Move Diagonally Down Left");
#my $cmd = "decoder_control.cgi?command=93"; # original diagonal down left
my $cmd = "decoder_control.cgi?command=90"; # for inverted camera operation

$self->sendCmd($cmd);
}

#Stop
sub moveStop
{
my $self = shift;
Debug( "Move Stop" );
$self->sendCmd( 'decoder_control.cgi?command=1&' );
}

#Move Camera to Home Position
sub presetHome
{
my $self = shift;
Debug( "Home Preset" );
$self->sendCmd( 'decoder_control.cgi?command=25&' );
}

#Turn IR on
sub wake {
my $self = shift;
Debug("Wake - IR on");
my $cmd = "decoder_control.cgi?command=95&";
$self->sendCmd($cmd);
}

#Turn IR off
sub sleep {
my $self = shift;
Debug("Sleep - IR off");
my $cmd = "decoder_control.cgi?command=94&";
$self->sendCmd($cmd);
}

1;

yawnorama
Posts: 1
Joined: Mon Apr 14, 2014 8:38 pm

Re: Foscam FI8910W control issue with 1.27

Post by yawnorama » Tue Apr 15, 2014 11:22 am

I had the same problem with my Foscam FI8910W after upgrading from 1.25

First off I moved the file FoscamFI8910W.pm file from /usr/share/perl5/ZoneMinder/Control to /usr/share/perl/5.14.2/ZoneMinder/Control

then edit the file as follows:

#$self->{ua}->agent( "ZoneMinder Control Agent/" . ZM_VERSION );

to


$self->{ua}->agent( "ZoneMinder Control Agent" );

Sorted my issue and I can now control my camera.

olsenh
Posts: 3
Joined: Sat Apr 12, 2014 2:11 pm

Re: Foscam FI8910W control issue with 1.27

Post by olsenh » Tue Apr 15, 2014 12:19 pm

Thanks yawnorama, that did the trick. :)

basketcase
Posts: 31
Joined: Thu Aug 22, 2013 10:04 pm

Re: Foscam FI8910W control issue with 1.27

Post by basketcase » Thu Apr 17, 2014 11:06 am

I noticed that didn't have the preset controls included in that control script... here's a bastardised version for anyone keen for the 8 preset controls.

Code: Select all

# ==========================================================================
#
# ZoneMinder Foscam FI8910W IP Control Protocol Module
# 
# primary control script from Troy Will Copyright (C) 2012
# from the Zoneminder PanasonicIP.pm by Philip Coombes, Copyright (C) 2001-2008
#
# 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 an implementation of a Foscam IP FI8910W camera control
# protocol
#
package ZoneMinder::Control::FoscamFI8910W;

use 5.006;
use strict;
use warnings;

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

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

# ==========================================================================
#
# Foscam FI8908W IP Control Protocol
#
# ==========================================================================

use ZoneMinder::Logger qw(:all);
use ZoneMinder::Config qw(:all);

use Time::HiRes qw( usleep );

sub new
{ 
	my $class = shift;
	my $id = shift;
	my $self = ZoneMinder::Control->new( $id );
	bless( $self, $class );
	srand( time() );
	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();

	use LWP::UserAgent;
	$self->{ua} = LWP::UserAgent->new;
	$self->{ua}->agent( "ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION );

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

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

sub printMsg
{
	my $self = shift;
	my $msg = shift;
	my $msg_len = length($msg);

	Debug( $msg."[".$msg_len."]" );
}

sub sendCmd
{
	my $self = shift;
	my $cmd = shift;
	my $result = undef;

	my ($user, $password) = split /:/, $self->{Monitor}->{ControlDevice};

	if ( !defined $password ) {
		# If value of "Control device" does not consist of two parts, then only password is given and we fallback to default user:
		$password = $user;
		$user = 'admin';
	}

	$cmd .= "user=$user&pwd=$password";

	printMsg( $cmd, "Tx" );

	my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd" );
	my $res = $self->{ua}->request($req);

	if ( $res->is_success )
	{
		$result = !undef;
	}
	else
	{
		Error( "Error check failed: '".$res->status_line()."' for URL ".$req->uri() );
	}

	return( $result );
}

sub reset
{
my $self = shift;
Debug( "Camera Reset" );
$self->sendCmd( 'reboot.cgi?' );
}

sub moveConUp {
my $self = shift;
Debug("Move Up");
#my $cmd = "decoder_control.cgi?command=0"; # original up
my $cmd = "decoder_control.cgi?command=2&"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveStop {
my $self = shift;
Debug("Move Stop");
my $cmd = "decoder_control.cgi?command=1&";
$self->sendCmd($cmd);
}

sub moveConDown {
my $self = shift;
Debug("Move Down");
#my $cmd = "decoder_control.cgi?command=2"; # original down
my $cmd = "decoder_control.cgi?command=0&"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConLeft {
my $self = shift;
Debug("Move Left");
#my $cmd = "decoder_control.cgi?command=6"; # original left
my $cmd = "decoder_control.cgi?command=4&"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConRight {
my $self = shift;
Debug("Move Right");
#my $cmd = "decoder_control.cgi?command=4"; # original right
my $cmd = "decoder_control.cgi?command=6&"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConUpRight {
my $self = shift;
Debug("Move Diagonally Up Right");
#my $cmd = "decoder_control.cgi?command=90"; # original diagonal up right
my $cmd = "decoder_control.cgi?command=93&"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConDownRight {
my $self = shift;
Debug("Move Diagonally Down Right");
#my $cmd = "decoder_control.cgi?command=92"; # original diagonal down right
my $cmd = "decoder_control.cgi?command=91&"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConUpLeft {
my $self = shift;
Debug("Move Diagonally Up Left");
#my $cmd = "decoder_control.cgi?command=91"; # original diagonal up left
my $cmd = "decoder_control.cgi?command=92&"; # for inverted camera operation

$self->sendCmd($cmd);
}

sub moveConDownLeft {
my $self = shift;
Debug("Move Diagonally Down Left");
#my $cmd = "decoder_control.cgi?command=93"; # original diagonal down left
my $cmd = "decoder_control.cgi?command=90&"; # for inverted camera operation

$self->sendCmd($cmd);
}

#Stop
sub moveStop
{
my $self = shift;
Debug( "Move Stop" );
$self->sendCmd( 'decoder_control.cgi?command=1&' );
}

sub presetClear {
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset' );
    Debug("Clear Preset $preset");
    my $cmd = "nphPresetNameCheck?Data=$preset&";
    $self->sendCmd($cmd);
}

sub presetSet {
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset' );
    my $presetCmd = 30 + ( $preset * 2 );
    Debug("Set Preset $preset: $presetCmd");
    my $cmd = "decoder_control.cgi?command=$presetCmd&";
    $self->sendCmd($cmd);
}

sub presetGoto {
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset' );
    my $presetCmd = 31 + ( $preset * 2 );
    Debug("Goto Preset $preset: $presetCmd");
    my $cmd = "decoder_control.cgi?command=$presetCmd&";
    $self->sendCmd($cmd);
}

sub presetHome {
    my $self = shift;
    Debug("Home Preset");
    my $cmd = "decoder_control.cgi?command=25&";
    $self->sendCmd($cmd);
}




#Turn IR on
sub wake {
my $self = shift;
Debug("Wake - IR on");
my $cmd = "decoder_control.cgi?command=95&";
$self->sendCmd($cmd);
}

#Turn IR off
sub sleep {
my $self = shift;
Debug("Sleep - IR off");
my $cmd = "decoder_control.cgi?command=94&";
$self->sendCmd($cmd);
}

1;




Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests