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

Discussion in 'B4R Questions' started by belajaran, Oct 4, 2018.

  1. belajaran

    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++?
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you post the code?
    Peter Simpson likes this.
  3. belajaran

    belajaran New Member

    Here is the code:

    #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
    End Sub

    Sub readA_Tick
    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?
  4. Erel

    Erel Administrator Staff Member Licensed User

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice