Updated the documentation, enhanced examples.
authorHeiko Schlittermann <hs@schlittermann.de>
Thu, 22 Jan 2009 03:57:27 +0100
changeset 22 7690e12fafda
parent 21 298db85d9c1d
child 23 66c21518904c
Updated the documentation, enhanced examples.
examples/client
lib/Quancom.pm
--- a/examples/client	Wed Jan 21 19:44:38 2009 +0100
+++ b/examples/client	Thu Jan 22 03:57:27 2009 +0100
@@ -13,6 +13,10 @@
     my $q = new Quancom $ARGV[0];
 
     my $r;
+
+    $q->set(1..64 => 1); sleep 1;
+    $q->set(1..64 => 0); sleep 1;
+
     foreach (1..64) {
 	$q->set($_ => 1);
 	usleep 1e6/20;
--- a/lib/Quancom.pm	Wed Jan 21 19:44:38 2009 +0100
+++ b/lib/Quancom.pm	Thu Jan 22 03:57:27 2009 +0100
@@ -161,6 +161,8 @@
     if ($result->error) { die $result->error_message } 
     else { print $result->data }
 
+    $q->set(1 .. 64 => 1);  # switch on all the lights
+
 
 =head1 METHODS
 
@@ -187,6 +189,10 @@
 all bits on the first relais. Some other (untested) string for setting
 just the lowest bit on the first relais should be "WB010001".
 
+B<Note:> This function is provided for functionality not covered by the
+above L<set()> function. Whenever possible, you should avoid using this
+L<cmd()>, since it binds you tightly to the specific hardware.
+
 =item B<reset>( )
 
 This resets the device by setting the reset control flag.
@@ -198,7 +204,6 @@
 This clears the outputs AND resets timeouts by writing zero 
 to all control bits.
 
-
 =item B<last_result>( )
 
 This returns an object containing the last result.
@@ -206,11 +211,25 @@
 
 =back
 
-=head1 MORE EXAMPLES
+=head1 EXAMPLES
 
     use Quancom;
     my $quancom = new Quancom("172.20.20.1");
-    die "Sorry" if $quancom->cmd("xxxx")->error;
+
+    my $result;
+    
+    $result = $quancom->set(1, 7 => 1);
+    die $quancom->error_message if $quancom->error;
+
+    $result = $quancom->set(23 => 0);
+    die $quancom->error_message if not $quancom->ok;
+
+    $quancom->set(12 => 1);
+    $result = $quancom->last_result;
+    die $quancom->error_message if not $quancom->ok;
+
+    $quancom->set(1..63 => 1)->ok 
+	or die $quancom->last_result->error_message;
 
 =head1 SEE ALSO
 
@@ -218,8 +237,8 @@
 
 =head1 AUTHOR
 
-    Maik Schueller
-    Heiko Schlittermann
+    Maik Schueller <maik.schueller@o3si.de>
+    Heiko Schlittermann <hs@schlittermann.de>
 
 =head1 THANKS