Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

How to get deviceid with C# code

RankRank

Total Posts: 33

Joined 0

PM

Hi,
I develop a programm, which can read the number of channels, but i want to dectect what kind of device is connected.
I read several C++ code, but i cannot find the way to detect the deviceid.

Can someone help how to detect the deviceid and device type connected to the usb ant stick.

Thanks

greetings
Klaasjan      
Avatar
RankRankRankRank

Total Posts: 213

Joined 2011-05-02

PM

Hello,

Please take a look at the ANT Windows Library Package here. The C# code in the ANT Managed Library shows the classes that are available for ANT devices, ANT device info, ANT channel info etc.

For an example using these classes, refer to the DEMO_NET folder, specifically demo.cs.

Cheers,

Kassandra      
RankRank

Total Posts: 33

Joined 0

PM

Hi Kassandra,

I got the deviceid and devicetype.

One thing i could not find.
The device is the usbstick. I got one with 4 channels.
I could not find the code to scan all channels for deviceid's

Can you give a some clues how to handle that.

Thanks.

Regards
Klaasjan      
Avatar
RankRankRankRank

Total Posts: 213

Joined 2011-05-02

PM

You can request the channel ID using ANT_ReferenceLibrary.RequestMessageID.CHANNEL_ID_0x51.

Cheers      
RankRank

Total Posts: 33

Joined 0

PM

To detect the device id, i use the following code:
Dim iDResp As ANT_Response

iDResp = device.requestMessageAndResponse(ANT_ReferenceLibrary.RequestMessageID.CHANNEL_ID_0x51, 500)

I only got information of the first channel.

What am I doing wrong.      
Avatar
RankRankRankRank

Total Posts: 213

Joined 2011-05-02

PM

This message is used to get the ID of a specific channel, so it needs to be done on a per channel basis.

This is some sample code you could go from:

ANT_Response IDresp = ant_channel.getParentDevice().requestMessageAndResponse(ant_channel.getChannelNum(), ANT_ReferenceLibrary.RequestMessageID.CHANNEL_ID_0x51, 500);

Note that ant_channel is just one ANT channel. If you want to do this for each of your channels you will have to do this 4 separate times, with the proper channel for each iteration.

Cheers      
RankRank

Total Posts: 33

Joined 0

PM

Hi Rizopoulus,

Thanks, it works perfect.

Simple solution.

Thanks.

Best Regard
Klaasjan