an ind 1 016 using lxi devices in canoe
TRANSCRIPT
8/9/2019 An IND 1 016 Using LXI Devices in CANoe
http://slidepdf.com/reader/full/an-ind-1-016-using-lxi-devices-in-canoe 1/6
8/9/2019 An IND 1 016 Using LXI Devices in CANoe
http://slidepdf.com/reader/full/an-ind-1-016-using-lxi-devices-in-canoe 2/6
Using LXI Devices in CANoe
2
Application Note AN-IND-1-016
Important: For this example the power supply CPX400SA from TTi was used. Some of the commands aredevice-dependent and can be different for other power supplies. Please read the appropriate usermanual of the device for the correct commands.
variables {
dword address_canoe;dword address_power_supply;
dword port = 9221; // used portchar buffer_id[16] = "*idn?" ; // Identification commandchar buffer_send_volt[128];char buffer_receive[128];
int output = 0; // output activate/deactivate
dword LXI_socket;}
on preStart {
address_canoe = IpGetAddressAsNumber( "192.168.100.1" ); // IP address PCaddress_power_supply = IpGetAddressAsNumber( "169.254.4.226" ); // IP address powersupply
}
on start {
LXI_socket = TcpOpen(address_canoe, port); // creation of an IP socket
TcpConnect(LXI_socket, address_power_supply, port); // connecting the IP socket}
on stopMeasurement {
TcpClose(LXI_socket);}
on sysvar sysvar ::LXI_Variables::var_ID // identification request{
if (1 == @ this ){
TcpSend(LXI_socket, buffer_id, strlen(buffer_id));TcpReceive(LXI_socket, buffer_receive, strlen(buffer_receive)); // Function toreceive data packets
}}
on sysvar sysvar ::LXI_Variables::var_Voltage // set voltage{
snprintf(buffer_send_volt, elcount (buffer_send_volt), "V1 %f" , @ this ); // creationof the command stringTcpSend(LXI_socket, buffer_send_volt, strlen(buffer_send_volt));TcpReceive(LXI_socket, buffer_receive, 128);
}
8/9/2019 An IND 1 016 Using LXI Devices in CANoe
http://slidepdf.com/reader/full/an-ind-1-016-using-lxi-devices-in-canoe 3/6
Using LXI Devices in CANoe
3
Application Note AN-IND-1-016
on key 'v' // measured output voltage{
TcpSend(LXI_socket, "V1 O?" , strlen( "V1 O?" ));TcpReceive(LXI_socket, buffer_receive, 128);
}
on key 'o' // activate/deactivate output{
if (0 == output){
TcpSend(LXI_socket, "OP1 1" , strlen( "OP1 1" ));output = 1;
}
else {
TcpSend(LXI_socket, "OP1 0" , strlen( "OP1 0" ));output = 0;
}}
void OnTcpReceive( dword socket, long result, dword address, dword port, char buffer[], dword size) // receive function{
write( "Received: %s" , buffer); // output of the received stringTcpReceive(LXI_socket, buffer_receive, 128);
}
2.1 Creating a network node
To create an interface a network node must be inserted into the test setup (“View” “Test Setup” right-click“New Test Environment” ”Insert Network Node”). The specification (.can file) for this node is the CAPL filedescribing the interface.
2.2 Including the IP addresses
To initialize the necessary socket for the communication the IP address of the PC and the power supply has to beconverted from a string (e.g. ‘192.168.100.1’) into a numerical value that can be used by the CAPL program. Forthis the CAPL function IpGetAddressAsNumber in the on preStart event handler is used.
on preStart {
address_canoe = IpGetAddressAsNumber( "192.168.100.1" ); // IP address PCaddress_power_supply = IpGetAddressAsNumber( "169.254.4.226" ); // IP address powersupply
}
2.3 Initiliazing a socket
After the IP addresses are converted the socket must be initiated. This can be done with the CAPL functionTcpOpen . This function needs the IP address of the PC and a port for the communication. Please remember that ithas to be a port that is not used by another program, in this case port 9221. After the socket is created it must be
8/9/2019 An IND 1 016 Using LXI Devices in CANoe
http://slidepdf.com/reader/full/an-ind-1-016-using-lxi-devices-in-canoe 4/6
8/9/2019 An IND 1 016 Using LXI Devices in CANoe
http://slidepdf.com/reader/full/an-ind-1-016-using-lxi-devices-in-canoe 5/6
Using LXI Devices in CANoe
5
Application Note AN-IND-1-016
on sysvar sysvar ::LXI_Variables::var_ID // identification request{
if (1 == @ this ){
TcpSend(LXI_socket, buffer_id, strlen(buffer_id));TcpReceive(LXI_socket, buffer_receive, strlen(buffer_receive)); // Function toreceive data packets
}}
on sysvar sysvar ::LXI_Variables::var_Voltage // set voltage{
snprintf(buffer_send_volt, elcount (buffer_send_volt), "V1 %f" , @ this ); // creationof the command stringTcpSend(LXI_socket, buffer_send_volt, strlen(buffer_send_volt));TcpReceive(LXI_socket, buffer_receive, 128);
}
on key 'v' // measured output voltage{
TcpSend(LXI_socket, "V1 O?" , strlen( "V1 O?" ));TcpReceive(LXI_socket, buffer_receive, 128);
}
on key 'o' // activate/deactivate output{
if (0 == output){
TcpSend(LXI_socket, "OP1 1" , strlen( "OP1 1" ));output = 1;
}
else {
TcpSend(LXI_socket, "OP1 0" , strlen( "OP1 0" ));output = 0;
}}
8/9/2019 An IND 1 016 Using LXI Devices in CANoe
http://slidepdf.com/reader/full/an-ind-1-016-using-lxi-devices-in-canoe 6/6
Using LXI Devices in CANoe
6
Application Note AN-IND-1-016
3.0 Contacts
Germanyand all countries not named below:
Vector Informatik GmbHIngersheimer Str. 2470499 StuttgartGERMANYPhone: +49 711-80670-0Fax: +49 711-80670-111E-mail: [email protected]
France, Belgium, Luxemburg:
Vector France S.A.S.168, Boulevard Camélinat92240 MalakoffFRANCEPhone: +33 1 42 31 40 00Fax: +33 1 42 31 40 09E-mail: [email protected]
Sweden, Denmark, Norway,Finland, Iceland:
VecScan ABTheres Svenssons Gata 941755 GöteborgSWEDENPhone: +46 31 764 76 00Fax: +46 31 764 76 19E-mail: [email protected]
United Kingdom, Ireland:
Vector GB Ltd.Rhodium, Central BoulevardBlythe Valley ParkSolihull, BirminghamWest Midlands B90 8ASUNITED KINGDOMPhone: +44 121 50681-50Fax: +44 121 50681-69
E-mail: [email protected]
China:
Vector Automotive Technology(Shanghai) Co., Ltd. Sunyoung Center, Room 1601-1603No.398 Jiang Su RoadChangning DistrictShanghai 200050P.R. CHINAPhone: +86 21 6432 53530Fax: +86 21 6432 5308E-mail: [email protected]
India:
Vector Informatik India Pvt. Ltd.4/1/1/1, Sutar Icon, Sus Road,Pashan, Pune - 411 021INDIA
Phone: +91 20 2587 2023Fax: +91 20 2587 2025
E-mail: [email protected]
USA, Canada, Mexico:
Vector CANtech, Inc.39500 Orchard Hill Place, Suite 550Novi, MI 48375USA
Phone: +1 248 449 9290Fax: +1 248 449 9704E-mail: [email protected]
Japan:
Vector Japan Co. Ltd.Tennozu Yusen Bldg. 16F2-2-20 Higashi-shinagawa,Shinagawa-ku,Tokyo 140-0002JAPANPhone: +81 3 5769 7800Fax: +81 3 5769 6975E-mail: [email protected]
Korea:
Vector Korea IT Inc. 5F, Gomoas bldg.12 Hannam-daero 11-gil, Yongsan-guSeoul, 140-889REPUBLIC OF KOREA
Phone: +82 2 807 0600Fax: +82 2 807 0601E-mail: [email protected]