HEXtoBIN for pure HEX-files

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: HEX2BIN for pure HEX-files

Post by rbytes »

Here is a hexdump of my 2.2 MB music file "ironman.mp3". It is the expected size of ~ 4.5 mb

When I try to decode it with HEXtoBIN, the program hangs up and no text is displayed on the screen. I thought it might be because of some faulty characters introduced during my laborious transfer process. To get it to Smart Basic without using Dropbox, I installed a simple Windows text editor that could load the dump file and allow me to select and copy it. From there I pasted it into an Outlook message and mailed it to myself. It seemed to arrive in good shape on my iPad Mail app, but I had the devil of a time trying to select and copy it from the mail message! The menu bar with the Selext All function took many seconds to appear, and the bar with the Copy command took even longer. Everything worked at a snail's pace with a file this big. Finally I created the new Smart Basic file and pasted the text into it. That is the file I have attached.

I did a second transfer of this same hexdump file via Dropbox, the same as I had done earlier for the short sound file that worked fine. Yet it hung up HEXtoBIN the same way. So I can't blame the problem on extraneous characters that snuck in. HEXtoBIN doesn't crash or show any errors, and I can switch to the debug screen and back multiple times. But it is paused somehow.

If you view the file, you'll see I set the dump line width to 32 rather than 16, thinking that would be more efficient to decode. Could that change have caused the hangup? Maybe tomorrow I'll dump it again with a line width of 16 and see how that works.
Attachments
IMG_2906.PNG
IMG_2906.PNG (54.98 KiB) Viewed 4224 times
ironman.mp3HEX.txt
(4.19 MiB) Downloaded 409 times
The only thing that gets me down is gravity...

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: HEX2BIN for pure HEX-files

Post by Dutchman »

The program was running and would have given results if you had waited sufficiently long. ;)
After completion I wondered if you really like the music :lol:
There was no display because the first print command was at the wrong position, after reading the file.
The reading of the file takes so long, because about 69000 lines had to be read and added to the string Line$.
I had the same experience with my program "Word Search" and therefore I packed each dictionary in a single long line.

In order to get informed about the progress, I added code to print dots during read of multiple lines. In total 50 dots will then be printed before completion.
The code has been updated.
The following screenshot shows the result:
ironman screenshot.PNG
ironman screenshot.PNG (131.34 KiB) Viewed 4213 times
The read phase took 7 minutes, whereas the file "hardy.mp3HEX" of 6 megabytes was read in one second.
So it would be nice if you could find a BIN to HEX coder which writes the coded data as a single line.
I will try to change the code such that the input-lines are not added to a single line.
In the speed by which the dots are printed you can see that the speed decreases during progress.
So the addition of the input-lines to Line$ probably takes progressively more time. ;)

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: HEX2BIN for pure HEX-files

Post by rbytes »

I just got a reply from stahl.com, the distributors of Swiss File Knife. Juergen Thumm gave me two different methods to get pure hex encoding with no CRs. I tried the first option on my 2.2 MB music file and got the expected hexfile size of 2x the binary file size. Brought it into Smart Basic and presto! It decoded in 7 seconds and played perfectly. I have attached it for you to try.

For future reference, the syntax I used was:

sfk hexdump -pure -nofile inputfile +filter -join >outputfile

There are still some issues if I can't use Dropbox for file transfer. I actually convert the hex file to text on my Windows tablet using a text editor app, copy it, paste it into an Outlook email message and mail it to myself. I had first tried to find an iOS app that could read the HEX file and let me copy the text. Trying to do this with a file as large as 4 MB or more of text usually crashes most apps - e.g. iOS Dropbox. When it can be done it is a slow and painstaking process with a lot of hangups - e.g. iOS Mail. Yet Mail was what I ended up using, so I could copy the hex text and paste it into the Smart Basic editor.

I will keep searching for more efficient steps in this process.
Attachments
ironman.mp3HEX.txt
(4.19 MiB) Downloaded 416 times
The only thing that gets me down is gravity...

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: HEX2BIN for pure HEX-files

Post by Dutchman »

I also tried the sfk-command. It works fine!
In the mean time I improved the multiline-approach and got the following result:
ironman screenshot.PNG
ironman screenshot.PNG (133.69 KiB) Viewed 4195 times
So that is an improvement from 7 minutes to 29 seconds.
That was obtained by reading lines into an array instead of adding them to Line$
I added the bars which grow during processing as indicator for the progress.
However, there is no need anymore for a multiline version.
So I will clean-up the code and the procedure-text, but that has to wait till after the weekend. :lol:

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: HEX2BIN for pure HEX-files

Post by rbytes »

You have done a great job with this concept. I am investigating a hex editor app that runs on iOS. I bought an app called "Hex Editor" and sent an app support question to the author to see if he would add a "copy pure hex to clipboard" option. That would mean that any Smart Basic user - whether or not they had a Mac or Windows device - could use Smart Basic.

As you know, Mr. K. Is very reluctant to disconnect Dropbox, and I understand why. I'm sure he will wait until there is an alternate method that he finds satisfactory.
The only thing that gets me down is gravity...

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: HEX2BIN for pure HEX-files

Post by rbytes »

One useful feature for HEXtoBIN would be a paste from clipboard option. That would eliminate some steps.
- Creating a HEX file in Smart Basic to be read and then deleted.
- Pasting the copied hex code into it.

I hope I am able to convince the author of Hex Editor for iOS to add a pure hex clipboard copy feature. If that doesn't pan out, I believe we have several Forum members with developer status. If Henk agreed, one of them might be willing to adapt his hex editor and publish it on the App Store as a free app. I think it would need just two additional features - Dropbox access and autocopy pure hex.

That would get us down to two simple steps.
1. Load desired file into the App Store hex editor.
2. Run HEXtoBIN in clipboard copy mode.

And there would be our desired file saved in Smart Basic.
The only thing that gets me down is gravity...

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: HEX2BIN for pure HEX-files

Post by Henko »

I don't know what this is all about, but i agree 😎

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: HEX2BIN for pure HEX-files

Post by rbytes »

Thanks, Henk. This thread is all about finding a way to get resource files into Smart Basic if the Dropbox connection is discontinued. Mr. K tells me he is going to hold off any updates until and unless a change in iOS breaks Smart Basic. At that point he may just discontinue support for it and remove it from the store. Dutchman and I hope we can find an efficient way to import resource files (e.g. images, sounds, etc.) without Dropbox, so that he might reconsider and continue his support. (Mr. K. and Ton, please correct or elaborate on any of my statements if you disagree with them)

The first step was Ton's posting of HEXtoBIN. It can process pure hex files and convert them back to the original binary.

Where do we get the hex files if there is no Dropbox connection?

Ton can use the hexdump command on the console on his Mac to convert binary files to pure hex files. He demonstrated with a short sound effect.

I followed up on my PC tablet by finding a third party utility called Swiss File Knife. I can now load binary files and dump them as pure hex files.

It is after that that things get hairy, at least for large files. The hex files are double the size of the source binary files. There are very few programs or apps that can accept having 4 or 5 megabytes of text pasted into them. Many freeze or crash during the paste operation. Others do the same when after pasting you try to select the text. But assuming one can get around this, one can mail the hex data to their own address and read it on their iOS device. Now it has to be copied AGAIN, and then pasted into a new Smart Basic file. HEXtoBIN reads that file and outputs the original binary file.

If there was an App Store app for iOS that could do a hexdump (pure hex only, no translation text, no line feeds or CRs), that would eliminate the inter-platform step. If it could access Dropbox for binary files, they could be acquired from many sources. If it could save the pure hex to the clipboard, there would be no more freezes and crashes trying to copy and paste.

Finally, if Ton added an option to HEXtoBIN to paste the hex data directly from the clipboard, that would reduce the number of steps in the transfer process to just two - not much more onerous than using Dropbox for file transfers into sb.

So far there is no App Store app that does what we need. So the question is - do we have a developer on the Forum who would make the necessary feature additions, run your Hex Editor through the SDK and post it on the Apple Store.
The only thing that gets me down is gravity...

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: HEX2BIN for pure HEX-files

Post by Henko »

I see.
If the current version (with Dropbox access) is kept on the device as final version, i think there is no way that Apple can disturb its functioning. Apart perhaps the use of the app store via the SDK.
I regard the current version as a very complete tool for the iDevices. Exept for the fact that the microphone input cannot be sensed 😖. That facility cannot be expected any longer.

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: HEX2BIN for pure HEX-files

Post by Dutchman »

Henko wrote:
Sun Sep 10, 2017 7:44 am
… I regard the current version as a very complete tool for the iDevices. Exept for the fact that the microphone input cannot be sensed …
I miss also WiFi-acces and/or Bluetooth connection to my computer and/or mail-facility and zipping of folder with contents.
All about SB without Dropbox ;)

Post Reply