Wish Astream.WriteNoBoundsCheck - Avoid checking array bounds

Discussion in 'B4R Bugs & Wishlist' started by miker2069, Oct 6, 2019.

  1. miker2069

    miker2069 Active Member Licensed User

    In working out using the ESP32 Camera (see tutorial here), I initially struggled with sending a buffer of data over 32KB using Astream.Write/Write2. For example, a picture taken by the camera at highest res (1600X1200 pixels) could easily be over 300KB. The camera returns a pointer to the buffer of bytes. Using a B4R byte pointer like:

    Code:
    Public buffer() As Byte
    We can then point the B4R buffer() pointer to the camera buffer using inline c buffer() like so:


    Code:
    b4r_esp32cam::_buffer->data = fb->buf;
          b4r_esp32cam::_buffer->length = frame_byte_length;
    The problem (as you can immediately see) is that the B4R buffer length member variable is based on an "int" which is max 32KB. So anything over this would get chopped off by any array bounds checking. I thought if using Astream.Write2 (which you can pass a number of bytes to write) would override the bounds check - it doesn't. I got around this by shifting the B4R buffer() pointer to the next "chunk" of data I wanted to send.

    This works great, however I think it would be greatly simplified if we could either get another array object type that could perhaps have a length of ULong, with the explicit understanding that it's used for such a situation to back end a buffer managed by some library elsewhere.

    Or maybe it's simpler to just have another Astream method such as WriteNoBoundsCheck which can specify a start/end index of the byte array you're trying to send.

    This will be very helpful as we can manage all the buffer indexing in B4R vs having to go back and forth to inline c.

    I think this will be more of an issue moving forward as the newer ESP32 boards are now shipping with PSRAM in sizes of 4MB,8MB and I've even read 16MB will be coming out at some point.
     
Loading...
  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