Help intergrating some code i found (Ethernet Code)....

OK I added the lines, but it's still going over my head..

in short the code I just uploaded returns these errors :frowning:

In file included from WebServer.cpp:7:
C:\arduino\arduino-1.0\libraries\Ethernet/utility/w5100.h:234: error: 'static uint16_t W5100Class::writeRIPR(uint8_t*)' cannot be overloaded
C:\arduino\arduino-1.0\libraries\Ethernet/utility/w5100.h:232: error: with 'static uint16_t W5100Class::writeRIPR(uint8_t*)'
C:\arduino\arduino-1.0\libraries\Ethernet/utility/w5100.h:234: error: 'static uint16_t W5100Class::readRIPR(uint8_t*)' cannot be overloaded
C:\arduino\arduino-1.0\libraries\Ethernet/utility/w5100.h:232: error: with 'static uint16_t W5100Class::readRIPR(uint8_t*)'

(EthernetCode ...zip contains my modified ethernet lib including the sub folders and modifications)

Thanks for helping.....

EthernetCodeNotCompiling.zip (25.3 KB)

I propose to delete the additional copy of ethernet lib and add the line

__GP_REGISTER_N(RIPR,   0x000C, 4); // Remote IP address

directly to w5100.h in the Arduino library directory. It is a small change without the hassle of cloning the library. You just have to remember that you made the change when updating to a newer version of Arduino.

The rest is done in your sketch by including w5100.h and calling the new function

#include <Ethernet.h>
#include <utility/w5100.h>
...
uint8_t remoteIP[4];
...
W5100.readRIPR(remoteIP);

Step 1 . Open w5100.h add the line

__GP_REGISTER_N(RIPR, 0x000C, 4); // Remote IP address

Step 2.

Insert code

static uint16_t writeRIPR(uint8_t *_buff) {
return write(0x000C, _buff, 4);
}
static uint16_t readRIPR(uint8_t *_buff) {
return read(0x000C, _buff, 4);
}
static uint16_t writeSIPR(uint8_t *_buff) {
return write(0x000F, _buff, 4);
}
static uint16_t readSIPR(uint8_t *_buff) {
return read(0x000F, _buff, 4);
}

/// What file?

Step 3, compile?

how does coding in C/C++ not make someone drink excessively ?

No, wrong. There is only one step. Only one line to add to w5100.h - do not drink and program :stuck_out_tongue:

I edited my previous post, so read it again, please.

Marek080:
@zoomkat: you forgot to show us the interesting patched part - this sketch obviously only gives an

error: 'class EthernetClient' has no member named 'getRemoteIP'

Just now remembering, below has the info on how to make the code work to get the client IP address. Just a little copy/paste work in the correct files.

Yayyyyyyyy thank you!!!

for future reference for anyone else..

        char crrip[16];
        byte rip[4];
   
        client.getRemoteIP(rip); // where rip is defined as byte rip[] = {0,0,0,0 };     
        sprintf(crrip, "%d.%d.%d.%d", (unsigned char)rip[0], (unsigned char)rip[1], (unsigned char)rip[2], (unsigned char)rip[3]);
        client.print("Welcome ");
        client.println(crrip);

modifications to ethernet...

I added the following lines to the end of the EthernetClient.cpp file:
uint8_t *EthernetClient::getRemoteIP(uint8_t remoteIP[])
{
W5100.readSnDIPR(_sock, remoteIP);
return remoteIP;
}

I then added the following line (under the virtual void stop(); line)to the EthernetClient.h file:
uint8_t *getRemoteIP(uint8_t RemoteIP[]);//adds remote ip address

Finally I used the following code in my sketch to access the remote IP:
client.getRemoteIP(rip); // where rip is defined as byte rip[] = {0,0,0,0 };

to display the IP in the serial monitor, I used:

for (int bcount= 0; bcount < 4; bcount++)
{
Serial.print(rip[bcount], DEC);
if (bcount<3) Serial.print(".");
}

I'm not sure that this is the most elegant way, but it works in the IDE v1.0

Works perfectly Cheers man :slight_smile:

http://110.175.97.110:1234

There it is in action :slight_smile: - that means I can now play with some of the other functionality like remote port etc etc (actually one day...maybe lol)

[/quote]