Intermittent compiler complaints of 'Point' does not define a type

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:

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.

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.

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.

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

Can you elaborate on how you added processes?

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.

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)

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

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

Put the definitions in it, eg.

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:

#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.

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

gotcha!

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

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:

// 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.

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.

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?

Show the amended code that compiles?

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)

definitions.h (892 Bytes)

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)

Stepper.cpp (6.54 KB)

Does it compile for you? I get:

tinyComm.cpp: In function 'boolean MoveX(float, int)':
tinyComm:259: error: void value not ignored as it ought to be
tinyComm.cpp: In function 'boolean MoveX(int)':
tinyComm:273: error: void value not ignored as it ought to be
tinyComm.cpp: In function 'boolean MoveY(float, int)':
tinyComm:284: error: void value not ignored as it ought to be
tinyComm.cpp: In function 'boolean MoveY(int)':
tinyComm:298: error: void value not ignored as it ought to be

I attached the modified lib and header, but to get it to compile on your system without changing Servo libraries change the calls to X_Axis.step() and Y_Axis.step() to read 1 * DD.

While running the machine making test cuts I noted my Current cursor is remaining 0,0. Is this statement being interpreted as ‘A replaced with NOT B’?

Current.X != ThisOperation.Begin.X

Where my premise was != meant the same as <> or not equal to.

The Y error was due to not closing the command with a whitespace char. MA 1234 4567 89FA BCDE* although reporting back on the acknowledge as 'MA 1234 4567 89FA BCDE' was being processed into the command structure as 'MA 1234 4567 89FA BCD'. I did not find this until I added a code for querying the current coordinate and discovered RP* did not report but RP * did. For those who are reading and may not know the format based on reading the code.... Verb (2 bytes) space BeginX (4 Bytes) space BeginY (4 Bytes) space FinishX ( 4 Bytes) space FinishY (4 Bytes) space ArcCenterX (4 Bytes) space ArcCenterY (4 Bytes) space BeginAngle (4 bytes) space EndingAngle (4 Bytes) space ToolDiameter (4 Bytes) space ToolBias (1 Byte) space * (end of command). Some commands do not use all fields and in those cases all fields right of the last applicable field are not sent and the * appears at the begin of the next field, unused fields between the verb field and the end of command are filled with XXXX. An 'X' causes the Chex function to return a -1 which is an invalid hexadecimal value as -1 would be FE. My command set is growing faster than I can code the commands I already wanted. I am however making strides toward the end goal with one squashed bug at a time! If you are merely "browsing" and have a question of curiosity ask it please! It may not be as dumb of a question as you might convince yourself it is.

ajofscott:
While running the machine making test cuts I noted my Current cursor is remaining 0,0. Is this statement being interpreted as ‘A replaced with NOT B’?

Current.X != ThisOperation.Begin.X

Where my premise was != meant the same as <> or not equal to.

That isn’t a statement. It would be if it had a semicolon on the end.

void setup ()
{
  int a, b = 5;
  
  a != b;
  
  Serial.begin (115200);
  Serial.println ();
  Serial.println (a);
  Serial.println (b);
  
}
void loop () {}

Output:

0
5

So yes, it appears to do that, but why not write:

Current.X = ! ThisOperation.Begin.X;

Wouldn’t that be clearer?