Skip to content

Commit

Permalink
[Quanta/device] Modify psuutil.py and config.bcm of IX1B (#1985)
Browse files Browse the repository at this point in the history
* Fix LED activity behavior

* Modify psuutil.py and config.bcm of IX1B
  • Loading branch information
cpchangtw authored and lguohan committed Aug 24, 2018
1 parent 83f0822 commit 0232218
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ parity_enable=1
# Control to disable parity correction
parity_correction=1

l2_mem_entries=<40960>
l3_mem_entries=<40960>
ipv6_lpm_128b_enable=1
l3_alpm_enable=2

l2_mem_entries=40960
l3_mem_entries=40960

portmap_1=1:100
portmap_2=5:100
Expand Down
57 changes: 28 additions & 29 deletions device/quanta/x86_64-quanta_ix1b_32x-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


import os.path
import commands
import subprocess
import logging

try:
Expand All @@ -17,59 +17,58 @@

def show_log(txt):
if DEBUG == True:
print "[IX1B]"+txt
print("[IX2]"+txt)
return

def exec_cmd(cmd, show):
logging.info('Run :'+cmd)
status, output = commands.getstatusoutput(cmd)
show_log (cmd +"with result:" + str(status))
show_log (" output:"+output)
if status:
logging.info('Failed :'+cmd)
try:
output = subprocess.check_output(cmd, shell=True)
show_log (cmd +"output:"+str(output))
except subprocess.CalledProcessError as e:
logging.info("Failed :"+cmd)
if show:
print('Failed :'+cmd)
return status, output
print("Failed :"+cmd +"returncode = {}, err msg: {}".format(e.returncode, e.output))
return output

def my_log(txt):
if DEBUG == True:
print "[QUANTA DBG]: "+txt
print("[QUANTA DBG]: "+txt)
return

def log_os_system(cmd, show):
logging.info('Run :'+cmd)
status = 1
output = ""
status, output = commands.getstatusoutput(cmd)
my_log (cmd +"with result:" + str(status))
my_log ("cmd:" + cmd)
my_log (" output:"+output)
if status:
try:
output = subprocess.check_output(cmd, shell=True)
my_log (cmd +"output:"+str(output))
except subprocess.CalledProcessError as e:
logging.info('Failed :'+cmd)
if show:
print('Failed :'+cmd)
return status, output
print("Failed :"+cmd +"returncode = {}, err msg: {}".format(e.returncode, e.output))
return output

def gpio16_exist():
ret, ls = log_os_system("ls /sys/class/gpio/ | grep gpio16", 0)
ls = log_os_system("ls /sys/class/gpio/ | grep gpio16", 0)
logging.info('mods:'+ls)
if len(ls) ==0:
return False

def gpio17_exist():
ret, ls = log_os_system("ls /sys/class/gpio/ | grep gpio17", 0)
ls = log_os_system("ls /sys/class/gpio/ | grep gpio17", 0)
logging.info('mods:'+ls)
if len(ls) ==0:
return False

def gpio19_exist():
ret, ls = log_os_system("ls /sys/class/gpio/ | grep gpio19", 0)
ls = log_os_system("ls /sys/class/gpio/ | grep gpio19", 0)
logging.info('mods:'+ls)
if len(ls) ==0:
return False

def gpio20_exist():
ret, ls = log_os_system("ls /sys/class/gpio/ | grep gpio20", 0)
ls = log_os_system("ls /sys/class/gpio/ | grep gpio20", 0)
logging.info('mods:'+ls)
if len(ls) ==0:
return False
Expand All @@ -86,20 +85,20 @@ def __init__(self):
PsuBase.__init__(self)

if gpio16_exist() == False:
status, output = exec_cmd("echo 16 > /sys/class/gpio/export ", 1)
status, output = exec_cmd("echo in > /sys/class/gpio/gpio16/direction ", 1)
output = exec_cmd("echo 16 > /sys/class/gpio/export ", 1)
output = exec_cmd("echo in > /sys/class/gpio/gpio16/direction ", 1)

if gpio17_exist() == False:
status, output = exec_cmd("echo 17 > /sys/class/gpio/export ", 1)
status, output = exec_cmd("echo in > /sys/class/gpio/gpio17/direction ", 1)
output = exec_cmd("echo 17 > /sys/class/gpio/export ", 1)
output = exec_cmd("echo in > /sys/class/gpio/gpio17/direction ", 1)

if gpio19_exist() == False:
status, output = exec_cmd("echo 19 > /sys/class/gpio/export ", 1)
status, output = exec_cmd("echo in > /sys/class/gpio/gpio19/direction ", 1)
output = exec_cmd("echo 19 > /sys/class/gpio/export ", 1)
output = exec_cmd("echo in > /sys/class/gpio/gpio19/direction ", 1)

if gpio20_exist() == False:
status, output = exec_cmd("echo 20 > /sys/class/gpio/export ", 1)
status, output = exec_cmd("echo in > /sys/class/gpio/gpio20/direction ", 1)
output = exec_cmd("echo 20 > /sys/class/gpio/export ", 1)
output = exec_cmd("echo in > /sys/class/gpio/gpio20/direction ", 1)

# Get sysfs attribute
def get_attr_value(self, attr_path):
Expand Down

0 comments on commit 0232218

Please sign in to comment.