/camera/camlib

To get this branch, use:
bzr branch http://darksoft.org/webbzr/camera/camlib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Headers;
use HTTP::Response;
use HTTP::Request;
use URI::URL;

$inf_url = "http://hpeat127.fzk.de:8000/cmd.html";
$cmd_url = $inf_url;
#$proxy = "http://proxy.fzk.de:8000";
$user = 'ufo';
$pass = 'fast';

$ua=new LWP::UserAgent;
if ($proxy) { $ua->proxy(['http','ftp'],$proxy); }

sub status {
    my ($req_url) = @_;
    
    my $url = new URI::URL($req_url);
    my $hdr = new HTTP::Headers("Referer"=>$url);
    $hdr->authorization_basic($user, $pass);
    my $req = new HTTP::Request("GET",$url,$hdr);
    my $resp = $ua->request($req);
    my $status = $resp->content;

#print $status;
    while ($status =~ /socket\((\d+)\s*,([^,]+)\s*,(\d+)\s*,(\d+)\s*\)/g) {
	print "$1 $2 = $3 \n"
    }
}


if ($#ARGV < 0) {
    print 
"Usage: 
    $0 <var>=<value>
	Example: $0 P1=0
	Example: $0 P1=1
	Example: $0 'P1=1&P2=0'
    $0 val1 val2 val3 val4
	Example: $0 1 1 0 0
\n\n";
    status($inf_url);
    exit(0);
}

if (($#ARGV>0)||($ARGV[0] =~ /^\d+$/)) {
    $POST = "";
    foreach ($i = 0; $i <= $#ARGV; $i++) {
	if ($i) { $POST .= "&"; }
	$POST .= "P".($i+1)."=".$ARGV[$i];
    }
} else {
    $POST = $ARGV[0];
}

$retries = 3;

RETRY:
$url = new URI::URL($cmd_url);
$hdr=new HTTP::Headers("Referer"=>$cmd_url);
$hdr->authorization_basic($user, $pass);
$req = new HTTP::Request("POST",$url,$hdr,$POST);
$req->content_type('application/x-www-form-urlencoded');
$resp = $ua->request($req);
if ($resp->content) { 
    if (($resp->content =~ /401\s+Authorization\s+Required/i)&&(--$i>0)) { goto RETRY; }
    print($resp->content . "\n"); 
}

status($inf_url);