83
CHAPTER 7 COMMUNICATION OF THE ETHERNET ADAPTER MODULE
7
7.
1 SLM
P
Com
m
unicat
ion
and Cyc
lic
T
ransm
ission
hostdata.sin_family = AF_INET;
hostdata.sin_port = sc.my_port;
hostdata.sin_addr.s_addr = sc.my_addr.s_addr;
if(bind(socketno, (LPSOCKADDR)&hostdata, sizeof(hostdata)) != SOCK_OK) { // Bind
Sockerror(ERROR_BIND); // Error handling
return
(SOCK_NG);
}
EthernetAD.sin_family = AF_INET;
EthernetAD.sin_port = sc.aj_port;
EthernetAD.sin_addr.s_addr = sc.aj_addr.s_addr;
if(connect(socketno, (LPSOCKADDR)&EthernetAD, sizeof(EthernetAD)) != SOCK_OK) {
// Connect (Active open)
Sockerror(ERROR_CONNECT); // Error handling
return
(SOCK_NG);
}
Closeflag = FLAG_ON;
// Connection end flag on
// Make non-blocking mode active.
ulCmdArg = 1;
ioctlsocket(socketno, FIONBIO, &ulCmdArg);
// Set to non-blocking mode
k = 1;
while (k) {
printf("For the Read command, enter 1.\n");
printf("For the Write command, enter 2.\n");
printf("For ending, enter a value other than 1 and 2.\n");
printf(">");
scanf_s("%d",
&j);
switch (j) {
case
1:
//Creates a frame requesting for reading RY0000 to RY001F devices (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] = 0x0c;
// Setting request data length (12 bytes)
s_buf[8] = 0x00;
s_buf[9] = 0x10;
// Setting CPU monitoring timer
s_buf[10] = 0x00;
s_buf[11] = 0x01; // Setting command (batch read of word data)
s_buf[12] = 0x04;
s_buf[13] = 0x00; // Setting subcommand
s_buf[14] = 0x00;
s_buf[15] = 0x00; // Setting device number 000000
s_buf[16] = 0x00;
s_buf[17] = 0x00;
s_buf[18] = 0x9d; // Setting device code (Y)
s_buf[19] = 0x02; // Setting device points (2 words)
s_buf[20] = 0x00;
Содержание NZ2GF-ETB
Страница 1: ...CC Link IE Field Network Ethernet Adapter Module User s Manual NZ2GF ETB ...
Страница 2: ......
Страница 49: ...47 CHAPTER 4 PROCEDURE BEFORE THE OPERATION 4 4 1 Start Up Procedure Memo ...
Страница 82: ...80 10 The following dialog box is displayed 11 Set the switch on the Ethernet adapter module to RUN Click ...
Страница 198: ...196 a Detail Setting ...
Страница 246: ...244 Memo ...
Страница 253: ......