08-11-2014 08:28 PM
Hello,
I am making a program that USRP1 can work with Labview 2011 using “call library function”. The main program of USRP1’s software is usrp hardware driver (UHD) which includes uhd.dll file with several example exe files. Also, they open all source files which written C++. However, I am totally new in C++.
So I need some help to do work with this.
Here is the source code of the USRP example program which just find the device and return the serial number.
--------------------------------------------------------------------------------------------------------------------------------------
#include <uhd/utils/safe_main.hpp>
#include <uhd/device.hpp>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <iostream>
#include <cstdlib>
namespace po = boost::program_options;
int UHD_SAFE_MAIN(int argc, char *argv[]){
po::options_description desc("Allowed options");
desc.add_options()
("help", "help message")
("args", po::value<std::string>()->default_value(""), "device address args")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
//print the help message
if (vm.count("help")){
std::cout << boost::format("UHD Find Devices %s") % desc << std::endl;
return EXIT_FAILURE;
}
//discover the usrps and print the results
uhd::device_addrs_t device_addrs = uhd::device::find(vm["args"].as<std::string>());
if (device_addrs.size() == 0){
std::cerr << "No UHD Devices Found" << std::endl;
return EXIT_FAILURE;
}
for (size_t i = 0; i < device_addrs.size(); i++){
std::cout << "--------------------------------------------------" << std::endl;
std::cout << "-- UHD Device " << i << std::endl;
std::cout << "--------------------------------------------------" << std::endl;
std::cout << device_addrs[i].to_pp_string() << std::endl << std::endl;
//uhd::device::make(device_addrs[i]); //test make
}
return EXIT_SUCCESS;
}
----------------------------------------------------------------------------------------------
At first, I checked the function name of UHD.dll and dependency of this exe file using dependency work program. The function name shows
“??0device_addr_t@uhd@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z “
Like this.. But when I double click this, I can see
“uhd::device_addr_t::device_addr_t”
However, if I put “uhd::device_addr_t::device_addr_t” in function name in call library node, I cannot run my vi due to node cannot find function name. If I put “??0device_addr_t@uhd@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z “, I am then enable to run the vi. But return 1097 error.
Anyway, I keep working to check manual of the uhd.dll’s class using
http://files.ettus.com/manual/classuhd_1_1device__addr__t.html
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Mapping of key/value pairs for locating devices on the system. When left empty, the device discovery routines will search all available transports on the system (ethernet, usb...).
To narrow down the discovery process to a particular device, specify a transport key/value pair specific to your device.
The device address can also be used to pass arguments into the transport layer control to set (for example) buffer sizes.
An arguments string, is a way to represent a device address using a single string with delimiter characters.
uhd::device_addr_t::device_addr_t | ( | const std::string & | args = "" |
) |
Create a device address from an args string.
args | the arguments string |
|
inline |
Lexically cast a parameter to the specified type, or use the default value if the key is not found.
key | the key as one of the address parameters |
def | the value to use when key is not present |
error | when the parameter cannot be casted |
std::string uhd::device_addr_t::to_pp_string | ( | void | ) | const |
Convert a device address into a pretty print string.
std::string uhd::device_addr_t::to_string | ( | void | ) | const |
Convert the device address into an args string. The args string contains delimiter symbols.
08-11-2014 08:53 PM
08-11-2014 08:59 PM
I am going to make a post in MSDN, but basically, I am making Labview program to use "call dll library function node". I already checked several posts and documantation, but still I am struggling to use this function.
That's why I asked here.
Thanks.
08-12-2014 07:57 AM - edited 08-12-2014 08:01 AM
The uhd API seems to be C++ (uhd:: namespace)!! The Call Library Node can not directly interface to C++ since there is no commonly accepted ABI standard for C++, each compiler uses its own ABI specification. You would have to get a standard C wrapper for the uhd interface in DLL form in order to access it with the Call Library Node. Maybe your uhd library also provides that but it is not very likely and in that case you would have to create the wrapper DLL yourself, which requires you to write C code and use a C++ compiler.