writing data to a raf from Astreams New data

mhewett737

Member
Licensed User
Longtime User
I have successfully read data from a raf file and have successfully sent an array of hex bytes to another device via Blue tooth .

I an now trying to use Astreams_NewData to capture data from this device and write it to a specific raf file.


B4X:
Sub AStreams_NewData (Buffer() As Byte)   

Dim msg As String   
msg = (BConv.HexFromBytes(Buffer))

dirname = ("/engine "&selectedengine&"/testload.dat")
raf.initialize(File.DirRootExternal,dirname,False)
Log(msg)
raf.WriteObject(msg, True, raf.CurrentPosition)

raf.Close


End Sub


The program runs with no error and the following captured data is shown in the log:

5555565566AA65699A96555555AAA5654D

When I look at the file "testload.dat" it is full of hex garbage not the above data.

What am I not doing correctly.

Thankyou
 

mhewett737

Member
Licensed User
Longtime User
I replaced the raf.writeobject line with the following:

B4X:
raf.Writebytes(msg.GetBytes("ASCII"))

It errors during compiling.....missing parameters ???
 
Upvote 0
Top