Omron CS CJ1W-ETN21 User Manual

Page 194

Advertising
background image

170

FINS/UDP Method

Section 7-3

85 /*

RECEIVE FINS RESPONSE*/

86

addrlen = sizeof(cs_addr);

87

88

if ((recvlen = recvfrom(sockfd,fins_resp,MAX_MSG,0,&cs_addr,&addrlen)) < 0)

89 {

90

if (errno == EINTR)

91 goto

CMND_SEND;

/*

92 err_exit("receive

error");

93 }

94 else

95 {

96

alarm(0); /*

97 printf("recv

length

%d¥n",recvlen);

98

99

if (recvlen < 14) /*

100 err_exit("FINS

length

error");

101

if ((fins_cmnd[3] != fins_resp[6]) || (fins_cmnd[4] != fins_resp[7]) ||

102 (fins_cmnd[5]

!=

fins_resp[8])

)

103 {

/*

104 err_exit("illegal

source

address

error");

105 }

106

if(fins_cmnd[9] != fins_resp[9]) /* SID CHECK*/

107 err_exit("illegal

SID

error");

108 }

109

110 /*

111 close(sockfd);

112

113 }

114

115

116 /*

117 *

118 */

119 err_exit(err_msg)

120 char *err_msg;

121 {

122

printf("client: %s %x¥n",err_msg,errno);

123 exit(1);

124 }

125

126 /*

127 *

128 */

129 recv_fail()

130 {

131

printf("response timeout error ¥n");

132 }

RE-SEND FINS COMMAND*/

STOP RESPONSE MONITOR TIMER*/

ILLEGAL RESPONSE LENGTH CHECK*/

DESTINATION ADDRESS CHECK*/

CLOSE SOCKET*/

ERROR PROCESSING FUNCTIONS

SIGNAL CAPTURE FUNCTIONS

Advertising