Skip to content
Snippets Groups Projects
Select Git revision
  • 82fa7d01687ccffb58bbcfafcd96d4dd7e9691cb
  • master default protected
2 results

hp2101nw_connect.pl

Blame
  • hp2101nw_connect.pl 12.62 KiB
    #!/usr/bin/perl
    ## hp2101nw_connect.pl - version 0.01
    ## 
    ## Linux connection utility for the HP 2101nw wireless G USB print server.
    ##
    ## (C) 2012 Reinhold Kainhofer <reinhold@kainhofer.com>
    ## License: GPL v2 or later
    
    ## This script (hp2101nw_connect.pl) provides a relatively easy way to identify and
    ## connect to the HP 2101nw wireless USB print server on linux.
    ## The device is not a real print server, but rather a USB port forwarder
    ## over TCP/UDP. On Windows it creates a virtual USB port, so for Linux
    ## support, we'll need a proper kernel module doing the USB port forwarding...
    ##
    ## This script "only" detects the device on the network, retrieves information and
    ## optionally lock it. Once a kernel module is ready, this is the user-space
    ## part of the driver.
    ##
    ## For the device protocol see:
    ## http://wiki.kainhofer.com/hardware/hp2101nw_wlan_printserver
    
    ## Supported devices:
    ##    -) HP 2101nw wireless G USB print server (USB-id 03f0:cd02)
    
    
    use IO::Socket;
    use IO::Select;
    # use Socket qw(:all);
    use Data::Dumper;
    use strict;
    # use warnings;
    
    our $debug=1;
    
    our $VERSION = 0.01;
    # Wait a maximum of 5 seconds for data:
    our $SOCK_TIMEOUT = 5; 
    
    print "hp2101nw_connect.pl - version $VERSION\n";
    print "Linux connection utility for the HP 2101nw wireless G USB print server.\n\n";
    print "(C) 2012 Reinhold Kainhofer <reinhold\@kainhofer.com>\n";
    print "License: GPL v2 or later\n\n";
    
    
    # The PC always identifies itself as XXXXXXXX.
    our $thisboxname = "XXXXXXXX";
    our $port_information = 34444;
    our $port_command = 34447;
    our $port_usbnet = 34448;
    
    our $SBSU_STATUS = 1;
    our $SBSU_UNKNOWN = 7;
    
    $| = 1;
    
    
    $Data::Dumper::Indent = 1;
    
    # USB vendor / product ids and descriptions of all supported devices
    my @supported_devices=(
      [0x03f0, 0xcd02, "HP 2101nw wireless G USB print server"]
    );
    
    
    
    ###############################################################################
    ##  HELPER FUNCTIONS
    ###############################################################################