error: expected initializer before 'read_data'

Hello Guys and Gals

I need your help with something. Currently I'm creating an app named "Cygnus". And I added two function which uses two Serial Ports of the Mega 2560 (Serial1 and Serial2). And as soon I'm trying to compile the code, I'm getting the following error:

Cygnus:138: error: expected initializer before 'read_data'
Cygnus:139: error: expected initializer before 'write_data'
Cygnus_FS20:8: error: expected initializer before 'read_data'

And now I need your help. I've googled already and found out, this error is always created by a missing semicolon. But I found not a single missing semicolon. And I tried to change somethings in the code too, but it changes nothing. The error is only getting away, when I'm deleting the declaration in the main .ino and in the Cygnus_FS20 tab. Both serial ports are initialised in setup().

Here's a part from cygnus.ino:

//Cygnus_Display
void check_standby();
void check_activity_display();
void lcd_on(int type);
void lcd_off(int type);
void clear_lcd(int type);
boolean check_buttonpress(int type, String name, int posx, int posy);
void create_button(int type, String buttname, String value, int posx, int posy, int width, int height);
void display_page(int type, String title, String layout, String* data, int* posx, int* posy);
void display_bitmap(int type, String name, boolean cleardisplay = false);
void display_message(int type, String message, boolean cleardisplay = false);
void throw_error(String type, String message, String event = "", boolean security_test = false);
//Cygnus_FS20
String function read_data(String input); //Line 138
void function write_data(char input); //Line 139
//Cygnus_Logs
String get_setlog();
void clear_setlog();
void write_setlog(String message);
String get_errorlog();
void clear_errorlog();
void write_errorlog(String message);
//Cygnus_Network
boolean connect_to_server(char* host, char* script);
boolean send_notify(char* host, char* script, char* state, String notify, boolean security_test = false);
void check_httprequests();
//Cygnus_Security
boolean check_output_behavior(int pin);
void check_runsecurity();
void check_outputs_lowset();
void clear_output_files();
void do_siren_test();
void stop_siren_test();
void siren_set(String event);
void siren_unset(String event = "");
void silent_siren(String event = "");

void setup() {
   //More code...
}

void loop() {
   //More code...
}

And here is the full Cygnus_FS20.ino:

/*
 * Cygnus
 * FS20-Funktionen
 * Copyright 2014 Charlotte Dunois
 */
 
/* Lest die Serial-Daten */
String function read_data(String input) {
  if(Serial2.available() > 0) {
    char returned = Serial.read();
    if(returned != "") {
      char data[200];
      while(Serial2.peek() != "") {
        strcat(data, char(Serial2.read()));
      }
      
      if(data != "") {
        String new_data = String(data);
        int index = new_data.indexOf(input);
        if(index != -1) {
          return new_data;
        }
      }
    }
  }
  return;
}

/* Schreibt Serial-Daten */
void function write_data(char input) {
  Serial1.write(input);
  Serial1.flush();
  return;
}

Can you help me with this error? :frowning:

Regards,
Charlotte Dunois

String function read_data(String input); //Line 138
void function write_data(char input); //Line 139

What is the word function doing in there, besides confusing the hell out of the compiler?

@CharlotteDunois, been programming in Pascal recently? (I often get the datatype / variable name backwards when switching between the two languages.)

PaulS:

String function read_data(String input); //Line 138

void function write_data(char input); //Line 139



What is the word function doing in there, besides confusing the hell out of the compiler?

Declaring a function because the function is not in main file?

No, only PHP. ;O

Declaring a function because the function is not in main file?

So don't do it. This is C.

Grumpy_Mike:

Declaring a function because the function is not in main file?

So don't do it. This is C.

If I don't do this, the compiler is bitching around. That's why I've done this.

If I don’t do this, the compiler is bitching around. That’s why I’ve done this.

And the compiler likes it?

There are lots of things you can do to upset the compiler.
Do you need extern

Grumpy_Mike:

If I don't do this, the compiler is bitching around. That's why I've done this.

And the compiler likes it?

Yes, much more than without it. ;o

Do you need extern

Well, I've never heard of "extern". And I don't know what I should do with extern.

Yes, much more than without it. ;o

Sorry but an error is an error, you can't say it is less of an error just because you have less verbiage on the printout.

Grumpy_Mike:

Yes, much more than without it. ;o

Sorry but an error is an error, you can't say it is less of an error just because you have less verbiage on the printout.

There is no error at all and I'm getting this kind error if the function is no declared in main file:

error: 'display_bitmap' was not declared in this scope

CharlotteDunois:

PaulS:

String function read_data(String input); //Line 138

void function write_data(char input); //Line 139



What is the word function doing in there, besides confusing the hell out of the compiler?

Declaring a function because the function is not in main file?

PaulS is asking about the word “function” not the concept of a function. In other words, the highlighted part has to be removed…

String function read_data(String input); //Line 138
void function write_data(char input); //Line 139

Which is also why I asked if you had been programming in another language recently; a language that includes the keyword “function”.

Oh! :confused:
Now it works. Thanks! :>

You are welcome.