error: 'nullptr' was not declared in this scope

Issue #24 resolved
Thomas Güntner created an issue

Hi Marc,

i´ve just bought Uduino in the Unity Asset Store. After installation, I tried to upload the Uduino sketch like in your Quick Start Guide. With the Arduino IDE 1.8.2 I´m getting this error:


C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\CoolDown\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10802 -build-path C:\Users\CoolDown\AppData\Local\Temp\arduino_build_452297 -warnings=none -build-cache C:\Users\CoolDown\AppData\Local\Temp\arduino_cache_860677 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\CoolDown\Documents\Arduino\libraries\Uduino\examples\Uduino\Uduino.ino C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\CoolDown\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10802 -build-path C:\Users\CoolDown\AppData\Local\Temp\arduino_build_452297 -warnings=none -build-cache C:\Users\CoolDown\AppData\Local\Temp\arduino_cache_860677 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\CoolDown\Documents\Arduino\libraries\Uduino\examples\Uduino\Uduino.ino Using board 'nano' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr Detecting libraries used... "C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\CoolDown\AppData\Local\Temp\arduino_build_452297\sketch\Uduino.ino.cpp" -o "nul" Generating function prototypes... "C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs" "C:\Users\CoolDown\AppData\Local\Temp\arduino_build_452297\sketch\Uduino.ino.cpp" -o "C:\Users\CoolDown\AppData\Local\Temp\arduino_build_452297\preproc\ctags_target_for_gcc_minus_e.cpp" open NUL: Das System kann die angegebene Datei nicht finden. Fehler beim Kompilieren für das Board Arduino Nano.


I know that the main problem with Versions above 1.6.3 is the "open NUL:" error. I´ve posted the first error just for the documentation. Even if I try to upload the Blink example or yours, I got that error.

With Version 1.6.3 I can properly upload every Arduino example. But Uduino throws me this:


Build-Optionen wurden verändert, alles wird neu gebaut Verwende die Bibliothek Uduino im Ordner: C:\Users\CoolDown\Documents\Arduino\libraries\Uduino (legacy) Verwende die Bibliothek Servo im Ordner: C:\Program Files (x86)\Arduino\libraries\Servo

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs -IC:\Users\CoolDown\Documents\Arduino\libraries\Uduino -IC:\Program Files (x86)\Arduino\libraries\Servo\src C:\Users\CoolDown\AppData\Local\Temp\build4580879749641212766.tmp\Uduino.cpp -o C:\Users\CoolDown\AppData\Local\Temp\build4580879749641212766.tmp\Uduino.cpp.o C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10603 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs -IC:\Users\CoolDown\Documents\Arduino\libraries\Uduino -IC:\Program Files (x86)\Arduino\libraries\Servo\src -IC:\Users\CoolDown\Documents\Arduino\libraries\Uduino\utility C:\Users\CoolDown\Documents\Arduino\libraries\Uduino\Uduino.cpp -o C:\Users\CoolDown\AppData\Local\Temp\build4580879749641212766.tmp\Uduino\Uduino.cpp.o C:\Users\CoolDown\Documents\Arduino\libraries\Uduino\Uduino.cpp: In static member function 'static void Uduino::printIdentity()': C:\Users\CoolDown\Documents\Arduino\libraries\Uduino\Uduino.cpp:80:40: error: 'nullptr' was not declared in this scope if(Uduino::_instance->customPrint != nullptr) { ^ Fehler beim Kompilieren.


I red you helped "heroofourtime" in August 2018 with the error "nullptr", but it wasn´t really helpful in my case.

Tried Nano and Mega2560. OS: Windows 7 64bit

What can I do? I appreciate any help. Can´t wait to play with it. :-)

Thank you.

Nice greetings,

Thomas

Comments (11)

  1. Thomas Güntner reporter

    Hi Marc,

    thank you so much for your quick response and the fix. Now my Arduino Nano works great. I can upload the update without any errors.

    But now my Arduino Mega 2560 isn´t that polite to me. The upload with the IDE works properly. In Unity it doesn´t work like my Nano. For my project I have to use the Mega.

    Here are the following steps I did.

    Steps with Nano: 1. Upload the updated version via IDE. 2. In Unity I open the scene "BlinkLED" like your description "Quick start guide" 3. Add Uduino library in the Arduino folder, click Move = everything OK 4. Change project settings, click Fix now = everything OK 5. Start using Arduino, click Discover ports = RX blinks once, then RX and TX twice and the Board informations will be shown Click Play = RX blinks three times, TX once, then everything works great. I can adjust i.e. the "Blink Speed" etc.

    Steps with Mega: Steps 1,2,3,4 and 5 are the same and work like with Nano. I also see the Board information etc. Click Play = RX blinks about 9 times, L (Pin 13) blinks once. Then in Unity the Panel "Arduino" switch back to "No Arduino connected". After that, nothing more happens. No blinking etc.. Only the light L and "ON" is still burning.

    How can I fix that problem or what would be the next step?

    Thank you again for let my Nano run.

    Greetings,

    Thomas

  2. Thomas Güntner reporter

    I found a workaround. As long as "Read on Thread" is unchecked for my Mega, it works. The Blink example and the "Advanced - Write to Arduino" is working. I just modified the original "Advanced - Write to Arduino" code for a Buzzer instead of the LED. For my Nano I don´t have to uncheck it.

    But it´s still a bit buggy.

    Sometimes after I click Play, Unity check "Read on Thread" again. Looks like it didn´t "save" my change. The only thing I found out to "fix" that, is to remove the specific Component from the tab "Advanced", then click Play, uncheck "Read on Thread", stop it and drop the class into the "Advanced", again. After this procedure, it stays unchecked and my sketch works.

    By the way: When I set the library path and click "Move" then the Update you sent me will be overwritten with the old (broken) one and I have to overwrite the Uduino library manually.

    I hope that will be fixed in the future. Or do you have some tips for me?!

    Thanks.

    Greetings,

    Thomas

  3. Marc Teys repo owner

    The Arduino MEGA has a small delay before starting the serial. If you change the setting under "Advanced>DiscoverDelay>" to 1.5s or more.

    It should fix your problem, even with "Read on Thread"

  4. Thomas Güntner reporter

    Thank you. It´s working (when it´s saved). When I set "Discover delay" or anything else, after clicking Play, it´s automatically reset.

    The solution that helped me:

    While in Play-Mode I have to change the value to i.e. 2. Then I must click on "Discover ports". After that the settings are "saved" and the Arduino is blinking etc.. Otherwise the changes are reset.

    Thanks again for your quick help.

  5. Marc Teys repo owner

    This "saving" behavior problem has been fixed in the new version of Uduino.

    I'm glad it's working, don't hesitate to tell me if you find any other issues.

  6. Thomas Güntner reporter

    Please excuse the bad display of my code. (No correct line-breaks) I have written this text in Word and copied it into the comment-box.

    With which Version, the "saving" problem should be fixed? Unity says the Current Version is: 2.1.8. and I still have the problem. But that´s not my major problem now.

    Can you take a look at my code, please: (It´s just an fast written code with snippets from "Advanced - Write to Arduino" without paying attention to it´s "look") :-) Info: On Port 2 I have connected a Buzzer.

    Unity


    using System.Collections; using System.Collections.Generic; using UnityEngine; using Uduino;

    public class BuzzerEmpfangen : MonoBehaviour {

    void Update()
    {
        if (Input.GetKeyDown("left"))
        {          
            //It doesn´t matter, if my parameter is a String or an Int.
           UduinoManager.Instance.sendCommand("turnOff", "22");
        }
        else if (Input.GetKeyDown("right"))
        {
            UduinoManager.Instance.sendCommand("turnOn", "12");
        }
    
    
    }
    

    }


    Arduino


    #include<Uduino.h> Uduino uduino("PixelBoard");

    void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode (2, OUTPUT); //buzzer ky-006

    uduino.addCommand("turnOn", turnOnPixel); uduino.addCommand("turnOff", turnOffPixel); }

    void loop() { // put your main code here, to run repeatedly: uduino.update(); delay(10); }

    void turnOnPixel() { digitalWrite(13, HIGH); //try to get Value by charToInt. //by sending the command/value from unity via textbox "Send Commands" then the right value is received //triggered values by clicking a key (left or right), it sends different values (see explanation below) int value = uduino.charToInt(uduino.getParameter(0)); if(value == 11) { digitalWrite(2, LOW); delay(500); digitalWrite(2, HIGH); delay(500); digitalWrite(2, LOW); delay(500); digitalWrite(2, HIGH); delay(500); digitalWrite(2, LOW); delay(500); } else { digitalWrite(2, LOW); delay(5000); digitalWrite(2, HIGH); delay(5000); digitalWrite(2, LOW); delay(5000); }

    digitalWrite(2, HIGH); }

    void turnOffPixel() { digitalWrite(13, LOW); //try to get Value by atoi. //by sending the command/value from unity via textbox "Send Commands" then the right value is received //triggered values by clicking a key (left or right), it sends different values (see explanation below) int led = atoi(uduino.getParameter(0));
    if(led == 22) { digitalWrite(2, LOW); delay(500); digitalWrite(2, HIGH); delay(500); } else { digitalWrite(2, LOW); delay(2000); digitalWrite(2, HIGH); delay(2000); } digitalWrite(2, LOW);
    }


    This example is working well, but the Unity routine is running the Arduino Sketch twice, everytime. (maybe a Bug???) It´doesn´t matter, if I send the value by tipping in the textbox (Send commands) or by triggering the functions i.e. Input.GetKeyDown.

    I.e. I trigger the left key to send "22" to the function "turnOff", the entry in Unity "Last sent Value" == "turnOff 0" With every left click, it counts -1. That means, with the second left click the "Last sent Value" == "turnOff -1". Right click counts +1. With that values, I have no chance to set my functions in Arduino properly.

    In my project, I have to send a value from Unity to Arduino i.e. 200, to move a stepper motor (with motor shield). I am using the library <AccelStepper.h>

    A direct control via Arduino to the stepper motor is working well. I need code that sends a value to my Arduino sketch, that sends the value to my stepper motors. Not more, not less.

    What did I wrong? Maybe you can give me an example code. I appreciate any help.

    Thank you.

  7. Marc Teys repo owner

    Can you post the message to the forum? https://marcteyssier.com/uduino/forum/ I'll answer but if you post it on the forum other people will see the response. ;)

    For the version, it's the next one, soon coming in the asset store

    PS: Have you looked at the example Advanced > SendCommandToArduino on the package ? It will help you, as it is close from what you need.

  8. Thomas Güntner reporter

    I just posted my text to the forum. https://marcteyssier.com/uduino/forum/d/54-problems-with-sending-values-from-unity-to-arduino

    Sounds great, that it will be fixed in the next version. I didn´t find anything in the examples what sounds like SendCommandToArduino. That´s what I have:

    Under Advanced:

    BoardType Bundle ButtonTrigger EncoderLibrary LedIntensity MultipleArduino OneLineRead ReadSensor ServoOptimized

    Under Basic:

    AnalogRead AnalogWrite BlinkLed DigitalReadButton Events FadeInOut ReadWrite Serve

    Maybe I overlooked it. ;-)

    It´s great to have an support, that´s answering fast and reliable, like you.

    Thanks.


    Update: 7:07 PM

    I have updated my post in your forum.

    Found out something new.

    Take a look, it could be interesting. :-)


    7:45 PM Another Update.

    Creating a new project fixed the "sending values by pressing a key" problem.

    I hope these informations are helpful for you.

    ;-)

  9. Thomas Güntner reporter

    Now I´m at a point where I can start coding for my major project. "Control a stepper motor from unity"

    I didn´t get any connection to Arduino respectively I can´t send values to Arduino. Closer error description. See below.

    Please take a look at my sketch.

    What could be wrong?

    Arduino


    #include<Uduino.h> #include <AccelStepper.h>

    Uduino uduino("accelstepper");

    AccelStepper stepper (4, 8, 9, 10, 11, true);

    void setup()

    {

    Serial.begin(9600);

    pinMode (2, OUTPUT);

    stepper.setMaxSpeed(20);

    stepper.setAcceleration(1000);

    uduino.addCommand("SetPosition", SetPositionTo);

    delay(1000);

    digitalWrite(2, HIGH); //Buzzer

    delay(1000);

    digitalWrite(2, LOW);

    void loop()

    {

    uduino.update();

    //uduino.readSerial();

    delay(15);

    }

    void SetPositionTo()

    {

    digitalWrite(2, HIGH);   //Buzzer
    
    delay(100);
    
    digitalWrite(2, LOW);
    
    int val = atoi(uduino.getParameter(0));
    

    if(val >= -300 && val <= 200)

    {

      stepper.moveTo(val);
    
      stepper.runToPosition();
    

    }

    else

    {

       digitalWrite(2, HIGH);    //Buzzer
    
       delay(5000);
    
       digitalWrite(2, LOW);
    
    }
    

    }


    Unity


    using System.Collections;

    using System.Collections.Generic;

    using UnityEngine;

    using Uduino;

    public class Stepper : MonoBehaviour

    {

    void Update()
    
    {
    
        //0 = Center of stepper
    
        //200 = 200 steps (one turn)
    
        if (Input.GetKeyDown("up"))
    
        {
    
            UduinoManager.Instance.sendCommand("SetPosition", "0");
    
        }
    
        else if (Input.GetKeyDown("down"))
    
        {
    
            UduinoManager.Instance.sendCommand("SetPosition", "200");
    
        }
    
    }
    

    }


    In Unity after click on Play, the message says "No Arduino connected".

    The console displays:

    Unable to find style 'OL Titleleft' in skin 'LightSkin' Layout UnityEngine.GUIStyle:op_Implicit(String) Uduino.UduinoManagerEditor:SetColorAndStyles() (at Assets/Uduino/Editor/UduinoManagerEditor.cs:197) Uduino.UduinoManagerEditor:OnInspectorGUI() (at Assets/Uduino/Editor/UduinoManagerEditor.cs:511) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

    Impossible to get name on <color=#2196F3>[COM17]</color>. Closing. UnityEngine.Debug:LogWarning(Object) Uduino.Log:Warning(Object, Boolean) (at Assets/Uduino/Scripts/Extra/UduinoDebug.cs:26) Uduino.UduinoConnection:BoardNotFound(UduinoDevice) (at Assets/Uduino/Scripts/Boards/Finder/UduinoConnection.cs:162) Uduino.UduinoConnection:DetectUduinoThread(UduinoDevice) (at Assets/Uduino/Scripts/Boards/Finder/UduinoConnection.cs:100) Uduino.<>c__DisplayClass7_0:<DetectUduino>b__0() (at Assets/Uduino/Scripts/Boards/Finder/UduinoConnection.cs:63) System.Threading.ThreadHelper:ThreadStart()

    Closing port : <color=#2196F3>[\.\COM17]</color> UnityEngine.Debug:LogWarning(Object) Uduino.Log:Warning(Object, Boolean) (at Assets/Uduino/Scripts/Extra/UduinoDebug.cs:26) Uduino.UduinoDevice_DesktopSerial:Close() (at Assets/Uduino/Scripts/Boards/Devices/UduinoDevice_DesktopSerial.cs:273) Uduino.UduinoConnection:BoardNotFound(UduinoDevice) (at Assets/Uduino/Scripts/Boards/Finder/UduinoConnection.cs:163) Uduino.UduinoConnection:DetectUduinoThread(UduinoDevice) (at Assets/Uduino/Scripts/Boards/Finder/UduinoConnection.cs:100) Uduino.<>c__DisplayClass7_0:<DetectUduino>b__0() (at Assets/Uduino/Scripts/Boards/Finder/UduinoConnection.cs:63) System.Threading.ThreadHelper:ThreadStart()

    I think it´s a problem with the library "AccelStepper"

    I´m thankful for any help.

    Greetings,

    Thomas

  10. Log in to comment