Go Down

Topic: printing and changing ip info (Read 761 times) previous topic - next topic

phinsil6

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: [Select]
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

PaulS

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?

robtillaart


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 -
Rob Tillaart

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

phinsil6

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?

PaulS

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?

phinsil6

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

PaulS

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.

phinsil6

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

Go Up