Chapter 8 Ethernet coupler
Manual VIPA System 200V
8-32
HB97E - IM - Rev. 06/29
Socket
System
1.
2.
3.
4.
5.
6.
PC
Slave
TCP Socket
IP: 172.16.192.50
Port: 1200
TCP Socket
ModbusTCP Server
IP: 172.16.192.11
Port: 502
TCP Socket
IP: 172.16.192.50
Port: 1200
TCP Socket
ModbusTCP Server
IP: 172.16.192.11
Port: 502
TCP Socket
Data
IP: 172.16.192.50
Port: 1200
TCP Socket
IP: 172.16.192.50
IP: 172.16.192.11
IP: 172.16.192.50
Port: 1200
TCP Socket
Programming sample
For the deployment of the Ethernet couplers at a PC you should have a
thorough knowledge in C programming, especially in socket programming.
This section gives you a short overview about the programming.
to 1.
Start Microsoft Socket
System
WSAStartup (wVersionRequested, &wsaData);
to 2.
Reserve Socket
resources for TCP
m_lsock = socket (AF_INET, SOCK_STREAM, 0):
to 3.
Link-up the socket to the
local PC
SockAddr.sin_port = htons( 0 );
SockAddr.sin_addr.S_un.S_addr = inet_addr( "0.0.0.0" );
bind(m_lsock, (LPSOCKADDR) &SockAddr, sizeof(SockAddr));
By calling
bind
with the value 0 for port and IP address, the socket gets the PC-IP
address and the next free Port.
(here: IP: 172.16.192.50, Port: 1200)
to 4.
Establish connection to
external device
SockAddr.sin_port = htons (m_wPort);
SockAddr.sin_addr.S_un.S_addr = inet_addr(m_szIpAddress);
connect(m_lsock, (LPSOCKADDR) &SockAddr, sizeof(SockAddr));
to 5.
For write res. read access you have to build up telegrams according to the protocol and
store them in sndBuf.
sndBufLen contains the number of Bytes to be sent.
Read access
Send sndBuf (Request)
send(m_lsock, (char *)sndBuf, sndBufLen, 0);
Receive telegram in
rcvBuf (Rdata)
recv(m_lsock, (char *)rcvBuf, sizeof(rcvBuf), 0);
Write access
Send sndBuf
(data)
send(m_lsock, (char *)sndBuf, sndBufLen, 0);
Receive telegram in
rcvBuf (Response)
recv(m_lsock, (char *)rcvBuf, sizeof(rcvBuf), 0);
to 6.
Close socket again
closesocket(m_lsock);
Steps of
Programming
An easy programming sample can be downloaded under ftp.vipa.de/support
Demo Client: Cx000059.
Summary of Contents for System 200V IM Series
Page 1: ...Manual VIPA System 200V IM Order No VIPA HB97E_IM Rev 06 29...
Page 2: ...Lerrzeichen...
Page 6: ...About this manual Manual VIPA System 200V Subject to change to cater for technical progress...
Page 10: ...Contents Manual VIPA System 200V iv HB97E IM Rev 06 29...
Page 18: ...Chapter 1 Basics Manual VIPA System 200V 1 6 HB97E IM Rev 06 29...
Page 136: ...Chapter 3 Profibus DP Manual VIPA System 200V 3 104 HB97E IM Rev 06 29...
Page 338: ...Chapter 8 Ethernet coupler Manual VIPA System 200V 8 34 HB97E IM Rev 06 29...
Page 344: ...Chapter 9 Bus expansion modules IM 260 IM 261 Manual VIPA System 200V 9 6 HB97E IM Rev 06 29...