Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By David Torres
#47607 Hi everyone!

I'm trying to make a project with Arduino IDE, but I can't make it works.

I have two variables:
Code: Select allchar* receivedbyserial;
char actualcharserial;


And I want to make this association:

Code: Select allif (Serial.available() > 0) {
      actualcharserial = Serial.read();
      *receivedbyserial = actualcharserial;
      receivedbyserial++;
    }


The code chrashes in the line *receivedbyserial = actualcharserial; and I don't know why...

Can you help me?
Thanks a lot!!
User avatar
By jcmvbkbc
#47609
David Torres wrote:
Code: Select allchar* receivedbyserial;
char actualcharserial;


Code: Select allif (Serial.available() > 0) {
      actualcharserial = Serial.read();
      *receivedbyserial = actualcharserial;
      receivedbyserial++;
    }


The code chrashes in the line *receivedbyserial = actualcharserial; and I don't know why...

You need to initialize receivedbyserial so that it points to a writable memory buffer before you can do this assignment.
And make sure it doesn't point past the buffer end in the process of receivedbyserial++-ing.
User avatar
By eriksl
#50945 This has nothing to do with esp8266, basic C knowledge.

It seems you don't want to use a pointer at all here.

Use something like:

char a;

a = function();