85
CHAPTER 7 COMMUNICATION OF THE ETHERNET ADAPTER MODULE
7
7.
1 SLM
P
Com
m
unicat
ion
and Cyc
lic
T
ransm
ission
case
2:
// Creates a frame requesting for writing to RWr0 and RWr1devices (3E frame)
s_buf[0] = 0x50; // Setting subheader
s_buf[1] = 0x00;
s_buf[2] = 0x00; // Setting network number
s_buf[3] = 0xff;
// Setting station number
s_buf[4] = 0xff;
// Setting request destination module I/O number
s_buf[5] = 0x03;
s_buf[6] = 0x00; // Setting request destination module station number
s_buf[7] = 0x10; // Setting request data length (16 bytes)
s_buf[8] = 0x00;
s_buf[9] = 0x10; // Setting CPU monitoring timer
s_buf[10] = 0x00;
s_buf[11] = 0x01; // Setting command (batch write of word data)
s_buf[12] = 0x14;
s_buf[13] = 0x00; // Setting subcommand
s_buf[14] = 0x00;
s_buf[15] = 0x00; // Setting device number 001000
s_buf[16] = 0x10;
s_buf[17] = 0x00;
s_buf[18] = 0xb4; // Setting device code (W)
s_buf[19] = 0x02; // Setting device points (2 words)
s_buf[20] = 0x00;
s_buf[21] = 0x34; // Setting write data
s_buf[22] = 0x12;
s_buf[23] = 0x78;
s_buf[24] = 0x56;
if(send(socketno, (char *)(s_buf), SEND_REQ_1, 0) == SOCKET_ERROR) {
// Data sending
Sockerror(ERROR_SEND); // Error handling
return
(SOCK_NG);
}
// Receiving data with the size checked
rbuf_idx = 0; // Initializes the head index of the receive data storage.
recv_size = 0; // Initializes the number of receive data.
while(1)
{
length = recv(socketno, (char *)(&r_buf[rbuf_idx]), (BUF_SIZE - rbuf_idx), 0);
// Receiving response data
if(length == 0) { // Was the connection cut off?
Sockerror(ERROR_RECIEVE); // Error handling
return
(SOCK_NG);
}
if(length == SOCKET_ERROR) {
nErrorStatus = WSAGetLastError();
if(nErrorStatus != WSAEWOULDBLOCK) {
Sockerror(ERROR_RECIEVE); // Error handling
return
(SOCK_NG);
} else {
continue;
// Repeat until data are received.
}
}
else
{
rb= length;
// Updates the receive data storage location.
rec= length;
// Updates the number of received data.
if(recv_size >= RECV_ANS_1) // Received all response messages?
break;
// Stops the repetition as they were received.
}
}
Summary of Contents for NZ2GF-ETB
Page 1: ...CC Link IE Field Network Ethernet Adapter Module User s Manual NZ2GF ETB ...
Page 2: ......
Page 49: ...47 CHAPTER 4 PROCEDURE BEFORE THE OPERATION 4 4 1 Start Up Procedure Memo ...
Page 198: ...196 a Detail Setting ...
Page 246: ...244 Memo ...
Page 253: ......