Go Down

Topic: Can't get string from Serial Monitor! Please Help! (Read 122 times) previous topic - next topic

stoianvictor618

  Hello guys!
My name is Victor, I am a c/c++ programmer (just hobbyist for the moment), and I'm new to Arduino.
First I want to say that I have a deep respect and gratitude,for all the people that brought their contribution to Arduino,with function libraries,different codes,or just gave an advice on the forum.
You are great,and I thank you very much, cause you made from Arduino such an amazing machine!
 
 Please,I need some help.I want to make Arduino act as web server with possibility to set network parameters from Serial Monitor (IP,MAC,Gateway,etc).When I try to read the Serial Monitor's buffer,nothing happens.Please see the code below.
 Another issue is that: the Ethernet/WiFiServer object is initialized with MAC adress composed of 6 byte,but in the sketch examples,is composed of 6 hex values,bigger in size than byte type.
  If I want to take MAC from Serial Monitor and store it to EEPROM, should I convert it somehow to hex after read it back from EEPROM,in order ot start server? Thank you very much for help,have a great day!

groundFungus


PaulS

Code: [Select]
  while(Serial.available()==0){;}
  char ch;
  int i=0;
  while(Serial.available()>0)
     {
      ch=Serial.read();
      buffer[i++]=ch;
     }

As soon as there is at least one byte to read, start reading them all. How many do you suppose will have arrived when the first while loop ends? Any answer other than ONE is wrong.

Quote
but in the sketch examples,is composed of 6 hex values,bigger in size than byte type
Rubbish. Post the code that you think does this.
The art of getting good answers lies in asking good questions.

stoianvictor618

 Thank you very,very much groundFungus! That was very useful !
 You're right PaulS, I've asked the wrong question !
 So, in this  statement:  "byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};"  how can an array of bytes
 hold these hex values? And more important,if I got from Serial Monitor a string like:
 "0xDE:0xAD:0xBE:0xEF:0xFE:0xED" and I've devided it in 6 substrings like: "0xDE", how do I store those
 values in EEPROM, in order to read them back and pass them to Ethernet.begin() ?
 Should I remove th "0x" part then split "DE" in 2 different bytes, and write them in EEPROM ?

Go Up