Mitsubishi Electric MELSEC-L SERIES Basic User Manual page 360

Melsec-l ethernet interface module
Hide thumbs Also See for MELSEC-L SERIES:
Table of Contents

Advertisement

// Perform receiving size check and receiving processing simultaneously
rbuf_idx = 0;
recv_size = 0;
while(1) {
length = recv(socketno, (char*) (&r_buf[rbuf_idx]), (BUF_SIZE - rbuf_idx), 0);
if(length == 0) { // Is connection cut off?
Sockerror(ERROR_RECEIVE);
return (SOCK_NG);
}
if(length == SOCKET_ERROR) {
nErrorStatus = WSAGetLastError();
if(nErrorStatus != WSAEWOULDBLOCK) {
Sockerror(ERROR_RECEIVE);
return (SOCK_NG);
} else {
continue;
}
} else {
rbuf_idx += length;
recv_size += length;
if(recv_size >= RECV_ANS_1)
break;
}
}
r_buf[rbuf_idx] = '\0' ;
printf("\n receive data\n%s\n",r_buf);
//
strcpy((char *)(s_buf), "01FF000A4420000000000500");
strcpy((char *)(s_buf), "500000FF03FF000018000A04010000D*0000000005");
length = strlen((char *)(s_buf));
if(send(socketno, (char *)(s_buf), length, 0) == SOCKET_ERROR) {
Sockerror(ERROR_SEND);
return (SOCK_NG);
}
printf("\n send data\n%s\n",s_buf);
358
// Receive data storage head index initialization
// Initialize the number of receive data
// Response data receiving
// Error handling
// Error handling
// Repeat until messages are received
// Update the receive data storage
// position
// Update the number of receive data
// Have all response messages been
// received?
// Stop repeating as messages have
// been received
// Set NULL at the end of receive data
// D0 to D4 batch read request
// (1E frame)
// D0 to D4 batch read request
// (3E frame)
// Data sending
// Error handling

Advertisement

Table of Contents
loading

Table of Contents