http://qs321.pair.com?node_id=11120089

Bpl has asked for the wisdom of the Perl Monks concerning the following question:

Hi monkers, in these days I was building an XS library, based on the librtlsdr library ( github link: https://github.com/librtlsdr/librtlsdr ) for now, some functions works fine but the "rtlsdr_open" call gives me some problems. For starting the code (from the github library) referred to the call is:
RTLSDR_API int rtlsdr_open(rtlsdr_dev_t **dev, uint32_t index); # where rtlsdr_dev_t is initialized as: typedef struct rtlsdr_dev rtlsdr_dev_t;
I think that my implementation of rtlsdr_dev is wrong, in the XS code I wrote
int rtlsdr_open(dev, index) RTLSDRDevice_T **dev uint32_t index # where RTLSDRDEVICE_T is typedef rtlsdr_dev_t RTLSDRDevice_T;
and from the TYPEMAP file the structure are declared as:
RTLSDRDevice_T * T_PTRREF RTLSDRDevice_T ** T_PTRREF
now, the problem is that, when I run this code:
use SDR::RTLSDR qw(:all); # my library my $serial_number = "00000001"; # from dmesg output my $index = rtlsdr_get_index_by_serial( $serial_number ); # it returns + 0, this is not an error value so I think is good my $device = rtlsdr_get_device_name( $index ); print rtlsdr_open( $device , $index)
I have the following error:
SDR::RTLSDR::rtlsdr_close: dev is not of type RTLSDRDevice_TPtr at sdr +.pl line 7.
Now, I think that the result is related to some pointer error but also with:
print rtlsdr_open( \$device , $index)
I had the same error code. hope in some helps Thanks Edoardo M.