Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Device::USB gives "Use of uninitialized value in concatenation" error

by Eliya (Vicar)
on Dec 11, 2013 at 00:48 UTC ( [id://1066531]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Device::USB gives "Use of uninitialized value in concatenation" error
in thread Device::USB gives "Use of uninitialized value in concatenation" error

My guess would be that it's complaining about undefined CFLAGS / CPPFLAGS / LDFLAGS environment variables (see line 19 and 20). Line numbers reported are not always precise when a statement stretches over multiple lines.

Try setting those env variables to nothing, i.e. export CFLAGS= etc., and see what happens...

  • Comment on Re^3: Device::USB gives "Use of uninitialized value in concatenation" error
  • Download Code

Replies are listed 'Best First'.
Re^4: Device::USB gives "Use of uninitialized value in concatenation" error
by holandes777 (Scribe) on Dec 11, 2013 at 00:59 UTC
    9 use Inline ( 10 C => "DATA", 11 ($ENV{LIBUSB_LIBDIR} 12 ? ( LIBS => "-L\"$ENV{LIBUSB_LIBDIR}\" " . 13 ($^O eq 'MSWin32' ? ' -llibusb -L\"$ENV{W +INDDK}\\lib\\crt\\i386\" -lmsvcrt ' : '-lusb') ) 14 : ( LIBS => '-lusb', ) 15 ), 16 ($ENV{LIBUSB_INCDIR} ? ( INC => "-I\"$ENV{LIBUSB_INCDIR}\ +"" ) : () ), 17 NAME => 'Device::USB', 18 VERSION => '0.35', 19 CCFLAGS => "$Config{ccflags} $ENV{CFLAGS} $ENV{CPPFLAGS}" +, 20 LDDLFLAGS => "$Config{lddlflags} $ENV{LDFLAGS}", 21 ); 22 print "CCFLAGS =>|$Config{ccflags}|$ENV{CFLAGS}|$ENV{CPPFLAGS}|\n +"; 23 print "LDDLFLAGS =>|$Config{lddlflags}|$ENV{LDFLAGS}|\n";

    this gave the following errors and output:

    root@gk-kubuntu-dev:~/dav/Nevada# perl kk.pl Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 10. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 10. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 10. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 22. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 22. CCFLAGS =>|-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno- +strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FIL +E_OFFSET_BITS=64||| Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 23. LDDLFLAGS =>|-shared -L/usr/local/lib -fstack-protector||

    This indicates $ENV{CFLAGS},$ENV{CPPFLAGS} and $ENV{LDFLAGS} are uninitialized. I'll need to determine what they are supposed to be. There is not much useful I can find. I wonder why the package did not set the variables it needed. Could it be the botched cpan install? Frankly I have no idea what those things should be. I will try defining them as '' or some value

    9 $ENV{CFLAGS} = 'A'; 10 $ENV{CPPFLAGS} = 'B'; 11 $ENV{LDFLAGS} = 'C'; 12 $ENV{LIBUSB_LIBDIR} = 'D'; 13 $ENV{WINDDK} = 'E'; 14 $ENV{LIBUSB__INCDIR} = 'F'; 15 use Inline ( 16 C => "DATA", 17 ($ENV{LIBUSB_LIBDIR} 18 ? ( LIBS => "-L\"$ENV{LIBUSB_LIBDIR}\" " . 19 ($^O eq 'MSWin32' ? ' -llibusb -L\"$ENV{W +INDDK}\\lib\\crt\\i386\" -lmsvcrt ' : '-lusb') ) 20 : ( LIBS => '-lusb', ) 21 ), 22 ($ENV{LIBUSB_INCDIR} ? ( INC => "-I\"$ENV{LIBUSB_INCDIR}\ +"" ) : () ), 23 NAME => 'Device::USB', 24 VERSION => '0.35', 25 CCFLAGS => "$Config{ccflags} $ENV{CFLAGS} $ENV{CPPFLAGS}" +, 26 LDDLFLAGS => "$Config{lddlflags} $ENV{LDFLAGS}", 27 ); 28 print "CCFLAGS =>|$Config{ccflags}|$ENV{CFLAGS}|$ENV{CPPFLAGS}|\n +"; 29 print "LDDLFLAGS =>|$Config{lddlflags}|$ENV{LDFLAGS}|\n";

    gives the following errors and output

    Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 16. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 16. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 16. CCFLAGS =>|-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno- +strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FIL +E_OFFSET_BITS=64|A|B| LDDLFLAGS =>|-shared -L/usr/local/lib -fstack-protector|C|

    from what I can tell, every ENV variable is assigned something, Why are there still 3 concatenation errors?

      I'll need to determine what they are supposed to be.

      I don't think they have to be set to anything. The idea presumably is that in case they are set they should be appended to whatever CCFLAGS / LDDLFLAGS options have been determined via %Config...

      IMHO, the code should either test if those vars are defined before interpolating them, or disable warnings :)

      As for your update:

      from what I can tell, every ENV variable is assigned something, Why are there still 3 concatenation errors?

      If you set them within the Perl source, you'll need to set them in a BEGIN { } block, because due to the use Inine (...) statement, they're being evaluated at compile time of the Perl code.

      ... BEGIN { $ENV{CFLAGS} = ''; $ENV{CPPFLAGS} = ''; $ENV{LDFLAGS} = ''; } use Inline ( ... ... ); ...

        I don't know if the warnings have anything to do with it, but this code:

        1 use Device::USB; 2 3 $usb = Device::USB->new(); 4 $dev = $usb->find_device('0403', '6001'); 5 printf("Device: %04X:%04X\n", $dev->idVendor(), $dev->idProduct( +)); 6 $dev->open(); 7 print "Manufactured by: $dev->manufacturer()\n"; 8 print "Product: $dev->product()\n";

        gives the concatenation warnings plus:

        Can't call method "idVendor" on an undefined value at kk.pl line 5, <D +ATA> line 1.

        Here is the part of dmesg that applies

        [349416.436284] usb 4-2: new full-speed USB device number 3 using uhci +_hcd [349416.634282] usb 4-2: New USB device found, idVendor=0403, idProduc +t=6001 [349416.634294] usb 4-2: New USB device strings: Mfr=1, Product=2, Ser +ialNumber=3 [349416.634302] usb 4-2: Product: FT232R USB UART [349416.634309] usb 4-2: Manufacturer: FTDI [349416.634316] usb 4-2: SerialNumber: A100X16Z [349416.642482] ftdi_sio 4-2:1.0: FTDI USB Serial Device converter det +ected [349416.642595] usb 4-2: Detected FT232RL [349416.642603] usb 4-2: Number of endpoints 2 [349416.642610] usb 4-2: Endpoint 1 MaxPacketSize 64 [349416.642618] usb 4-2: Endpoint 2 MaxPacketSize 64 [349416.642624] usb 4-2: Setting MaxPacketSize 64 [349416.644397] usb 4-2: FTDI USB Serial Device converter now attached + to ttyUSB0

        OK, SLAM ON THE BRAKES: I jumped onto my Ubuntu 13.04 box and ran the same code. It asked for Device::USB. I installed it correcly by using apt-get install libdevice-usb-perl. The warnings went away and all I still have left is the error: "Can't call method "idVendor" on an undefined value at kk.pl line 5, <DATA> line 1." which is probably due to my lack of knowledge so I have to go study this. Thanks for your help and the lesson here is: IF YOU'RE USING UBUNTU, AVOID CPAN!!"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1066531]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-19 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found