Herunterladen Inhalt Inhalt Diese Seite drucken

Mitsubishi Electric MELSEC System Q Bedienungsanleitung Seite 444

Speicher programmierbare steuerungen
Vorschau ausblenden Andere Handbücher für MELSEC System Q:
Inhaltsverzeichnis

Werbung

Programmbeispiel für ein verbundenes Gerät
// Per form receiv ing size check and receiv ing pro cess ing simul ta neously
rbuf_idx = 0;
recv_size = 0;
while(1) {
}
r_buf[rbuf_idx] = '\0' ;
printf(„\n receive data\n%s\n",r_buf);
//
strcpy((char *)(s_buf), „01FF000A4420000000000500"); // D0 to D4 batch read request
strcpy((char *)(s_buf), „500000FF03FF000018000A04010000D*0000000005");
length = strlen((char *)(s_buf));
if(send(socketno, (char *)(s_buf), length, 0) == SOCKET_ERROR) {
}
printf(„\n send data\n%s\n",s_buf);
(Fort set zung auf der nächs ten Seite)
// Per form receiv ing size check and receiv ing pro cess ing simul ta neously
A - 54
length = recv(socketno, (char*) (&r_buf[rbuf_idx]), (BUF_SIZE - rbuf_idx), 0);
if(length == 0) { // Is con nec tion cut off?
Sockerror(ERROR_RECEIVE);
return (SOCK_NG);
}
if(length == SOCKET_ERROR) {
nErrorStatus = WSAGetLastError();
if(nErrorStatus != WSAEWOULDBLOCK) {
Sockerror(ERROR_RECEIVE);
return (SOCK_NG);
} else {
con tinue;
}
} else {
rbuf_idx += length;
recv_size += length;
if(recv_size >= RECV_ANS_1)
break;
}
Sockerror(ERROR_SEND);
return (SOCK_NG);
// Receive data stor age head index ini tial iza tion
// Ini tial ize the num ber of receive data
// Response data receiv ing
// Error han dling
// Error han dling
// Repeat until mes sages are received
// Update the receive data stor age
// posi tion
// Update the num ber of receive data
// Have all response mes sages been
// received?
// Stop repeat ing as mes sages have
// been received
// Set NULL at the end of receive data
// (1E frame)
// D0 to D4 batch read request
// (3E frame)
// Data send ing
// Error han dling
An hang
MITSUBISHI ELECTRIC

Werbung

Inhaltsverzeichnis
loading

Diese Anleitung auch für:

Qj71e71-b2Qj71e71-b5Qj71e71-100

Inhaltsverzeichnis