Okay, not really. Had a request to write a complete program from the speedfan post I made forever ago.
Here is the main cs file for a simple console app that logs to stdout or to a file if one is given on the command line.
program.cs
EDIT: This is only meant as an example. I don't know how well this works, its been a long time since I've played around with this stuff. If you really need a decent logging tool, check out HWMonitor Pro. Nothing to do with me, and it will cost you a small amount, but its a solid program.
Subscribe to:
Post Comments (Atom)
wow thanks!! haha, back from the dead.
ReplyDeletenow all i have to do is change the memory it reads and the values it reads from the memory according to this: http://aida64.helpmax.net/en/external-applications/shared-memory/
thanks!
oh i just looked at the new .cs, are they meant to be combined or what? im not sure what you did there.
ReplyDeletethanks
Create a new command line project, replace Program.cs with the one here, and include the cs from the Speedfan post.
ReplyDeleteyeah, i didnt work on it right away so i wasnt sure, i got it! now im changing it to a AIDA64 shared memory reader that i post above.
ReplyDeletei dunno if you looked at that link above, but how would you recommend reading/trimming the data blob of AIDA64 after its been extracted from memory? XMLReader in C#?
thanks
You'll probably need to do it in two steps. First, copy the memory into a managed structure. Use one of the Marshal.PtrToString variants (probably Ptr.ToStringAuto), this will give you a String object that contains the XML.
ReplyDeleteFrom there you can use XMLReader.Create() on the string to get an XMLReader object... assuming you want to parse it. If you just want to save the xml to a file, just output the string as is.
ok thanks, ill see if google can get me anywhere:)
ReplyDeletedoes the xmlcreate stuff replace the printheader and print data?
and im going to be puting this code in with a gmail notifier to send info to my arduino over serial.
So you are using AIDA64 to get sensor information, which you are going to use to control something via an arduino? Why do you need XML, can't you just control the arduino directly? Or are you controlling a display of some kind?
ReplyDeleteYou've got me curious!
printheader and printdata are just the output functions -- if you want the output to do something different (ie send to a device over serial), then those are the things you want to change.
You've got me curious! haha i suppose id dint ever give you the link to the project.
ReplyDeletebasically what im doing is getting email notifications and temp data via a C# app then sending it over serial to a arduino to be displayed on a Serial LCD.
see here: http://arduino.cc/forum/index.php/topic,69831.0.html
Looks pretty cool, for a water cooling set up or something? Good luck!
ReplyDeleteok i ve been at it for an hour. i cant seem to get the "ptrtostring" instead of "ptrtostruct" to work. could you do that? i think i can manage the XML stuff thanks.
ReplyDeletehere is the code:
http://pastebin.com/FXdySSzS
if you want also, another problem ive been stuck on is in that gmail C# code in the paste bin. i can enter my password into the app bc it tries to do something with it, my pass has letters and numbers but if i put just random letters in it compiles fine. so the numbers mess it up.
thanks
You need to drop the Data structure. Its not helping you here, you are trying to marshal a string, not a structure.
ReplyDeleteSo, GetData() should look something like this:
public String GetData()
{
if (fileOpen)
{
String data = (String)Marshal.PtrToStringAuto(map);
return data;
}
else
return null;
}
}
The gmail thing looks fine, just remember that certain characters need to be escaped in a string in C# (ie \ needs to be \\)
ok the code that writes the info:
ReplyDeletetry
{
bool first = true;
while (!done)
{
AIDA.Data d = sf.GetData();
if (first)
{
printHeader(d);
first = false;
}
printData(d);
if (writer != null)
writer.Flush();
// Sleep for a second
System.Threading.Thread.Sleep(1000);
}
}
what is AIDA.Data d = sf.GetData(); doing?
GetData() reads from the shared memory area. The shared memory area is written into by AIDA. But if you made the change I suggested above, its returning a String, so should look like this:
ReplyDeleteString d = sf.GetData();
we could do this over chat would be easier but ok.
ReplyDeleteumm so XML and the serial stuff would go in the code i had in last post?
also another thing i ve been tinkering with:
ReplyDeletein the gmail code:
private int GetNumberOfMail(string user, string pass)
{
XmlDocument xmldoc = GetGmailFeed(user, pass);
XmlNodeList count = xmldoc.GetElementsByTagName("fullcount");
return int.Parse(count[0].InnerText);
}
thats the code gets the email count from the xml once it is retrieved from gmail, correct?
how do i display the number retreived?
thanks for all your help! im out for the night.
YUSH! i got gmail working!
ReplyDeletenow i jsut got temps left. where is the shared memory stored after it is read? what string?
ive been at this for days, could please just do it for me? you could prob do it in 10minutes. PLEASE
ReplyDeletethanks!
The gmail code you posted gets an XML document and extracts the email count out of it. You'd have to look at GetGmailFeed() to see what else is returned here.
ReplyDeleteWhen you call Marshall.PtrTo*Something* a copy of the source (in this case, the shared memory object) is created, and returned. So, in context of the code above, the call to GetData() copies the shared memory area, and returns an object that is a managed version (ie copy) of it.
TL;DR version: GetData() returns a String that contains the data from the shared memory object.
ahaha!!! so String d = sf.GetData();
ReplyDeletethat would create a new string then i could write something like to save it to file.
but i kinda figured that out before(not saying that your not helpful ofc)
and i was experimenting on how to write the data to a simple txt file on the hard drive. isntead of re-explaing it again, see here: http://stackoverflow.com/questions/7153816/shared-memory-write-to-file
antoehr Q: what do i do with the Public Class Data? it was used to store the structlayout, but now i dont use that. but its still in the marshal ptr.
i did manage to create a file from the string but it wasn't anywhere near what the output should be. it was all "㰾慬敢㹬楔敭⼼"
ReplyDeleteI HAZ SUCCESS!!!
ReplyDeletehttp://pastebin.com/aGuNe0kv