B4R Question ESP to ESP Serial and Astream

Discussion in 'B4R Questions' started by rodmcm, Dec 7, 2018.

  1. rodmcm

    rodmcm Member Licensed User

    I am having trouble with a simple ESP to ESP serial comms. The enclosed is a cut down from a larger project passing 200 int values (MV) from one ESP to another.. To demonstrate the problem I am passing these one at a time. At a high baud rate the best I can do is 27 reads of 200 sends. (Serail2.zip is the sender and Serial1.zip the receiver programs)

    Each send is via a SendArray(20) with SendArray(0) being a key (3 in this case) to the type of data being sent

    Played with changes to the #StackBufferSize, MaxBufferSize and baud rate with little effect.

    Of note in Capture 1 the buffer length changes from 23 to 24 and then fails on the be(60) call

    Any help appreciated.. I've been on this simple thing for ages.

    (As a footnote the reason I am using two ESP is one to transmit WIFI and one as a straight processor with I2C involved.. If I use WIFI and I2C in one ESP I get continuous crashes!)

    Two other clarifications please.

    a) Is there another way of coding ser.ConvertArraytoBytes) for say SendArray(20) rather than


    ) I realize I can pack more variables into SendArray(20) to reduce the number of sends for 200 variables but is there a more efficient way of sending 200 variables

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    Your code is not efficient.

    Sub SendRXT1
    Dim bc As ByteConverter
    Dim b() As Byte = bc.IntsToBytes(SendArray)
    End Sub
    Read the data with bc.IntsFromBytes.
  3. rodmcm

    rodmcm Member Licensed User

    Thanks for that
    The problem turned out to be the size of the serial buffer, changed as per attached

    #if C
    //HardwareSerial Serial1(1); // Second Hardware Port        ' Pins i/o 25 (RXD2) and i/o 26 (TXD2)
    void SerialNative1(B4R::Object* unused)
    HardwareSerial Serial1(1);  // Nextion Port
    #define SERIAL1_RXPIN 25
    #define SERIAL1_TXPIN 26

      ::Serial1.begin(57600, SERIAL_8N1, SERIAL1_RXPIN, SERIAL1_TXPIN);
    b4r_main::_serialnative1->wrappedStream = &::Serial1;
    #End If
  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