Subject: | sane_exit() is not exported |
The included patch exports sane_exit() as Sane->reset().
Calling sane_exit() is important when scanners are hot-plugged, because
Sane->list_devices caches the results of the previous call.
Subject: | Sane-reset-PG-01.patch |
diff -rub Sane-0.05-ORIG/Sane.xs Sane-0.05/Sane.xs
--- Sane-0.05-ORIG/Sane.xs 2012-04-02 02:48:28.000000000 -0400
+++ Sane-0.05/Sane.xs 2012-08-22 18:40:09.751933138 -0400
@@ -577,6 +577,17 @@
SANE_Status status
void
+sane__exit (class)
+ CODE:
+ SV* sv = get_sv("Sane::_vc", FALSE);
+ if (SvTRUE(sv)) {
+ sv = get_sv("Sane::DEBUG", FALSE);
+ if (SvTRUE(sv)) printf("Exiting via sane_exit\n");
+ sane_exit();
+ }
+
+
+void
END ()
CODE:
SV* sv = get_sv("Sane::_vc", FALSE);
diff -rub Sane-0.05-ORIG/lib/Sane.pm Sane-0.05/lib/Sane.pm
--- Sane-0.05-ORIG/lib/Sane.pm 2012-04-02 02:48:27.000000000 -0400
+++ Sane-0.05/lib/Sane.pm 2012-08-22 20:32:14.281091327 -0400
@@ -255,7 +255,7 @@
SANE_NAME_LAMP_OFF_AT_EXIT
);
-our $VERSION = '0.05';
+our $VERSION = '0.05-PG1';
our $DEBUG = 0;
our ($STATUS, $_status, $_vc);
@@ -296,6 +296,12 @@
return Sane::_get_devices();
}
+sub reset {
+ return unless $_vc;
+ print "Running reset\n" if $DEBUG;
+ Sane->_exit;
+ $_vc = undef();
+}
# todo
# add simple sane methods
@@ -458,6 +464,11 @@
print "Type: $devices[0]->{type}\n";
}
+=head2 Sane->reset
+
+This method will release all resources held by the sane library. This
+allows the library to rescan the system for new or removed devices.
+
=head2 Sane::Device->open
This function is used to establish a connection to a particular device.