Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Saving machine code as binary file - Write binary, not text.

samuel.wickstrom
Explorer
Explorer

Saving machine code as binary file - Write binary, not text.

samuel.wickstrom
Explorer
Explorer

Hello there,

 

I'm writing a post processor for a proprietary machine code. The file format is binary.

 

I have tried to call the BinaryFile class, but it doesn’t work. I’m using Fusion 360. I don’t know if the BinaryFile will do the job, but it seems like I only can use methods/functions within the PostProcessor class.

 

Do you have any ideas how I can save an array of bytes?

 

Thanks,

 

Samuel W.

0 Likes
Reply
614 Views
3 Replies
Replies (3)

George-Roberts
Collaborator
Collaborator

You will need to reformat/recreate the post to output the file in the correct way. Reconfiguring the writeBlock function will work to output the binary correctly, but you need to modify all other function to ensure every writeBlock is being called with the correct information to output the binary.

 

Do you have a sample binary file from that machine? I'd be interested in seeing what needs doing here

0 Likes

samuel.wickstrom
Explorer
Explorer

Hello Robert,

 

Thanks for the reply.

 

I have started to write a viewer/editor for the binary format in javascript which runs in the browser. The file format has more than cutting and moving commands. It also provides information to the machine GUI. Basically I have to do a lot of rearranging before writing the final file. To top it all, the binary has to be scrambled with magic numbers. This will done to a byte array before writing.

 

My problem is that I don’t know how to write binary output from the post processor.

 

I have tried to call the static method BinaryFile.saveBinary(path, data); but I get an error: … ReferenceError: BinaryFile is not defined  ...

 

It’s the same if I use for example the XMLHttpRequest class.

 

It seems like I can’t get access to those classes. However, calling the methods of the FileSystem class works. I haven’t gone any further in my testing

 

So basically this is what I’m trying to do.

  • Creating and arranging a uint8 byte array (should be possible with standard javascript)
  • Save the array as a binary file (I don’t know how to do this from the post processor, this is my problem). 

    In other words:  -- How do I save a uint8 array as a binary file?

 

Your help is appreciated

 

Best regards,

 

Samuel W.

0 Likes

George-Roberts
Collaborator
Collaborator

I'm looking through the manual now to see if there is some sort of function which will allow this. I have noticed this:

2017-07-11_08h48_38.png

 

Perhaps if it is not supported, you could create an external application and pass data into that to write it as binary? Use the execute command to pass through the values needed to create the file

2017-07-11_08h57_03.png

 

I haven't done much work with binary files, but could put together a sample later today if needed!

0 Likes