Help with PTZ on Vstarcam_C24S.pm needs updating for 1.34.23

A place for discussion of topics that are not specific to ZoneMinder. This could include Linux, Video4Linux, CCTV cameras or any other topic.
Post Reply
orionstoy
Posts: 17
Joined: Wed Jun 22, 2011 8:26 pm

Help with PTZ on Vstarcam_C24S.pm needs updating for 1.34.23

Post by orionstoy »

I used to use the PTZ on my ip cameras when I was using zoneminder 1.30.4 with the file I included (with a txt extension instead if the .pm so it would allow me to attach it here). I had issues with a bunch of things I wont go into but I am using Xubuntu 18.04 and Zoneminder 1.34.23 and Vstarcam_C24S.pm doesn't seem to function anymore. I think the onvif.pm made "some sort of contact" I got an error in a log somewhere and it showed the address it tried and failed on so I saw what it had "called". It was not the proper format for my cameras but I don't remember what it actually "called".

I do use a webpage that redirects to this address which can only be accessed through the local network of course:

Code: Select all

http://192.168.0.xxx:port/decoder_control.cgi?loginuse=loginName&loginpas=loginPassword&command=33&onestep=0
and

Code: Select all

http://192.168.0.xxx:port/decoder_control.cgi?loginuse=loginName&loginpas=loginPassword&command=31&onestep=0
These also launch a page that I have to physically close that is a blank white page that says "var result="ok"; "
I use these to set the cam position to preset 1 and 2 but I would like to use Zoneminder and be able to have full control again

I also can tell you when I was using 1.30.4 I modified the webpage in zoneminder and added two shortcuts to control that camera with this:

Code: Select all

#!/usr/bin/perl
#my @command1 = ("/usr/bin/zmcontrol.pl", "--preset=2", "--command=presetGoto", "--id=3");
#print "Content-type: text/html\n\n";
#system(@command1);
#print qq!<script>
#window.close()
#</script>!;
of course since the Vstarcam_C24S.pm "talking" properly to version 1.34.23, zmcontrol.pl isn't going to understand or be able to execute the command.

I just don't understand scripting very much. I muddle through ... I find code and modify it to meet my needs but .. I just cant grasp this enough to figure it out. I need the Vstarcam_C24S.pm to give the right information to zmcontrol in the proper format for my camera so that the zmcontrol commands work Vstarcam_C24S.pm needs to supply zmcontrol with the format ...

Code: Select all

http://IP:PORT/decoder_control.cgi?loginuse=xx&loginpas=xx&command=xx&onestep=x

I hope this is understandable to those looking here lol ... Not sure if I explained it well enough. I tried to give all the info that I have and that may be needed or helpful :) Everything in the C24S.pm for the commands seem to be accurate but I think it doesn't log in properly. I notice that the commands show

Code: Select all

my $cmd = "decoder_control.cgi?command=18&";
but it seems to need

Code: Select all

loginuse=xx&loginpas=xx&
before

Code: Select all

command=18&
I just don't know where to insert it in and where it gets the information from. I may be wrong but if I remember correctly, the onvif.pm I think made a call to

Code: Select all

http://loginName:loginPassword@IP:PORT/decoder_control.cgi?command=xx
. That fails .. it has to be the format I first listed

Any help would be greatly appreciated
Attachments
Vstarcam_C24S (copy).txt
(14.18 KiB) Downloaded 283 times
alabamatoy
Posts: 360
Joined: Sun Jun 05, 2016 2:53 pm

Re: Help with PTZ on Vstarcam_C24S.pm needs updating for 1.34.23

Post by alabamatoy »

You didnt post any logs, usually the logs will assist in this kind of troubleshooting.

The PTZ scripts are fiddley - I have spent a LOT of time working on the Amcrest scripts. I had coded them so they worked push-to-pan/zoom and then they released a new version of ZM that broke that functionality. Oh well. And during this time Amcrest changed from basic authentication to digest authentication and it all broke again. That required some serious intervention from iconnor to get it going again.

I do not have the camera you are wanting to work with, so TS is difficult, but know that you can go into the script and add error or debug calls to write out anything you need to during TS, then go back and remove them (there's probably a better way to do that, but I havent found it).
I need the Vstarcam_C24S.pm to give the right information to zmcontrol in the proper format for my camera so that the zmcontrol commands work Vstarcam_C24S.pm needs to supply zmcontrol with the format
In my experience, the PTZ scripts dont give much of anything back to zmcontrol except error messages. The result is evident in the movement of the camera. zmcontrol sends control signals to the PTZ script (move up, move left, zoom out) which are interpreted by the script and sent to the camera. If they work, they work, and if they dont work, then its up to the script to capture the error message and do something with it.

The script also depends on the config info for the correct "control address" in the monitor config control tab. I saw no digest auth setup in the script you provided, so I must assume its using basic auth as you describe "http://IP:PORT/decoder_control.cgi?loginuse=xx&loginpas=xx&command=xx&onestep=x" So you setup the commands for moveconupleft:

Code: Select all

sub moveConUpLeft
{
    my $self = shift;
    my $params = shift;
    Debug( "Move Diagonally Up Left" );
    my $cmd = "decoder_control.cgi?command=90&" . "${cmdext}";
    $self->sendCmd( $cmd );
    my $autostop = $self->getParam( $params, 'autostop', 0 );
    if ( $autostop && $self->{Monitor}->{AutoStopTimeout} )
    {
        usleep( $self->{Monitor}->{AutoStopTimeout} );
        $self->moveStop( $params );
    }
}
The debug statement under sub sendcmd should show you exactly what is being sent to the camera, and you could also add a debug statement (change the error to a debug so you get it even if its not an error) for the result, so you can see the camera responding "huh? Say what??".

You should be able to craft a https call to the camera from a regular browser app (FF or Chrome etc) to get it to pan, and see the resulting movement in a monitor window. Once you have that working, you have to change the script to send the move command in the same format.

HTH....
alabamatoy
Posts: 360
Joined: Sun Jun 05, 2016 2:53 pm

Re: Help with PTZ on Vstarcam_C24S.pm needs updating for 1.34.23

Post by alabamatoy »

http://loginName:loginPassword@IP:PORT/decoder_control.cgi?command=xx
This probably should be something like

http://ipaddress:port/decoder_control.cgi?loginuse=xx&loginpas=xx&command=xx&onestep=x

You should be able to fabricate that string, paste it into a browser URL bar, hit enter and see the camera move in the ZM monitor window. Obviously, the browser will have to be able to reach the camera IP, and the other browser window has to be able view the monitor. With basic auth, you have to send the loginuse and loginpas with every command.
orionstoy
Posts: 17
Joined: Wed Jun 22, 2011 8:26 pm

Re: Help with PTZ on Vstarcam_C24S.pm needs updating for 1.34.23

Post by orionstoy »

Sorry to say ... I guess I'm confused since you haven't really said anything that I didn't already say. The code you posted is the exact code in the pm file and it doesn't show any errors or anything at all, so I don't know what the debug statements mean or do.

You said to change the error to a debug so you get it even if its not an error but you are talking a foreign language to me. I don't see anything having to do with error to be able to change it to debug.

Thank you for taking the time but .... either I missed something in the reply .. or you basically said exactly what I already said .. You did mention something about debug but what you said is already in the script and you talked about changing something but didn't really show me what the heck you meant by the statement. Not easy for someone to change the error to a debug when there is no "error statement" to change. All there is is one debug line in the script and it doesn't really make sense to me ... as I said .. I don't really know this code. The statements make no sense to me... commands like my $self = shift means absolutely nothing to me. I am assuming that $self is a variable and it equals "shift" but I have no idea what shift means and it seems to be used a lot. Since they make no sense I cant "follow" it through the code. LoL I got excited when you talked about the debug code and I thought yeah that might help .. then I looked at your code and launched the pm file and was like ... wait ... that's already how its written and it doesn't do crap for giving me errors or any logging at all.

Can you give me some instruction as to what you mean and how I can change the code or add the code to
he debug statement under sub sendcmd should show you exactly what is being sent to the camera, and you could also add a debug statement (change the error to a debug so you get it even if its not an error) for the result, so you can see the camera responding "huh? Say what??".
Thanks again for the time, sorry you are dealing with a novice, I may have missed something

ok I looked a bit further in the pm file and did see the sub sendcmd section ... I still don't really understand it since as I say .. it gives me no output at all of what it is doing in any file that i can find. and the only error isn't something that can be changed .. its an 'else' statement if the debug fails? I would still need some details as to what you meant and where I needed to change and what I need to change it too

Oh and thanks .. now I realize that ... you communicate with zoneminder "control" and that accesses the pm script and the pm script then communicates with the camera. I guess I had it backwards thinking the zoneminder was sending the information to the camera and the pm file was telling zoneminder the format.
alabamatoy
Posts: 360
Joined: Sun Jun 05, 2016 2:53 pm

Re: Help with PTZ on Vstarcam_C24S.pm needs updating for 1.34.23

Post by alabamatoy »

The control script is PERL scripting language. I am not able or competent to try to teach that language. I suggest taking the existing script and tinker with it to learn how it works, that what I did. Some insight may be helpful to that end:

" my $cmd = "decoder_control.cgi?command=90&" . "${cmdext}"; "
This statement sets up the command string. The "." concatenates strings together.

" $self->sendCmd( $cmd ); "
This statement calls the subroutine to actually send the command, passing it the command string.

" Debug( "http://".$self->{Monitor}->{ControlAddress}."/$cmd"."&".$self->{Monitor}->{ControlDevice} ); "
This statement is essentially a debug write, you can turn debugging on within the ZM options and when the script is run, there will be visible results of the debug statements in the log. This is so you can see the contents of the command string that the subroutine has formulated. Debug statements only get written if debug is turned on in the options, error statement get written to the lgos no matter what, that's the only reason I conflated them. Change the debugs to errors and they get written to the log as an error no matter what, its a means of reverse engineering what the code is doing.

" my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."/$cmd"."&".$self->{Monitor}->{ControlDevice} ); "
This statement formulates the actual command.

" my $res = $self->{ua}->request($req); "
This statement actually sends the command to the camera (http://blah blah blah just as you would with a browser), and the resulting response from the camera is stored in $res.

" if ( $res->is_success )
{
$result = $res->decoded_content;
}
else
{
Error( "Error check failed:'".$res->status_line()."'" );
}
return( $result ); "

All of this checks the response back from the camera, was the command successful? If so, send the result back to control, if not, write an error in the log showing what the camera gave back as a response.

Is this making sense?
orionstoy
Posts: 17
Joined: Wed Jun 22, 2011 8:26 pm

Re: Help with PTZ on Vstarcam_C24S.pm needs updating for 1.34.23

Post by orionstoy »

thanks again for taking the time ... that information helps. At least now I understand a bit more of what is going on. I've played with php and had to learn a bit of that. As you see by my post, I did play a bit with perl to modify the zoneminder montage.php with a couple of buttons that were direct links to "preset 1 and 2" using zmcontrol.pl. I will have to dig deeper into perl to try to get a basic knowledge of it and I will see about figuring out how to enable debugging logs in zoneminder.. I believe I had done that once but shut it off because I was having space issues and the logs were huge... but that was an older version of zoneminder several years ago along with a very limited server at the time.

I will have to figure out if the script is being called because as I say when I select to use it and click any of the controls... as of now I get nothing at all in any logs from zoneminder and apache. If I remember correctly the onvif.pm did show an error I think in apache logs saying http://loginName:loginPassword@IP:PORT/decoder_control.cgi?command=xx failed to connect so if I can figure out how it sends that format and where it gets the call from zoneminder for the login and password I should be able to add it to the

Code: Select all

my $cmd = "decoder_control.cgi?<insert"loginuse=loginName&loginpas=loginPassword&"code>command=xx&";
I guess I will have better luck if I get the debugging turned on and I can follow whats being called.

Thanks again .. you gave me a lot of information to digest and more to learn but at least a have a better idea of how to start.
alabamatoy
Posts: 360
Joined: Sun Jun 05, 2016 2:53 pm

Re: Help with PTZ on Vstarcam_C24S.pm needs updating for 1.34.23

Post by alabamatoy »

One more important point - understand that if you make any changes to code, and ZM gets updated, those changes will be overwritten. Its a good way to lose a bunch of work really quickly. How do I know? Yep, the hard way.
orionstoy
Posts: 17
Joined: Wed Jun 22, 2011 8:26 pm

Re: Help with PTZ on Vstarcam_C24S.pm needs updating for 1.34.23

Post by orionstoy »

lol .. yeah I actually set up another folder in /usr/share/zoneminder/. I have the original www and I made a separate one called wwwpi. I have two Apache sites. One for the stock version and one for my raspberry pi setup that has a few modified php files. I have a pi setup as a monitor with a pi 7" touchscreen. I modified the montage screen to have the cameras on the top of the page before anything else so the pi setup shows the cameras without having to scroll past the "header" and I had links set up to change one camera that had two positions depending on the situation Since its in a folder called wwwpi it doesn't get overwritten and I save a copy of the original filies. This way I can compare the versions to see if I can copy the files in www that may have been updated and just copy the files I modified over if they haven't changed or I can add my modifications to the updated php files if they have changed. I do this with any files I modify in the perl5/zoneminder so I save a copy of the original file, a copy of the modified file and the file I modified, this way if it overwrites my modified file, I still have a copy. I'm ok tho if I'm only modifying the Vstarcam file because that's not a zoneminder file. It was supplied I believe here by someone and it just happens to be the one that worked with my camera (which I think is a clone for the vstarcam)
Post Reply