W5100 can't send a zero

Hello everybody,

I have a problem with mit w5100.
I want to send a byte array look like this uint8_t data[8] = {0x62, 0xC8, 0x03, 0xC8, 0x00, 0x43, 0xC8, 0x00};
And now there is the problem, when I send this array the first 4 bytes were send, but after 0x00 all position wont be send.
Do I have to escape this 0x00?

Does anyone know how I can fix the problem? :unamused:


Hi oadna,

W5100 can send a zero (0x00). :smiley:

Please, check data length, data copy or updating Sn_TX_WR in your code.

Reference Code is [url]http://www.wiznet.co.kr/sub_modules/kr/product/product_detail.asp?Refid=677&page=1&cate1=5&cate2=7&cate3=26&pid=1019&cType=2[/url].

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;

   if (len > getIINCHIP_TxMAX(s)) ret = getIINCHIP_TxMAX(s); // check size not to exceed MAX size.
   else ret = len;

   // if freebuf is available, start.
    freesize = getSn_TX_FSR(s);
    status = IINCHIP_READ(Sn_SR(s));
    if ((status != SOCK_ESTABLISHED) && (status != SOCK_CLOSE_WAIT))
      ret = 0;
  } while (freesize < ret);

  // copy data
  send_data_processing(s, (uint8 *)buf, ret);

  /* +20071122[chungs]:wait to process the command... */
  while( IINCHIP_READ(Sn_CR(s)) )
  /* ------- */

#ifdef __DEF_IINCHIP_INT__
  while ( (getISR(s) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK )
  while ( (IINCHIP_READ(Sn_IR(s)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK )
    /* m2008.01 [bj] : reduce code */
    if ( IINCHIP_READ(Sn_SR(s)) == SOCK_CLOSED )
#ifdef __DEF_IINCHIP_DBG__
      return 0;
#ifdef __DEF_IINCHIP_INT__
    putISR(s, getISR(s) & (~Sn_IR_SEND_OK));
    return ret;

void send_data_processing(SOCKET s, uint8 *data, uint16 len)
	uint16 ptr;

        /* read Sn_TX_WritePointer */
	ptr = IINCHIP_READ(Sn_TX_WR0(s));
	ptr = ((ptr & 0x00ff) << 8) + IINCHIP_READ(Sn_TX_WR0(s) + 1);

	write_data(s, data, (uint8 *)(ptr), len);
	ptr += len;
        /* update Sn_TX_WritePointer */
	IINCHIP_WRITE(Sn_TX_WR0(s),(uint8)((ptr & 0xff00) >> 8));
	IINCHIP_WRITE((Sn_TX_WR0(s) + 1),(uint8)(ptr & 0x00ff));


he, thanks for your reply.

I have tried it again and again, but it doesn`t work.
When i remove the 0x00 from the array, the whole array will be sent.
This is so crazy.


Hi oadna,

Please, attach your code.
We will review the code.


I attached the file, I hope you can find the error.
Thank you.
WebClient.c (17.4 KB)

Hi oadna,

We may find the error. :0

size_t strlen ( const char * str );
Get string length
Returns the length of the C string str.

The length of a C string is determined by the terminating null-character

So, your code should be change, as below

  • replace ‘strlen’ to ‘sizeof’
  • input data length directly
/* your code */
uint8_t data[8] = {0x62, 0xC8, 0x03, 0xC8, 0x00, 0x43, 0xC8, 0x00};
uint8_t end[2];
sprintf((char *) end, "\n\r");
if (send(sockreg,data,strlen((char *)data)) <= 0) break; //send data  <= here
printf((char *)data);
if (send(sockreg,end,strlen((char *)end)) <= 0) break; //send end   <= here

/*fix code*/
//if (send(sockreg,data,  sizeof((char *)data)) <= 0) break; //send data
if (send(sockreg,data,  8)) <= 0) break; //send data
printf((char *)data);
//if (send(sockreg,end, sizeof((char *)end)) <= 0) break; //send end
if (send(sockreg,end, 2)) <= 0) break; //send end


hi suhwan,

You helped me so much, thank you a lot.
Now my thesis is save. :smiley: