Page 4 of 4 FirstFirst 1234
Results 31 to 36 of 36

Thread: Can I extract xy coordinates values from ILDA file??

  1. #31
    Join Date
    May 2014
    Location
    Connecticut
    Posts
    774

    Default

    Quote Originally Posted by james View Post
    It sounds like the local file is the actual binary version and the url is coming in uu code. It's a whole mess of visible ascii characters. Each character represents 6 bits. 4 of those characters in a row translate to 24 bits or 3 binary bytes. This is how all binary files move over http. Because http is an ascii only transmission protocol.
    Awesome. Thanks. Is there an easy way to convert that into the source binary version using JavaScript? UUdecode?

  2. #32
    Join Date
    Mar 2012
    Location
    Akron, Ohio USA
    Posts
    1,846

    Default

    Well I did it way back in 1998 in C++. I wrote an api for developing cgi web apps (executables that run inside of apache web server) that accept the contents of a web form, including binary file upload.

    If I recall correctly, there is a string of random looking characters that begin the chunk of text and the same string that indicates the end of the chunk. Each character is visible, so you have to subtract the offset in the ascii table to the first character to shift it down, then you have to bit twiddle 4 of these shifted values together into a 24 bit number and split that into 3 8-bit bytes.

    I'm quite sure it can be done in JavaScript, since that is a text manipulation language.

    I'm also sure that it's already done and out there somewhere.
    Creator of LaserBoy!
    LaserBoy is free and runs in Windows, MacOS and Linux (including Raspberry Pi!).
    Download LaserBoy!
    YouTube Tutorials
    Ask me about my LaserBoy Correction Amp Kit for sale!
    Either do or do not do. There is no undo!

  3. #33
    Join Date
    May 2014
    Location
    Connecticut
    Posts
    774

    Default

    Quote Originally Posted by james View Post
    Well I did it way back in 1998 in C++. I wrote an api for developing cgi web apps (executables that run inside of apache web server) that accept the contents of a web form, including binary file upload.

    If I recall correctly, there is a string of random looking characters that begin the chunk of text and the same string that indicates the end of the chunk. Each character is visible, so you have to subtract the offset in the ascii table to the first character to shift it down, then you have to bit twiddle 4 of these shifted values together into a 24 bit number and split that into 3 8-bit bytes.

    I'm quite sure it can be done in JavaScript, since that is a text manipulation language.

    I'm also sure that it's already done and out there somewhere.
    I don't think that's it, because the file MIME type header sent upon access is "application/octet-stream" which is a straight binary download. No headers or other embedding or encoding.

  4. #34
    Join Date
    Mar 2012
    Location
    Akron, Ohio USA
    Posts
    1,846

    Default

    When your browser sees that it does the conversion before it saves the file. Can you see the size of the local vs. the remote data? Not the remote file size, the size of the data coming in. If it's about 25% bigger, then you'll know.

    Maybe it is binary but there is some kind of header on it that is messing up your data conversion.
    Creator of LaserBoy!
    LaserBoy is free and runs in Windows, MacOS and Linux (including Raspberry Pi!).
    Download LaserBoy!
    YouTube Tutorials
    Ask me about my LaserBoy Correction Amp Kit for sale!
    Either do or do not do. There is no undo!

  5. #35
    Join Date
    May 2014
    Location
    Connecticut
    Posts
    774

    Default

    Ok, I solved the problem.

    As I mentioned, the browser downloads the raw file exactly as requested, removing any HTTP headers. There's also no byte encoding. The code is quite simple and demonstrates this:

    PHP Code:
    $.get(url, function(data) {$("#rawoutput").html(data);}); 
    This shows the raw ILDA file data downloaded.. even the ILDA header info parts in plaintext are visible, and the frame/point data as binary data following the header.

    The problem was converting this binary data into the Javascript "ArrayBuffer" or Uint8Array format which the rendering engine required. This is a Javascript array of the actual binary file byte values -- one uint8_t byte per array element (the rendering engine later combines these bytes into larger INT16 values for XY values, etc). So for the 4 ILDA header bytes which is just "ILDA", the javascript ByteArray is: {73,76,68,65} And when this is output to the browser, this looks like an ASCII representation of each byte's decimal value, so the ILDA header is output to the web page as "73766865" and so on for the rest of the file.

    You see this all demonstrated here here: https://ildac32.com/render/

    There are two options.
    Option 1: upload your own ILD file -- just drag/drop it to the box that says "Drop your local ILD file here". That will load the file and output the ArrayBuffer format in yellow.
    Option 2: Click one of the buttons to load an .ILD file from the web server. Due to CORS restrictions, the page can't download any ILD file located elsewhere, only files on the web server. But when you click one of those buttons, the ILD file is downloaded into your browser, and you can see below the actual RAW data format downloaded (in magenta), and then the same data converted into the ArrayBuffer format (in cyan). If you watch the JS console, you can see all of this incoming data.

    Once a pattern is loaded and running, you can change the render speed and size using the sliders at the top of the page.
    Last edited by HankLloydRight; 02-08-2022 at 06:15.

  6. #36
    Join Date
    May 2014
    Location
    Connecticut
    Posts
    774

    Default

    BTW, if you want to see the raw binary data download from the webserver to see they aren't padded or encoded or plaintext ("ASCII only transmission protocol"), you can try these two curl commands:

    PHP Code:
    // includes HTTP headers
     
    curl -si  "https://ildac32.com/ild/AllColoursSharpDots.ild"  less    

    // excludes HTTP  headers
    curl -"https://ildac32.com/ild/AllColoursSharpDots.ild" less 
    (type "q" to exit 'less')
    Last edited by HankLloydRight; 02-08-2022 at 06:17.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •