in reply to Re: Win32::API cant define function
in thread Win32::API cant define function

Thank you for your feed back but I still can not get it to work. I am kind of a nubie when it comes to Perl. The function that reads in is actually called ReadInputs not SetOutputs but I guess that was just a typo.

I have pasted the code I am trying to get to work below. The code is suppost to print out what ReadInputs has read every second. The error that I am getting in command prompt is "Not a Code reference at line 20" and it's talking about "my $rv = $read_inputs->($buf);"

use strict; use Win32::API; Win32::API->Import("wsp", "int InitWasp()"); my $read_inputs = Win32::API->new("wsp", "ReadInputs", "P", "I"); InitWasp(); #connect to WASP USB board #constant input read in # while(1){ print ReadInputs()."\n"; sleep(1); } #Subroutines # sub ReadInputs{ my $buf = "\x00" x (4 * 32/8); my $rv = $read_inputs->($buf); return ($rv, unpack('l4', $buf)); }

Replies are listed 'Best First'.
Re^3: Win32::API cant define function
by GrandFather (Saint) on Mar 29, 2010 at 01:09 UTC

    Try:

    my $rv = $read_inputs->Call ($buf);

    Oh, and note that ReadInputs returns a list of values so print will print them concatenated together without any white space. You could:

    my @values = ReadInputs(); print "@values\n";

    to at least get a space between each value. Note that the first value is the 'bool' result of the call and that the following values are the ADC input values.


    True laziness is hard work