How can I setup serial RS 422 PTZ in ZM

Forum for questions and support relating to the 1.28.x releases only.
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

Hello Guys,
I been searching for how you can setup a local PTZ camera using serial RS422. I've seen documentation for network Ptz but not local serial. Can any one guide through this setup?
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: How can I setup serial RS 422 PTZ in ZM

Post by knight-of-ni »

We can't give you a precise answer because you've neglected to tell us what hardware you have and how you have the rs422 wired to your machine.
Looks like we also need to know the baud rate of your equipment. It should be either 2400 or 4800.

Generally, you need to select either the PelcoP of PelcoD control script for the camera in question and enter the serial device into the Control Device field.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

Hi sorry for the less info.

Hardware is
American Dynamics Ultra 8 dome camera
Set to Pelco P 9600 RS 422
Connected to
RS232 to Rs422 4 wire configuration
PC is levnovo running Ubuntu

The equipment have been tested on Windows PCs with a Ptz test software.

I have entered the Pelco P, and serial /dev/ttyS0 for serial 1.
Is there any other configuration?
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

So in config I entered these values
'PELCO-D'
'Control Device' /dev/ttyS0 or /dev/ttyS1 (serial 0 or 1 I tried both)

'Control Address' 2
'Auto Stop' to 1.00

No Track Motion
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

Also to mention on my RS 232 to RS 422 I have transmit and receive l.e.d's which are inactive when trying to send commands to the camera.
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

Hi just an update
I have transmit light working.
before i check to see if the com port was working so i send a command echo -ne '\033[2J' > /dev/ttyS0
the transmit functioned.
i tried in ZM I got no response.
I found out i had to adduser www-data dialout
Now I tried again in ZM this time I got some activity.
now with the camera attached and set too 4800 Pelco P with address 2 I cannot get the camera to turn
my ZM settings are:
Control tab
controllable checked
control type Pelco P
control device /dev/ttyS0
Control address 0
Auto Stop Timeout 1.00
track motion off
track delay 0
return location none
return delay 0

Source tab
device channel 2
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

My logs are showing this:
2015-12-13 00:05:39.327386 web_php 2974 ERR /usr/bin/zmcontrol.pl --panspeed=46 --autostop --command=moveConRight --id=6=> /usr/share/zoneminder/includes/functions.php 2330
2015-12-13 00:05:39.233640 zmcontrol 3600 FAT Can't connect: No such file or directory zmcontrol.pl
2015-12-13 00:05:31.188377 zmc_m2 3382 INF Back-graden: 23000 - Capturing at 13.16 fps zm_monitor.cpp 2907
2015-12-13 00:05:29.232500 zmcontrol 3602 INF Control server 6/PelcoP starting at 15/12/13 00:05:29 zmcontrol.pl
2015-12-13 00:05:29.104280 zmcontrol 3600 INF Starting control server 6/PelcoP zmcontrol.pl
2015-12-13 00:05:28.923391 web_php 2526 ERR /usr/bin/zmcontrol.pl --panspeed=35 --autostop --command=moveConRight --id=6=> /usr/share/zoneminder/includes/functions.php 2330
2015-12-13 00:05:28.856870 zmcontrol 3596 FAT Can't connect: No such file or directory zmcontrol.pl
2015-12-13 00:05:18.855740 zmcontrol 3598 INF Control server 6/PelcoP starting at 15/12/13 00:05:18 zmcontrol.pl
2015-12-13 00:05:18.779080 zmcontrol 3596 INF Starting control server 6/PelcoP zmcontrol.pl
2015-12-13 00:05:18.599299 web_php 2546 ERR /usr/bin/zmcontrol.pl --panspeed=32 --autostop --command=moveConRight --id=6=> /usr/share/zoneminder/includes/functions.php 2330
2015-12-13 00:05:18.539090 zmcontrol 3589 FAT Can't connect: No such file or directory zmcontrol.pl
2015-12-13 00:05:08.537950 zmcontrol 3592 INF Control server 6/PelcoP starting at 15/12/13 00:05:08 zmcontrol.pl
2015-12-13 00:05:08.467120 zmcontrol 3589 INF Starting control server 6/PelcoP zmcontrol.pl
2015-12-13 00:05:08.272799 web_php 3113 ERR socket_sendto( /var/run/zm/zms-630592s.sock ) failed: No such file or directory
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

Any ideas guys,
I was also think do I need to change the serial port 1 to 4800 or leave it at default 115200. As ZM Pelco P is at 4800. I notice on the my Windows machine I didn't have to do this just had to select 9600 (at the time) in the software.
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: How can I setup serial RS 422 PTZ in ZM

Post by knight-of-ni »

It looks like you are doing it correctly. The ZoneMinder Pelco P control script expects the receiving device to be at 4800 baud, which it looks like you've set. You've also verified the LED's on the 232/422 are indicating activity. I would not expect a need to mess with the port settings of the serial port.

What I would do next is get a laptop. Tie the serial port of the laptop to the serial port of the zoneminder machine with a null modem cable.
Using your favorite terminal program on the laptop, record the ascii ptz commands being sent out of the port from the zoneminder server.

Now repeat this test using the (Windows) machine that works correctly.

Now compare the two outputs. Is there a difference?
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

Hi thanks for the reply.
I will try what you said with the laptop.
However if i send a pan up command through Zoneminder i get this error:
  • Control response was status = undefined
    message = /usr/bin/zmcontrol.pl --tiltspeed=27 --autostop --command=moveConUp --id=6=>
Also the Tx light have stopped so its indicating it's not transmitting.
I've i changed the Control.pm script to this:

Code: Select all

# ==========================================================================
#
# ZoneMinder Pelco-P Control Protocol Module, $Date$, $Revision$
# Copyright (C) 2001-2008  Philip Coombes
#
# 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 Pelco-P camera control
# protocol
#
package ZoneMinder::Control::PelcoP;

use 5.006;
use strict;
use warnings;

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

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

# ==========================================================================
#
# Pelco-P Control Protocol
#
# ==========================================================================

use ZoneMinder::Logger qw(:all);

use Time::HiRes qw( usleep );

use constant STX => 0xa0;
use constant ETX => 0xaf;
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() );
    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 Device::SerialPort;
    $self->{port} = new Device::SerialPort( $self->{Monitor}->{ControlDevice} );
    $self->{port}->baudrate(4800);
    $self->{port}->databits(8);
    $self->{port}->parity('none');
    $self->{port}->stopbits(1);
    $self->{port}->handshake('none');

    $self->{port}->read_const_time(50);
    $self->{port}->read_char_time(10);

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

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

sub printMsg
{
    if ( logDebugging() )
    {
        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; $i++ )
        {
            if ( ($i > 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 sendCmd
{
    my $self = shift;
    my $cmd = shift;
    my $ack = shift || 0;

    my $result = undef;

    my $checksum = 0x00;
    for ( my $i = 1; $i < int(@$cmd); $i++ )
    {
        $checksum ^= $cmd->[$i];
    }
    $checksum &= 0xff;
    push( @$cmd, $checksum );

    $self->printMsg( $cmd, "Tx" );
    my $id = $cmd->[0] & 0xf;

    my $tx_msg = pack( "C*", @$cmd );

    #print( "Tx: ".length( $tx_msg )." bytes\n" );
    my $n_bytes = $self->{port}->write( $tx_msg );
    if ( !$n_bytes )
    {
        Error( "Write failed: $!" );
    }
    if ( $n_bytes != length($tx_msg) )
    {
        Error( "Incomplete write, only ".$n_bytes." of ".length($tx_msg)." written: $!" );
    }

    if ( $ack )
    {
        Debug( "Waiting for ack" );
        my $max_wait = 3;
        my $now = time();
        while( 1 )
        {
            my ( $count, $rx_msg ) = $self->{port}->read(4);

            if ( $count )
            {
                #print( "Rx1: ".$count." bytes\n" );
                my @resp = unpack( "C*", $rx_msg );
                printMsg( \@resp, "Rx" );

                if ( $resp[0] = 0x80 + ($id<<4) )
                {
                    if ( ($resp[1] & 0xf0) == 0x40 )
                    {
                        my $socket = $resp[1] & 0x0f;
                        Debug( "Got ack for socket $socket" );
                        $result = !undef;
                    }
                    else
                    {
                        Error( "Got bogus response" );
                    }
                    last;
                }
                else
                {
                    Error( "Got message for camera ".(($resp[0]-0x80)>>4) );
                }
            }
            if ( (time() - $now) > $max_wait )
            {
                Warning( "Response timeout" );
                last;
            }
        }
    }
}

sub remoteReset
{
    my $self = shift;
    Debug( "Remote Reset" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x0f, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
}

sub resetDefaults
{
    my $self = shift;
    Debug( "Reset Defaults" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x29, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
}

sub cameraOff
{
    my $self = shift;
    Debug( "Camera Off" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x08, 0x00, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
}

sub cameraOn
{
    my $self = shift;
    Debug( "Camera On" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x88, 0x00, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
}

sub autoScan
{
    my $self = shift;
    Debug( "Auto Scan" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x90, 0x00, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
}

sub manScan
{
    my $self = shift;
    Debug( "Manual Scan" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x10, 0x00, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
}

sub stop
{
    my $self = shift;
    Debug( "Stop" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x00, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
}

sub moveConUp
{
    my $self = shift;
    my $params = shift;
    my $speed = $self->getParam( $params, 'tiltspeed' );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Move Up" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x08, 0x00, $speed, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->stop( $params );
    }
}

sub moveConDown
{
    my $self = shift;
    my $params = shift;
    my $speed = $self->getParam( $params, 'tiltspeed' );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Move Down" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x10, 0x00, $speed, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->stop();
    }
}

sub moveConLeft
{
    my $self = shift;
    my $params = shift;
    my $speed = $self->getParam( $params, 'panspeed' );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Move Left" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x04, $speed, 0x00, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->stop();
    }
}

sub moveConRight
{
    my $self = shift;
    my $params = shift;
    my $speed = $self->getParam( $params, 'panspeed' );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Move Right" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x02, $speed, 0x00, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->stop();
    }
}

sub moveConUpLeft
{
    my $self = shift;
    my $params = shift;
    my $panspeed = $self->getParam( $params, 'panspeed', 0x3f );
    my $tiltspeed = $self->getParam( $params, 'tiltspeed', 0x3f );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Move Up/Left" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x0c, $panspeed, $tiltspeed, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->stop();
    }
}

sub moveConUpRight
{
    my $self = shift;
    my $params = shift;
    my $panspeed = $self->getParam( $params, 'panspeed', 0x3f );
    my $tiltspeed = $self->getParam( $params, 'tiltspeed', 0x3f );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Move Up/Right" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x0a, $panspeed, $tiltspeed, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->stop();
    }
}

sub moveConDownLeft
{
    my $self = shift;
    my $params = shift;
    my $panspeed = $self->getParam( $params, 'panspeed', 0x3f );
    my $tiltspeed = $self->getParam( $params, 'tiltspeed', 0x3f );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Move Down/Left" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x14, $panspeed, $tiltspeed, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->stop();
    }
}

sub moveConDownRight
{
    my $self = shift;
    my $params = shift;
    my $panspeed = $self->getParam( $params, 'panspeed', 0x3f );
    my $tiltspeed = $self->getParam( $params, 'tiltspeed', 0x3f );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Move Down/Right" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x12, $panspeed, $tiltspeed, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->stop();
    }
}

sub moveStop
{
    my $self = shift;
    Debug( "Move Stop" );
    $self->stop();
}

sub flip180
{
    my $self = shift;
    Debug( "Flip 180" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x07, 0x00, 0x21, ETX );
    $self->sendCmd( \@msg );
}

sub zeroPan
{
    my $self = shift;
    Debug( "Zero Pan" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x07, 0x00, 0x22, ETX );
    $self->sendCmd( \@msg );
}

sub _setZoomSpeed
{
    my $self = shift;
    my $speed = shift;
    Debug( "Set Zoom Speed $speed" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x25, 0x00, $speed, ETX );
    $self->sendCmd( \@msg );
}

sub zoomStop
{
    my $self = shift;
    Debug( "Zoom Stop" );
    $self->stop();
    $self->_setZoomSpeed( 0 );
}

sub zoomConTele
{
    my $self = shift;
    my $params = shift;
    my $speed = $self->getParam( $params, 'speed', 0x01 );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Zoom Tele" );
    $self->_setZoomSpeed( $speed );
    usleep( COMMAND_GAP );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x20, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->zoomStop();
    }
}

sub zoomConWide
{
    my $self = shift;
    my $params = shift;
    my $speed = $self->getParam( $params, 'speed', 0x01 );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Zoom Wide" );
    $self->_setZoomSpeed( $speed );
    usleep( COMMAND_GAP );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x40, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->zoomStop();
    }
}

sub _setFocusSpeed
{
    my $self = shift;
    my $speed = shift;
    Debug( "Set Focus Speed $speed" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x27, 0x00, $speed, ETX );
    $self->sendCmd( \@msg );
}

sub focusConNear
{
    my $self = shift;
    my $params = shift;
    my $speed = $self->getParam( $params, 'speed', 0x03 );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Focus Near" );
    $self->_setFocusSpeed( $speed );
    usleep( COMMAND_GAP );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x01, 0x00, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->_setFocusSpeed( 0 );
    }
}

sub focusConFar
{
    my $self = shift;
    my $params = shift;
    my $speed = $self->getParam( $params, 'speed', 0x03 );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Focus Far" );
    $self->_setFocusSpeed( $speed );
    usleep( COMMAND_GAP );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x80, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->_setFocusSpeed( 0 );
    }
}

sub focusStop
{
    my $self = shift;
    Debug( "Focus Stop" );
    $self->stop();
    $self->_setFocusSpeed( 0 );
}

sub focusAuto
{
    my $self = shift;
    Debug( "Focus Auto" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x2b, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
}

sub focusMan
{
    my $self = shift;
    Debug( "Focus Man" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x2b, 0x00, 0x02, ETX );
    $self->sendCmd( \@msg );
}

sub _setIrisSpeed
{
    my $self = shift;
    my $speed = shift;
    Debug( "Set Iris Speed $speed" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x27, 0x00, $speed, ETX );
    $self->sendCmd( \@msg );
}

sub irisConClose
{
    my $self = shift;
    my $params = shift;
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Iris Close" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x04, 0x00, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->_setIrisSpeed( 0 );
    }
}

sub irisConOpen
{
    my $self = shift;
    my $params = shift;
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    Debug( "Iris Open" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x02, 0x80, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
    if( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->_setIrisSpeed( 0 );
    }
}

sub irisStop
{
    my $self = shift;
    Debug( "Iris Stop" );
    $self->stop();
    $self->_setIrisSpeed( 0 );
}

sub irisAuto
{
    my $self = shift;
    Debug( "Iris Auto" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x2d, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
}

sub irisMan
{
    my $self = shift;
    Debug( "Iris Man" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x2d, 0x00, 0x02, ETX );
    $self->sendCmd( \@msg );
}

sub writeScreen
{
    my $self = shift;
    my $params = shift;
    my $string = $self->getParam( $params, 'string' );
    Debug( "Writing '$string' to screen" );
    
    my @chars = unpack( "C*", $string );
    for ( my $i = 0; $i < length($string); $i++ )
    {
        my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x15, $i, $chars[$i], ETX );
        $self->sendCmd( \@msg );
        usleep( COMMAND_GAP );
    }
}

sub clearScreen
{
    my $self = shift;
    Debug( "Clear Screen" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x17, 0x00, 0x00, ETX );
    $self->sendCmd( \@msg );
}

sub clearPreset
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset', 1 );
    Debug( "Clear Preset $preset" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x05, 0x00, $preset, ETX );
    $self->sendCmd( \@msg );
}

sub presetSet
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset', 1 );
    Debug( "Set Preset $preset" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x03, 0x00, $preset, ETX );
    $self->sendCmd( \@msg );
}

sub presetGoto
{
    my $self = shift;
    my $params = shift;
    my $preset = $self->getParam( $params, 'preset', 1 );
    Debug( "Goto Preset $preset" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x07, 0x00, $preset, ETX );
    $self->sendCmd( \@msg );
}

sub presetHome
{
    my $self = shift;
    Debug( "Home Preset" );
    my @msg = ( STX, $self->{Monitor}->{ControlAddress}, 0x00, 0x07, 0x00, 0x22, ETX );
    $self->sendCmd( \@msg );
}

sub reset
{
    my $self = shift;
    Debug( "Reset" );
    $self->remoteReset();
    $self->resetDefaults();
}

sub wake
{
    my $self = shift;
    Debug( "Wake" );
    $self->cameraOn();
}

sub sleep
{
    my $self = shift;
    Debug( "Sleep" );
    $self->cameraOff();
}

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

Philip Coombes, E<lt>philip.coombes@zoneminder.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2001-2008  Philip Coombes

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
To me it's like Zoneminders not talking to /dev/ttyS0
I removed /dev/ttyS0 from the X10 option in case there was conflict.
Besides the option Control Device is there any place i need it point to com 1?
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

Zmptz wrote:Hi just an update
I have transmit light working.
before i check to see if the com port was working so i send a command echo -ne '\033[2J' > /dev/ttyS0
the transmit functioned.
i tried in ZM I got no response.
I found out i had to adduser www-data dialout
Now I tried again in ZM this time I got some activity.
just to make clear where i said its working in zoneminder its stopped working with no changes just reboot. but if send the command manually it still sends in terminal.
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

has anyone got good instruction on how to setup Pelco P PTZ on zoneminder?
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

Update: strange thing happened, I left the zoneminder PCs on for three day without touching it and now if I send a move command the Tx lights start flashing. However if I do too many commands then it stops flashing.
Not sure this might be indicator the com port buffer getting full because it can't transmit and receive to clear message.
Any ideas will be appreciated
Zmptz
Posts: 38
Joined: Thu Dec 10, 2015 9:08 am

Re: How can I setup serial RS 422 PTZ in ZM

Post by Zmptz »

with this being the ERROR im getting does it mean i need to configure the Pelco P script? Also How?

Code: Select all

2015-12-23 22:11:28.637419	web_php	17672	ERR	/usr/bin/zmcontrol.pl --panspeed=35 --autostop --command=moveConRight --id=4=>	/usr/share/zoneminder/includes/functions.php	2330
2015-12-23 22:11:28.576290	zmcontrol	18229	FAT	Can't connect: No such file or directory	zmcontrol.pl	
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: How can I setup serial RS 422 PTZ in ZM

Post by knight-of-ni »

Run the zmcontrol.pl command, with all the parameters shown in the error message you posted, directly on the command line, and see if it produces a more helpful output.
You'll need to be root to do this.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
Locked