cancel
Showing results for 
Search instead for 
Did you mean: 

XML parser

totti001
Associate II
Posted on October 07, 2013 at 13:12

Hello everybody!

Is anyone use XML parser at STM32 mikrocontrollers? I search a lot but not found a good for the embedded applications.
10 REPLIES 10
frankmeyer9
Associate II
Posted on October 07, 2013 at 13:42

Is anyone use XML parser at STM32 mikrocontrollers? I search a lot but not found a good for the embedded applications.

 

Probably because they rarely exist for the Cortex M class. Such complex text file parsing applications beg for a virtual-memory-backed malloc(), which hardly exists here.

I'd rather go for a Cortex A kind of device, with RAM size measured in MB instead of kB.

Amel NASRI
ST Employee
Posted on October 07, 2013 at 18:26

Hi Janos,

Could you please tell us for which purpose exactly do you need an XML parser?

Thanks

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on October 07, 2013 at 18:58

Seems like a pretty generic request for something that is both industrial/robust, general purpose and has a small code/data footprint.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
totti001
Associate II
Posted on October 08, 2013 at 00:10

Hy Mayla,

I develop a testing tool by stm32f407 mikrokontroller. This tool has LIN, CAN, ETH, SD-card and so on peripheral. For the LIN communication I need to parse the LDF file which contains the bus settings and the LIN signals. This is not an easy to parse, so my idea is, I write a C# program to parse the LDF and create an XML file with own structure. I search an xml parser then parse the xml file in the controller.

Posted on October 08, 2013 at 08:23

While I have written an unusually lightweight XML parser for one of my projects, and while I can see ways how to avoid dynamic memory allocation (with fixed limits for nesting depth, number of attributes, etc., which for a particularly given type of input *may* be well appropriate), I'd avoid going that way at any cost.

If the file to be parsed is created by you, you'd better use a simpler structure which can be parsed trivially. For example, the structure of a windows-ini-file-like-format is relatively trivial to parse. It also avoids the nesting, which is the true memory killer in XML. I personally would even go down to a binary file, if it would help me to write a simpler program on the mcu side. Let the PC do all the heavy lifting.

YMMV.

JW

chen
Associate II
Posted on October 08, 2013 at 16:03

Hi Janos

As pointed out, it is often not possible to parse an XML document because an embedded processor does not have the memory to load the whole XML document.

There are many open source document parsers available but none of them will work in an embedded environment!

Instead, you could try a XML line parser. Obviously there are limitations to parsing by line (instead of the document) but it can be done.

I used LlamahXML on a freescale CortexM4 processor

totti001
Associate II
Posted on October 08, 2013 at 16:31

Thank you for the answers. So the big problem is the memory space. Stm32F4 has FSMC port, so I can connect SRAM for the controller, and use this for store the xml data.

Or anyone has a good idea for the project. So I have a Lin Description File(LDF) which contains the Lin bus attributes(speed, nodes, signals). I have a program at the controller, and specifications says, store the LDF or similar file at the SD card, and use this for the communication. If LDF change, the software can working without rewrite it on the controller.

Posted on October 09, 2013 at 09:05

> So the big problem is the memory space.

IMO the biggest problem is that you focus on the incorrect thing.

You DON'T need a generic XML parser. That would assume ''infinite'' resources to parse a ''infinite'' depth of nesting, ''infinite'' number of tag attributes, and usually tries to keep the whole parsed structure in memory.

You don't need that.

I looked briefly at the LDF specification, and it appears to be a very simple, mostly linear configuration file. I'd say it's quite easy to parse as it is. I personally would still process it on PC and output a simpler version (fixed items placed into a fixed struct, lists replaced by linked lists, etc.) for the mcu to work with... Szóval az egyszeru az nagyszeru... 😉

JW

frankmeyer9
Associate II
Posted on October 09, 2013 at 09:50

Adding to jan's point, it is usually not a good idea to add complexity (that XML parser) and hardware costs (SRAM, layout) to a project when not absolutely necessary.

This can't be a commercial project, otherwise you could expect a slap on the wrists from your project management...