avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avrdude-dev] Initial STK600 support committed to CVS


From: Bob Paddock
Subject: Re: [avrdude-dev] Initial STK600 support committed to CVS
Date: Sat, 15 Mar 2008 21:49:27 -0400
User-agent: KMail/1.9.7

> Are there any preferences for an XML parser library to use?

I've been using TinyXPath to parse the AVR Studio files
for the AVRDUDE GUI I've been slowly hacking on, not very
far along yet.

http://tinyxpath.sourceforge.net/

See below for a code snippet.  I use the resulting data to build
a single hierarchical wxWidgets config file, which is far easier to deal
with in the GUI than the XMLs:
http://www.wxwidgets.org/manuals/2.8/wx_wxconfigbase.html#wxconfigbase

/devices
/devices/can64
/devices/can64/hfuse
/devices/can64/lfuse
...

The existing avrdude.conf file doesn't have the needed fuse
strings for a GUI etc.

> Any other things to consider?

Do you know if all of the existing and future Studio XML Device files have 
the "V2" verbose fuse strings et.al.?


TinyXPath code looks like this,  with wxWidgets:
...
BuildStudioConfig::BuildStudioConfig( wxString& studio_xml_path_wxS )
{
  wxLogVerbose( "[%s/%s/%u]", __FILE__, __FUNC__, __LINE__ );
  wxASSERT( !studio_xml_path_wxS.IsEmpty() ); // Must not be empty.

  wxLogVerbose( wxT( "Building list of AVRStudio XML files to process:" ) );

  wxArrayString xmls_to_process;
  wxDir::GetAllFiles( studio_xml_path_wxS, &xmls_to_process, wxT( "*.xml"), 
(wxDIR_FILES|wxDIR_DIRS) );
  xmls_to_process.Sort();
  wxLogVerbose( _( "Found %d files to process." ), 
xmls_to_process.GetCount() );

  for( size_t i = 0; i < xmls_to_process.GetCount(); i++ )
    {
      wxLogVerbose( wxT( "Processing XML file: %s"), 
xmls_to_process[i].c_str() );

      TiXmlDocument Document( xmls_to_process[i] );
      if( !Document.LoadFile() )
        {
          wxLogVerbose( _( "Failed to load XML file %s for proessing." ), 
xmls_to_process[i].c_str() );
          continue;// Process the next file, if any.
        }

      // -------- Part Name --------
      TinyXPath::xpath_processor PartName_proc( 
Document.RootElement(), "/AVRPART/ADMIN/PART_NAME/text()" );
      TIXML_STRING Part_Name = PartName_proc.S_compute_xpath();
      wxLogVerbose( _( "Part Name: %s " ), Part_Name.c_str() );

 // -------- Device Siganture --------
      TinyXPath::xpath_processor SignatureBytes_proc( 
Document.RootElement(), "/AVRPART/ADMIN/SIGNATURE" );
      unsigned int u_nb = SignatureBytes_proc.u_compute_xpath_node_set(); // 
Retrieve number of Signature nodes; Note: This function *MUST* be called 
before calling get_xpath_node()
      wxLogVerbose( wxT( "There are %d Signature Nodes" ), u_nb );

      TiXmlNode    *node         = SignatureBytes_proc.XNp_get_xpath_node( 
0 );
      assert( node );

      TiXmlElement *ElementPoint = node->ToElement();
      assert( ElementPoint  );

      // Walk all the elements in the node:
      for( TiXmlElement *element = ElementPoint->FirstChildElement();
           element;
           element = element->NextSiblingElement()
         )
     {
          const char *pKey =element->Value();
          const char *pText=element->GetText();

          if( pKey )
         {
              wxLogVerbose( wxT( "Signature Key: \"%s\" " ), pKey );
         }

          if( pText )
        {
              wxLogVerbose( wxT( "Signature Text: \"%s\"" ), pText );
         }

    }
...

-- 
                http://www.wearablesmartsensors.com/
 http://www.softwaresafety.net/ http://www.designer-iii.com/
                 http://www.unusualresearch.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]