Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

troubling linking library using old dev kit

Rank

Total Posts: 5

Joined 2009-02-20

PM

Hi,
I'm having trouble building a simple c++ application for the ant usb stick that simply receives data.
I'm using the old dev kit: nRF24AP1_EVKIT_Release 1.3 - 2006 10 05
I'm using Microsoft Visual Studio 2005 with .NET Framework version 2.0.50727 SP1 on a PC with windows XP Pro.
Here are the problems I'm facing:

(1) When I try to statically link in the library "ANT_Interface.lib"
I get the following build error:
fatal error LNK1136: invalid or corrupt file ANT_Interface.lib line 1

(2) When I try to statically link in the library "ANT_DLL.dll"
I get the following build error:
fatal error LNK1107: invalid or corrupt file: cannot read at 0x410 ANT_DLL.dll line 1

(3) When I dynamically link in "ANT_DLL.dll" with the functon call to "LoadLibrary" I do get a non-null HINSTANCE return value.
And when I call "GetProcAddress" with functions such as ANT_Init, ANT_Close, ANT_AssignChannel, ANT_UnAssignChannel, etc....
I do get return values that are non-null so it seems like everything is ok.
But when I call "ANT_Init" i get a run-time error of "Access violation" and it seems i'm accessing an address of 0x00.

I think i've installed the drivers ok because when I run 2 instances of the tool "Antware.exe" on 2 dev-kits or 1 dev-kit and 1 ant usb stick,
i'm able to send data from one to the other.

I just can't seem to get a simple application running.

Please help.

Thanks very much.

Max      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

(1) When I try to statically link in the library "ANT_Interface.lib"
I get the following build error:
fatal error LNK1136: invalid or corrupt file ANT_Interface.lib line 1


You can only statically link ANT_Interface.lib using Borland.

(2) When I try to statically link in the library "ANT_DLL.dll"
I get the following build error:
fatal error LNK1107: invalid or corrupt file: cannot read at 0x410 ANT_DLL.dll line 1


The ANT_DLL.dll can only be dynamically linked.


(3) When I dynamically link in "ANT_DLL.dll" with the functon call to "LoadLibrary" I do get a non-null HINSTANCE return value.
And when I call "GetProcAddress" with functions such as ANT_Init, ANT_Close, ANT_AssignChannel, ANT_UnAssignChannel, etc....
I do get return values that are non-null so it seems like everything is ok.
But when I call "ANT_Init" i get a run-time error of "Access violation" and it seems i'm accessing an address of 0x00.


If you have not done it yet, try upgrading to the latest drivers, available here.
Make sure to fully remove the old drivers before installing the new ones. Instructions for this are attached.

Using the ANT DLL with .NET has a few intricacies, due to having to mix managed and unmanaged code in the same application. The attached sample code shows how to use the ANT DLL with C++ and .NET.

[file name=D0000XXXX___TN01_Uninstalling_USB_Drivers_0.pdf size=231596]http://www.thisisant.com/images/fbfiles/files/D0000XXXX___TN01_Uninstalling_USB_Drivers_0.pdf[/file]      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

Reference design for the ANT DLL using VC++ .NET.
This will compile using Visual C++ 2008 Express Edition.

[file name=ant_demo_reference_design.zip size=116356]http://www.thisisant.com/images/fbfiles/files/ant_demo_reference_design.zip[/file]      
Rank

Total Posts: 5

Joined 2009-02-20

PM

Thank you Kit for the reply.
I did as you said, followed the instructions for the complete removal of the old drivers and installed the new drivers.
I then tested with 2 dev-kits with the "ANTware" tool and got the boards talking to each other, which is good news.

My question is when i write a visual C++ application for ANT,
under
project properties tab->
Configuration Properties->
General->
Project Defaults->
Common Language Runtime support

Should I choose:
No Common Language Runtime support
Common Language Runtime support
Pure MSIL Common Language Runtime Support
Safe MSIL Common Language Runtime Support
Common Language Runtime Support, Old Syntax ??

I guess i was wondering if the ANT DLL was built in managed code or unmanaged code.      
Rank

Total Posts: 5

Joined 2009-02-20

PM

Also I am using Visual Studio 2005, i know its a previous version than 2008, so are the DLLs in "ant_demo_reference_design.zip" built using 2008 ?? If so there may be compatibility problems with the olf visual studio 2005.

Are there any old ANT DLLs available for the old dev kit and Visual Studio 2005 usage?      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

The ANT DLL is unmanaged code. If your entire application is unmanaged as well, you would use the No CLR option, but if you want to mix managed and unmanaged code, like in the demo, you need to use CLR.

The DLL's provided have been tested with previous versions of Visual Studio, you only need the 2008 version to open the solution and project. They should work with the old devkit.      
Rank

Total Posts: 5

Joined 2009-02-20

PM

Thanks again for the help,
I'm able to "LoadLibrary" successfully on the new DLL,
and able to get function pointers successfully using "GetProcAddress".

The only problem I have now is that when I call
ANT_Init(0, 57600) i get a return value of 0.

When i run the "ANTWare" tool or the "ANTDemo" app,
and connect to usbport=0 at 57600 baud i always get a successful connect.

Am I forgetting to do something?

(I'm writing the app using unmanaged C++)

Thanks.

Max      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

Make sure you have all the DLLs (ANT_DLL.dll, DSI_SiUSBXp_3_1.dll and DSI_CP210xManufacturing_3_1.dll) in the same directory as your executable.      
RankRankRankRank

Total Posts: 523

Joined 2012-11-15

PM

hello, am trying to do the same.. but

can you share with me the Borland original project???

that is the one that I did not tryed...

thanx

you cand send me that to andresandres @ radio . fm      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

Andres,

You can find a reference design for Borland in the CD accompanying the DevKit, and in the DevZone.      
RankRankRankRank

Total Posts: 523

Joined 2012-11-15

PM

I don't think it has anything to do with RealBasic. I'm using C++ unmanaged code and I'm getting the getting the exact same problem in Visual Studio 2008 SP1 under Win7.

I verified the demos in
ANT_USB2_Windows_Package also fail the same way.
DEMO_DLL fails

The problem appears to be with ANT_DLL.dll 3/12/2010 69KB

I found an older version of the ANT_DLL.dll 2/29/2008 20KB and my code works fine, though with fewer interface.

The new DLL fails on
bOk = ANT_Init(AntDeviceNumber, AntUtils::BaudRate);
ANT_Init is valid, loaded via GetProcAddress and verififed.

First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: LibusbError::Enum at memory location 0x0041f35c..
First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: LibusbError::Enum at memory location 0x0041f360..
First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
'DEMO_DLL.exe': Loaded 'C:\\Users\\tomw\\Desktop\\bikestuff\\ant_usb2_windows_package\\ANT_USB2_Windows_Package\\Debug\\DSI_CP210xManufacturing_3_1.dll', Binary was not built with debug information.
First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: int at memory location 0x0041f63c..
First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
Again same code with the older DLL and everything works.

What's the difference between the 2 DLLs? There is a lot more interfaces and the size is different.

It seems bad that the demo fails as well.
-Tom      
RankRankRankRank

Total Posts: 523

Joined 2012-11-15

PM

I'm having a similar problem with the latest ANT_DLL.dll.

The problem appears to be with ANT_DLL.dll 3/12/2010 69KB
I found an older version of the ANT_DLL.dll 2/29/2008 20KB and my code works fine, though with fewer interface.

bOk = ANT_Init(AntDeviceNumber, AntUtils::BaudRate);
Fails for me in LibusbError(see below).

AntWareII works fine for me. I can see my usb stick, change settings,etc. I've installed the latest drivers. I also tried on a fresh machine that never had any drivers.

I verified the demos in
ANT_USB2_Windows_Package also fail the same way.
DEMO_DLL fails


The new DLL fails on
bOk = ANT_Init(AntDeviceNumber, AntUtils::BaudRate);
ANT_Init is valid, loaded via GetProcAddress and verified.

First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: LibusbError::Enum at memory location 0x0041f35c..
First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: LibusbError::Enum at memory location 0x0041f360..
First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
'DEMO_DLL.exe': Loaded 'C:\\Users\\tomw\\Desktop\\bikestuff\\ant_usb2_windows_package\\ANT_USB2_Windows_Package\\Debug\\DSI_CP210xManufacturing_3_1.dll', Binary was not built with debug information.
First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: int at memory location 0x0041f63c..
First-chance exception at 0x7705b727 in DEMO_DLL.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
Again same code with the older DLL and everything works.

What's the difference between the 2 DLLs? There is a lot more interfaces and the size is different.

-Tom      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

The main difference between the two DLL's is that the latest version adds support for USB2 (libusb). Are you attempting to connect to an USB1 or USB2 stick? What parameters are you setting for ANT_Init?      
RankRankRankRank

Total Posts: 523

Joined 2012-11-15

PM

I'm using an USB1(nRF24AP1) 4 Channel Ant Stick.

I've tried a few settings and baud rates
bOk = ANT_Init(0, 57600);
bOk = ANT_Init(0, 50000);
bOk = ANT_Init(0, 38400);

I verified the demo "DEMO_DLL" in ANT_USB2_Windows_Package also fails the same way, so it doesn't seem to be anything unique I'm doing. The exception LibusbError sounds like it must be related to the latest libusb changes you mentioned. Do I have do do something different with USB1 sticks now? Does the Demo_DLL example work for you? I'd like to support the latest driver/dll.

I've tried both the USB1 and USB2 drivers. Currently I've given up and I'm sticking with the old ANT_DLL.dll unless you have another suggetion.

Thanks for the help
-Tom Whittaker      
Avatar
RankRankRankRank

Total Posts: 662

Joined 2012-10-09

PM

You do not need anything special to work with USB1 with the newest DLL. All the demos and applications we have have been tested with both USB1 and USB2.

The libusb exceptions you are seeing are being handled internally by the library, and all they mean is that the library tried to find a USB2 stick to connect to, but did not find one. This is normal.

You do not need to install the USB2 driver, although that should not make a difference. You should be using baud rate 50000. When you look in the device manager, is your USB1 stick enumerated, without any conflicts? Is the DSI_SiUSBXp_3_1.dll in the same directory as your executable?

Are you able to run the DEMO_LIB? You can find this on the Windows Library Package in the DevZone. As this links statically to the library, it would let you step though the initialization and get more information on why it fails.