perl and IO Warrior 24

This is the English forum for all topics related to IO-Warrior. Please post in English only

Moderator: Guido Körber

Post Reply
vanne
Posts: 3
Joined: Mon Aug 20, 2007 5:57 pm

perl and IO Warrior 24

Post by vanne »

Hi all,

I'm writing a perl daemon that needs to access a IO Warrior 24. I'm stuck there as i don't know the USB protocol....
The Device::USB and accompaining modules are installed and working correctly. I can do things like the example in the Device::USB docs, meaning print $dev->manufacturer and so on.
Problem is i don't have a clue on how to read to/write from it...
I was explained there are 2 bytes you can read/write.
Let's say there is byte 0: bit 0 to 7 and byte 1: bit 8 to 15.
What i exactly have to do is read the first 9 bits (0 - 8) and write 0 or 1 to the last one (15).

Anyone has some sample code to get me started?

TIA
vanne
wayoda
Posts: 362
Joined: Fri Dec 19, 2003 12:00 pm
Location: Wuppertal/Germany

Post by wayoda »

Hi vanne,
what is your target Operating System?
Most people use the iowkit-library for accessing the IOWarrior.
If you know how to make calls from Perl into the C-library (win32 dll for windows, so.lib for linux, no idea about the Mac) everything should be fairly easy.

There are already wrappers for Java, and I have a small lib to access the devices from Python, but I haven't seen an Perl-implementation yet.

But anyway, using the iowkit-lib from Perl is the way to go, since you don't need to know anything about the usb-issues to use it.
All you need is the library-docs and the datasheet for the IOWarrior.

Eberhard
vanne
Posts: 3
Joined: Mon Aug 20, 2007 5:57 pm

Post by vanne »

Okay,

I'll have a look at the iowkit-library then.

Anyone any sample code of using the iowkit library with perl?

Vanne
vanne
Posts: 3
Joined: Mon Aug 20, 2007 5:57 pm

problem writing to IO Warrior 24

Post by vanne »

Hi,

I got a bit further with this.
I can read that i want to read but i cant write ti the io warrior :(
I don't use the kernel module or iowkit lib, but i use the parl libusb wrapper.
Here is how i read:

Code: Select all

#!/usr/bin/perl

use Device::USB;

my $IOW_VENDOR = 0x07c0;
my $IOW_PRODUCT = 0x1501;
my $IOW_CONFIGURATION = 1;
my $IOW_INTERFACE = 0;
my $IOW_IN_ENDPOINT  = 0x81;
my $IOW_TIMEOUT = 1000;

my $usb = Device::USB->new();
my $inbuf = "\0" x 2;

my $iow = $usb->find_device($IOW_VENDOR, $IOW_PRODUCT);
$iow->open >= 0 or die "FATAL: Cannot open IOW device: $!\n";
$iow->reset >= 0 or die "FATAL: Cannot reset IOW device: $!\n";
$iow->set_configuration($IOW_CONFIGURATION) >= 0 or die "FATAL: Cannot set IOW configuration: $!\n";
$iow->claim_interface($IOW_INTERFACE) >= 0 or die "FATAL: Cannot claim IOW interface: $!\n";

$iow->interrupt_read($IOW_IN_ENDPOINT, $inbuf, length($inbuf), $IOW_TIMEOUT) >= 0
    or die "Cannot read IOW device: $!\n";
print unpack ("b16", $inbuf), "\n";
that gives me the fillowing:

Code: Select all

debian:/usr/local/sbin# ./write.pl 
1001000011111111
debian:/usr/local/sbin# 
If i understand correctly i need an OUT endpoint (and thus another address?) to write to, but i can find only IN endpoints :(

Code: Select all

debian:/usr/local/sbin# lsusb -vv -s 2:2 | grep -i endpointaddress
        bEndpointAddress     0x81  EP 1 IN
        bEndpointAddress     0x82  EP 2 IN
debian:/usr/local/sbin# 
any hints on this?

FYI:
debian:/usr/local/sbin# uname -a
Linux debian 2.6.21-2-686 #1 SMP Wed Jul 11 03:53:02 UTC 2007 i686 GNU/Linux
debian:/usr/local/sbin#
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Post by Guido Körber »

There are no Out endpoints on IOW24 and IOW40, data to the chips goes through the default endpoint. You should try talking to the interfaces instead of the endpoints, at interface level both interfaces are bidirectional.
Post Reply