Commit 0a729a6a authored by Andrey Filippov's avatar Andrey Filippov

added hwmon command

parent 8a8dc145
......@@ -159,7 +159,31 @@ class X393AxiControlStatus(object):
'refresh_en': self.get_refresh_en(quiet),
'sequences_set': self.get_sequences_set(quiet)
}
def hwmon(self):
"""
Read current temperature and supply voltages
"""
HWMON_PATH = "/sys/devices/amba.0/f8007100.ps7-xadc/"
FILE = "file"
ITEM = "item"
UNITS = "units"
SCALE = "scale"
HWMON_ITEMS= [{FILE:"temp", ITEM:"Temperature", UNITS:"C", SCALE: 1.0},
{FILE:"vccaux", ITEM:"VCCaux", UNITS:"V", SCALE: 0.001},
{FILE:"vccint", ITEM:"VCCint", UNITS:"V", SCALE: 0.001},
{FILE:"vccbram", ITEM:"VCCbram", UNITS:"V", SCALE: 0.001}]
print("hwmon:")
for par in HWMON_ITEMS:
with open(HWMON_PATH + par[FILE]) as f:
d=int(f.read())
num_digits=0
s = par[SCALE]
while s < 1:
s *= 10
num_digits += 1
w = 2+num_digits + (0,1)[num_digits > 0]
frmt = "%%12s = %%%d.%df %%s"%(w,num_digits)
print(frmt%(par[ITEM],(d*par[SCALE]),par[UNITS]))
def write_control_register(self, reg_addr, data):
"""
Write 32-bit word to the control register
......
......@@ -976,6 +976,21 @@ print_sensor_i2c 0
#r
add hwmon:
root@elphel393:/sys/devices/amba.0/f8007100.ps7-xadc# cat /sys/devices/amba.0/f8007100.ps7-xadc/temp
47
root@elphel393:/sys/devices/amba.0/f8007100.ps7-xadc# cat /sys/devices/amba.0/f8007100.ps7-xadc/temp_max
48
root@elphel393:/sys/devices/amba.0/f8007100.ps7-xadc# cat /sys/devices/amba.0/f8007100.ps7-xadc/temp_min
41
root@elphel393:/sys/devices/amba.0/f8007100.ps7-xadc# cat /sys/devices/amba.0/f8007100.ps7-xadc/v
0
root@elphel393:/sys/devices/amba.0/f8007100.ps7-xadc# cat /sys/devices/amba.0/f8007100.ps7-xadc/vccaux
1808
root@elphel393:/sys/devices/amba.0/f8007100.ps7-xadc# cat /sys/devices/amba.0/f8007100.ps7-xadc/vccbram
967
root@elphel393:/sys/devices/amba.0/f8007100.ps7-xadc# cat /sys/devices/amba.0/f8007100.ps7-xadc/vccint
966
"""
......@@ -39,7 +39,7 @@ import x393_mcntrl_buffers
#import verilog_utils
import x393_mcntrl
MEM_PATH='/sys/devices/elphel393-mem.2/'
BUFFER_ASSRESS_NAME='buffer_address'
BUFFER_ADDRESS_NAME='buffer_address'
BUFFER_PAGES_NAME='buffer_pages'
BUFFER_ADDRESS=None
BUFFER_LEN=None
......@@ -113,7 +113,7 @@ class X393McntrlMembridge(object):
print ("Running in simulated mode, using hard-coded addresses:")
else:
try:
with open(MEM_PATH+BUFFER_ASSRESS_NAME) as sysfile:
with open(MEM_PATH+BUFFER_ADDRESS_NAME) as sysfile:
BUFFER_ADDRESS=int(sysfile.read(),0)
with open(MEM_PATH+BUFFER_PAGES_NAME) as sysfile:
BUFFER_LEN=PAGE_SIZE*int(sysfile.read(),0)
......
......@@ -55,7 +55,7 @@ PAGE_SIZE = 4096
SI5338_PATH = '/sys/devices/amba.0/e0004000.ps7-i2c/i2c-0/0-0070'
POWER393_PATH = '/sys/devices/elphel393-pwr.1'
MEM_PATH = '/sys/devices/elphel393-mem.2/'
BUFFER_ASSRESS_NAME = 'buffer_address'
BUFFER_ADDRESS_NAME = 'buffer_address'
BUFFER_PAGES_NAME = 'buffer_pages'
BUFFER_ADDRESS = None # in bytes
BUFFER_LEN = None # in bytes
......@@ -111,7 +111,7 @@ class X393SensCmprs(object):
print ("Running in simulated mode, using hard-coded addresses:")
else:
try:
with open(MEM_PATH + BUFFER_ASSRESS_NAME) as sysfile:
with open(MEM_PATH + BUFFER_ADDRESS_NAME) as sysfile:
BUFFER_ADDRESS = int(sysfile.read(),0)
with open(MEM_PATH + BUFFER_PAGES_NAME) as sysfile:
BUFFER_LEN = PAGE_SIZE * int(sysfile.read(),0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment