One difference from before is that I work with Windows and not macOS so I still have to check if this also applies for the mac. However, the joy was not long lasting as I’m still not able to save the binary file successfully. I can load, open, a file, but when saving all efforts results in a 0 byte file. Hmm… This is maybe something I should address to Autodesk but for now I just want to explore the options.
Basically this is how I solved the task of saving a file as binary (for Windows) from the post-processor a.k.a a cps-file:
- Create a path to Fusion 360 python.exe
- Check for a python script in a folder. If not there, create the script by writing a py-file to the destination.
- Write the all the machine code as hex-text, i.e. 2EFA etc, to a separate temporarily text-file. Note: The actual machine code for the RuiDa controller is still do be done.
- Finally launch the python script which will take convert the hex-text-file to a binary.
By doing it this way. You don’t need anything else than the ruida.cps file since the python execution is handle by the post-processor itself. Cool…
Next step will be to do the actual machine code, which is the actual point of having a post-processor for the RuiDa controller. I will also check if this solution also works with macOS. However this will not be explored in a near future…..
Here is an example of the python script that could be created by the post-processor:
import os, sys # Open hextext, tmp-file r = open(sys.argv,'r') lines = [line.rstrip('\n') for line in r] be r.close() # Delete tmp-file os.remove(sys.argv) # create a binary file with open(sys.argv, 'wb') as f: for line in lines: f.write(bytes.fromhex(line))