Øyvind > Consider "flash banks 0".

Øyvind > The output it produces is pretty hellish to parse from Tcl
Øyvind > (or any language really) + if we make that output of that
Øyvind > command part of the API, then changing it becomes
Øyvind > very awkward.

Ditto for the the at91sam7 - "flash info" output.

Then why not just change the out put of those commands to something that 
is both human and machine readable.

What is really easy to parse is NAME/VALUE pairs in ASCII text formated 
like this:

status: ok
cpuid:   1234
cpuname:   at91sam7x256
flash-size:   0x00040000
ram-size:    0x00010000
cpu: arm7tdmi
sector-size: 256
n-sectors: 1234
<blankline>

The format is really simple:

(0) it is human readable :-)  Humans do not always read this sort of 
stuff - we do once in a while - I hope nobody stays up late reading the 
output of "flash info"

(1) Every result has a name and a value, aka NVP - name value pair.

    format is:   <name>  <colon> <space> <string... to EOL>
   
    Names: Start with a letter - Contains [A-Za-z0-9] and "-"
    Values start after the space - and end at the EOL.

(2) Name Value pairs can reasonably come in any order

(3) In the future - and this will happen - we forget something - you can 
add any item you want to the list of NVPs returned

(4) The client - should follow a simple rule:
        If you do not know, or understand the NVP item - ignore it

(5) the list ends when there is a blank line.

The above is not a format I dreamed up, it is a very robust and powerful 
format that has stood the test of time. It is used by every web browser 
and web server - it is identical to the HTTP request and HTTP responses. 
It is also - identical to SMTP used to transport all email on the internet.

We could add a few more restrictions - for example:

(6) All responses must contain: "status: ok" or "status: error"

(7) All "status: error" responses must contain:  "error-code: NUMBER" 
and "error-human: <some string>"
One for the benefit of the program - and one for the benefit of the 
human using the program.

(8) All numbers use C style syntax: ie: 0x prefix for hex, or 0 prefix 
for octal.

(9) If you need double quotes (mostly you do not) use use C style double 
quotes

-Duane.


_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to