B4A Library ByteConverter library

It's occasionally useful to be able to poke around in things as arrays of bytes so this library lets you do it.

It can transform arrays of primitive types to and from arrays of bytes with the "endian-ness" of the conversion specified. If you need endian-ness you will either know about it or rather quickly find out. :)

Byte arrays can be transformed to and from a hexadecimal string representation.

Strings can be transformed to and from arrays of Bytes using specified encodings and to and from arrays of Chars.

An array copy method is thrown in for good measure.

EDIT :- Version 1.1 posted. See post #4 for details.

Download link: www.b4x.com/android/files/ByteConverter1.1.zip
 
Last edited by a moderator:

rasaliad

Member
Licensed User
Hi, i want to test the RDC demo: Install de ByteConverter Lib in a AddLibs folder and add this path to B4A, the Lib is checked in the libraries tab. I open the ByteConverter Demo then when compile get the following error: I'm using the B4A V5.8 Trial Version

The Javac.exe path is: C:\Program Files\Java\jdk1.8.0_77\bin\javac.exe

*** Remote compilation mode ***
B4A version: 5.80
Parsing code. (0.00s)
Compiling code. (0.10s)
Compiling layouts code. (0.00s)
Compiling debugger engine code. (1.12s)
Sending data to remote compiler. Error
step: Compiling generated Java code.
javac 1.7.0
src\anywheresoftware\b4a\agraham\byteconverter\main.java:344: error: cannot find symbol
public static anywheresoftware.b4a.agraham.byteconverter.ByteConverter _conv = null;
^
symbol: class ByteConverter
location: package anywheresoftware.b4a.agraham.byteconverter
1 error


Then i open the RemoteServerClient Demo, the ByteConverter Lib is installed (Both files, .jar and .xml) in the Addlibs Folder. When complie get this error:

*** Remote compilation mode ***
B4A version: 5.80
Parsing code. (0.07s)
Compiling code. (0.19s)
Compiling layouts code. (0.01s)
Compiling debugger engine code. (1.79s)
Sending data to remote compiler. Error
step: Compiling generated Java code.
javac 1.7.0
src\b4a\example\dbrequestmanager.java:71: error: package anywheresoftware.b4a.agraham.byteconverter does not exist
public anywheresoftware.b4a.agraham.byteconverter.ByteConverter _bc = null;
^
1 error

What i'm doing wrong?

Thanks in advnaced,

Rafael Liriano
 

rasaliad

Member
Licensed User
You should use the full version instead of the trial version.

Hi, I just buy the upgrade, but I do it with the following email to use paypal, how can you match this upgrade to may account?

Thanks

Rafael Liriano
 
Last edited by a moderator:

engvidal

Member
Licensed User
I am trying to use the ByteConverter lib to send a message using the mqtt library.

The publish needs the message to be in array of bytes.

I tried:

B4X:
  Dim MyMessage As String = "Hi"
   Dim bc As ByteConverter
   Dim pack() As Byte = bc.StringToBytes(MyMessage,"UTF8")
     
   mqtt.Publish(mytopic, pack);    // error !!

but there is an error. Can anyone help ?
 

DonManfred

Expert
Licensed User
but there is an error.
Syntax error? Filenotfound? Runtimeexception?

We CANT help if you dont tell us which error you get exactly!!!
 

engvidal

Member
Licensed User
Hi. I found the error. Just a typing mistake, BUT I have another problem, now receiving messages:

Using this sub:

B4X:
Private Sub mqtt_MessageArrived (Topic As String, Payload() As Byte)
   Dim obj As Object = serializator.ConvertBytesToObject(Payload)
 Dim s As String = obj

   Label2.Text = s
     
End Sub

Just at start up (and after that, if I say to continue, on each message arriving):

java.io.IOException:

2016-08-25.png
 
Hello ,
I created an app that communicates via tcp with an instrument using also the byteconverter 1.1 library on the android 5 version.
The problem is that it doesn't work with android 9 or higher.
Can you help me please.
thank you
 

Attachments

  • error.jpg
    error.jpg
    75.4 KB · Views: 93

Alessandro71

Active Member
Licensed User
You land on this page by clicking on ByteConverter in the Libraries tab, but differently from the other libs, the first post does not contains any useful info about it: no list of Subs, no "How to use" section.
 
Top