recompiling changed library code [solved]

hi,

I want to develop an application based on the library SimpleSDAudio.
Everything works ok if I run the examples included with the library.

After changing some C-code in the library sources these changes are not compiled when compiling the sketch. Always the original code is used.
For example I added a variable, anzsect, in the public area of the class definition in SimpleSDAudio.h and wanted to print it with Serial.print.
The compiler outputs the error: 'class SdPlayClass' has no member named 'anzsect'.

What shall I do to get the changed code of the library compiled?
I am confused ! :confused:

SupArdu

I added a variable, anzsect, in the public area of the class definition in SimpleSDAudio.h and wanted to print it with Serial.print.

How exactly are you trying to print it ?

If you posted your code it would be easier to provide help.

Where is the library installed? What changes did you make? It is possible that you added code to the library but didn't do it right. Can you show the code? All of it please, the sketch, the .h file and the .cpp file.

Go into the preferences, check "Use external editor". Close the prefs. Compile. Reopen prefs, uncheck that option. Or switch to an external editor for real :). I like Geany.

hi,

the tip of SukkoPera does not work.

Here the code:
File SimpleSDAudio.h

class SdPlayClass {
// don't change this struct from here ...
  private:
    volatile uint8_t  _flags;
    uint8_t  _flags2;           // flags not touched in interrupt
    volatile uint16_t _Buflen;  // how much bytes are availible in buffer
    uint8_t *_pBuf;             // pointer to working buffer, used for audio and all kind of file access
    volatile uint8_t *_pBufout; // pointer where next byte can read from the buffer
    uint8_t *_pBufoutend;       // points to _pBuf + _Bufsize
    uint16_t _Bufsize;          // size of working buffer, must be a multiple of 512, at least 1024    
    volatile uint16_t _Bufin;   // index where next byte can put into the buffer
	uint16_t _BufsizeMinus512;	// used to avoid one calculation every time
	volatile uint8_t _WorkTrig; // counter to autotrigger worker
// ...to here as it is adressed directly by assembler functions!
    ...
public:
    SdPlayClass(void);  // constructor
    ~SdPlayClass(void); // destructor
    
	uint32_t anzsect;    // this is the inserted code for test purposes <------------
    void    interrupt(void);
...

In SimpleSDAudio.cpp there is a function definition where I added 1 line too.
The else path is really performed. Otherwise the program woud not work at all:

boolean SdPlayClass::setFile(char *fileName) {
  if(!_pBuf) {
    _lastError = SSDA_ERROR_NOT_INIT;
    return(false);
  }
  uint8_t retval;
  stop();
  _fileinfo.Size = 0;
  retval = SD_L2_SearchFile((uint8_t *)fileName, 0UL, 0x00, 0x18, &_fileinfo);
  
  if(retval) {
     _lastError = retval;
     return(false);
  } else {
		start_sec_file = _fileinfo.ActSector;
		act_playlist_index = 0;
		_fileinfo.ActSector = start_sec_file + playlist_anfsec[act_playlist_index];
		rest_anzsec = playlist_anzsec[act_playlist_index];
		Serial.print("filesize=");
		Serial.println(_fileinfo.size);
		anzsect = _fileinfo.size/512;   // this line inserted for test <-------------
     return(true);
  }
}

And now the sketch ( I have an UNO):

void setup()
{ 
  Serial.begin(9600);
  // If your SD card CS-Pin is not at Pin 4, enable and adapt the following line:
  // SdPlay.setSDCSPin(10);
  
  // Init SdPlay and set audio mode
  if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO)) {
    while(1); // Error while initialization of SD card -> stop.
  } 
  
  // Select file to play
  if(!SdPlay.setFile("EXAMPLE.AFM")) {
    while(1); // Error file not found -> stop.
  }   
      Serial.print(F("max. Zahl Sektoren="));   // this line is inserted and is compiled and executed
      Serial.print(SdPlay.anzsect);   // on this line the compiler reports the error
      
  // Start playback
  SdPlay.play();
  
  // Let the worker work until playback is finished
  while(!SdPlay.isStopped()) {
      SdPlay.worker();
  }
}

When I delete the line where the error is reported everything is ok.

Where is the library installed?

The library is installed in H:\Arduino\examples\SimpleSDAudio
All my editing is performed also in this location. For editing I am using Notepad++.
a frustrated SupArdu

Serial.print(SdPlay.anzsect);   // on this line the compiler reports the error

You have a variable named anzsect in the library not a method (function) named anzsect hence the error message

'class SdPlayClass' has no member named 'anzsect'.

I am really not the expert for object oriented programming :slight_smile: , but ...

Isn't it possible to access the variables in the public area of an object from outside the object?
What else does it mean "public"?

I will try it with a function returning the value of anzsect.

It is really a problem of compiling the changed code.

Now, I added a simple function to the class SdPlayClass :

uint32_t SdPlayClass::get_anzsect(void) {
	return anzsect;
}

The print statement now is:

Serial.print(SdPlay.get_anzsect());

Again the compiler reports: 'class SdPlayClass' has no member named 'get_anzsect'

:frowning:

SupArdu:
It is really a problem of compiling the changed code.

Now, I added a simple function to the class SdPlayClass :

uint32_t SdPlayClass::get_anzsect(void) {
return anzsect;

}




The print statement now is:


Serial.print(SdPlay.get_anzsect());




Again the compiler reports: 'class SdPlayClass' has no member named 'get_anzsect'

:(

Did you add a declaration for it in the class definition in the .h file?

yes, of course the h-file contains

...
public:
    SdPlayClass(void);  // constructor
    ~SdPlayClass(void); // destructor
    
	uint32_t anzsect;
	uint32_t get_anzsect();
	
    void    interrupt(void);
...

In the function
boolean SdPlayClass::setFile(char *fileName)
I also added a dummy call of get_anzsect() in order to see if this function can be executed:

...
uint32_t hhv=get_anzsect();
...

But now, considering your question, I deleted the declaration of get_anzsect() in the header file.

The status now is:

  • no declaration of get_anzsect() within header file
  • existing definition of get_anzsect() in the cpp file
  • call of get_anzsect() in the changed code of the library

In spite of calling the function within the code there is no error message during build.
Is'nt this a proof that the changed code is not used for build?

hi,

the problem is solved!
The questions where the library is located brought me on the right track.

I had the directory SimpleSDAudio twice, once in ...\examples\ and another one in ...\examples\libraries.

I guess that the IDE needs libraries in a directory named "libraries". During installation of the library I defined the path as ...\examples. But the IDE generated a folder "libraries" in the defined location and the library then in ...\examples\libraries\SimpleSDAudio.

Anyway, somebody (me? >:( ) copied the content of the library one level higher,
i.e. to ...\examples\SimpleSDAudio. Here I changed the code but the IDE used the code in
...\examples\libraries\SimpleSDAudio.

Thank you for your tips. I learned from them.

SupArdu

P.S.: how can I mark my question as "solved"?

P.S.: how can I mark my question as “solved”?

By editing the title of the first post

I cannot get into the text of the title to edit it.

The title is a link. Clicking on it for editing puts me to my first post back again.

Click on the Quick Edit button on yourfirst post. Then you will see at the top of the first post there is a white box with the title that is editable. Edit it and then click the Save button.