안녕하세요.
W5100 을 사용해 TCP/IP 통신을 하고 있고, i/o lib 은 Ver 1.9를 사용 중입니다.
사용 도중, socket.h 의 send() API 를 non-blocking 으로 수정 및 사용하고 싶은데, 문의 드릴 것이 있어
글 남기게 되었습니다.
/**
@brief This function used to send the data in TCP mode
@return 1 for success else 0.
*/
uint16 send(
SOCKET s, /**< the socket index */
const uint8 * buf, /**< a pointer to data */
uint16 len /**< the data size to be send */
)
{
uint8 status=0;
uint16 ret=0;
uint16 freesize=0;
#ifdef __DEF_IINCHIP_DBG__
printf("send()\r\n");
#endif
if (len > getIINCHIP_TxMAX(s)) ret = getIINCHIP_TxMAX(s); // check size not to exceed MAX size.
else ret = len;
// if freebuf is available, start.
do
{
freesize = getSn_TX_FSR(s);
status = IINCHIP_READ(Sn_SR(s));
if ((status != SOCK_ESTABLISHED) && (status != SOCK_CLOSE_WAIT))
{
ret = 0;
break;
}
#ifdef __DEF_IINCHIP_DBG__
printf("socket %d freesize(%d) empty or error\r\n", s, freesize);
#endif
} while (freesize < ret);
// copy data
send_data_processing(s, (uint8 *)buf, ret);
**IINCHIP_WRITE(Sn_CR(s),Sn_CR_SEND);**
=> 이 부분에서, send 명령 후 Sn_IR 확인을 통해 SEND_OK interrupt 를 확인하는 것으로 보이는데,
이 interrupt 발생 시점이 data 전송 후, ACK 를 통해 전송 완료 확인까지 한 뒤인가요?
만약, 통신 오류로 ACK 를 받지 못한 경우에도 SEND_OK 가 발생하는지, 그리고 ACK 를 받지 못한 경우,
자체적으로 RCR, RTR 에 따라 Retry 를 시도한 뒤, Timeout Interrupt 를 발생하나요?
/* +20071122[chungs]:wait to process the command... */
while( IINCHIP_READ(Sn_CR(s)) )
;
/* ------- */
/* +2008.01 bj */
#ifdef __DEF_IINCHIP_INT__
while ( (getISR(s) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK )
#else
while ( (IINCHIP_READ(Sn_IR(s)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK )
#endif
{
/* m2008.01 [bj] : reduce code */
if ( IINCHIP_READ(Sn_SR(s)) == SOCK_CLOSED )
{
#ifdef __DEF_IINCHIP_DBG__
printf("SOCK_CLOSED.\r\n");
#endif
close(s);
return 0;
}
}
/* +2008.01 bj */
#ifdef __DEF_IINCHIP_INT__
putISR(s, getISR(s) & (~Sn_IR_SEND_OK));
#else
IINCHIP_WRITE(Sn_IR(s), Sn_IR_SEND_OK);
#endif
return ret;
}
질문
IINCHIP_WRITE(Sn_CR(s),Sn_CR_SEND);
=> 이 부분에서, send 명령 후 Sn_IR 확인을 통해 SEND_OK interrupt 를 확인하는 것으로 보이는데,
이 interrupt 발생 시점이 data 전송 후, ACK 를 통해 전송 완료 확인까지 한 뒤인가요?
만약, 통신 오류로 ACK 를 받지 못한 경우에도 SEND_OK 가 발생하는지, 그리고 ACK 를 받지 못한 경우,
자체적으로 RCR, RTR 에 따라 Retry 를 시도한 뒤, Timeout Interrupt 를 발생하나요?