If you are talking about a byte the likes of that used in modbusrtu you will need to do some high low bit manipulation on it. RegardsMike
On Monday, 15 May 2017, 13:19, Alexie <uale...@gmail.com> wrote: Following should work for you: Public Sub XXX_Read() Dim iLen As Integer Dim aData As Byte[] iLen = Lof(Last) aData = New Byte[] aData.Resize(iLen) Try aData.Read(Last, 0, iLen) End You need to get the length (lof) first, then resize array ... only then you can read it. 2017-05-14 21:56 GMT+02:00 Tobias Boege <tabo...@gmail.com>: > On Sun, 14 May 2017, alexchernoff wrote: > > Good day all, > > > > Anyone know how to read data received on serial port into an array of > bytes > > instead of string? > > > > I think that's not possible. > > > String gets unreadable binary characters, so how can I > > put them into byte[] or so? > > > > This shouldn't be a problem. Gambas Strings are not null-terminated and can > contain any sequence of bytes, which includes non-printable characters > (which > I think is what you meant by "unreadable" characters). > > If you insist on a Byte[], read it into a String and use > Byte[].FromString(), > but there is no way to go around the String, AFAICT (and that is because > there is no need to, as Strings can handle binary data just fine). > > Regards, > Tobi > > -- > "There's an old saying: Don't change anything... ever!" -- Mr. Monk > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user