Omron CS CJ1W-ETN21 User Manual
Page 213
![background image](/manuals/203138/213/background.png)
189
FINS/TCP Method
Section 7-4
139 alarm(RESP_TIMEOUT); /*
140
printf("FINS/TCP header send length %d¥n",sendlen);
141
}
142
else {
143
err_exit("FINS/TCP header send error");
144
}
145
146
147
/* SEND FINS COMMAND FRAME*/
148
/*
149
*
150
* (READ 150 WORDS FROM DM 100)
151
*/
152
fins_cmnd[0] = 0x80; /* ICF */
153
fins_cmnd[1] = 0x00; /* RSV */
154
fins_cmnd[2] = 0x02; /* GCT */
155
fins_cmnd[3] = 0x00; /* DNA */
156
fins_cmnd[4] = srv_node_no; /* DA1 *//*
157
fins_cmnd[5] = 0x00; /* DA2 */
158
fins_cmnd[6] = 0x00; /* SNA */
159
fins_cmnd[7] = cli_node_no; /* SA1 *//*
160
161
fins_cmnd[8] = 0x00; /* SA2 */
162
fins_cmnd[9] = ++sid; /* SID */
163
fins_cmnd[10] = 0x01; /* MRC */
164
fins_cmnd[11] = 0x01; /* SRC */
165
fins_cmnd[12] = 0x82; /*
166
fins_cmnd[13] = 0x00; /*
167
fins_cmnd[14] = 0x64;
168
fins_cmnd[15] = 0x00;
169
fins_cmnd[16] = 0x00; /*
170
fins_cmnd[17] = 0x96;
171
/* SEND FINS COMMAND FRAME*/
172
signal(SIGALRM,recv_fail);
173
sendlen = 18;
174
if (send(sockfd,fins_cmnd,sendlen,0) == sendlen)
175
{
176
printf("send
length
%d¥n",sendlen);
177
}
178
else
179
{
180
err_exit("send
error");
181
}
182
183
/* RECEIVE FINS/TCP COMMAND (READ RECEIVE FUNCTIONS)*/
184
recvlen = 16;
185
if (tcp_recv(sockfd, fins_tcp_header, recvlen) == recvlen)
186
{
187
/*
CONFIRM WHETHER FINS FRAME SEND COMMAND WAS RECEIVED*/
188
if ((fins_tcp_header[8] != 0x00) || (fins_tcp_header[9] != 0x00) ||
189
(fins_tcp_header[10] != 0x00) || (fins_tcp_header[11] != 0x02))
190
{
191
err_exit("FINS/TCP
illegal
command
error");
GENERATE MEMORY AREA READ COMMAND
Ethernet Unit FINS NODE NUMBER*/
WS FINS NODE NUMBER OBTAINED
AUTOMATICALLY*/
VARIABLE TYPE: DM*/
READ START ADDRESS: 100*/
WORDS READ: 150*/
START RESPONSE MONITOR TIMER*/