Deployment
Wieland Electric GmbH | BA001269 | 09/2021 (Rev. A)
45
Diagnosis
•
Configuration State: The current configuration status is shown here.
•
Diagnosis Entries: Here all pending diagnostic messages are shown.
•
Diagnosis Buffer: Here the content of the diagnostics buffer is listed.
Expert View
[Expert View] takes you to the advanced 'Expert View'.
6.4.2
C-/Socket programming
The Modbus/TCP server is accessed via port 502. Via simple C program it is possible to transfer data
between PC and Ethernet coupler with Modbus/TCP. For the deployment of the Ethernet couplers at
a PC you should have a thorough knowledge in C programming, especially in socket programming.
In the following the steps of programming are shown.
Start Microsoft Socket System
WSAStartup (wVersionRequested, &wsaData);
Reserve Socket resources for TCP
m_lsock = socket (AF_INET, SOCK_STREAM, 0):
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) &Sock-
Addr, sizeof(SockAddr));
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);
Close socket again
closesocket(m_lsock);
6.4.3
Modbus utility
The access is via port 502 at the Modbus/TCP server. Modbus utility means all tools and programs
that have a Modbus/TCP interface. For example, you may find the demo tool
'ModbusScan32'
from
WinTech for download at
www.win-tech.com
.
1
4
3
2
5