Show Posts
Pages: 1 ... 6 7 [8] 9 10
106  Forum 2005-2010 (read only) / Syntax & Programs / Re: combining bytes into one on: January 08, 2011, 02:29:47 am
  byte *ptr = textCopy[0];

I get an error for this code:  invalid conversion from byte to byte
should the asterisk be there?

int octet1[4];
  for(int i=0; i<4; i++)
  {
    octet1 = atoi(ptr);
    ptr +=4;
  }

so this above code is only for the first octet right?

thanks
107  Forum 2005-2010 (read only) / Syntax & Programs / Re: combining bytes into one on: January 07, 2011, 07:13:13 pm
i really do appreciate your help on this but i read that last message over and over again trying to understand what you meant and i still dont fully understand.  would you mind showing me a little sample code? especially on the atoi() command, i couldnt find too much online bout that command.  what do you mean by pointer?  and by copy the buffer do you mean like a memcopy? do you have sample code for that or a place where i can read up on it?

thank you so much
108  Forum 2005-2010 (read only) / Syntax & Programs / Re: combining bytes into one on: January 07, 2011, 04:22:05 pm
basically what i am doing is that i am trying to read in an ip address, parse it, and store it as 4 bytes into the eeprom so that it can be read upon reboot.  so what i have so far at accomplishing that is that i am reading a byte one at a time and storing it into 12 distinct bytes.  so for example:
Code:
byte newIP1 = textBuff[10];
  byte newIP2 = textBuff[11];
  byte newIP3 = textBuff[12];
  byte newIP4 = textBuff[14];
  byte newIP5 = textBuff[15];
  byte newIP6 = textBuff[16];
  byte newIP7 = textBuff[18];
  byte newIP8 = textBuff[19];
  byte newIP9 = textBuff[20];
  byte newIP10 = textBuff[22];
  byte newIP11 = textBuff[23];
  byte newIP12 = textBuff[24];

but then i want to take the first 4 bytes and create a new byte and so on and so forth until i get all four bytes.

such as:
byte1 is read as 1
byte2 is read as 2
byte3 is read as 3

and then the new byte would be:
byte1byte2byte3 otherwise known as 123
so the new byte would have a value of 123 which would then be written to eeprom

is that enough detail?  im tryin to be clear lol
109  Forum 2005-2010 (read only) / Syntax & Programs / combining bytes into one on: January 07, 2011, 02:22:42 pm
Hi, for a program I'm writing, I am parsing one character at a time from an "    ".read buffer i've set up and storing those as bytes.  However where I'm getting stuck is that I need to combine say three or four bytes into one new byte.  i looked at some of the references on the arduino page and found a little promise in the byte() command but I'm not sure how to setup the syntax for that.  and i dont even know if its the right command.

so for example if i have:

byte data1[] = {1};
byte data2[] = {2};
byte data3[] = {3};

can i do something like:

byte newdata[] = {data1 & data2 & data3};

thanks
110  Forum 2005-2010 (read only) / Syntax & Programs / Re: Duplicate Case error for switch command on: January 06, 2011, 09:48:19 pm
well I will try all those options after classes tomorrow and post how it goes

also, will the whole command typed it be put into the textbuff then?

thanks alot
111  Forum 2005-2010 (read only) / Syntax & Programs / Re: Duplicate Case error for switch command on: January 06, 2011, 08:25:42 pm
do they have to be though?  it seems that with string values the commands can make more sense to the user
112  Forum 2005-2010 (read only) / Syntax & Programs / Re: Duplicate Case error for switch command on: January 06, 2011, 08:00:39 pm
i changed some stuff in my code (made sure the 9th character was different for each case) and all is well now, thanks alot guys.  i learn something new everyday from this forum
113  Forum 2005-2010 (read only) / Syntax & Programs / Re: Duplicate Case error for switch command on: January 06, 2011, 07:58:10 pm
oh i see, so if i had a different character at the end of each string then there won't be an duplicate case errors
114  Forum 2005-2010 (read only) / Syntax & Programs / Duplicate Case error for switch command on: January 06, 2011, 07:24:39 pm
Hi I am trying to parse some incoming data with a switch case command with the following code:
Code:
void parseReceivedText()
{
  switch (textBuff[8])
  {
    case 'printf_ip' : IPPrint();                             break;
    case 'poe_resta' : PoeRestart();                          break;
    case 'cha_dname' : ChangeDeviceName();                    break;
    case 'change_ip' : ChangeIP();                            break;
    case 'change_gw' : ChangeGW();                            break;
    case 'change_sm' : ChangeSM();                            break;
    case 'rfinished' : ReadyToContinue();                     break;
    case 'adminlock' : AdminLockdown();                       break;
    case 'adminover' : AdminOverride();                       break;
    case 'term_teln' : telnet_session.stop();                 break;
    case 0x0d :                                               break;
    default   : telnet_session.println("invalid command");    break;
  }
}

But I get a duplicate case error and since i have no idea what the error means i don't even know what to look for.  anybody have ideas that could help with this?

thanks
115  Forum 2005-2010 (read only) / Syntax & Programs / Re: Help with EEPROM.write() on: January 06, 2011, 05:39:14 pm
wow I can't believe I missed that.  its a first time of programming for me
thanks a lot
116  Forum 2005-2010 (read only) / Syntax & Programs / Help with EEPROM.write() on: January 06, 2011, 05:00:53 pm
Hi, I am simply trying to write a byte of data to the EEPROM and then read it to the serial port as shown with the following code:
Code:
#include <EEPROM.h>

byte data[1] = {192};
int a = 1;
int value;

void setup()
{
  EEPROM.write(a, data[1]);
  Serial.begin(9600);
}

void loop()
{
  value = EEPROM.read(a);
  Serial.print(a);
  Serial.print("\t");
  Serial.print(value);
  Serial.println();
}

But all the serial window shows is "1       1".  Meaning that the value stored at EEPROM Address 1 is 1.  But the value written should 192 right?  Am I missing something really simple here?

thanks
117  Forum 2005-2010 (read only) / Syntax & Programs / Re: printing and changing ip info on: January 06, 2011, 01:11:22 pm
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
118  Forum 2005-2010 (read only) / Syntax & Programs / Re: printing and changing ip info on: January 06, 2011, 12:42:41 pm
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
119  Forum 2005-2010 (read only) / Syntax & Programs / Re: printing and changing ip info on: January 06, 2011, 10:05:37 am
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?
120  Forum 2005-2010 (read only) / Syntax & Programs / printing and changing ip info on: January 06, 2011, 12:14:13 am
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
Pages: 1 ... 6 7 [8] 9 10