Esempio n. 1
0
def hardwareInit():
    print("Init hardware...")
    rpieGlobals.osinuse = misc.getosname(0)
    rpieGlobals.ossubtype = misc.getsupportlevel(1)
    pinout = "0"
    if rpieGlobals.osinuse == "linux":
        import linux_os as OS
        import linux_network as Network
        Settings.NetMan = Network.NetworkManager()
        if len(OS.getsounddevs()) > 0:
            Settings.SoundSystem["usable"] = True
        if rpieGlobals.ossubtype == 10:
            rpv = OS.getRPIVer()
            if rpv:
                pinout = rpv["pins"]
                misc.addLog(
                    rpieGlobals.LOG_LEVEL_DEBUG,
                    str(rpv["name"]) + " " + str(rpv["pins"]) + " pins")
    print("Load network settings...")
    Settings.loadnetsettings()
    Settings.NetMan.networkinit()

    print("Load GPIO settings...")
    if pinout != "0":
        Settings.loadpinout()
        if pinout == "40" and len(Settings.Pinout) != 41:
            Settings.Pinout = gpios.PINOUT40
        elif pinout == "26R1" and len(Settings.Pinout) != 27:
            for p in range(27):
                Settings.Pinout.append(gpios.PINOUT40[p])
            for p in range(len(gpios.PINOUT26R1_DELTA)):
                pi = int(gpios.PINOUT26R1_DELTA[p]["ID"])
                Settings.Pinout[pi] = gpios.PINOUT26R1_DELTA[p]
        elif pinout == "26R2" and len(Settings.Pinout) != 27:
            for p in range(27):
                Settings.Pinout.append(gpios.PINOUT40[p])
            for p in range(len(gpios.PINOUT26R2_DELTA)):
                pi = int(gpios.PINOUT26R2_DELTA[p]["ID"])
                Settings.Pinout[pi] = gpios.PINOUT26R2_DELTA[p]
        perror = False
        try:
            gpios.HWPorts.readconfig()
        except:
            perror = True
        if perror or len(Settings.Pinout) < 26:
            misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,
                        "Your GPIO can not be identified!")
            Settings.Pinout = []
        else:
            gpios.HWPorts.initpinstates()

    else:
        Settings.Pinout = []
    return 0
Esempio n. 2
0
def hardwareInit():
    #print("Init hardware...")
    rpieGlobals.osinuse = misc.getosname(0)
    rpieGlobals.ossubtype = misc.getsupportlevel(1)
    pinout = "0"
    if rpieGlobals.osinuse == "linux":
        import linux_os as OS
        import linux_network as Network
        Settings.NetMan = Network.NetworkManager()
        if len(OS.getsounddevs()) > 0:
            Settings.SoundSystem["usable"] = True
        if rpieGlobals.ossubtype == 10:
            rpv = OS.getRPIVer()
            if rpv:
                pinout = rpv["pins"]

    Settings.loadnetsettings()
    Settings.NetMan.networkinit()

    if pinout != "0":
        Settings.loadpinout()
        if pinout == "40" and len(Settings.Pinout) != 41:
            Settings.Pinout = gpios.PINOUT40
        elif pinout == "26R1" and len(Settings.Pinout) != 27:
            for p in range(27):
                Settings.Pinout.append(gpios.PINOUT40[p])
            for p in range(len(gpios.PINOUT26R1_DELTA)):
                pi = int(gpios.PINOUT26R1_DELTA[p]["ID"])
                Settings.Pinout[pi] = gpios.PINOUT26R1_DELTA[p]
        elif pinout == "26R2" and len(Settings.Pinout) != 27:
            for p in range(27):
                Settings.Pinout.append(gpios.PINOUT40[p])
            for p in range(len(gpios.PINOUT26R2_DELTA)):
                pi = int(gpios.PINOUT26R2_DELTA[p]["ID"])
                Settings.Pinout[pi] = gpios.PINOUT26R2_DELTA[p]
        gpios.HWPorts.readconfig()
        gpios.HWPorts.initpinstates()

    else:
        Settings.Pinout = []
    return 0
Esempio n. 3
0
def hardwareInit():
 print("Init hardware...")
 rpieGlobals.osinuse = misc.getosname(0)
 rpieGlobals.ossubtype = misc.getsupportlevel(1)
 pinout = "0"
 if rpieGlobals.osinuse=="linux":
  import linux_os as OS
  import linux_network as Network
  Settings.NetMan = Network.NetworkManager()
  if len(OS.getsounddevs())>0:
    Settings.SoundSystem["usable"]=True
  if rpieGlobals.ossubtype == 10: # rpi
   rpv = OS.getRPIVer()
   if rpv:
     pinout = rpv["pins"]
     misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG,str(rpv["name"])+" "+str(rpv["pins"])+" pins")
  elif rpieGlobals.ossubtype == 3: # opi
   opv = OS.getarmbianinfo()
   if opv:
    pinout = opv["pins"]
    misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG,str(opv["name"])+" "+str(opv["pins"])+" pins")
 hwtype = rpieGlobals.ossubtype
 if pinout=="0":
  try:
   import lib.lib_ftdigpios as ftdigpio # check for ftdi hwtype?
   if ftdigpio.get_ftdi_devices(0)>0:
    hwtype = 19
    pinout = "ftdi"
  except Exception as e:
   print(e)
 print("Load network settings...")
 Settings.loadnetsettings()
 Settings.NetMan.networkinit()

 print("Load GPIO settings...")
 if pinout != "0":
  Settings.loadpinout()
  try:
   gpios.preinit(hwtype) # create HWPorts variable
  except Exception as e:
   print("init",e)
  if (("40" in pinout) and (len(Settings.Pinout)<41)) or (("26" in pinout) and (len(Settings.Pinout)<27)) or (pinout=="ftdi" and len(Settings.Pinout)<1):
   print("Creating new pinout")
   try:
    gpios.HWPorts.createpinout(pinout)
   except Exception as e:
    print("Pinout creation error:",e)
  perror = False
  try:
   gpios.HWPorts.readconfig()
  except Exception as e:
#   print(e) # debug
   perror = True
  if perror or len(Settings.Pinout)<1:
   misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"Your GPIO can not be identified!")
   Settings.Pinout = []
  else:
   gpios.HWPorts.initpinstates()

 else:
  Settings.Pinout = []
 return 0
Esempio n. 4
0
def hardwareInit():
 print("Init hardware...")
 rpieGlobals.osinuse = misc.getosname(0)
 rpieGlobals.ossubtype = misc.getsupportlevel(1)
 pinout = "0"
 if rpieGlobals.osinuse=="linux":
  import linux_os as OS
  import linux_network as Network
  if OS.isAlreadyRunning()>1:
   time.sleep(1)
   print("\nAn RPIEasy is already running! Close that first!")
   sys.exit(0)
  Settings.NetMan = Network.NetworkManager()
  if len(OS.getsounddevs())>0:
    Settings.SoundSystem["usable"]=True
  if rpieGlobals.ossubtype == 10: # rpi
   rpv = OS.getRPIVer()
   if rpv:
     pinout = rpv["pins"]
     misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG,str(rpv["name"])+" "+str(rpv["pins"])+" pins")
  elif rpieGlobals.ossubtype == 9: # rockpi
   ropv = OS.getRockPIVer()
   if ropv:
    pinout = ropv["pins"]
    misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG,str(ropv["name"])+" "+str(ropv["pins"])+" pins")
  elif rpieGlobals.ossubtype == 3: # opi
   opv = OS.getarmbianinfo()
   if opv:
    pinout = opv["pins"]
    misc.addLog(rpieGlobals.LOG_LEVEL_DEBUG,str(opv["name"])+" "+str(opv["pins"])+" pins")
 if rpieGlobals.osinuse=="windows":
  print("Windows OS is not supported")
  import win_os as OS
  import win_network as Network
  Settings.NetMan = Network.NetworkManager()
  Settings.SoundSystem["usable"]=False
 hwtype = rpieGlobals.ossubtype
 if pinout=="0":
  try:
   import lib.lib_ftdigpios as ftdigpio # check for ftdi hwtype?
   ftdigpio.correctdependencies()
   if ftdigpio.get_ftdi_devices(0)>0:
    hwtype = 19
    pinout = "ftdi"
  except Exception as e:
   print(e)
 print("Load network settings...")
 Settings.loadnetsettings()
 Settings.NetMan.networkinit()

 print("Load GPIO settings...")
 if pinout != "0":
  Settings.loadpinout()
  try:
   gpios.preinit(hwtype) # create HWPorts variable
  except Exception as e:
   print("init",e)
  if (("40" in pinout) and (len(Settings.Pinout)<41)) or (("26" in pinout) and (len(Settings.Pinout)!=27) and (len(Settings.Pinout)!=53) ) or (pinout=="ftdi" and len(Settings.Pinout)<1):
   print("Creating new pinout")
   try:
    gpios.HWPorts.createpinout(pinout)
   except Exception as e:
    print("Pinout creation error:",e)
  perror = False
  try:
   gpios.HWPorts.readconfig()
  except Exception as e:
   perror = True
  if perror or len(Settings.Pinout)<1:
   misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"Your GPIO can not be identified!")
   Settings.Pinout = []
  else:
   gpios.HWPorts.initpinstates()

 else:
  Settings.Pinout = []
 return 0