How can I choose a specific Ethernet adapter for host-target communication using xPC Target 4.3 (R2010a) when my target PC has multiple adapters of the same type?

7 views (last 30 days)
In my target PC, I have multiple Ethernet adapters of the same type. I would like to specify which of these adapters is used for host-target communication. Similarly, after updating to xPC Target 4.3 (R2010a), the adapter automatically selected for host-target communication has changed. I would like to know how to force selection of the adapter to the one previously used for host-target communication.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Sep 2011
If your target PC has multiple Ethernet adapters of the same type, the kernel, upon booting, selects one of these adapters for host-target communication. Without manually testing, it is not possible to determine which physical Ethernet connector (port) is associated with the selected adapter.
Connect the host-target network cable to one of the Ethernet ports and issue the following command in the MATLAB Command Window:
xpctargetping
If the return status is "failed", move the network cable to a different Ethernet port on the target PC and retry. The above command will return "success" when you are connected to the port associated with the adapter in use for host-target communication.
You can manually select a different Ethernet adapter for host-target communication. The xPC Target kernel uses an indexing mechanism called "EthernetIndex" to identify adapters. Indexing starts at 0; hence, if you have two Ethernet adapters of the same type, one will be identified as EthernetIndex 0 and one as EthernetIndex 1. By default, the adapter identified as EthernetIndex 0 will be used for host-target communication. To switch adapters, issue the following command:
setxpcenv('EthernetIndex', '1');
You will need to recreate the kernel image and reboot for this to take effect.
If you want to change this selection for a target PC other than the default target PC (say, 'TargetPC2') , issue the following commands:
allTargets = xpctarget.targets;
myTargetEnv = allTargets.Item('TargetPC2');
set(myTargetEnv, 'EthernetIndex', '1');
If you have more than two Ethernet adapters of the same type, each will have a unique EthernetIndex (0, 1, 2, 3, …).
Note: If you are using the Network Boot method, it is possible that Ethernet adapter (A) used by the BIOS of the target PC to load and boot the xPC Target kernel is different from Ethernet adapter (B) chosen by the xPC Target kernel for host-target communication. For instance, consider this situation:
  • The xPC Target kernel loads and boots when the host-target network cable is attached to Ethernet adapter 'A'.
  • While booting, the xPC Target kernel selects Ethernet adapter 'B' for host-target communication.
After booting, you move the network cable from the port for adapter 'A' to the port for adapter 'B', you should now be able to communicate over the host target-link. However, communication will initially fail because the Windows OS on the host PC will have logged an entry in the Address Resolution Protocol (ARP) table associating the physical (MAC) address of adapter 'A' with the TCP/IP address selected for the target PC. To remove this association, confirm the host-target network cable is connected to the port for adapter 'B' and execute the following command in the MATLAB Command Window:
!arp –d
You should now be able to communicate with the target PC. To confirm, verify that "success" is returned when issuing the xpctargetping command. To circumvent this problem, use the method described above to force the xPC Target kernel to use adapter 'A' for host-target communication.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!