From d27535c208fb73017a6f945441c3df9e93441158 Mon Sep 17 00:00:00 2001 From: stan Date: Fri, 16 Dec 2005 12:20:36 +0000 Subject: [PATCH] Bug 233 - Updated debug format git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1685 e3e1d417-86f3-4887-817a-d78f3d33393f --- scripts/zmcontrol-pelco-p.pl | 82 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/scripts/zmcontrol-pelco-p.pl b/scripts/zmcontrol-pelco-p.pl index 4b221a626..23e37fc67 100644 --- a/scripts/zmcontrol-pelco-p.pl +++ b/scripts/zmcontrol-pelco-p.pl @@ -33,7 +33,7 @@ use strict; # # ========================================================================== -# None +use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== @@ -105,7 +105,7 @@ open( STDERR, ">&LOG" ) || die( "Can't dup stderr: $!" ); select( STDERR ); $| = 1; select( LOG ); $| = 1; -print( $arg_string."\n" ); +Info( $arg_string."\n" ); srand( time() ); @@ -128,16 +128,16 @@ sub printMsg my $line_length = 16; my $msg_len = int(@$msg); - print( $prefix ); + my $msg_str = $prefix; for ( my $i = 0; $i < $msg_len; $i++ ) { if ( ($i > 0) && ($i%$line_length == 0) && ($i != ($msg_len-1)) ) { - printf( "\n%*s", length($prefix), "" ); + $msg_str .= printf( "\n%*s", length($prefix), "" ); } - printf( "%02x ", $msg->[$i] ); + $msg_str .= printf( "%02x ", $msg->[$i] ); } - print( "[".$msg_len."]\n" ); + $msg_str .= "[".$msg_len."]\n"; } sub sendCmd @@ -166,16 +166,16 @@ sub sendCmd my $n_bytes = $serial_port->write( $tx_msg ); if ( !$n_bytes ) { - print( "Error, write failed: $!" ); + Error( "Write failed: $!" ); } if ( $n_bytes != length($tx_msg) ) { - print( "Error, incomplete write, only ".$n_bytes." of ".length($tx_msg)." written: $!" ); + Error( "Incomplete write, only ".$n_bytes." of ".length($tx_msg)." written: $!" ); } if ( $ack ) { - print( "Waiting for ack\n" ); + Info( "Waiting for ack\n" ); my $max_wait = 3; my $now = time(); while( 1 ) @@ -193,23 +193,23 @@ sub sendCmd if ( ($resp[1] & 0xf0) == 0x40 ) { my $socket = $resp[1] & 0x0f; - print( "Got ack for socket $socket\n" ); + Info( "Got ack for socket $socket\n" ); $result = !undef; } else { - print( "Error, got bogus response\n" ); + Error( "Got bogus response\n" ); } last; } else { - print( "Error, got message for camera ".(($resp[0]-0x80)>>4)."\n" ); + Error( "Got message for camera ".(($resp[0]-0x80)>>4)."\n" ); } } if ( (time() - $now) > $max_wait ) { - print( "Warning, response timeout\n" ); + Warning( "Response timeout\n" ); last; } } @@ -221,42 +221,42 @@ my $etx = 0xaf; sub cameraOff { - print( "Camera Off\n" ); + Info( "Camera Off\n" ); my @msg = ( $stx, $address, 0x10, 0x00, 0x00, 0x00, $etx ); sendCmd( \@msg ); } sub cameraOn { - print( "Camera On\n" ); + Info( "Camera On\n" ); my @msg = ( $stx, $address, 0x40, 0x00, 0x00, 0x00, $etx ); sendCmd( \@msg ); } sub autoScan { - print( "Auto Scan\n" ); + Info( "Auto Scan\n" ); my @msg = ( $stx, $address, 0x90, 0x00, 0x00, 0x00, $etx ); sendCmd( \@msg ); } sub manScan { - print( "Manual Scan\n" ); + Info( "Manual Scan\n" ); my @msg = ( $stx, $address, 0x10, 0x00, 0x00, 0x00, $etx ); sendCmd( \@msg ); } sub stop { - print( "Stop\n" ); + Info( "Stop\n" ); my @msg = ( $stx, $address, 0x00, 0x00, 0x00, 0x00, $etx ); sendCmd( \@msg ); } sub moveUp { - print( "Move Up\n" ); + Info( "Move Up\n" ); my $speed = shift || 0x3f; my @msg = ( $stx, $address, 0x00, 0x08, 0x00, $speed, $etx ); sendCmd( \@msg ); @@ -269,7 +269,7 @@ sub moveUp sub moveDown { - print( "Move Down\n" ); + Info( "Move Down\n" ); my $speed = shift || 0x3f; my @msg = ( $stx, $address, 0x00, 0x10, 0x00, $speed, $etx ); sendCmd( \@msg ); @@ -282,7 +282,7 @@ sub moveDown sub moveLeft { - print( "Move Left\n" ); + Info( "Move Left\n" ); my $speed = shift || 0x3f; my @msg = ( $stx, $address, 0x00, 0x04, $speed, 0x00, $etx ); sendCmd( \@msg ); @@ -295,7 +295,7 @@ sub moveLeft sub moveRight { - print( "Move Right\n" ); + Info( "Move Right\n" ); my $speed = shift || 0x3f; my @msg = ( $stx, $address, 0x00, 0x02, $speed, 0x00 , $etx); sendCmd( \@msg ); @@ -308,7 +308,7 @@ sub moveRight sub moveUpLeft { - print( "Move Up/Left\n" ); + Info( "Move Up/Left\n" ); my $panspeed = shift || 0x3f; my $tiltspeed = shift || 0x3f; my @msg = ( $stx, $address, 0x00, 0x0c, $panspeed, $tiltspeed, $etx ); @@ -322,7 +322,7 @@ sub moveUpLeft sub moveUpRight { - print( "Move Up/Right\n" ); + Info( "Move Up/Right\n" ); my $panspeed = shift || 0x3f; my $tiltspeed = shift || 0x3f; my @msg = ( $stx, $address, 0x00, 0x0a, $panspeed, $tiltspeed, $etx ); @@ -336,7 +336,7 @@ sub moveUpRight sub moveDownLeft { - print( "Move Down/Left\n" ); + Info( "Move Down/Left\n" ); my $panspeed = shift || 0x3f; my $tiltspeed = shift || 0x3f; my @msg = ( $stx, $address, 0x00, 0x14, $panspeed, $tiltspeed, $etx ); @@ -350,7 +350,7 @@ sub moveDownLeft sub moveDownRight { - print( "Move Down/Right\n" ); + Info( "Move Down/Right\n" ); my $panspeed = shift || 0x3f; my $tiltspeed = shift || 0x3f; my @msg = ( $stx, $address, 0x00, 0x12, $panspeed, $tiltspeed, $etx ); @@ -364,14 +364,14 @@ sub moveDownRight sub flip180 { - print( "Flip 180\n" ); + Info( "Flip 180\n" ); my @msg = ( $stx, $address, 0x00, 0x07, 0x00, 0x21, $etx ); sendCmd( \@msg ); } sub zeroPan { - print( "Zero Pan\n" ); + Info( "Zero Pan\n" ); my @msg = ( $stx, $address, 0x00, 0x07, 0x00, 0x22, $etx ); sendCmd( \@msg ); } @@ -385,7 +385,7 @@ sub setZoomSpeed sub zoomTele { - print( "Zoom Tele\n" ); + Info( "Zoom Tele\n" ); my $speed = shift || 0x01; setZoomSpeed( $speed ); my @msg = ( $stx, $address, 0x00, 0x20, 0x00, 0x00, $etx ); @@ -399,7 +399,7 @@ sub zoomTele sub zoomWide { - print( "Zoom Wide\n" ); + Info( "Zoom Wide\n" ); my $speed = shift || 0x01; setZoomSpeed( $speed ); my @msg = ( $stx, $address, 0x00, 0x40, 0x00, 0x00, $etx ); @@ -420,7 +420,7 @@ sub setFocusSpeed sub focusNear { - print( "Focus Near\n" ); + Info( "Focus Near\n" ); my $speed = shift || 0x03; setFocusSpeed( $speed ); my @msg = ( $stx, $address, 0x02, 0x00, 0x00, 0x00, $etx ); @@ -434,7 +434,7 @@ sub focusNear sub focusFar { - print( "Focus Far\n" ); + Info( "Focus Far\n" ); my $speed = shift || 0x03; setFocusSpeed( $speed ); my @msg = ( $stx, $address, 0x01, 0x80, 0x00, 0x00, $etx ); @@ -448,14 +448,14 @@ sub focusFar sub focusAuto { - print( "Focus Auto\n" ); + Info( "Focus Auto\n" ); my @msg = ( $stx, $address, 0x00, 0x2b, 0x00, 0x01, $etx ); sendCmd( \@msg ); } sub focusMan { - print( "Focus Man\n" ); + Info( "Focus Man\n" ); my @msg = ( $stx, $address, 0x00, 0x2b, 0x00, 0x02, $etx ); sendCmd( \@msg ); } @@ -463,7 +463,7 @@ sub focusMan sub writeScreen { my $string = shift; - print( "Writing '$string' to screen\n" ); + Info( "Writing '$string' to screen\n" ); my @chars = unpack( "C*", $string ); for ( my $i = 0; $i < length($string); $i++ ) @@ -476,7 +476,7 @@ sub writeScreen sub clearScreen { - print( "Clear Screen\n" ); + Info( "Clear Screen\n" ); my @msg = ( $stx, $address, 0x00, 0x17, 0x00, 0x00, $etx ); sendCmd( \@msg ); } @@ -484,7 +484,7 @@ sub clearScreen sub clearPreset { my $preset = shift || 1; - print( "Clear Preset $preset\n" ); + Info( "Clear Preset $preset\n" ); my @msg = ( $stx, $address, 0x00, 0x05, 0x00, $preset, $etx ); sendCmd( \@msg ); } @@ -492,7 +492,7 @@ sub clearPreset sub presetSet { my $preset = shift || 1; - print( "Set Preset $preset\n" ); + Info( "Set Preset $preset\n" ); my @msg = ( $stx, $address, 0x00, 0x03, 0x00, $preset, $etx ); sendCmd( \@msg ); } @@ -500,14 +500,14 @@ sub presetSet sub presetGoto { my $preset = shift || 1; - print( "Goto Preset $preset\n" ); + Info( "Goto Preset $preset\n" ); my @msg = ( $stx, $address, 0x00, 0x07, 0x00, $preset, $etx ); sendCmd( \@msg ); } sub presetHome { - print( "Home Preset\n" ); + Info( "Home Preset\n" ); my @msg = ( $stx, $address, 0x00, 0x07, 0x00, 0x22, $etx ); sendCmd( \@msg ); } @@ -602,7 +602,7 @@ elsif ( $command eq "preset_goto" ) } else { - print( "Error, can't handle command $command\n" ); + Error( "Can't handle command $command\n" ); } $serial_port->close();