From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting installed CAN card.

Hi,

I am trying to detect what CAN/DeviceNet cards is installed on the computer and I am having a problem.

I use ncGetHardwareInfo() to find all cards and I use this to check if the card is a high-speed card. This works fine the first time I run my program. However, if I run the program again, it doesn't detect the card as a high-speed card. The code I get back is '5' (instead of '0' for high-speed), which is not defined in the nican.h at all. I have to reboot the computer again to be able to detect the card correctly again.

This is a Windows 2000 machine with NI-DNET v1.4.2 installed and a PCI 1 port card.

Thanks,

Olav Haugan
0 Kudos
Message 1 of 10
(5,195 Views)

Hi Olav,

I can not reproduce your problem. Perhaps you can provide an example which shows the behavior?

I assume you are using multiple devices with mixed configuration of DNet and CAN?  Do you have only Series 1 boards installed or also Series 2 boards?

Which CAN driver are you using for the Get Hardware Info VI?

DirkW

0 Kudos
Message 2 of 10
(5,185 Views)
I am only using one card as a DeviceNet card. There is only 1 card installed.
 
Here is the sample code. I have removed all error checking to simplify a bit:
 
ncGetHardwareInfo(1, 1, NC_ATTR_NUM_CARDS, 4, &number_of_cards);
for(unsigned int i = 1; i <= number_of_cards; i++)
{
    unsigned int series = 0;
    ncGetHardwareInfo(i, 1, NC_ATTR_HW_SERIES, 4, &series);
    if(series == NC_HW_SERIES_1)
    {
        unsigned int formfactor = 0;
        ncGetHardwareInfo(i, 1, NC_ATTR_HW_FORMFACTOR, 4, &formfactor);
        if(formfactor == NC_HW_FORMFACTOR_PCMCIA)
        {
            unsigned int intf = 0;
            ncGetHardwareInfo(i, 1, NC_ATTR_INTERFACE_NUM, 4, &intf);
            sprintf(buf, "DNET%u", intf);
            interfaces.push_back(buf);
        }
        else
        {
            unsigned int type = 0;
            ncGetHardwareInfo(i, 1, NC_ATTR_TRANSCEIVER_TYPE, 4, &type);
            if(type == NC_TRANSCEIVER_TYPE_HS)
            {
                unsigned int intf = 0;
                ncGetHardwareInfo(i, 1, NC_ATTR_INTERFACE_NUM, 4, &intf);
                sprintf(buf, "DNET%u", intf);
                interfaces.push_back(buf);
            }
            else
            {
              //error, not high-speed
              //This is where I end up. "type" returns "5" which is not a valid transceiver type..
            }
        }
    }
}
 
 
I am using version 1.4.2 of NI-DNET.
0 Kudos
Message 3 of 10
(5,179 Views)
Are you using a Series 1 can card, or a series 2 can card?

Matt S.

LabVIEW Integration Engineer with experience in LabVIEW Real-Time, LabVIEW FPGA, DAQ, Machine Vision, as well as C/C++. CLAD, working on CLD and CLA.
0 Kudos
Message 4 of 10
(5,154 Views)
Hi Haugan,
 
Yes the code looks good, as far as i see, but i can still not reproduce your 5. It would be helpful if you could run the NI Spy during execution of your Code.
The Spy can log all the API calls to a file, so we can get the attribute 5 in the Log File, if it ocurs.
You can find the Spy within Start>>Programs>>National Instruments.
 
DirkW
0 Kudos
Message 5 of 10
(5,154 Views)
Hi,

Here is a SPY capture of the run of the program when it failes with '5'. Please note that if I in my application ignore the fact that it returns '5' instead of the correct value I can use the card as if nothing is wrong. However, that is just a temporary fix until we figure out what is really wrong.

Thanks,

Olav Haugan
0 Kudos
Message 6 of 10
(5,103 Views)

Hi Haugan,

This is unbelievable. Can you give me your Device Serial number, to check which version it is, so we can check the same with this revision?

Dirk W
0 Kudos
Message 7 of 10
(5,093 Views)
Hi,

Here is the information you requested (and more...):

SERIAL# D7E454 -- as reported by NI MAX
SERIES 1.
PROTOCOL DEVICENET

------------------------------------------------------
As reported by windoze device manager
PCI SLOT 5, PCI BUS 2, DEVICE 13, FUNCTION 0
INTERRUPT REQUEST 9, NO CONFLICTS
DRIVER, PCI CAN 2.3.2.12289

MEMORY RANGE E6004000-E60047FF
MEMORY RANGE E6000000-E6003FFF

------------------------------------------------------

Olav Haugan
0 Kudos
Message 8 of 10
(5,090 Views)

Hi Olav,

I tried the same revision but still could not reproduce the problem. Try to use one of our  hidden properties, to identify the transceiver ID correctly.

The property is 0x80020020 for ncget hardware info, and should give you a 1 for Series 1 High Speed.

DirkW

0 Kudos
Message 9 of 10
(5,069 Views)

Hi,

Maybe what I am doing the first time I use the card causes the card to go into a weird state resulting in a '5' returned. Attached is a trace of what I do the first time when it is working. After this the card starts reporting '5' and I have to reboot. You can see that I try to open an explicit message connection to myself (I use '0' as the MAC ID for my interface card) which of course returns with error. Maybe this is why I have problems? Could you try to see if you can reproduce this?

Thanks,

Olav Haugan

 

0 Kudos
Message 10 of 10
(5,064 Views)