M Mostez Well-Known Member Licensed User Longtime User Jul 29, 2016 #1 hello, is it possible to load variable or values to an array in one line of code instead of using: B4X: Private Buffer(8) As Byte ..... ...... Buffer(0) = 0x5A Buffer(1) =0xA5 Buffer(2) = 0x05 Buffer(3) =0x82 Buffer(4) =0x00 Buffer(5) = 0x41 Buffer(6) =0x00 Buffer(7) = 0x01 Serial1.Stream.WriteBytes (Buffer,0,8) and how can I send it to stream with variable length(must be declared with length!), i.e. one time holds 3 bytes and next time holds 4 bytes, as WriteBytes method must include number of bytes! Thanks
hello, is it possible to load variable or values to an array in one line of code instead of using: B4X: Private Buffer(8) As Byte ..... ...... Buffer(0) = 0x5A Buffer(1) =0xA5 Buffer(2) = 0x05 Buffer(3) =0x82 Buffer(4) =0x00 Buffer(5) = 0x41 Buffer(6) =0x00 Buffer(7) = 0x01 Serial1.Stream.WriteBytes (Buffer,0,8) and how can I send it to stream with variable length(must be declared with length!), i.e. one time holds 3 bytes and next time holds 4 bytes, as WriteBytes method must include number of bytes! Thanks
Erel B4X founder Staff member Licensed User Longtime User Jul 29, 2016 #2 B4X: Dim Buffer() As Byte = Array As Byte(0x5A, 0XA5, ...) Serial1.Stream.WriteBytes(Buffer, 0, Buffer.Length) Note that you should use AsyncStreams instead. Upvote 0
B4X: Dim Buffer() As Byte = Array As Byte(0x5A, 0XA5, ...) Serial1.Stream.WriteBytes(Buffer, 0, Buffer.Length) Note that you should use AsyncStreams instead.