EthernetUtils libraries


I'm trying to use stonehippo's library in a Due board.

It gives me some error on casting conversion.
D:\Dropbox\Arduino\libraries\EthernetUtils\utility\EthernetCompat.cpp: In function 'void ethernet_compat_write_data(int, uint8_t*, uint8_t*, uint16_t)':
D:\Dropbox\Arduino\libraries\EthernetUtils\utility\EthernetCompat.cpp:98: error: cast from 'uint8_t*' to 'uint16_t' loses precision
D:\Dropbox\Arduino\libraries\EthernetUtils\utility\EthernetCompat.cpp: In function 'void ethernet_compat_read_data(int, uint8_t*, uint8_t*, uint16_t)':
D:\Dropbox\Arduino\libraries\EthernetUtils\utility\EthernetCompat.cpp:125: error: invalid conversion from 'uint8_t*' to 'uint16_t'
D:\Dropbox\Arduino\libraries\EthernetUtils\utility\EthernetCompat.cpp:125: error: initializing argument 2 of 'void W5100Class::read_data(SOCKET, uint16_t, volatile uint8_t*, uint16_t)'

The function that generates the error is this with the red line being the error:
void ethernet_compat_write_data(int socket, uint8_t* src, uint8_t* dst, uint16_t len)
uint16_t size;
uint16_t dst_mask;
uint16_t dst_ptr, dst_ptr_base;

dst_mask = (uint16_t)dst & SMASK;
dst_ptr_base = TXBUF_BASE + socket * W5100Class::SSIZE;
dst_ptr = dst_ptr_base + dst_mask;

if( (dst_mask + len) > W5100Class::SSIZE )
size = W5100Class::SSIZE - dst_mask;
ethernet_compat_write_private(dst_ptr, (uint8_t *) src, size);
src += size;
ethernet_compat_write_private(dst_ptr_base, (uint8_t *) src, len - size);
ethernet_compat_write_private(dst_ptr, (uint8_t *) src, len);

Can anyone point me in the right direction on how to change it, so it would work?


error: cast from 'uint8_t*' to 'uint16_t' loses precision

This is, I think, a consequence of pointer alignment, on the Due a pointer to an int
has to be 4-byte aligned, so casting a byte pointer to an int or short pointer
involves masking out the lower bits.

The code probably assumes this isn't the case, so you'll need to check it in
detail to confirm/refute this.

If all the pointers are originally malloc'd buffers you'll be fine as malloc returns
the most aligned pointer possible.

Any update on this? I'm trying to get the same library running with a Due and I'm getting the same result :(.