B4R Question Does b4r or arduino nano have cache?

hatzisn

Expert
Licensed User
Longtime User
Take a look at this code:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public Serial1 As Serial
End Sub

Private Sub AppStart
    Serial1.Initialize(9600)
    Log("AppStart")
    Delay(1500)

    RunNative("sarr", Null)
End Sub


#if C
void sarr (B4R::Object* o) {
   Serial.print("1235464654");
}

#End if

I try to run it experimentally in an Arduino Nano. This code displays this:

********************* PROGRAM STARTING ****************
1235464654AppStart

Here are two questions about that:
1) Why does it print the AppStart second?
2) If I change what it is printed in inline c and I press run, it displays the previous string. Does b4r have some kind of cache?
 

Daestrum

Expert
Licensed User
Longtime User
Probably change Serial.print(...) to Serial.println(...) so the buffer gets flushed.
The number got printed before AppStart as that was from previous print(...) and never got flushed until restart.

If you use Serial.print(....) always have a Serial.println() as the last print statement.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
You are correct, thank you.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…