saunwin Active Member Licensed User Longtime User Jan 28, 2016 #1 Good morning, I have a HEX file that I've chosen with file chooser and read into a list. Code: Copy Dim List1 As List List1.Initialize List1 = File.ReadList(File.GetFileParent(filename), File.GetName(filename)) For i = 0 To List1.Size - 1 Log(List1.Get(i)) Next Next step is to transmit this list/hex file to a microcontroller (over an opened com port). How would I do this ? Hints, tips, advice, gratefully received - Many thanks in advance
Good morning, I have a HEX file that I've chosen with file chooser and read into a list. Code: Copy Dim List1 As List List1.Initialize List1 = File.ReadList(File.GetFileParent(filename), File.GetName(filename)) For i = 0 To List1.Size - 1 Log(List1.Get(i)) Next Next step is to transmit this list/hex file to a microcontroller (over an opened com port). How would I do this ? Hints, tips, advice, gratefully received - Many thanks in advance
stevel05 Expert Licensed User Longtime User Jan 28, 2016 #2 Have you seen this? https://www.b4x.com/android/forum/threads/jserial-library.34762/ Upvote 0
saunwin Active Member Licensed User Longtime User Jan 28, 2016 #3 Hi Steve, Yes I have comms between the PC and the micro, it's getting the list into a byte array suitable from transmission (I think) I'm struggling with. Upvote 0
Hi Steve, Yes I have comms between the PC and the micro, it's getting the list into a byte array suitable from transmission (I think) I'm struggling with.
stevel05 Expert Licensed User Longtime User Jan 28, 2016 #4 Then you should probably use the jRandomAccessFile Library and it's Read as bytes Method. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jan 28, 2016 #5 You can read a file to an array of bytes with: Code: Copy Dim bytes() As Byte = Bit.InputStreamToBytes(File.OpenInput(...)) 'InputStreamToBytes closes the stream Upvote 0
You can read a file to an array of bytes with: Code: Copy Dim bytes() As Byte = Bit.InputStreamToBytes(File.OpenInput(...)) 'InputStreamToBytes closes the stream
saunwin Active Member Licensed User Longtime User Jan 28, 2016 #6 Hi Erel, Thanks for the advice. I seem to be missing some bytes. The code is below and the log will log b.length correctly as 36133 the loop will only log 603 values ? Any idea what's happening here. Many thanks in advance. Code: Copy Dim b() As Byte = Bit.InputStreamToBytes(File.OpenInput(File.GetFileParent(filename), File.GetName(filename))) Log (b.Length) For x =0 To b.Length Log (x &" - " & b(x)) Next Upvote 0
Hi Erel, Thanks for the advice. I seem to be missing some bytes. The code is below and the log will log b.length correctly as 36133 the loop will only log 603 values ? Any idea what's happening here. Many thanks in advance. Code: Copy Dim b() As Byte = Bit.InputStreamToBytes(File.OpenInput(File.GetFileParent(filename), File.GetName(filename))) Log (b.Length) For x =0 To b.Length Log (x &" - " & b(x)) Next
Erel B4X founder Staff member Licensed User Longtime User Jan 28, 2016 #7 Don't you see an error with this code? It should be b.Length - 1. Upvote 0
DonManfred Expert Licensed User Longtime User Jan 28, 2016 #8 Erel said: Don't you see an error with this code? It should be b.Length - 1. Click to expand... Then it ill be one byte less But 36133 (b.length) - 603 (log output in lines) = 35530 missing bytes. Or did i miss something? ;-) Upvote 0
Erel said: Don't you see an error with this code? It should be b.Length - 1. Click to expand... Then it ill be one byte less But 36133 (b.length) - 603 (log output in lines) = 35530 missing bytes. Or did i miss something? ;-)
saunwin Active Member Licensed User Longtime User Jan 28, 2016 #9 Erel said: Don't you see an error with this code? It should be b.Length - 1. Click to expand... No Error's Erel, The sub just completes after 603 loops (it doesn't reach the end of the array, so wouldn't throw the error) Upvote 0
Erel said: Don't you see an error with this code? It should be b.Length - 1. Click to expand... No Error's Erel, The sub just completes after 603 loops (it doesn't reach the end of the array, so wouldn't throw the error)
Erel B4X founder Staff member Licensed User Longtime User Jan 29, 2016 #10 Please upload a small project with this file and code. Upvote 0
saunwin Active Member Licensed User Longtime User Feb 1, 2016 #11 Hi Erel, I Think I've done this correctly. Attachments test.zip test.zip 12.3 KB · Views: 598 Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Feb 1, 2016 #12 It is an IDE issue. The logger becomes overflown and then dismisses the items. It will be fixed in v4.20 (non-beta). The data is there. It will also show if you put a breakpoint in this sub. Upvote 0
It is an IDE issue. The logger becomes overflown and then dismisses the items. It will be fixed in v4.20 (non-beta). The data is there. It will also show if you put a breakpoint in this sub.