B4R Question how to get C++ String data type to B4R?

belajaran

New Member
hi, i am new to programming using B4R
currently i have some problem to get string data form C++

this is the error message i got:

b4r_main.cpp:31: error: cannot convert 'std::string {aka std::basic_string<char>}' to 'Byte {aka unsigned char}' in assignment

is there any way to get string data from c++?
 

belajaran

New Member
Here is the code:

B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region

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
    'Dim lcd16x2 As LiquidCrystal
    Private result As Byte
    Dim readA As Timer
End Sub

Private Sub AppStart
    Serial1.Initialize(2400)
    Log("AppStart")
    readA.Initialize("readA_Tick",100)
    readA.Enabled=True
End Sub

Sub readA_Tick
    RunNative("serialread",Null)
    Log("Serial Value : " ,result)
End Sub


#If c++
void setupserial(B4R::Object* o) {
    Serial.begin(2400, SERIAL_7N1);
}

void serialread(B4R::Object* o){
    if (Serial.available()){
        String value = Serial.readString();
        b4r_main::_result = value;
    }
}   
#End If

i've tried to read the data from serial communication trought db9 connector using ESP8266 wemos R1 D1, and how can i initialize the serial communication using 7 data bits and 1 parity?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top