Initializes the object in prefix mode. Both sides of the connection must adhere to the "prefix" protocol. It is recommended to set #StackBufferSize to 600 or more. MaxBufferSize will be set to 500 bytes and WaitForMoreDataDelay will be set to 300ms. BigEndian - Sets the length prefix endianess.
MaxBufferSizeAsUInt
The internal buffer limit. The NewData event will be raised when the buffer reaches this size or if no more data is available. The data is stored in the stack buffer. Make sure that #StackBufferSize is large enough.
WaitForMoreDataDelayAsUInt
Number of milliseconds to wait for new data (when there is at least one byte available).
Converts arrays of objects to bytes and vice versa. The data can be shared with other B4X tools using the B4RSerializator class (not to confuse with B4XSerializator which is not compatible with B4R).
Converts an array of objects to an array of bytes. Supported types: numbers, strings and array of bytes. Booleans will be converted to 0 or 1. The returned array is created on the stack buffer.
Converts a previously serialized array of bytes to an array of objects. Returns an empty array if the input is invalid. Make sure to check the returned array size. The returned array will share the memory with ObjectsBuffer array. ObjectsBuffer length must be equal or larger than the number of items.
Provides methods that allow converting between different types of arrays to arrays of bytes. The conversion methods do not modify the memory, instead they provide a different representation of the same memory block. ArrayCopy and ObjectCopy allow copying of arrays and objects. These methods can be used to copy local objects to global variables. The endianess used is the board's native endianess (little endian for Arduino). Note that strings are casted to arrays of bytes automatically.
Compares the two arrays. Returns 0 if both arrays are equal. Returns a value lower than 0 if Arr2 value is larger (the first byte that is different is larger). Returns a value larger than 0 if Arr1 value is larger.
ArrayCopy (Src() AsByte, Dest() AsByte) Asvoid
Copies the Src array to the Dest array. The destination array length will be set to the length of the source array. Bounds are not checked. This method is useful for copying local arrays to global arrays.
Copies the bytes from the source array to the destination array. Make sure that the destination array is large enough. Bounds are not checked. Src - Source array. SrcOffset - Index of the first byte to be copied. Dest - Destination array. DestOffset - The first byte will be copied to this index. Count - Number of bytes to copy.
DoublesFromBytes (Bytes() AsByte) AsDouble()
Converts the bytes array to an array of 32 bit floating points. Note that both arrays share the same memory.
DoublesToBytes (UInts() AsDouble) AsByte()
Converts the 32 bit floating points array to an array of bytes. Note that both arrays share the same memory.
Returns true if the Src array ends with the Suffix array.
HexFromBytes (Bytes() AsByte) AsString
Converts the bytes array to a hex string.
HexToBytes (HexAsString) AsByte()
Converts the hex string to a bytes array.
IndexOf (Src() AsByte, SearchFor() AsByte) AsInt
Returns the index of the first occurrence of SearchFor array in the Src array. Starts searching from the given Index. Returns -1 if SearchFor was not found.
Returns the index of the first occurrence of SearchFor array in the Src array. The search starts at the end of the array and advances to the beginning.
Copies the source object to the destination object. This method makes a shallow copy of the source object's memory. The destination object must be a variable of the same type. You can use this method to copy local objects to global variables. Src - The source object. Dest - Destination variable. ObjectSize - The object size as computed with SizeOf. Example: bc.ObjectCopy(LocalType, GlobalType, SizeOf(LocalType))
ObjectFromBytes (Bytes() AsByte) AsObject
Converts the array of bytes to an object. Note that the array and the object share the same memory.
Splits the array of bytes based on the Separator array and returns an iterator. Example: DimbcAsByteConverter ForEachs() AsByteInbc.Split("abc,def,ghf", ",")
Log(s)
Next
Returns true if the Src array starts with the Prefix array.
StringFromBytes (Src() AsByte) AsString
Creates a new string based on the bytes array. Note that you can print bytes arrays directly so in most cases this method is not required. Unlike StringToBytes this method does allocate a new memory block for the returned string.
StringToBytes (StrAsString) AsByte()
Converts the string to an array of bytes. This is the same as calling Str.GetBytes. Note that the array and the string share the same memory.
Create a new array that shares the same memory as the given array. Src - Source array. BeginIndex - The index of the first element in the new array. Example: DimbcAsByteConverter Log(bc.SubString("012345", 2)) '2345
Create a new array that shares the same memory as the given array. Src - Source array. BeginIndex - The index of the first element in the new array. EndIndex - The index of the last element. The last element will not be included. Example: DimbcAsByteConverter Log(bc.SubString2("012345", 2, 4)) '23
Trim (Src() AsByte) AsByte()
Creates a new array that shares the same memory as the given array, without the leading and trailing whitespace characters.
UIntsFromBytes (Bytes() AsByte) AsUInt()
Converts the bytes array to an array of 16 bit unsigned ints. Note that both arrays share the same memory.
UIntsToBytes (UInts() AsUInt) AsByte()
Converts the 16 bit unsigned ints array to an array of bytes. Note that both arrays share the same memory.
ULongsFromBytes (Bytes() AsByte) AsULong()
Converts the bytes array to an array of 32 bit unsigned longs. Note that both arrays share the same memory.
ULongsToBytes (ArrayULong() AsULong) AsByte()
Converts the 32 bit unsigned longs array to an array of bytes. Note that both arrays share the same memory.
Copies bytes from the backend array to the Dest array. Boundaries are not checked. Dest - Destination array. StartOffset - Index of the first byte in the destination array. Length - Number of bytes to copy. Position - Position of the first byte.
ReadBytes2 (LengthAsInt, PositionAsUInt) AsByte()
Similar to ReadBytes, however data is not copied. Returns an array that shares the same memory as the backend array. Length - The returned array length. Position - Position of the first byte in the backend array.
Copies bytes to the backend array. Boundaries are not checked. Src - Source array. StartOffset - Offset of the first byte in the source array. Length - Number of bytes to copy. Position - Position of the first byte in the backend array.