Su, Yu (Eugene) wrote:
Hi,
I have a DLL from FTDI (ftd2xx.dll www.ftdichip.com) for a USB
device. I try to write a simple perl script to list a number of (FTD)
USB devices connected to a PC. My code below got an error on invalid
parameter;
Argument M-\0\0\0\0\ isn't numeric in subroutine entry at demo.pl
line #
I guess I did not pass a hex data in the function call properly. Can
someone help me?
Thanks.
Eugene
code snippet ###
use strict;
use Win32::API;
use Carp;
use warnings;
# from FTD2xx programmer guide:
# FT_ListDevices(PVOID numDevs,PVOID NULL,DWORD FT_LIST_NUMBER_ONLY)
# FT_LIST_NUMBER_ONLY is defined in FTD2xx.h as #define
FT_LIST_NUMBER_ONLY = 0x8000 # my $function = new
Win32::API(ftd2xx, FT_ListDevices, PPN, N); if (not defined
$function) { die Can't import API FT_ListDevices: $!\n; } my
$DevBuffer = x 80; my $FT_LIST_NUMBER_ONLY=pack('N', 0x8000);
my $status=$function-Call($DevBuffer,0,$FT_LIST_NUMBER_ONLY);
print status: $status\n;
print DeviceNumber: $DevBuffer;
I think that you problem is the 'pack'. Why do you think you need it?.
Just use 0x8000 in your function call, or if you want to define it
as a constant, 'use constant FT_LIST_NUMBER_ONLY = 0x8000;' is more
nearly equivalent to the #define you quote, and will add to your codes
readability. For example, you dould write it something like this:
use strict;
use warnings;
use Win32::API;
use constant FT_LIST_NUMBER_ONLY = 0x8000;
my $function = new Win32::API(ftd2xx, FT_ListDevices, PPN, N);
die Can't import API FT_ListDevices: $!\n unless defined $function;
my $DevBuffer = x 80;
my $status=$function-Call($DevBuffer, 0 ,FT_LIST_NUMBER_ONLY);
print status: $status\n;
print DeviceNumber: $DevBuffer;
HTH
--
Brian Raven
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient or have received this e-mail in error, please advise
the sender immediately by reply e-mail and delete this message and any
attachments without retaining a copy.
Any unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs