![](/images/new-backgrounds/1193384/193384425x1.webp)
FINS/TCP Method | Section | ||
|
|
|
|
139 | alarm(RESP_TIMEOUT); /* START RESPONSE MONITOR TIMER*/ | ||
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* GENERATE MEMORY AREA READ COMMAND
150* (READ 150 WORDS FROM DM 100)
151*/
152fins_cmnd[0] = 0x80; /* ICF */
153fins_cmnd[1] = 0x00; /* RSV */
154fins_cmnd[2] = 0x02; /* GCT */
155fins_cmnd[3] = 0x00; /* DNA */
156fins_cmnd[4] = srv_node_no; /* DA1 *//* Ethernet Unit FINS NODE NUMBER*/
157fins_cmnd[5] = 0x00; /* DA2 */
158fins_cmnd[6] = 0x00; /* SNA */
159fins_cmnd[7] = cli_node_no; /* SA1 *//* WS FINS NODE NUMBER OBTAINED
160 | AUTOMATICALLY*/ |
|
161fins_cmnd[8] = 0x00; /* SA2 */
162fins_cmnd[9] = ++sid; /* SID */
163fins_cmnd[10] = 0x01; /* MRC */
164fins_cmnd[11] = 0x01; /* SRC */
165fins_cmnd[12] = 0x82; /* VARIABLE TYPE: DM*/
166fins_cmnd[13] = 0x00; /* READ START ADDRESS: 100*/
167fins_cmnd[14] = 0x64;
168fins_cmnd[15] = 0x00;
169fins_cmnd[16] = 0x00; /* WORDS READ: 150*/
170fins_cmnd[17] = 0x96;
171SEND FINS COMMAND FRAME*/
172signal(SIGALRM,recv_fail);
173sendlen = 18;
174if (send(sockfd,fins_cmnd,sendlen,0) == sendlen)
175{
176printf("send length %d¥n",sendlen);
177}
178else
179{
180err_exit("send error");
181}
182
183/* RECEIVE FINS/TCP COMMAND (READ RECEIVE FUNCTIONS)*/
184recvlen = 16;
185if (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{
191err_exit("FINS/TCP illegal command error");