|
Post by levelKro on May 24, 2021 20:01:15 GMT
Hello, I have tried to find information for how is possible to get system values from SIV. I want made a little program for sharing this data for another device on my network (Raspberry Pi). Any tutorial or explanation for this ? Thank you for you answer.
|
|
|
Post by siv on May 24, 2021 20:29:10 GMT
No, there is no tutorial and I have no plans to develop one.
As you have not specified which "system values" you wish to get and how often you wish to get them I have guessed it's the sensor values.
While SIV is active have you tried running sentest? If will report all the sensor values SIV exports and in the past I have given others the 264 lines of C code so they can read them directly.
|
|
|
Post by levelKro on May 25, 2021 7:12:54 GMT
I know the little "sentest.exe", it serves as a guide to configure a RainMeter plugin. Precisely, it is this plugin that leads me to this question. Because I would like to use the values in other projects.
Either through calls like an "API" or the like, or output the values in a format, like a JSon file or whatever else can easily be worked on.
So I wondered if there was some way, undocumented, that allows an activity of this kind.
I'm coding under PHP, Python or Java.
|
|
|
Post by siv on May 26, 2021 8:46:31 GMT
What SENTEST.exe does is read the values from HKEY_LOCAL_MACHINE\HARDWARE\SIV\, if you run SENTEST then look with REGEDIT then you should see all the data there. Note SIV will delete it after 30 seconds so do sentest 0 20 25000 to request it every 25,000 ms.
I assume you can read this data easily enough, but I don't know if PHP, Python or Java will be able to trigger SIV to load it. If you look at Menu->Help->Lock Usage there will be SIV_Export_Event + SIV_Sensor_Event, basically you have to set SIV_Export_Event then wait for SIV_Sensor_Event and once the wait completes the data will be in the registry. If these events don't exist the it means SIV is not running. The initial load typically takes 0.039 seconds for 345 values on my system with updates typically taking 0.013 seconds.
If you e-mail me then I will send you the source code of SENTEST.c which should be enough to show you how to use the events and enumerate the registry data. As I recall this is what I did for the guy who wrote the RainMeter plugin.
D:\SIV\DEV>sentest 0
Failed to Open Global\SIV_Export_Event, check that SIV is active.
D:\SIV\DEV>sentest 0 6 Loop 1 of 6 Sensor Values 345 with a 0.039 Second Request Delay Loop 2 of 6 Sensor Values 345 with a 0.009 Second Request Delay Loop 3 of 6 Sensor Values 345 with a 0.013 Second Request Delay Loop 4 of 6 Sensor Values 345 with a 0.013 Second Request Delay Loop 5 of 6 Sensor Values 345 with a 0.014 Second Request Delay Loop 6 of 6 Sensor Values 345 with a 0.014 Second Request Delay
D:\SIV\DEV>
|
|
|
Post by levelKro on May 27, 2021 6:37:31 GMT
Oh ok, good to know. I not have problem to start a process under PHP or Python. If data is saved in the registry, is possible to read. Anyway, can also check output in Python with sub_process, never really tested for a large output or under Windows, but I guest can be work.
Thank for your answer. Now just find how to build my project with that, but is not SIV related :)
|
|
|
Post by levelKro on May 28, 2021 8:44:54 GMT
If you want an example of working code in Python for pasting general values (cpu,gpu,ram,mb). Not final, just for testing.
import winreg import re import os import subprocess
class WindowsRegistry: """Class WindowsRegistry is using for easy manipulating Windows registry.
Methods -------
query_value( full_path : str) Check value for existing. get_value( full_path : str) Get value's data. set_value( full_path : str, value : str, value_type='REG_SZ' : str) Create a new value with data or set data to an existing value. delete_value( full_path : str) Delete an existing value. query_key( full_path : str) Check key for existing. delete_key( full_path : str) Delete an existing key(only without subkeys).
Examples: WindowsRegistry.set_value('HKCU/Software/Microsoft/Windows/CurrentVersion/Run', 'Program', r'"c:\Dir1\program.exe"') WindowsRegistry.delete_value('HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run/Program')
"""
@staticmethod
def __parse_data(full_path): full_path = re.sub(r'/', r'\\', full_path) hive = re.sub(r'\\.*$', '', full_path)
if not hive: raise ValueError('Invalid \'full_path\' param.')
if len(hive) <= 4: if hive == 'HKLM': hive = 'HKEY_LOCAL_MACHINE'
elif hive == 'HKCU': hive = 'HKEY_CURRENT_USER' elif hive == 'HKCR': hive = 'HKEY_CLASSES_ROOT' elif hive == 'HKU': hive = 'HKEY_USERS' reg_key = re.sub(r'^[A-Z_]*\\', '', full_path) reg_key = re.sub(r'\\[^\\]+$', '', reg_key) reg_value = re.sub(r'^.*\\', '', full_path) return hive, reg_key, reg_value
@staticmethod
def query_value(full_path): value_list = WindowsRegistry.__parse_data(full_path)
try: opened_key = winreg.OpenKey(getattr(winreg, value_list[0]), value_list[1], 0, winreg.KEY_READ) winreg.QueryValueEx(opened_key, value_list[2]) winreg.CloseKey(opened_key) return True except WindowsError: return False
@staticmethod
def get_value(full_path): value_list = WindowsRegistry.__parse_data(full_path)
try: opened_key = winreg.OpenKey(getattr(winreg, value_list[0]), value_list[1], 0, winreg.KEY_READ) value_of_value, value_type = winreg.QueryValueEx(opened_key, value_list[2]) winreg.CloseKey(opened_key) return value_of_value
except WindowsError: return None
@staticmethod
def set_value(full_path, value, value_type='REG_SZ'): value_list = WindowsRegistry.__parse_data(full_path)
try: winreg.CreateKey(getattr(winreg, value_list[0]), value_list[1]) opened_key = winreg.OpenKey(getattr(winreg, value_list[0]), value_list[1], 0, winreg.KEY_WRITE) winreg.SetValueEx(opened_key, value_list[2], 0, getattr(winreg, value_type), value) winreg.CloseKey(opened_key) return True except WindowsError: return False
@staticmethod
def delete_value(full_path): value_list = WindowsRegistry.__parse_data(full_path)
try: opened_key = winreg.OpenKey(getattr(winreg, value_list[0]), value_list[1], 0, winreg.KEY_WRITE) winreg.DeleteValue(opened_key, value_list[2]) winreg.CloseKey(opened_key) return True except WindowsError: return False
@staticmethod
def query_key(full_path): value_list = WindowsRegistry.__parse_data(full_path) try: opened_key = winreg.OpenKey(getattr(winreg, value_list[0]), value_list[1] + r'\\' + value_list[2], 0, winreg.KEY_READ) winreg.CloseKey(opened_key) return True
except WindowsError: return False
@staticmethod def delete_key(full_path): value_list = WindowsRegistry.__parse_data(full_path)
try: winreg.DeleteKey(getattr(winreg, value_list[0]), value_list[1] + r'\\' + value_list[2]) return True
except WindowsError: return False
def getSIV(sector,keyname,keynum = 0): chk = str(WindowsRegistry.get_value("HKEY_LOCAL_MACHINE\\HARDWARE\\SIV\\" + sector + "\\" + keyname)) out = chk.split(",") try: return out[keynum] except: return out[0]
class Siv: def cpu(self,key): if key == "name": return getSIV("H","CPU-0-NAM") elif key == "use": return getSIV("H","SYSCPUUSE").split(" ")[0] elif key == "temp": return getSIV("T","CPU-0-T") elif key == "tempMB": return getSIV("T","C-TA") elif key == "load": return getSIV("L","CPU-T-L")+"%" else: return "?"
def gpu(self,key):
if key == "name": return getSIV("H","GPU-0-NAM") elif key == "use": return getSIV("H","SYSGPUUSE").split(" ")[0] elif key == "temp": return getSIV("T","GPU-0-T") elif key == "fan": return getSIV("C","GPU-0-X").replace(" ","") elif key == "load": return getSIV("L","GPU-T-L")+"%" elif key == "memUse": return getSIV("L","GPU-T-P")+"%" elif key == "memUsage": return getSIV("L","GPU-T-B") elif key == "memTotal": return getSIV("L","GPU-T-B",4) else: return "?"
def ram(self,key): if key == "name": return getSIV("H","SYSMEMSUM") elif key == "use": return getSIV("H","SYSRAMPOT").replace(" ","") elif key == "free": return getSIV("H","SYSRAMFRE").replace(" ","") elif key == "usage": return getSIV("H","SYSRAMUSE").replace(" ","") elif key == "total": return getSIV("H","SYSRAMTOT").replace(" ","") else: return "?"
def mb(self,key): if key == "name": return getSIV("H","Motherboard") else: return "?"
def start(self): print(subprocess.check_output([SIVPATH + "sentest.exe","0"]))
SIVPATH = "C:\\PATH\\TO\\SIV\\"
siv = Siv() siv.start()
print("MB\t"+siv.mb("name")) print("CPU\t"+siv.cpu("name")+"\n\t\t"+siv.cpu("use")+"/"+siv.cpu("load")+" ("+siv.cpu("temp")+"/"+siv.cpu("tempMB")+")") print("RAM\t"+siv.ram("name")+"\n\t\t"+siv.ram("use")+" ("+siv.ram("usage")+"/"+siv.ram("total")+", "+siv.ram("free")+" free)") print("GPU\t"+siv.gpu("name")+"\n\t\t"+siv.gpu("use")+"/"+siv.gpu("load")+" ("+siv.gpu("temp")+")") print("\t\tFan "+siv.gpu("fan")) print("\t\tMemory "+siv.gpu("memUse")+" ("+siv.gpu("memUsage")+siv.gpu("memTotal")+")")
|
|
|
Post by levelKro on May 28, 2021 17:26:46 GMT
If, I running SIV, values from sentest.exe are ignored ? I already use SIV main app for my usages with RainMeter. When use the sentest.exe with parameter, is never change.
sentest.exe <0> <ms>
* I guest the "0" is for hide results * "ms" is the time between update, if set it to 500 or 500000, no change, always report refresh to 0.0000s delay.
Not really need to set a refresh if data is updated with SIV main app.
|
|
|
Post by siv on May 29, 2021 10:18:56 GMT
- If you are going to post code make it readable, all the code you posted was double spaced and in general a PITA to read. This time I cleaned it up, but if you do it again I will delete the post.
- I never intended that any code should be running sentest.exe but rather manipulate the events directly, why are you not doing this?
- I also specified you should email me and and I would send you the sentest.c source which shows how to use the events, but you have not done this, why not?
- As I specified SIV will only update the data when requested and will delete it 30 seconds after the last request. Obviously the RainMeter plug-in will be doing this so you can get away without doing this. Stop the RainMeter plug-in and your code won't work!
|
|