Pages: 1 [2]   Go Down
Author Topic: Help intergrating some code i found (Ethernet Code)....  (Read 2229 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
Walking on Nails
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@zoomkat: you forgot to show us the interesting patched part - this sketch obviously only gives an
Code:
error: 'class EthernetClient' has no member named 'getRemoteIP'
Logged

loved the 68000 assembler back then and now I have to deal with THIS 8 bit thingy

Offline Offline
Edison Member
*
Karma: 29
Posts: 2448
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice one but im still staggering around in near darkness may i see the rest of the code then? lol
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
Walking on Nails
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tried this? http://arduino.cc/forum/index.php/topic,100267.msg752315.html#msg752315
Logged

loved the 68000 assembler back then and now I have to deal with THIS 8 bit thingy

Offline Offline
Edison Member
*
Karma: 29
Posts: 2448
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oops, I used Android (and you don't see scroll bars on the code) so it looked like far less code than you posted...

I'll try it out, thanks....
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
Walking on Nails
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is only three lines to add to the code to get the remote IP and you already figured out the most important one. The rest is the explanation.
Logged

loved the 68000 assembler back then and now I have to deal with THIS 8 bit thingy

Offline Offline
Edison Member
*
Karma: 29
Posts: 2448
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

in short the code I just uploaded returns these errors smiley-sad

Quote








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.27 KB - downloaded 12 times.)
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
Walking on Nails
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I propose to delete the additional copy of ethernet lib and add the line
Code:
__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
Code:
#include <Ethernet.h>
#include <utility/w5100.h>
...
uint8_t remoteIP[4];
...
W5100.readRIPR(remoteIP);
« Last Edit: April 07, 2012, 08:04:09 pm by Marek080 » Logged

loved the 68000 assembler back then and now I have to deal with THIS 8 bit thingy

Offline Offline
Edison Member
*
Karma: 29
Posts: 2448
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Edison Member
*
Karma: 29
Posts: 2448
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
Walking on Nails
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

I edited my previous post, so read it again, please.
« Last Edit: April 07, 2012, 08:10:45 pm by Marek080 » Logged

loved the 68000 assembler back then and now I have to deal with THIS 8 bit thingy

0
Offline Offline
Tesla Member
***
Karma: 143
Posts: 9593
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@zoomkat: you forgot to show us the interesting patched part - this sketch obviously only gives an
Code:
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.

http://arduino.cc/forum/index.php/topic,82416.msg619420.html#msg619420
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Edison Member
*
Karma: 29
Posts: 2448
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yayyyyyyyy thank you!!!

for future reference for anyone else..

Code:
       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...

Quote
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 smiley


http://110.175.97.110:1234


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





[/quote]
« Last Edit: April 07, 2012, 09:28:30 pm by cjdelphi » Logged

Pages: 1 [2]   Go Up
Jump to: