S.M.A.R.T.

Share your advanced PureBasic knowledge/code with the community.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

S.M.A.R.T.

Post by Droopy »

SMART = Self-Monitoring Analysis and Reporting Technology

This Lib / Example can monitor your Hard Disk Smart function.

The source code is from Rings and Max (viewtopic.php?t=6599)
I just add a GUI and made it easier to use ( for library purpose).

You can download a first sample here.
Last edited by Droopy on Wed Nov 30, 2005 10:52 pm, edited 1 time in total.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

WoW !!!

Image
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Nice lib but my HD has a temperatur of 134°C

There is maybe something wrong. :-)

Mike
Tranquil
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Tranquil wrote:Nice lib but my HD has a temperatur of 134°C

There is maybe something wrong. :-)

Mike
Value is returned by the Disk an may be wrong.
In this case try reading Raw Value :wink:

( My disk return 105 as temperature, but Raw Value = 35C )
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

It don't work with Win9x/Me, because of

Code: Select all

hdh = CreateFile_("\\.\PhysicalDrive" + Str(Drive),#GENERIC_READ | #GENERIC_WRITE, #FILE_SHARE_READ | #FILE_SHARE_WRITE,0, #OPEN_EXISTING, 0, 0) 
Maybe it would work with

Code: Select all

hdh = CreateFile_("\\.\SMARTVSD", #GENERIC_READ, #FILE_SHARE_READ, 0, #OPEN_EXISTING, 0, 0)
Like :

Code: Select all

    VersionInfo\dwOSVersionInfoSize = SizeOf(OSVERSIONINFO)
    Platform = GetVersionEx_(VersionInfo)
    If Platform
      If VersionInfo\dwPlatformId = #VER_PLATFORM_WIN32_WINDOWS ; Win9x/Me
        hdh = CreateFile_("\\.\SMARTVSD", #GENERIC_READ, #FILE_SHARE_READ, 0, #OPEN_EXISTING, 0, 0)
      Else ; NT kernel
        hdh = CreateFile_("\\.\PhysicalDrive" + Str(Drive), #GENERIC_READ | #GENERIC_WRITE, #FILE_SHARE_READ | #FILE_SHARE_WRITE, 0, #OPEN_EXISTING, 0, 0)
      EndIf
    EndIf
    If hdh <> #INVALID_HANDLE_VALUE
      etc ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

39 degrees on my first drive. VERY cool lib :)
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Max.
Enthusiast
Enthusiast
Posts: 225
Joined: Fri Apr 25, 2003 8:39 pm

Post by Max. »

GeoTrail wrote:39 degrees on my first drive. VERY cool lib :)
Very cool Lib?

Give the credits to Rings mostly, as he did the really hard work about accessing the Physical Drive.

I did the entire retrieval of the S.M.A.R.T. attributes in extension to Rings code.

Droopy wrapped around it and added some constants. You guys should really learn to give the kudos, where it belongs to. What you do is close to stealing intellectual property. As coder you should understand that this is the worst in this business.

Recycling top, innovation flop!

And stop calling everything a Lib. Just because I take some other people's code and add a gui doesn't make it a lib, ffs.
Athlon64 3800+ · 1 GB RAM · Radeon X800 XL · Win XP Prof/SP1+IE6.0/Firefox · PB 3.94/4.0
Intel Centrino 1.4 MHz · 1.5 GB RAM · Radeon 9000 Mobility · Win XP Prof/SP2+IE6.0/Firefox · PB 3.94/4.0
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Well, I can't disagree with Max.

Hmm is this supossed to work with SATA drives anyway?

In any case... any real programmer would know how to handle errors, at line 185 you should add this (on the next, blank, line, of, course)..

Code: Select all

If CountList(SmartLList()) < 1 ;use = 0 if it makes you horny though.
      ProcedureReturn 0
EndIf
So if there arent any items, break. In my case with the SATA drives I dont get any output from the list, so thats why you should have this kind of error checking. You shouldnt avoid error checking, ever. (Even less if you're going to release something to public).
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

You might want to be a little careful with this one - hung me tight - had to reset/reboot.

cheers
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Woot?, it will crash (the program itself) since it has no error checking, but crashing the OS? which OS are you using? 9x ?

Not that I care though (about this 'lib' crashing people's systems)..
Last edited by dagcrack on Wed Nov 30, 2005 4:32 am, edited 1 time in total.
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

The program hung my system - winxp sp2.

Hour glass on the program could not access task manager or even move the mouse. Had to reset/reboot the system.

I do have drives attached via a pci interface card as well as through the normal motherboard ide connector.

cheers,
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Well here havent got any output from it.. using 2 SATA drives. Also I have a couple of IDE ones at another system, one of them has SMART (the other is very old and therefore doesnt have SMART support).. anyway the program doesnt detect it at all, nor the sata ones..
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Give the credits to Rings mostly, as he did the really hard work about accessing the Physical Drive.
In the source code the credit is done to Rings and you, sorry to omit this in the post.
And stop calling everything a Lib. Just because I take some other people's code and add a gui doesn't make it a lib, ffs.
This code is for including in the Droopy Lib, i'll compile it with tailbite / add documentation in chm format for each functions / add credit to for each author.
Recycling top, innovation flop!
I add Status State : (Test done by destroying some hard disk, i need to check smart status, it's a major value for me )

Code: Select all

If Smart\Value < Smart\Threshold 
  Status= "BAD" 
Else 
  Status="OK" 
EndIf

I have a dead disk, wich Smart status is OK, but Smart Error Log report many errors. (With SmartMonTools http://smartmontools.sourceforge.net/
I want to retrieve SMART Error Log, someone know how to do this ?
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Max. wrote:Very cool Lib?

Give the credits to Rings mostly, as he did the really hard work about accessing the Physical Drive.

I did the entire retrieval of the S.M.A.R.T. attributes in extension to Rings code.

Droopy wrapped around it and added some constants. You guys should really learn to give the kudos, where it belongs to. What you do is close to stealing intellectual property. As coder you should understand that this is the worst in this business.

Recycling top, innovation flop!

And stop calling everything a Lib. Just because I take some other people's code and add a gui doesn't make it a lib, ffs.
Then why are you quoting me? It isn't my responsibility to check who the original author is before I say something is cool :!:
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Max.
Enthusiast
Enthusiast
Posts: 225
Joined: Fri Apr 25, 2003 8:39 pm

Post by Max. »

My beef with what you did (and also do with other people's stuff) is:

1. This is a Tips & Tricks section. I understand this as sharing new source codes/snippets for people to learn & use and not to announce libraries or applications, even more if there was nothing really new.

2. If you like to enhance stuff of others, add it to their threads, so people learn to know where it comes from and also maybe get hints from the development history.

3. If you recycle, use proper credits. This is more than mentioning a bunch of names in the source code only without a clear indicator who did what.

4. If you intend to Tailbite stuff of others in order to distribute it, I'd consider it good style if you asked for the original coders consent.

5. If you quote, like you did in the source code, do it in an appropriate way.
;{- ORIGINAL POST : viewtopic.php?t=6599&postdays=0&postorder=asc&start=15
; I extended Rings' snippet a bit so it reads also the S.M.A.R.T. data of an harddisk
; (If The HDD is capable of).
; The values are held in two structures.
; bAttrValue is The current value of an Attribute. Attribute means certain monitoring
; parameter, like temperature, Read errors And such.
; bWorstValue is speaking For itself.
; bRawValue is The value translated; for example, for Attribute 194 my system reports
; "104" as current value, "7" as worst (O_o), "0" as threshold And "39" as raw value.
; The "39" is "39 °C", as we are talking about temperatures.
; bWarrantyThreshold is The value defined by The vendor And The actual value should
; never be below.
;}
Without knowing better or rereading the entire thread, I'd think that it is you who said: "I extended Rings' snippet a bit so it reads also the S.M.A.R.T. data of an harddisk..."

6. Don't omit the origin in the posting. This is what people see.
SMART = Self-Monitoring Analysis and Reporting Technology

This Lib / Example can monitor your Hard Disk Smart function.

http://www.penguinbyte.com/apps/pbwebst ... /SMART.zip
and as with the good old tin-can phones, this is what results of it

http://forums.purebasic.com/german/view ... highlight=
Subject: S.M.A.R.T. von Droopy

Droopy hat folgendes geschrieben:
SMART = Self-Monitoring Analysis and Reporting Technology

This Lib / Example can monitor your Hard Disk Smart function.


viewtopic.php?t=17974

Grüße ... Kiffi
----------------

Some might see things like that not as serious as I do, but for me, several incidents like this were reason enough not to share any more code since more than 1 year and this one confirms me. So...
I want to retrieve SMART Error Log, someone know how to do this ?
...:lol:
Athlon64 3800+ · 1 GB RAM · Radeon X800 XL · Win XP Prof/SP1+IE6.0/Firefox · PB 3.94/4.0
Intel Centrino 1.4 MHz · 1.5 GB RAM · Radeon 9000 Mobility · Win XP Prof/SP2+IE6.0/Firefox · PB 3.94/4.0
Post Reply