Pages: [1] 2   Go Down
Author Topic: Intermittent compiler complaints of 'Point' does not define a type  (Read 1493 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is perplexing is that the same typedef structures were working earlier before I added more processes to the application.
Point and Command are defined as follows:
Code:
typedef struct Point
{
  int X;
  int Y;
}Point;
typedef struct Command 
{ //0 based offsets:
word Verb; //Zero and First  Bytes of Serial stream.
Point Begin; //third to sixthth Bytes (x) Eighth to Eleventh Bytes (y) of Serial stream.
Point Finish; //thirteenth to sixteenth Bytes (x) Eighteeenth to Twenty-first Bytes (y) of Serial stream.
Point AC; //Twenty-third to Twenty-sixth Bytes (x) Twenty-eighth to Thirty-first Bytes (y) of Serial Stream.
unsigned int BA; //Thirty-third to Thirty-sixth Bytes of Serial stream.
unsigned int EA; //Thirty-eighth to Fourty-first Bytes of Serial stream.
unsigned int TD; //Fourty-third to Fourty-sixth Bytes of Serial stream.
              boolean Bias; //Fourty-eighth byte of Serial stream.
              float Scalor; //Scaling factor for motor movement.
              boolean Major; //If true X has the major displacement.
}Command;
Also to add to the puzzlement is that 'Command' is being accepted as a datatype and if a library is included I have to have the inclusion appear after the typedefs or neither one sets.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11173
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What do you mean by 'intermittent'? The same sketch sometimes compiles OK and sometimes fails?
What do you mean by 'added more processes to the application'?

All I can guess so far is that you are using a library that declares Point as something else.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Provide a "working" sketch that demonstrates the problem. Trying to fix compiler errors when you just talk about what you did is not very easy.

Quote
... working earlier before I added more processes ...

Can you elaborate on how you added processes?
Logged

Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

while trying to format for screen here I became aware of some open grouping symbols.
As far as the intermittent part goes, when I populated the instance ThisCommand, of Type Command directly without calls to GetValueFromString() all was working well, in fact that version is currently running on the UNO. Stupid me I did not make an archival copy before
embellishing on things.
Logged

Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Groupings corrected leaving the only complaint being:
Code too long to post in tags so it is attached.

 "tinyComm:-1: error: 'Point' does not name a type
tinyComm.cpp: In function 'void ExecuteMovement()':
tinyComm:158: error: 'GetDisplacements' was not declared in this scope
"

* tinyComm.ino (9.14 KB - downloaded 8 times.)
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, the IDE has some tricks for you. smiley

Make a new tab (button in top RH corner). Call it something.h (eg. definitions.h)

Put the definitions in it, eg.

Code:
typedef struct Point
{
  int X;
  int Y;
}Point;
typedef struct Command 
{ //0 based offsets:
word Verb; //Zero and First  Bytes of Serial stream.
Point Begin; //third to sixthth Bytes (x) Eighth to Eleventh Bytes (y) of Serial stream.
Point Finish; //thirteenth to sixteenth Bytes (x) Eighteeenth to Twenty-first Bytes (y) of Serial stream.
Point AC; //Twenty-third to Twenty-sixth Bytes (x) Twenty-eighth to Thirty-first Bytes (y) of Serial Stream.
unsigned int BA; //Thirty-third to Thirty-sixth Bytes of Serial stream.
unsigned int EA; //Thirty-eighth to Fourty-first Bytes of Serial stream.
unsigned int TD; //Fourty-third to Fourty-sixth Bytes of Serial stream.
  boolean Bias; //Fourty-eighth byte of Serial stream.
  float Scalor; //Scaling factor for motor movement.
  boolean Major; //If true X has the major displacement.
}Command;

At the start of your main sketch add:

Code:
#include <Arduino.h>
#include "definitions.h"

Now it almost compiles. You have a couple of other problems, but nothing to do with Point not being defined.
Logged

Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

definitions.h? I have no header by that name.
Logged

Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

gotcha!
Logged

Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

compiles without errors. Should I always put UDT definitions in a seperate file?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Depends a bit on the code, but the IDE rearranges things a bit. What is really happening is that it is "helpfully" generating function prototypes for you. So I bet that the file given to the compiler would start like this:

Code:
// prototypes
Point GetDisplacements(Point locStart, Point locEnd);

typedef struct Point
{
  int X;
  int Y;
}Point;


So it has made a prototype for the function GetDisplacements at the very start, and then throws in your file, which is where Point is declared.
Logged

Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

duly noted, Thanks Nick!
it runs but doesn't work yet
input "MA FF65 AD34 7655 7894*"
gave an output of:
"MA FF65 AD34 7655 7894
Current X Position = 0
Current Y Position = 0
Current X Position = 0
Current Y Position = 0
Awaiting next command.
"
I must have some error in the way I am branching in ExecuteMovement().
I shall be adding serial print statements to find out where I failed to branch as expected.
Logged

Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Command from the serial terminal
MA 0000 0000 0053 13FF*

pre execute coordinates:
Current X Position = 0
Current Y Position = 0
Execute command 'MA':
4D41

post move position:
Current X Position = 83
Current Y Position = 5103

Y is always 16 short, although both X and Y are interpreted from the serial stream with the same algorithm. Any ideas?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Show the amended code that compiles?
Logged

Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code attached. I have it operating on the mill. I get 0.05 mil/step so an integer is going to be too small but will do fine while I develop the routines.

* tinyComm.ino (9.88 KB - downloaded 9 times.)
* definitions.h (0.87 KB - downloaded 9 times.)
Logged

Offline Offline
God Member
*****
Karma: 0
Posts: 547
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My servo lib is a modified one such that the step member returns a 1 if a step occours and a 0 if it didn't.

* Stepper.h (2.58 KB - downloaded 10 times.)
* Stepper.cpp (6.54 KB - downloaded 9 times.)
Logged

Pages: [1] 2   Go Up
Jump to: