Go Down

Topic: Intermittent compiler complaints of 'Point' does not define a type (Read 2196 times) previous topic - next topic

ajofscott

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: [Select]
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.

PeterH

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.
I only provide help via the forum - please do not contact me for private consultancy.

Nick Gammon

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?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

ajofscott

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.

ajofscott


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
"

Nick Gammon

Ah, the IDE has some tricks for you. :)

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

Put the definitions in it, eg.

Code: [Select]
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: [Select]
#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.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics



ajofscott

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

Nick Gammon

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: [Select]

// 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.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

ajofscott

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.

ajofscott

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?

Nick Gammon

Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

ajofscott

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.

ajofscott

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.

Go Up