Error compiling

I have a uint8_t array in PROGMEM I am trying to read from (byte 8), second line of the code below.

Compiler error is "expected ')' before ';' token".

If I remark out this line, the sketch compiles no problem....

I can't see anything wrong, almost copied from the reference text....

if (! data_valid) {

colour = pgm_read_byte_near( RemoteXY_CONF[8] );

get_LED_RGB(colour);
RemoteXY.valid_r = red;
RemoteXY.valid_g = grn;
RemoteXY.valid_b = blu;
}

Perhaps it just needs a fresh pair of eyes......

Perhaps we need code tags and all your code, and the exact error message.

TolpuddleSartre:
Perhaps we need code tags and all your code, and the exact error message.

I can't post ALL the code, it exceeds the maximum number of characters

"colour" is a global uint8_t, so are red, grn, and blue

the get_LED_RGB function works if I just put a number as the argument to it

It's throwing up a lot of references to the declaration of the RemoteXY_CONF array, which is in RemoteXY.h

Here's all the error messages....

Arduino: 1.8.5 (Windows 7), Board: "Arduino Nano, ATmega328P"

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,

from sketch\BaitBoat2.ino.cpp:1:

C:\Users\Dave\Documents\Arduino\BaitBoat2\BaitBoat2.ino: In function 'void loop()':

C:\Users\Dave\Documents\Arduino\libraries\RemoteXY/RemoteXY.h:158:23: error: expected primary-expression before 'const'

#define RemoteXY_CONF const PROGMEM RemoteXY_CONF_PROGMEM

^

C:\Users\Dave\Documents\Arduino\BaitBoat2\BaitBoat2.ino:557:35: note: in expansion of macro 'RemoteXY_CONF'

colour = pgm_read_byte_near(RemoteXY_CONF[8]);

^

C:\Users\Dave\Documents\Arduino\libraries\RemoteXY/RemoteXY.h:158:23: error: expected ')' before 'const'

#define RemoteXY_CONF const PROGMEM RemoteXY_CONF_PROGMEM

^

C:\Users\Dave\Documents\Arduino\BaitBoat2\BaitBoat2.ino:557:35: note: in expansion of macro 'RemoteXY_CONF'

colour = pgm_read_byte_near(RemoteXY_CONF[8]);

^

BaitBoat2:557: error: expected ')' before ';' token

colour = pgm_read_byte_near(RemoteXY_CONF[8]);

^

exit status 1
expected ')' before ';' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

See how much easier it is, when you can see the whole picture?

Do the macro expansion manually, and you'll see the problem.

TolpuddleSartre:
See how much easier it is, when you can see the whole picture?

Do the macro expansion manually, and you'll see the problem.

I have no idea what you mean by "Do the macro expansion manually".

Perhaps if you posted the whole of the details it might get easier, but one-liners are not much help to a novice.

Are you suggesting I have to modify RemoteXY.h ??

The macro "RemoteXY_CONF" is invalid, fix it :slight_smile:

Here is the code section that defines the bytes in RemoteXY_CONF

It is in my sketch, not in RemoteXY.h

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////


// RemoteXY select connection mode and include library 
#define REMOTEXY_MODE__HARDSERIAL

#include <RemoteXY.h>

// RemoteXY connection settings 
#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 115200


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,35,0,10,0,13,3,8,178,4,
  131,1,0,57,13,5,1,8,31,77,
  97,105,110,0,129,0,4,1,40,5,
  0,8,66,97,105,116,66,111,97,116,
  32,67,111,110,116,114,111,108,0,131,
  0,36,57,13,5,2,16,8,83,101,
  116,117,112,0,5,32,3,12,42,42,
  1,178,26,31,129,0,45,32,3,4,
  1,8,82,0,129,0,0,31,2,4,
  1,8,76,0,129,0,20,8,9,4,
  1,8,70,87,68,0,4,0,52,10,
  8,47,1,204,26,129,0,52,58,9,
  3,1,24,76,105,103,104,116,115,0,
  129,0,51,5,10,3,1,24,66,97,
  116,116,101,114,121,0,130,0,60,1,
  4,4,1,134,130,0,48,1,12,4,
  1,1,66,131,48,1,16,4,1,30,
  8,65,22,69,0,10,10,1,1,0,
  70,1,8,8,1,246,31,80,0,129,
  0,81,4,7,3,1,24,72,111,111,
  107,0,129,0,79,7,11,3,1,24,
  82,101,108,101,97,115,101,0,65,22,
  90,0,10,10,1,1,0,91,1,8,
  8,1,246,31,83,0,66,1,93,14,
  4,39,1,1,17,4,0,91,10,8,
  47,1,2,26,66,1,72,14,4,39,
  1,1,17,4,0,70,10,8,47,1,
  2,26,129,0,79,58,12,3,1,24,
  72,111,112,112,101,114,115,0,129,0,
  20,55,8,4,1,8,82,69,86,0,
  129,0,46,1,14,5,2,24,83,101,
  116,117,112,0,129,0,2,14,30,3,
  2,8,80,111,114,116,32,72,111,112,
  112,101,114,32,83,101,114,118,111,32,
  37,0,129,0,35,8,12,3,2,8,
  77,105,110,0,7,22,35,12,11,5,
  2,94,26,2,129,0,53,8,6,3,
  2,8,77,97,120,0,7,22,52,12,
  11,5,2,94,26,2,129,0,1,21,
  30,3,2,8,83,116,98,100,32,72,
  111,112,112,101,114,32,83,101,114,118,
  111,32,37,0,7,22,35,19,11,5,
  2,94,26,2,7,22,52,19,11,5,
  2,94,26,2,129,0,9,28,31,3,
  2,8,82,117,100,100,101,114,32,83,
  101,114,118,111,32,37,32,32,32,40,
  45,47,43,41,0,7,22,44,26,11,
  5,2,94,26,2,129,0,11,35,30,
  3,2,8,84,104,114,111,116,116,108,
  101,32,69,83,67,32,37,32,32,32,
  40,45,47,43,41,0,7,22,44,33,
  11,5,2,94,26,2,129,0,16,50,
  15,3,2,8,66,97,116,116,101,114,
  121,32,40,86,41,0,7,14,35,48,
  11,5,2,94,26,2,2,129,0,1,
  43,30,3,2,8,72,111,111,107,32,
  82,101,108,101,97,115,101,32,84,105,
  109,101,32,83,0,7,22,35,41,11,
  5,2,94,26,2,1,2,80,0,20,
  6,2,204,31,82,101,115,101,116,32,
  73,110,100,105,99,97,116,111,114,115,
  0,129,0,84,8,13,3,2,8,68,
  105,114,101,99,116,105,111,110,0,129,
  0,68,22,6,3,2,8,84,114,105,
  109,0,7,22,66,26,11,5,2,94,
  26,2,7,22,66,33,11,5,2,94,
  26,2,65,31,79,51,21,12,2,129,
  0,82,52,14,3,2,178,0,1,2,
  80,54,19,6,2,0,1,83,97,118,
  101,0,129,0,48,13,2,4,2,8,
  60,0,129,0,48,20,2,4,2,8,
  60,0,2,0,81,12,18,5,2,29,
  24,1,136,82,69,86,0,78,79,82,
  0,2,0,81,19,18,5,2,29,24,
  1,136,82,69,86,0,78,79,82,0,
  2,0,81,26,18,5,2,29,24,1,
  136,82,69,86,0,78,79,82,0,2,
  0,81,33,18,5,2,29,24,1,136,
  82,69,86,0,78,79,82,0 };
  
// this structure defines all the variables of your control interface 
struct {

    // input variable
  int8_t joystick_1_x; // =-100..100 x-coordinate joystick position 
  int8_t joystick_1_y; // =-100..100 y-coordinate joystick position 
  int8_t lights; // =0..100 slider position 
  uint8_t hkr_p; // =1 if button pressed, else =0 
  uint8_t hkr_s; // =1 if button pressed, else =0 
  int8_t stbdhopper; // =0..100 slider position 
  int8_t porthopper; // =0..100 slider position 
  int16_t PHop_Min;  // −32767.. +32767 
  int16_t PHop_Max;  // −32767.. +32767 
  int16_t SHop_Min;  // −32767.. +32767 
  int16_t SHop_Max;  // −32767.. +32767 
  int16_t Rud_Rng;  // −32767.. +32767 
  int16_t Thr_Rng;  // −32767.. +32767 
  float Batt_Volts;
  int16_t Hook_Rel;  // −32767.. +32767 
  uint8_t Reset; // =1 if button pressed, else =0 
  int16_t Rud_Trim;  // −32767.. +32767 
  int16_t Thr_Trim;  // −32767.. +32767 
  uint8_t Save_Settings; // =1 if button pressed, else =0 
  uint8_t PHop_Rev; // =1 if switch ON and =0 if OFF 
  uint8_t SHop_Rev; // =1 if switch ON and =0 if OFF 
  uint8_t Rud_Rev; // =1 if switch ON and =0 if OFF 
  uint8_t Thr_Rev; // =1 if switch ON and =0 if OFF 

    // output variable
  int8_t batt_meter; // =0..100 level position 
  uint8_t rel_flag_p_r; // =0..255 LED Red brightness 
  uint8_t rel_flag_p_g; // =0..255 LED Green brightness 
  uint8_t rel_flag_s_r; // =0..255 LED Red brightness 
  uint8_t rel_flag_s_g; // =0..255 LED Green brightness 
  int8_t s_max; // =0..100 level position 
  int8_t p_max; // =0..100 level position 
  uint8_t valid_r; // =0..255 LED Red brightness 
  uint8_t valid_g; // =0..255 LED Green brightness 
  uint8_t valid_b; // =0..255 LED Blue brightness 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 
  
} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

Danois90:
The macro "RemoteXY_CONF" is invalid, fix it :slight_smile:

How can it be "wrong" if works...

This array block is pushed to the connected mobile to define the control screens.

So what exactly is stopping me reading from that array ?

Just to clarify what TolpuddleSartre wrote...

When you #define something, that's a macro.

#define bla blub

From that point on, the compiler will replace any occurrence of bla with blub. That's called macro expansion. It expands the thing you've #defined to the stuff you've #defined it to be. In this case, it expands bla into blub.

In your case, RemoteXY_CONF is a macro. It occurs in the line you're asking about. That line looks normal if you don't know that RemoteXY_CONF is a macro, but do the macro expansion manually, and you'll see the problem.

You are using the macro "#define RemoteXY_CONF const PROGMEM RemoteXY_CONF_PROGMEM" as argument to "pgm_read_byte_near", your code will expand to:

pgm_read_byte_near(const PROGMEM RemoteXY_CONF_PROGMEM[8]);

Which is a malformed statement, therefore the macro is not working.

Jobi-Wan:
Just to clarify what TolpuddleSartre wrote...

When you #define something, that's a macro.

#define bla blub

From that point on, the compiler will replace any occurrence of bla with blub. That's called macro expansion. It expands the thing you've #defined to the stuff you've #defined it to be. In this case, it expands bla into blub.

In your case, RemoteXY_CONF is a macro. It occurs in the line you're asking about. That line looks normal if you don't know that RemoteXY_CONF is a macro, but do the macro expansion manually, and you'll see the problem.

From what I can see RemoteXY_CONF is a uint8_t array, I can't see it #define'd anywhere, it must be in the RemoteXY library....

Does this mean that there is no way to read bytes from RemoteXY_CONF ??

I would not have a clue how to "do the macro expansion manually" with my sketch....

Here's a simpler example with much less "CONF"

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library 
#define REMOTEXY_MODE__SOFTSERIAL
#include <SoftwareSerial.h>

#include <RemoteXY.h>

// RemoteXY connection settings 
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,11,0,8,108,0,
  4,0,26,14,10,36,2,26 };
  
// this structure defines all the variables of your control interface 
struct {

    // input variable
  int8_t slider_1; // =0..100 slider position 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

daba:
From what I can see RemoteXY_CONF is a uint8_t array, I can't see it #define'd anywhere, it must be in the RemoteXY library....

Does this mean that there is no way to read bytes from RemoteXY_CONF ??

I would not have a clue how to "do the macro expansion manually" with my sketch....

In post #2 where you post all messages, you can see where and how it is #defined.

Jobi-Wan:
In post #2 where you post all messages, you can see where and how it is #defined.

In which case, I'll go no further, I'm not into modifying someone else's library code.... I'll send him a message with a link to this thread, and see if he can "fix it" so we can read bytes from that array.

Does the library come with any example sketches that show how it is intended to be used?

daba:
In which case, I'll go no further,

How about using the time waiting for a response reading this ?

Jobi-Wan:
Does the library come with any example sketches that show how it is intended to be used?

Not really, the "Examples" page just shows some finished (sic) projects.

the web-site is here if you want to look.

I really like RemoteXY, it's simple enough to use, I can modify my screen layout and content in the EDITOR, generate the "source code", and copy/Paste-over the configuration block in my sketch. When the phone connects, it sends all the _CONF data to the phone to reproduce the design-time.

Not being able to read from that _CONF array isn't a deal-breaker. I'm only using it to get the screen background colour RGB values, I can see the number, so I'll continue just quoting it literally.

Does it show the source code for those projects? And do they read from the CONF array?

But let's get back to this macro expansion thing...

You include a header that defines this:

#define RemoteXY_CONF const PROGMEM RemoteXY_CONF_PROGMEM

Then you declare an array like this:

uint8_t RemoteXY_CONF[] =
 { 255,35,0,10,0,13,3,8,178,4,
 131,1,0,57,13,5,1,8,31,77,

Then you read from that array:

colour = pgm_read_byte_near(RemoteXY_CONF[8]);

Note that the macro occurs in both the declaration of the array and in the attempt at reading from it.

Do the macro expansion in the array declaration. In a text editor, not in your head. You will see that it still looks good.

Then do the macro expansion in the colour read part. You should see that it does not look good.

Look at the now macro-expanded array declaration again. You should see what to read from.

I may be a new forum member here, but I am in no way unfamiliar with forum etiqutte.

My field is PLC Programming, and was once a technical trainer for Rockwell Automation (you may have heard of them).

I am also a regular contributor to, and moderator for, the PLCs.net community, with over 4,000 posts to date. My user-name there is the same as here.

There is absolutely no way I would have posted replies like some of the earlier ones, being as much use as chocolate teapots. Terse, unhelpful, and slightly condescending. Everyone needs some help, at all levels.

There, I've had my say, and if this post gets me barred from this forum, then so be it.

Let's just examine your technical writer's approach to problem solving, shall we? (you don't have to answer that, it was rhetorical)

First post, incomplete code (not in code tags, so you got the 8) smilie) and an incomplete error message.

Second post, still no code ("it's too long" - you could have attached it), but an error message that points exactly to your problem.

Third post

Perhaps if you posted the whole of the details it might get easier, but one-liners are not much help to a novice.

So, you can post incomplete snippets, but we have to provide fully crafted answers?

but I am in no way unfamiliar with forum etiqutte (sic)

Yeah, right.

This isn't about etiquette, it's about common-sense.

TolpuddleSartre:
An embroidery forum? Gardening?

Have you been on those forums?
Some people use a type-B needle for underhand stitching. Savages!