The SANE Scanner Interface
By definition, SANE is only as good as the programs that use it. This means the more applications and the more devices that use SANE, the merrier. The SANE distribution comes with a detailed document that explains the SANE API; however, the interface is quite simple. The six main functions are listed below:
handle <- sane_open(device-name) allows you to open a SANE device by name (e.g., pnm:0).
sane_close(handle) allows you to close a SANE device by name.
sane_get_option_descriptor(handle, option-number) is used to query the controls available to the device (such as the brightness control in the PNM pseudo-device driver).
sane_control_option(handle, option-number, action, value) is used to get or set the value of an option. For example, it can be used to set the value of the brightness option to 50 percent. In addition, some options support an auto-mode where the driver picks a reasonable value. For such options, sane_control_option() can also be used to turn auto-mode on or off.
sane_start(handle) is used to start the acquisition of an image.
bytes-read <- sane_read(handle, buffer, buffer-size) is used to read the actual image data until the entire image has been acquired.
The SANE API is simple by design. The goal was to make it possible to accomplish a simple task in a small amount of time while still providing enough functionality to enable sophisticated drivers and applications. The simplicity is best evidenced by the fact that it took just two evening sessions to convert the hpscanpbm program into a SANE driver for HP scanners. On the other end of the spectrum, the Mustek driver and xscanimage are fairly complicated programs and SANE had no problems accommodating them.
What's our position with respect to commercial SANE drivers or applications? In the spirit of the GNU Public License, it is preferrable to have the source for SANE programs available. However, it is permissible to write a dynamically loaded, commercial SANE driver on Linux and other platforms that support dynamic loading. (Drivers are always dynamically loaded, so this doesn't cause any extra work.) By the same token, it is also proper to write a commercial application that links with the libsane.so shared library. The basic ideas supporting this position are:
Healthy competition between commercial and free programs is an asset, not a liability.
The more wide-spread use SANE finds, the better for the Linux/Unix community.
In the immediate future, the plan is to add support for many more devices. For example, Agfa and Plustek scanner and Nikon filmscanner drivers are planned, and there is hope that drivers for some of the more popular digital cameras will materialize soon as well. To get the ultimate in network connectivity, there are also plans to implement a scanner application in Java, making it possible to control your scanner from your favorite Java-enabled web browser.
In the long term, it would be interesting to generalize SANE to embrace other multimedia devices including audio sources or video tape recorders.
In other words, SANE has just started, and there are many exciting projects to come. If you're interested in pursuing some of these by all means get in touch with other developers through the SANE mailing list (see Resources).
Webinar: 8 Signs You’re Beyond Cron
On Demand NOW
Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.View Now!
|Non-Linux FOSS: Vienna, Not Just for Sausages||Jun 02, 2015|
|June 2015 Issue of Linux Journal: Networking||Jun 01, 2015|
|June 2015 Video Preview||Jun 01, 2015|
|My Humble Little Game Collection||May 28, 2015|
|New Linux Based OS Brings Internet of Things Closer to Reality||May 27, 2015|
|Non-Linux FOSS: All the Bitcoin, None of the Bloat||May 26, 2015|
- Non-Linux FOSS: Vienna, Not Just for Sausages
- June 2015 Issue of Linux Journal: Networking
- New Linux Based OS Brings Internet of Things Closer to Reality
- Dr Hjkl on the Command Line
- Initializing and Managing Services in Linux: Past, Present and Future
- Using Hiera with Puppet
- My Humble Little Game Collection
- Gartner Dubs DivvyCloud Cool Cloud Management Vendor
- Infinite BusyBox with systemd
- Goodbye, Pi. Hello, C.H.I.P.