Pages: [1]   Go Down
Author Topic: printing and changing ip info  (Read 624 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 1
Posts: 137
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I have the Dum. and Eth Shield.  I am trying to be able to read and print the ip, gw, and subnet info to a telnet session, however I am new to the whole byte, string, char business and am unsure as to how to actually print the values.  for instance i have
Code:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1, 250 };
byte gateway[] = {192,168,1,1};
byte subnet[] = {255,255,255,0};

i've tried something like a telnet.println(ip) but it gives me an "(byte[4]) is ambiguous error.  what kind of syntax should I be using?  also, would I be able to change the ip value from a telnet.read();?

thanks
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ip is an array of bytes. You print it like any other array - one element at a time, in a loop.

It is the address of the ethernet device. How can it change mid-session?
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


Check - http://www.arduino.cc/en/Reference/Array

On the tutorial section there is a lot of info about chars and bytes and so - http://arduino.cc/en/Tutorial/HomePage -
Logged

Rob Tillaart

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

0
Offline Offline
Full Member
***
Karma: 1
Posts: 137
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the help on the printing of the array.  for the changing the ip, i was thinking that possibly if you changed the ip info in the order of, subnet, gateway, ip then do a soft reset of the device which would restart the ethernet session.  would that work?  it is really imperative that I can change the ip info of the device.  if not possible over the telnet session, could i do it over a serial connection?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
it is really imperative that I can change the ip info of the device.
This is the part I have trouble with. Do you routinely change the IP address of your PC? What happens when you try?
Logged

0
Offline Offline
Full Member
***
Karma: 1
Posts: 137
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

now you've confused me lol...the point of this device is so that others can use it and change the default ip address from a telnet prompt

i was thinking more about it and what if i stored the new ip info input into a buffer of sorts and then did a soft reset and had the arduino ethernet server start off of that buffer.  and also it would start off that buffer every time the arduino is initialized
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the point of this device is so that others can use it and change the default ip address from a telnet prompt
OK. Still not sure I understand this, but, that's not the issue.

Quote
i was thinking more about it and what if i stored the new ip info input into a buffer of sorts
You could do that.

Quote
and then did a soft reset
Not sure what this means, or how you would accomplish it.

Quote
and had the arduino ethernet server start off of that buffer.
Well, that buffer's data would have been lost in a reset.

You could store the IP address in EEPROM, and read from there on startup to get the IP address to use. Then, you could change the value in EEPROM with the right input.
Logged

0
Offline Offline
Full Member
***
Karma: 1
Posts: 137
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

okay so from with what you said would this procedure work:
1) Start ethernet.begin with ip, gateway, subnet from PROGMEM
2) from telnet session, if new ip, gateway, subnet info received store to buffer
3) stop telnet session
4) write buffer to PROGMEM
5) restart ethernet.begin server
6) voila new ip, gateway, subnet with new telnet session

please let me know if i'm way off base
Logged

Pages: [1]   Go Up
Jump to: