LPCManager.py
changeset 26 735464c8616a
parent 25 c5b5509bd224
child 27 77b6f3c5f1ba
equal deleted inserted replaced
25:c5b5509bd224 26:735464c8616a
    14 def Bpath(*args):
    14 def Bpath(*args):
    15     return os.path.join(CWD,*args)
    15     return os.path.join(CWD,*args)
    16 
    16 
    17 if __name__ == '__main__':
    17 if __name__ == '__main__':
    18     def usage():
    18     def usage():
    19         print "\nUsage of LPCBeremiz.py :"
    19         print "\nUsage of LPCManager.py :"
    20         print "\n   %s Projectpath Buildpath port\n"%sys.argv[0]
    20         print "\n   %s Projectpath Buildpath port [arch]\n"%sys.argv[0]
    21     
    21     
    22     try:
    22     try:
    23         opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
    23         opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
    24     except getopt.GetoptError:
    24     except getopt.GetoptError:
    25         # print help information and exit:
    25         # print help information and exit:
    29     for o, a in opts:
    29     for o, a in opts:
    30         if o in ("-h", "--help"):
    30         if o in ("-h", "--help"):
    31             usage()
    31             usage()
    32             sys.exit()
    32             sys.exit()
    33     
    33     
    34     if len(args) != 3:
    34     if len(args) < 3 or len(args) > 4:
    35         usage()
    35         usage()
    36         sys.exit()
    36         sys.exit()
    37     else:
    37     else:
    38         projectOpen = args[0]
    38         projectOpen = args[0]
    39         buildpath = args[1]
    39         buildpath = args[1]
    40         try:
    40         try:
    41             port = int(args[2])
    41             port = int(args[2])
    42         except:
    42         except:
    43             usage()
    43             usage()
    44             sys.exit()
    44             sys.exit()
       
    45         if len(args) > 3:
       
    46             arch = args[3]
       
    47         else:
       
    48             arch = "MC8"
    45 
    49 
    46     if os.path.exists("LPC_DEBUG"):
    50     if os.path.exists("LPC_DEBUG"):
    47         __builtin__.__dict__["BMZ_DBG"] = True
    51         __builtin__.__dict__["BMZ_DBG"] = True
    48     else :
    52     else :
    49         __builtin__.__dict__["BMZ_DBG"] = False
    53         __builtin__.__dict__["BMZ_DBG"] = False
   886             if result:
   890             if result:
   887                 return result
   891                 return result
   888             #Load and init all the children
   892             #Load and init all the children
   889             self.LoadChildren()
   893             self.LoadChildren()
   890         
   894         
   891         if havecanfestival and self.GetChildByName("CanOpen") is None:
   895         canopen_child = self.GetChildByName("CanOpen")
       
   896         if arch == "MC8" and havecanfestival and canopen_child is None:
   892             canopen = self.CTNAddChild("CanOpen", "CanOpen", 0)
   897             canopen = self.CTNAddChild("CanOpen", "CanOpen", 0)
   893             #canopen.BaseParams.setEnabled(False)
       
   894             canopen.LoadChildren()
   898             canopen.LoadChildren()
   895             canopen.CTNRequestSave()
   899             canopen.CTNRequestSave()
       
   900         
       
   901         elif (arch != "MC8" or not havecanfestival) and canopen_child is not None:
       
   902             canopen_child.CTNRemove()
   896         
   903         
   897         if self.CTNTestModified():
   904         if self.CTNTestModified():
   898             self.SaveProject()
   905             self.SaveProject()
   899         
   906         
   900         if wx.GetApp() is None:
   907         if wx.GetApp() is None:
  1809     def readline(self):
  1816     def readline(self):
  1810         idx = self.Buffer.find("\n")
  1817         idx = self.Buffer.find("\n")
  1811         while idx == -1:
  1818         while idx == -1:
  1812             text = self.socket.recv(2048)
  1819             text = self.socket.recv(2048)
  1813             if text == "":
  1820             if text == "":
  1814                 break
  1821                 return ""
  1815             self.Buffer += text
  1822             self.Buffer += text
  1816             idx = self.Buffer.find("\n")
  1823             idx = self.Buffer.find("\n")
  1817         if idx != -1:
  1824         if idx != -1:
  1818             line = self.Buffer[:idx+1]
  1825             line = self.Buffer[:idx+1]
  1819             self.Buffer = self.Buffer[idx+1:]
  1826             self.Buffer = self.Buffer[idx+1:]
  1820             if BMZ_DBG:
  1827             if BMZ_DBG:
  1821                 print "command >"+line+str(len(line))
  1828                 print "command >"+line
  1822             return line
  1829             return line
  1823         return ""
  1830         return ""
  1824     
  1831     
  1825     """ Base class for file like objects to facilitate StdOut for the Shell."""
  1832     """ Base class for file like objects to facilitate StdOut for the Shell."""
  1826     def write(self, s, style = None):
  1833     def write(self, s, style = None):