---
title: "Problem sending large data buffer with W5500 and ioLibrary"
url: "https://maker.wiznet.io/forum/12504"
markdown_url: "https://maker.wiznet.io/forum/12504/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "seands"
created: "2017-10-04T13:04:14+09:00"
last_activity: "2017-10-04T19:44:32+09:00"
language: "en"
views: 1485
replies: 3
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Problem sending large data buffer with W5500 and ioLibrary

## Question

Asked by seands on 2017-10-04 in Ethernet Chips.

I’ve got the following code to send buffered data to a server with the W5500. It uses the standard `ioLibrary` socket functions.

```
// runs every 1 second
send_data(void) {
    // data payload
    uint8_t payload[32];
    sprintf(payload, "%.2f,%.2f,%.2f,%u", env_t, env_p, env_h, env_l);

    // open socket number 1
    socket(1, Sn_MR_TCP, NULL, NULL);
    // connect to the server
    connect(1, dest_ip, dest_port);
    // send payload
    send(1, payload, strlen(payload));
}
```

Variables `env_t`, `env_h`, etc. are sensor values measured elsewhere in the code. The `dest_ip` and `dest_port` variables are the destination server details.

As it is shown above, the program works. However, if I increase the `payload` buffer size higher (e.g. to 64) in order to make the payload larger, the program no longer works (no serial output, no network activity). I know that `ioLibrary` checks the size of the provided buffer against its TX buffer size, but that is set to 2048 bytes, so it shouldn’t be a problem.

In my initialisation code I set the TX buffer size to 2kB:

```
uint8_t wiznet_buf_size[] = {2, 2, 2, 2, 2, 2, 2, 2};
wizchip_init(wiznet_buf_size, wiznet_buf_size);
```

Have I done something silly here?

## Replies

### Reply 1 by Eugeny, 2017-10-04

![](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/48.png) seands:

> ```
// send payload
send(1, payload, strlen(payload));
```

What `strlen(payload)` returns exactly?

### Reply 2 by kenearl, 2017-10-04

Hi Seands,

You might want to check if wizchip_init returns 0?

### Reply 3 by seands, 2017-10-04 (in reply to reply 1)

That question got me thinking a bit more about memory. I moved the definition of `payload` into the global scope and it now works. I am not sure why it didn’t work before though, because shouldn’t `send()` be able to see the variables in the scope of `send_data` if I pass a pointer to it?

This bug seems really bizarre - why did it work for a 32 byte buffer and not much higher?

---

Source: https://maker.wiznet.io/forum/12504
