Flowcode v6 File Format

Hello. In this article I’m going to talk briefly about the file format of Flowcode projects.

One of the aims of Flowcode v6 was to make things more open and easier for our users to build on. A major change here is the file format has undergone a complete overhaul, from a closed binary format to an XML layout. XML is a format used widely on the Web, and HTML is closely related to XML. This means that most web-based technologies can parse XML.

So Flowcode is no longer the only application that can read project files, opening up the possibility for additional applications to be packaged with Flowcode.

One of the most common issues affecting our users is an incorrect configuration or clock frequency. So to illustrate parsing a Flowcode project file I thought of putting together a small JavaScript based web page that would show these details.

The first thing to do is load the XML into a JavaScript DOM – this is a representation of the XML file which is easier to pull data from. For this, a quick search on the web reveals the required code.

Pic1

Now we can load an XML file it is time to parse the FCFX document. Looking at the start of the test.FCFX file we see the details we are after:

Pic2

Tags are shown in blue and attributes are shown in red. We want to pull out the documents title, description, target, clock speed and config data.

First, in JavaScript, create the variables we want to store the data:

Pic3

Now the xmlDoc is pointing to the correct root tag, we can loop through the tags as though they are an array and pull out what we want:

Pic4

There is still a bit of work to do to decode the configuration data – this is stored in a single string of values. Each entry is an address,value pair and starts with an exclamation mark for any config words and a question mark for any config bits. We just want to show the words in a more legible format. Luckily JavaScript strings have a method to split a string into parts, so we can use this to decode the configuration:

Pic5

We can use the JavaScript document.Write() method to output the text as a HTML table, remembering to escape any HTML tags for security, and our script is complete!

Pic6

The HTML file containing this JavaScript and the example test file can be accessed by clicking this link: JW BLog files. I would like to extend this into a complete on-line Flowcode project viewer if there is ever a spare minute in Flowcode development!

You can see this small project at work in our forums as all FCFX files uploaded to the forum now show the chip, clock and configuration values along with the project file.

22,176 total views, 2 views today

Leave a Reply