W5500 Client TCP: sending status flag

Hello all:
Now, when sending data to server is working well, finally, i am looking for a status flag that will let me know when send() is free for the next transaction, as I want to send data blocks (34 bytes) continuously, as fast as possible.
Any idea?
Thanks
Dan

You can check it via Sn_IR register. There is a SEND_OK register that is set when SEND command is completed.

But if you are using iolibrary, the send() function waits for the same signal so that you don’t need to check other flags.

Thanks.

I know the SEND_OK flag but the sock_is_sending flag is checked at the begining of send() and it high due to previos send(). So it check the SEND_OK which already released in previos send()…So i got BUSSY at second send()…
I think that I can manage…
Thanks
Dan

Hi, I have same problem. And I wander how sned() should work. New interrupt clear socket interrupt register with new flags. Hence " sock_is_sending" flag will be always set on because SENDOK never appear again.
Any idea?
Thanks
Krzysztof

…Hi, I was surprised by your question so long time since my post was sent
I have working very nice since than/ see code of my SEND() proc:
int32_t send(uint8_t sn, uint8_t * buf, uint16_t len)
{
uint8_t tmp=0, SendOK=FALSE;;
uint16_t freesize=0;

// printf("\r\nSending proc …\r\n\0" );
CHECK_SOCKNUM();
CHECK_SOCKMODE(Sn_MR_TCP);
CHECK_SOCKDATA();

tmp = getSn_SR(sn);

if(tmp != SOCK_ESTABLISHED && tmp != SOCK_CLOSE_WAIT)
return SOCKERR_SOCKSTATUS;

if( sock_is_sending & (1<<sn) )
{

      tmp = getSn_IR(sn);
      if(tmp & Sn_IR_SENDOK)
      {
         setSn_IR(sn, Sn_IR_SENDOK);
         sock_is_sending &= ~(1<<sn);

      }
      else if(tmp & Sn_IR_TIMEOUT)
      {
          close(sn);
           printf("Sending SOCKERR_TIMEOUT..\r\n\0" );
          return SOCKERR_TIMEOUT;
      }
      else
      {
           printf("Sending SOCK_BUSY..\r\n\0" );
           return SOCK_BUSY;
      }

}

// freesize = getSn_TxMAX(sn);
// if (len > freesize) len = freesize; // check size not to exceed MAX size.
while(1)
{
freesize = getSn_TX_FSR(sn);
tmp = getSn_SR(sn);
if ((tmp != SOCK_ESTABLISHED) && (tmp != SOCK_CLOSE_WAIT))
{
close(sn);
return SOCKERR_SOCKSTATUS;
}
if( (sock_io_mode & (1<<sn)) && (len > freesize) ) return SOCK_BUSY;
if(len <= freesize) break;
}

// printf("\r\nSending proc: wiz_send_data …\r\n\0",len );
wiz_send_data(sn, buf, len);

setSn_CR(sn,Sn_CR_SEND);
/* wait to process the command… */
while(getSn_CR(sn));

while(1)
{
tmp = getSn_IR(sn);
if(tmp & Sn_IR_SENDOK)
{
// setSn_IR(sn, Sn_IR_SENDOK); ???
SendOK = TRUE;
TxMsg(“SEND OK…\r\n\0”);

     break;
  }

  else if(tmp & Sn_IR_TIMEOUT)
  {
     setSn_IR(sn, Sn_IR_TIMEOUT);
      TxMsg("SOCKER_TIMEOUT..\r\n\0");
     return SOCKERR_TIMEOUT;
  }
  ////////////

}
sock_is_sending |= (1 << sn);

// return (int32_t)len;
return (int32_t)SendOK;
}
Good luck
Dan

1 Like