Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

How change CAN type in C (PCI-CAN/XS2 card) without MAX

I would like change CAN type (High speed-low speed) with C language. I have the PCI-CAN/XS2 card.
I search an example code or an description to explain how I can do .
thank
0 Kudos
Message 1 of 6
(4,403 Views)
Hi,

Use a standart example from Ni.
Take care that they are using a Network Interface Object.

1. ncConfig --> with start on open = FALSE
2. ncOpenObejct --> Networkinface
3. ncSetAttribute --> NC_ATTR_TRANCEIVER_TYPE
desired Value(see CAN_HELP 11-77)
4. ncAction --> Start

changing

n. ncAction --> Stop
n+1 ncSetAttribute
n+2 ncAction --> Start

Hope this helps

Greetings
Juergen
0 Kudos
Message 2 of 6
(4,403 Views)
Hi,

one more thing: Given that a mismatch of transceiver type and cable medium can cause problems for other devices on the network, it's best to add a step where you set the transceiver mode to the 'disconnected'. That's the best point to change the cables or change the tranceiver on your other devices without having mentioned mismatch.

Here's Channel API version (LabVIEW API) of Juergen's sequence:
1. CAN Init
2. CAN Set Property (Interface Tranceiver Type)
3. CAN Start

To change the transceivers:

n. CAN Stop
n+1 CAN Set Property (Interface Tranceiver Type » Disconnected)
n+2 Now change the cables or the device
n+3 CAN Set Property (Interface Tranceiver Type » desired tranceiver type)
n+4 CAN Start

Greetings,
B2k
0 Kudos
Message 3 of 6
(4,403 Views)
Hi, Biker2000

Thank you for this IMPORTANT hint

Greetings from
the lake of constance, Germany

Juergen
0 Kudos
Message 4 of 6
(4,403 Views)
Hi,

Here is an example which demonstrates the use of the attribute Transceiver Type (for CVI) for XS CAN devices.

Matthieu Gourssies
National Instruments
0 Kudos
Message 5 of 6
(4,402 Views)
Hi Matthieu,

one would need to add the step with the disconnect to your C example (see my above comment):

// ***************************************************
// Bring the receiving Network Interface Object into LOW SPEED
   ...
   Sleep(2000);

// Disconnect the transceiver from the CAN bus
   TransceiverType = NC_TRANSCEIVER_TYPE_DISC;
   Status = ncSetAttribute (RxHandle, NC_ATTR_TRANSCEIVER_TYPE, sizeof (TransceiverType), &TransceiverType);
   PrintStat (Status, "ncSetAttribute CAN0 (disconnected)");
   printf ("Transceiver type set = %d\n", TransceiverType);

/*
   Wait (until the user switched the cables);
*/

// Bring t
he receiving Network Interface Object into HIGH SPEED
   ...
   Sleep(2000);

// ***************************************************

-B2k
0 Kudos
Message 6 of 6
(4,403 Views)