Pages: 1 [2] 3   Go Down
Author Topic: Get IP Address of Anyone Connected to my Arduino set up as server  (Read 4168 times)
0 Members and 1 Guest are viewing this topic.
Medford, OR
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, I feel like the village idiot... Yes, I was looking for and gave you the wrong files... Here are the correct ones...
http://www.towerboy.com/arduino/Client.h //Removed from my server now.
http://www.towerboy.com/arduino/Client.cpp //Removed from my server now.

I made the changes to them and I still get the same error as before:
Code:
sketch_mar07a.cpp: In function 'void loop()':
sketch_mar07a:47: error: 'class Client' has no member named 'IP_address'

Any ideas? I am using the arduino uno if that makes a difference...

Jeremy
« Last Edit: April 22, 2011, 09:56:38 am by Jeremy-arduino » Logged

Medford, OR
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

maybe i messed something up, because now I can't compile anything with Ethernet.h in it... overwriting messed up files now...

Jeremy
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

After modifying files you might need to restart all instances of the IDE.

Which version of the IDE are you using?

Rob
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Medford, OR
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, here is what I have now... It took me a while to figure out that in your snippets of the .h and .cpp file I was supposed to find some of the text and add the pertinant stuff right after it... Got that done now. I am running Ver0022 and yes, every time I make a change to the files, I close and reopen all the Arduino IDE's. When I compile now, this is what I get:
Code:
C:\Users\Jeremy\Desktop\arduino-0022\libraries\Ethernet\Client.cpp: In member function 'void Client::IP_address(uint8_t*)':
C:\Users\Jeremy\Desktop\arduino-0022\libraries\Ethernet\Client.cpp:26: error: 'getSn_DIPR' was not declared in this scope
???

Jeremy
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


@ Jeremy :

See my previous post, but here again:
The ethernet lib changed in version 19. The patch proposed here was for version 18.

-----
1)    #include <SPI.h>  should be added for version 19 and up
2)   'getSn_DIPR' was not declared in this scope

The first was solved easily, do you know how to fix the second? Fixed!!
The second is to use the code below in Client.cpp

void Client::IP_address(uint8_t * addr)
{
   W5100.readSnDIPR(_sock, addr);    // replaces the getSn_DIPR(_sock, addr); V18 and below
}

Hopes this helps,
Rob
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Medford, OR
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Rob

I am not used to going back and looking for edits in post. On most forums, a new post is made. This is not your fault. I am just explaining why I missed it and will learn to re-read and look for edits. Thank you for your help.

I made the change that you edited and got a few more errors that I will not bother to post because, I read through them and managed to understand what was wrong! When I copied the code into the Client.h file, I missed copying the semicolon. Now it all compiles and uploads fine. Thanks!

Any idea now, how to make the arduino scan the connected computer for credit card info?

Yes, the previous line of text was a JOKE!!! smiley Thanks everyone that help straighten me out!

Jeremy
Logged

'round the world...
Offline Offline
Faraday Member
**
Karma: 42
Posts: 3225
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Any idea now, how to make the arduino scan the connected computer for credit card info?

Ohhh, just when I thought I had found a new day project to get me busy.

Glad you got it working.
Logged

Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

Medford, OR
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, so this has worked great for everything that I have tried so far except one thing. I'm sure it's something simple but I am trying to store the IP to a variable instead of just printing the IP at the present time. This is what I have but it does not work.
Code:
client.IP_address(&client_ip[0]);//added
           //client.println("Your IP is:");//added
           int currentIP;  // My addition
           for (int n = 0; n<=3; n++)//added
            {//added
            lcd.print((int)client_ip[n]);//added --  I changed this and it works
            currentIP += ((int)client_ip[n]);  // My addition
            if(n < 3){
              lcd.print(".");//added -- I changed this and it works
              currentIP += '.';  // My addition
            }//added
I would have thought that would work but it might not be the right data type? Not sure what it is that I should do. Thanks.

Jeremy
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


An IP address is four bytes, that cannot be storeds in an int of two bytes. You need a long

pack:
for (int i=0; i<3; i++)
{
  long_ip *= 256;
  long_ip += client_ip;
}

unpack;

temp = long_ip;
for (int i=0; i<3; i++)
{
  client_ip = (byte) temp & 0xFF;
  temp /= 256;
}
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Medford, OR
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know I had this working at one time and now when I compile, after I made changes to an unrelated part of code, it fails. Here is the part that is failing.
Quote
           client.IP_address(&client_ip[0]);
           lcd.setCursor(0, 1);
           lcd.print("                ");
           lcd.setCursor(0, 1);
           long long_ip;
           for (int n = 0; n<=3; n++)
            {
              long_ip *= 256;
              long_ip += client_ip; // This part here is where I get my errors.....which are posted below...
            }
            
           long temp = long_ip;
           for (int i=0; i<3; i++)
            {
              client_ip = (byte) temp & 0xFF; // This part here is where I get my errors.....which are posted below...
              temp /= 256;
            }


Code:
gate_garage_NewHTML.cpp: In function 'void loop()':
gate_garage_NewHTML:129: error: invalid conversion from 'byte*' to 'long int'
gate_garage_NewHTML:135: error: incompatible types in assignment of 'int' to 'byte [4]'

client_ip is declared before the setup function...
What is supposed to be happening here is the clients ip is to be written to a long and then printed to the LCD16X2. I have it working on the arduino right now, but that was from a burn about a month ago and I don't seem to have saved the correct way to do it... Any ideas?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 long_ip += client_ip[n];  // need to add the index of the array you want to add

client_ip = (byte) temp & 0xFF;  // idem
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Medford, OR
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, adding the index fixed the first issue. Thanks. But I have now idea what "idem" means. I googled it, and found some results, but they didn't make any sense...
Logged

'round the world...
Offline Offline
Faraday Member
**
Karma: 42
Posts: 3225
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What were you planning to achieve with this:

Code:
for (int i=0; i<3; i++)
            {
              client_ip = (byte) temp & 0xFF; // This part here is where I get my errors.....which are posted below...
              temp /= 256;
            }


?
Logged

Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

Medford, OR
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't quite know what that does, I didn't write it. It was given a few posts back and at one time, I had it working, must have forgot to save my work after the last burn, and lost it. If there is a simpler idea, I'm open to it.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What were you planning to achieve with this:
It looks like splitting a long into 4 separate bytes, but the index [n] is missing.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: 1 [2] 3   Go Up
Jump to: