Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Issues with getting code to compile. on: August 13, 2013, 05:21:10 pm
SUCCESS!

putting it a tab called "LogModel.h" and adding
Code:
#include "LogModel.h"
worked.

Net for everyone:
Arduino/Wiring appears to create forward declaration prototypes automatically; however, it doesn't do a consistent job of it.

Moving the structure into a new tab (and new file) with a .h extention. Adding an #include "myfile.h" will place it above the auto-declared prototypes.
2  Using Arduino / Programming Questions / Re: Issues with getting code to compile. on: August 13, 2013, 04:51:02 pm
Update

Ok, I moved this structure into its own tab "LogModel.cpp"
Code:
struct LogModel {
  unsigned int time;
  int temperature;
  int humidity;
};
...and I am still getting the same errors...
Code:
jLogger:12: error: 'LogModel' was not declared in this scope
jLogger:12: error: 'record' was not declared in this scope
jLogger:12: error: expected primary-expression before 'int'
jLogger:12: error: initializer expression list treated as compound expression
jLogger:13: error: 'LogModel' was not declared in this scope
jLogger:13: error: 'record' was not declared in this scope
jLogger:13: error: expected primary-expression before 'int'
jLogger:13: error: initializer expression list treated as compound expression
jLogger:27: error: 'LogModel' was not declared in this scope
...

This didn't work.
3  Using Arduino / Programming Questions / Re: Issues with getting code to compile. on: August 13, 2013, 04:12:02 pm
Oh thanks@nick...

I found the intermediate jLogger.cpp file...

Here is the excerpt from the beginning of that file.
Code:
#line 1 "jLogger.ino"
/*  130808
    jLogger is an application that will read temperature and humidity from
    an SHI 11 and an MCP9700A and log it into memory logbook (EEPROM)
*/

#include <EEPROM.h>
// TYPES
// EEPROM data strcutre
#include "Arduino.h"
void delaySeconds(int seconds);
int readLog(LogModel* record, int index);
int writeLog(LogModel * record, int index);
void initializeLog();
void startSHTtransmission();
void sendSHTbit(int b);
int readSHTtemperature();
void usage();
void setup();
void loop();
#line 9
struct LogModel {
  unsigned int time;
  int temperature;
  int humidity;
} logRecord;

// CONSTANTS
const int SAMPLE_PERIOD = 10;    // seconds between samples
const int SAMPLES = 5;
...

I see what the issue is here. They create the forward declarations for me but 1) omit the structure LogModel definition and 2) place the prototypes in front of the structure definition.

So you say that I have to move the structure definition.
4  Using Arduino / Programming Questions / Re: Issues with getting code to compile. on: August 13, 2013, 03:49:24 pm
The structure is a declaration of type.

In this case I am creating a variable of type LogModel
Code:
LogModel logRecord; // variable logRecord of type LogModel

Later on in my code I create another variable:
Code:
LogModel * record;
And you see references in the error stream above to 'record'.

I then typecast the LogModel* to a byte*.
Code:
...
record = &logRecord;
...
byte * eeData = (byte*)record;
This is so I can read/write bytes to the EEPROM with eeData[] semantics.

I create two utility functions:
Code:
int readLog (LogModel * record, int index);
int writeLog (LogModel * record, int index);
I use these to read and write the logRecord variable to EEPROM.

While I am new to wiring/arduino, I have been doing embedded C development for decades.

What I don't understand is how to tell wiring to ignore a block and not attempt to create prototypes (I can do that myself).
5  Using Arduino / Programming Questions / Issues with getting code to compile. on: August 13, 2013, 03:25:44 pm
I get a bunch of errors when trying to compile some code I have written to log temperatures into the EEPROM.

I have declared a structure & variable:
Code:
struct LogModel {
  unsigned int time;
  int temperature;
  int humidity;
} logRecord;

I get a whole host of errors:
Code:

jLogger:11: error: 'LogModel' was not declared in this scope
jLogger:11: error: 'record' was not declared in this scope
jLogger:11: error: expected primary-expression before 'int'
jLogger:11: error: initializer expression list treated as compound expression
jLogger:12: error: 'LogModel' was not declared in this scope
jLogger:12: error: 'record' was not declared in this scope
jLogger:12: error: expected primary-expression before 'int'
jLogger:12: error: initializer expression list treated as compound expression
jLogger.ino: In function 'int readLog(LogModel*, int)':
jLogger:43: error: 'int readLog(LogModel*, int)' redeclared as different kind of symbol
jLogger:11: error: previous declaration of 'int readLog'
jLogger:47: error: expected ';' before 'int'
jLogger.ino:49: warning: comparison between signed and unsigned integer expressions
jLogger.ino: In function 'int writeLog(LogModel*, int)':
jLogger:56: error: 'int writeLog(LogModel*, int)' redeclared as different kind of symbol
jLogger:12: error: previous declaration of 'int writeLog'
jLogger.ino:63: warning: comparison between signed and unsigned integer expressions
jLogger.ino: In function 'void initializeLog()':
jLogger:78: error: 'writeLog' cannot be used as a function
jLogger.ino: In function 'void setup()':
jLogger:328: error: 'readLog' cannot be used as a function

How can I better match these errors to my code? Is there an intermediate file I can look at? I read somewhere that Arduino/Wiring is trying to create prototypes for me. That would explain the early line numbers (prior to where I declared these functions).

Thanks,
Jon
w1jp
6  Using Arduino / Programming Questions / Re: What is the TypeDef for HIGH and LOW? on: August 10, 2013, 10:05:30 am
Thanks. I guess I was looking for the correct prototype for digitalWrite()

Which is am guessing to be:
Code:
void digitalWrite(int pin, int value);
7  Using Arduino / Programming Questions / Internal pull-up confusion... on: August 10, 2013, 10:00:00 am
What is the difference between
Code:
pinMode(pin, INPUT);
digitalWrite(pin, HIGH);
—and—
Code:
pinMode(pin, INPUT_PULLUP);
?
8  Using Arduino / Programming Questions / What is the TypeDef for HIGH and LOW? on: August 10, 2013, 09:39:02 am
I want to pass in a variable to a routine for digitalWrite(). In the help, I do not see a standard typedef definition for digitalWrite().

What is HIGH and LOW? int? boolean? unsigned byte?...
9  Using Arduino / Installation & Troubleshooting / avrdude: stk500_recv(): programmer is not responding on: July 11, 2011, 01:59:52 pm
I know there are a lot of these posts. This is indicating that this error condition is too broad and must provide more information.

Arduino: Sparkfun Pro-Mini ATMega 328 (5V)
OS: Mac OS X 10.6.8
Arduino s/w: 0022
cable: FTDI 5V5

For a review of the steps taken to get this error see this video:


There must be something going on with this configuration that avrdude doesn't like.

Thanks,
Jon
w1jp
Pages: [1]