icefairy333 Active Member Licensed User Longtime User Jul 25, 2012 #1 Code: @BA.ShortName("RandomAccessFile") @BA.Version(1.3F) there is something wrong with the function "AsyncStreams.write2" yesterday I have wrote a bluetooth communication app when I call write2 the other device can not receivedany message,But when I call write it works fine!Then I had to wrote a simply function to spilt the bytes Code: Sub bytebuild(buf() As Byte,start As Int,length As Int) As Byte() Dim strTmp As String Dim bytes(0) As Byte If buf.length<length Then Return bytes strTmp=BytesToString(buf,start,length,"UTF-8") bytes=strTmp.GetBytes("UTF8") Return bytes End Sub and I have check the code of the AsyncStreams java Code: public boolean Write(byte[] Buffer) { return Write2(Buffer, 0, Buffer.length); } public boolean Write2(byte[] Buffer, int Start, int Length) { return aout.put(Buffer, Start, Length); } I found that the codes are the same ~:sign0161: what's wrong with me? serial connect and listen by "connect and listen" the other code haven't be modify
Code: @BA.ShortName("RandomAccessFile") @BA.Version(1.3F) there is something wrong with the function "AsyncStreams.write2" yesterday I have wrote a bluetooth communication app when I call write2 the other device can not receivedany message,But when I call write it works fine!Then I had to wrote a simply function to spilt the bytes Code: Sub bytebuild(buf() As Byte,start As Int,length As Int) As Byte() Dim strTmp As String Dim bytes(0) As Byte If buf.length<length Then Return bytes strTmp=BytesToString(buf,start,length,"UTF-8") bytes=strTmp.GetBytes("UTF8") Return bytes End Sub and I have check the code of the AsyncStreams java Code: public boolean Write(byte[] Buffer) { return Write2(Buffer, 0, Buffer.length); } public boolean Write2(byte[] Buffer, int Start, int Length) { return aout.put(Buffer, Start, Length); } I found that the codes are the same ~:sign0161: what's wrong with me? serial connect and listen by "connect and listen" the other code haven't be modify
Erel B4X founder Staff member Licensed User Longtime User Jul 25, 2012 #2 I don't see any bug. I guess that the values you pass (Start and Length) are incorrect.
icefairy333 Active Member Licensed User Longtime User Jul 25, 2012 #3 sadly!today I use the astream object like Code: AStream.InitializePrefix(Main.serial1.InputStream,true, Main.serial1.OutputStream, "AStream") when I pass the small file(example :1kb) it works fine ,but when i send a big file (for example 20kb),there are some probabilitys the file will be muddled.maybe I should use AStream.InitializePrefix(Main.serial1.InputStream,false, Main.serial1.OutputStream, "AStream") Click to expand... ???:sign0085:
sadly!today I use the astream object like Code: AStream.InitializePrefix(Main.serial1.InputStream,true, Main.serial1.OutputStream, "AStream") when I pass the small file(example :1kb) it works fine ,but when i send a big file (for example 20kb),there are some probabilitys the file will be muddled.maybe I should use AStream.InitializePrefix(Main.serial1.InputStream,false, Main.serial1.OutputStream, "AStream") Click to expand... ???:sign0085:
icefairy333 Active Member Licensed User Longtime User Jul 25, 2012 #4 and I have spilted the file into 1kb or 10kb as an unit~
Erel B4X founder Staff member Licensed User Longtime User Jul 25, 2012 #5 Are you using prefix mode in both sides of the connection?
icefairy333 Active Member Licensed User Longtime User Jul 26, 2012 #6 yes Im sure that;now I had to split and rebuild the big file,I add the "filecontent index no." before the file content unit then it works fine.
yes Im sure that;now I had to split and rebuild the big file,I add the "filecontent index no." before the file content unit then it works fine.