Show Posts
Pages: 1 2 [3] 4 5 ... 7
31  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 11:00:09 am
great thanks!

any chance i could get you to comment on that other topic i mentioned that is related to all this?

topic is here
Arduino Forum › Software › Syntax & Programs › "wiznet configuration settings in a struct"
32  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 10:39:24 am
Quote
The next increment of the pointers would be 102(byte) and 104(int). and on and on.

got it. because an int uses two bytes.
33  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 10:37:24 am
Quote
You're not casting for the contents of the structure, only for the structure itself.

I think i understand. so you change it to a byte pointer and then assign it to a byte pointer.
34  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 10:30:00 am
Quote
The type of the expression "&configuration;" is "struct config_t*", so you can't (shouldn't) assign it to a varaible of type "byte*"
Excellent thanks!

what if the first element of the struct was an int or long?
Would you still do the same cast?
35  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 10:22:43 am
Thanks for all the help this morning
couple of questions for clarification purposes.
is uint8_t the same as saying byte?
why the cast to uint8_t when doing the address of assignment?
being a noobie to C i would have written
Code:
byte *ptr = &configuration;
would this have worked?
is the delay 100 to let the buffer fill up?
i understand using sizeof in the for loop so you don't write past the end of the struct. but why use it in the while loop?
the members in the struct are basically all byte size members. would size of work if some of them were ints or longs?


now that i can store and retrieve these things from the struct and the eeprom. i am trying to use them to call ethernet.begin and it is not working for some reason. it is very hard to debug as there are no functions to check with the ethernet class to see if things are getting assigned properly. any thoughts on this?
I started a new topic in Arduino Forum › Software › Syntax & Programs › "wiznet configuration settings in a struct"
if you want to look at the code i'm using
thanks for all your help spinlock
Jeff
36  Forum 2005-2010 (read only) / Syntax & Programs / Traverse struct with pointer on: December 17, 2009, 11:31:49 am
Hi All,
If i have a struct like the following...
Code:
struct config_t
{
  byte mac[6];
  byte ip[4];
  byte subnet[4];
  byte gateway[4];
  byte server[4];
  char path[128];
};

can i set a pointer to the struct so that i can take some serial input and put each input byte into the struct all in one shot with out having to refer to each of the struct's members individually.

I can't seem to get this to work.
below is what i am currently doing, but it just seems kinda clunky.

Code:
void CheckSerial(){

  if (Serial.available() > 0){
    switch (Serial.read()){
    case 'W':
      {
        delay(1000);
        int i=0;
        while ((Serial.available()>0) && i<6) configuration.mac[i++] = Serial.read();
        Serial.println(i);
        i=0;
        while ((Serial.available()>0) && i<4) configuration.ip[i++] = Serial.read();
        Serial.println(i);
        i=0;
        while ((Serial.available()>0) && i<4) configuration.subnet[i++] = Serial.read();
        Serial.println(i);
        i=0;
        while ((Serial.available()>0) && i<4) configuration.gateway[i++] = Serial.read();
        Serial.println(i);
        i=0;
        while ((Serial.available()>0) && i<4) configuration.server[i++] = Serial.read();
        Serial.println(i);
        i=0;
        while(Serial.available() > 0) configuration.path[i++] = Serial.read();

        configuration.path[i++] = '\0';
        Serial.println(i);
        PrintConfig();
      }
      EEPROM_writeAnything(0, configuration);
      //PrintConfig();
      break;

    case 'R':
      EEPROM_readAnything(0, configuration);
      PrintConfig();
      break;

    default:
      Serial.flush();

    }

  }

}

Thanks in advance
Jeff
37  Forum 2005-2010 (read only) / Syntax & Programs / Re: wiznet configuration settings in a struct on: December 18, 2009, 02:42:46 pm
yes, it is correct.
i have been successfully using my data logger with this setup. It is one of those so called shared ip addresses that requires you to access it like so 74.86.153.136/~latenigh

so i just set my get statement up like this
GET /~latenigh/zzz.php?speed=24 HTTP/1.0

 but this part all works fine.

for some reason i don't think the ethernet initialization is happening
again this all works fine when i hard code all the settings.
but when i try to set them from the struct is where the problems start
Jeff
38  Forum 2005-2010 (read only) / Syntax & Programs / Re: wiznet configuration settings in a struct on: December 18, 2009, 12:12:20 pm
i just put "test" in there when i made this code example.
it is outputting the "connection failed" message after a long timeout period

it is not being initialized correctly i think and i can't figure out how to read what the ethernet class has after i put my values in to see if they took
39  Forum 2005-2010 (read only) / Syntax & Programs / Re: wiznet configuration settings in a struct on: December 17, 2009, 11:14:52 pm
oops!
there is a delay(1000) that should be in the main loop so that the data will eventually be sent once per second
40  Forum 2005-2010 (read only) / Syntax & Programs / wiznet configuration settings in a struct on: December 17, 2009, 11:12:45 pm
can anybody tell me why the following will not work

I'm trying to store the wiznet config settings in a struct so i can eventually store and retrieve from the eeprom so that i don't have to hard code the settings

setting up byte arrays and passing them to ethernet.begin works but not when i pass them in from the struct

Code:
#include <Ethernet.h>

struct config_t
{
  byte mac[6];
  byte ip[4];
  byte subnet[4];
  byte gateway[4];
  byte server[4];
  char path[192];
};

struct config_t configuration = {
  {
    0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED                  }
  , {
    192,168,0,54                  }
  , {
    255,255,255,0                  }
  , {
    192,168,0,1                  }
  , {
    73,86,153,136                  }
  ,{
    '/','p','\0'        }
};

Client client(configuration.server, 80);

void setup()
{

  Ethernet.begin(configuration.mac, configuration.ip, configuration.gateway, configuration.subnet);
  Serial.begin(9600);
    delay(500);

    Serial.println("Ready:");

}

void loop()
{

    if (client.connect()) {
      client.println("Test");
      client.println();
      client.stop();
    }
    else {
      Serial.println("connection failed");
    }

}

Thanks
JEff
41  Forum 2005-2010 (read only) / Syntax & Programs / interrupt question on: May 01, 2009, 07:17:20 pm
Hi all,

What would happen if a pin2 interrupt occurred in the middle of a serial transmission?
Would it be possible that a byte of data could get lost?

Or would the board just handle the interrupt and then continue with the transmission. no data loss.

thanks for the help

Jeff
42  Forum 2005-2010 (read only) / Syntax & Programs / Re: trying to slim down my program... on: October 28, 2008, 07:44:25 am
flash
43  Forum 2005-2010 (read only) / Syntax & Programs / Re: trying to slim down my program... on: October 27, 2008, 10:02:07 pm
Thanks for the help
44  Forum 2005-2010 (read only) / Syntax & Programs / Re: trying to slim down my program... on: October 27, 2008, 09:03:56 pm
sorry this is definitely not homework since i'm not taking any classes

i am already using strcat and strcpy elsewhere in my program

is your answer still the same?
45  Forum 2005-2010 (read only) / Syntax & Programs / trying to slim down my program... on: October 27, 2008, 07:45:39 pm
which is more costly regarding compiled program size

Code:
 Serial.print("OPW ");
  Serial.print(dataFileName);
  Serial.print(32, BYTE);
  Serial.print("0x");
  Serial.print(datestamp, HEX);
  Serial.print(13, BYTE);

or
using strcat several times to create one string and then calling Serial.print once

thanks

Jeff
Pages: 1 2 [3] 4 5 ... 7