---
title: "Ponting ioLibrary_v100 to 16bit, bugs"
url: "https://maker.wiznet.io/forum/10079"
markdown_url: "https://maker.wiznet.io/forum/10079/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "JimMartz"
created: "2014-03-21T20:51:39+09:00"
last_activity: "2017-05-04T08:32:09+09:00"
language: "en"
views: 470
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Ponting ioLibrary_v100 to 16bit, bugs

## Question

Asked by JimMartz on 2014-03-21 in Ethernet Chips.

All,

I have come across 3 bug today in code from ioLibrary_v100 that
has issues when ported to 16bit.

Function “wiz_send_data”, in W5500.c:
uint16_t ptr = 0; needs changed to a uint32.
If not the upper 8 bits gets truncated during
addrsel = (ptr &lt;&lt; 8) + (WIZCHIP_TXBUF_BLOCK(sn) &lt;&lt; 3);
This causes garbage to be sent out during a send data.
Also changed it in wiz_recv_data, although it was working.

Function “inet_ntoa” and “inet_ntoa”_pad, in sockutil.c:
sprintf((char*)addr_str,“%d.%d.%d.%d”,(int32_t)(addr>>24 & 0xFF),(int32_t)(addr>>16 & 0xFF),(int32_t)(addr>>8 & 0xFF),(int32_t)(addr & 0xFF))
int32’s needs changed to int16’s.
It may be compiler dependent, but for me I had to change it to int16’s or I was getting
extra characters out of the sprintf function.

Function “loopback_tcps”, in loopback.c:
ret is defined as int32, but in this line:
SendLen = TCPSend(sock, data_buf, ret)
function TCPSend is expecting the length to be uint32.
Had to add a type cast like this:
SendLen = TCPSend(sock, data_buf, (Uint32)ret)
with out the type cast garbage was passed to TCPSend.

Maybe this will help someone, and maybe for future updates.

Thanks,
Jim

## Replies

### Reply 1 by JimMartz, 2014-03-24

Come across another one today.

Function “loopback_udp”, in loopback.c:
The destination IP is defined as,
uint32_t destip = 0;

The problem is that the UDPRecv function places the IP
address in 4 consecutive memory locations, in the case of a 16bit processor,
it uses 4 16bit words, this don’t fit into the 32bit address defined.
After the UDPRecv function the memory is Eg. 0x00A800C0 (192.0.168.0).
To resolve this I defined the destination IP like:
Uint8 destip[4] = { 0 };

There are pointer castings on the function, (Uint8*)&destip but this
did not seem to matter to my compiler.

Jim,

---

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