[Tinyos-2-commits] CVS: tinyos-2.x/tools/tinyos/misc tos-storage-at45db.1, 1.2, 1.3 tos-storage-at45db.in, 1.2, 1.3

David Gay idgay at users.sourceforge.net
Wed Apr 11 14:07:04 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x/tools/tinyos/misc
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv26460

Modified Files:
	tos-storage-at45db.1 tos-storage-at45db.in 
Log Message:
at45db include support


Index: tos-storage-at45db.1
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tools/tinyos/misc/tos-storage-at45db.1,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** tos-storage-at45db.1	12 Jul 2006 17:00:51 -0000	1.2
--- tos-storage-at45db.1	11 Apr 2007 21:06:58 -0000	1.3
***************
*** 6,10 ****
  .SH SYNOPSIS
  
! \fBtos-storage-at45db\fR
  .SH DESCRIPTION
  
--- 6,10 ----
  .SH SYNOPSIS
  
! \fBtos-storage-at45db\fR \fIplatform-directory\fR
  .SH DESCRIPTION
  
***************
*** 15,18 ****
--- 15,22 ----
  written to standard output.
  
+ The argument should specify the platform directory for the current
+ compilation target; this is necessary for the correct handling of 
+ file include statements in the XML input.
+ 
  This program is normally invoked automatically by the TinyOS build system
  when your application directory contains a \fBvolumes-at45db.xml\fR file.

Index: tos-storage-at45db.in
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tools/tinyos/misc/tos-storage-at45db.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** tos-storage-at45db.in	12 Jul 2006 17:00:52 -0000	1.2
--- tos-storage-at45db.in	11 Apr 2007 21:06:58 -0000	1.3
***************
*** 1,4 ****
  #!@pathpython@
! # Copyright (c) 2006 Intel Corporation
  # All rights reserved.
  #
--- 1,4 ----
  #!@pathpython@
! # Copyright (c) 2006-2007 Intel Corporation
  # All rights reserved.
  #
***************
*** 12,15 ****
--- 12,31 ----
  from re import match
  from sys import *
+ from subprocess import Popen, PIPE
+ 
+ # print an error message and exit
+ def nfail(s):
+   stderr.write(s + "\n")
+   exit(2)
+ 
+ if len(argv) == 2:
+   platformdir = argv[1]
+   # This gives the whole string when there's no / in platformdir
+   platform = platformdir[platformdir.rfind("/") + 1:]
+ elif len(argv) == 1:
+   platformdir = ""
+   platform = ""
+ else:
+   nfail("Usage: tos-storage-at45db <platform directory>")
  
  sector_size = 256
***************
*** 19,27 ****
  volmap = []
  
- # print an error message and exit
- def nfail(s):
-   stderr.write(s + "\n")
-   exit(2)
- 
  def check_volume(name, base, size):
    if base == "":
--- 35,38 ----
***************
*** 77,94 ****
    volmap.append((name, base, size))
  
! try:
!   dom = parse(stdin)
! except xml.parsers.expat.ExpatError:
!   nfail("no valid input")
  
! for volume in dom.documentElement.getElementsByTagName("volume"):
!   name = volume.getAttribute("name")
!   size = volume.getAttribute("size")
!   base = volume.getAttribute("base")
!   if name == None:
!     nfail("name omitted in volume")
!   if size == None:
!     nfail("size omitted in volume %s" % name)
!   check_volume(name, base, size)
  
  # allocate fixed-address volumes
--- 88,149 ----
    volmap.append((name, base, size))
  
! def expand_path(path):
!   substrs = path.split("%")
!   path = substrs[0]
!   i = 1
!   while i < len(substrs):
!     if substrs[i] == "":
!       # There was a %%, leading to a blank substring, and the next string
!       # should just be appended
!       path += "%"
!       i = i + 1
!       if i < len(substrs):
!         path += substrs[i]
!     else:
!       # The first character of the string is the one that followed %
!       c = substrs[i][0]
!       if c == 'p':
!         sub = platform
!       elif c == 'P':
!         sub = platformdir
!       elif c == 'T':
!         sub = Popen(["ncc", "-print-tosdir"], stdout=PIPE).communicate()[0]
!         sub = sub[:-1] # remove newline
!       else:
!         nfail("unknown include-path substitution character " + c)
!       path += sub
!       path += substrs[i][1:]
!     i = i + 1
!   return path
  
! def volumeparse(file, fname, depth):
!   if depth > 10:
!     nfail("include nesting too deep - check for cycles")
!   try:
!     dom = parse(file)
!   except xml.parsers.expat.ExpatError:
!     nfail(fname + " is not a valid input file")
!   except IOError:
!     nfail("couldn't open file " + fname)
! 
!   for volume in dom.documentElement.getElementsByTagName("volume"):
!     name = volume.getAttribute("name")
!     size = volume.getAttribute("size")
!     base = volume.getAttribute("base")
!     if name == None:
!       nfail("name omitted in volume " + fname)
!     if size == None:
!       nfail("size omitted in volume %s %s" % (name, fname))
!     check_volume(name, base, size)
!   for include in dom.documentElement.getElementsByTagName("include"):
!     included = include.firstChild
!     if included != None and included.nodeType == included.TEXT_NODE:
!       included = expand_path(included.data)
!       volumeparse(included, "(file %s)" % included, depth + 1)
!     else:
!       nfail("invalid include directive " + fname)
!   dom.unlink()
! 
! volumeparse(stdin, "(standard input)", 0)
  
  # allocate fixed-address volumes



More information about the Tinyos-2-commits mailing list