|
Thanks Saneesh!
You mean i can use the dll that was build by C++, is that right?
But i just want to known how can i only use the C# language to build a dll and use it.
Can you give me some advice about this?
|
|
|
|
|
Did anyone had any luck with using this program to monitor SMART params for HDDs that are connected through SCSI? It is giving device I/O errors. Any help is appreciated.
|
|
|
|
|
I never tried on a SCSI hard drive. What error code is it getting for DeviceIoControl?
Saneesh
|
|
|
|
|
Hi Saneesh,
DeviceIoControl control returns the error code 1117 which is error code for I/O device error.
Regards,
Sukhas
|
|
|
|
|
Hi Saneesh, Could you please throw some light on the error code for the SCSI hard disks?
sukhas
|
|
|
|
|
I never tried on the SCSI. Did you tried any other deviceiocontrol codes with scsi?
Saneesh
|
|
|
|
|
May be the driver does not like it. Can you check with a sample scsi disk driver code?
Saneesh
|
|
|
|
|
Hello,
i have some probs on my laptop and desktop pc...both xp machines..
all the threshhold values are 0....smartmontools and hddlife is getting other and i think correct threshold values ?
any idea how to get the right ones
|
|
|
|
|
Did you tried to debug and see if the buffer is getting values properly? Also the .ini file, is that in the executable / debug path? Without that the code wont work.
Saneesh
|
|
|
|
|
Thx 4 this fine code!
but, a small bug is fixed.
first:
My threshold is always 0, but HD-Tune has some values!
I fix this:
stCIP.irDriveRegs.bFeaturesReg=READ_THRESHOLDS;
stCIP.cBufferSize=READ_THRESHOLD_BUFFER_SIZE;
bRet=DeviceIoControl(hDevice,SMART_RCV_DRIVE_DATA,&stCIP,sizeof(stCIP),szAttributes,sizeof(ST_ATAOUTPARAM) + READ_ATTRIBUTE_BUFFER_SIZE - 1,&dwRet,NULL);
if(bRet)
{
pT1=(PBYTE)(((ST_ATAOUTPARAM*)szAttributes)->bBuffer);
for(ucT1=0;ucT1<30;++ucT1)
{
pT2=(PDWORD)&pT1[2+ucT1*12+<big>5</big>];
to
stCIP.irDriveRegs.bFeaturesReg=READ_THRESHOLDS;
stCIP.cBufferSize=READ_THRESHOLD_BUFFER_SIZE;
bRet=DeviceIoControl(hDevice,SMART_RCV_DRIVE_DATA,&stCIP,sizeof(stCIP),szAttributes,sizeof(ST_ATAOUTPARAM) + READ_ATTRIBUTE_BUFFER_SIZE - 1,&dwRet,NULL);
if(bRet)
{
pT1=(PBYTE)(((ST_ATAOUTPARAM*)szAttributes)->bBuffer);
for(ucT1=0;ucT1<30;++ucT1)
{
pT2=(PDWORD)&pT1[2+ucT1*12+<big>1</big>];
+5 is 4 bytes after usable threshold data.
second:
Some RAW data is truncated, see HD-Tune or smartmontools at many hd drives.
i fix all of this (at 2 positions):
pT3[INDEX_ATTRIB_RAW+2]=pT3[INDEX_ATTRIB_RAW+3]=pT3[INDEX_ATTRIB_RAW+4]=pT3[INDEX_ATTRIB_RAW+5]=pT3[INDEX_ATTRIB_RAW+6]=0;
to
pT3[INDEX_ATTRIB_RAW+4]=pT3[INDEX_ATTRIB_RAW+5]=pT3[INDEX_ATTRIB_RAW+6]=0;
pT3[INDEX_ATTRIB_RAW+2]=pT3[INDEX_ATTRIB_RAW+3]=0 kills high word from data.
Now works fine for me, all data like hd-tune and smartmontools!
|
|
|
|
|
Thanks for pointing it out.
Saneesh
Saneesh
|
|
|
|
|
I searched a long time for that.. especially to read the temperature of the hdd !
thank you
|
|
|
|
|
Good luck with your project..
Saneesh
Saneesh
|
|
|
|
|
hi, i would like to ask how can i get the partition or size of the disk since the demo code cant get it if i nt mistaken?
hope to hear u soon.
thanks.
regards
warr~~en
modified on Friday, June 20, 2008 5:17 AM
|
|
|
|
|
Hi,
The code here is only to get the SMART parameters from the HDD and not the partition information. How ever the information for partition is stored in sector 0 of the hard drive ( that's what i remember). There are some fixed structures also on how each record is defined with type, size, name etc. I think i saw this in the code project it self. If you can not find it in the code project, let me know. Once i get time, i will upload it as a new article in code project.
Thanks,
Saneesh
Saneesh
|
|
|
|
|
Hi, i think i figured out how to get the size of the size...
if i still cannot solve then i will come here and trouble you again...
haha...
anyway, thanks a lot for your code and this reply...
thanks...
regards
warr~~en
|
|
|
|
|
I have been struggling with the smart interface for some time now, though C++ isnt a specialty of mine I stumbled upon a bit of a problem. I have no problem reading info from my own harddrives but when i try reading smart info from the HDD's of one of our servers I get nothing but a blanc screen.
Now my guesse is my drives are just not detected, but why?
For all i know they're all SMART enabled.
Is there some kind of conflict with the fact that its on SCSI or a RAID configuration?
it's a nice bit of code though nicely done
Hope to hear from you soon !
|
|
|
|
|
Hi,
Did you put the SMART.ini in the same folder as SMART.exe? If so please do it and try again.
If it still does not show any information, you have to debug the code / put some message boxes in the code and compile it. It should detect the drives. If the OS can see it, this one should also see it.
Good luck!
Saneesh
Saneesh
|
|
|
|
|
Hi:
I am from Taiwan ,and would like to read/write HDD Device,my question is
1. which control code will I select when I using DeviceIoControl()?IOCTL_ATA_PASS_THROUGH or others?
2. How can I fill the InBuffer and OutBuffer? if use the ATA_PASS_THROUGH_EX structure ,or exists other data structure?
3.if it's ok? can you show me an example just modify your demo project ?
since I cannot get your e-mail account ? if it's fine can you show me your contact e-mail?
and my e-mail is: johnnyhuang@itri.org.tw
I AM LOOK FORWARD FOR youe kindly reply!
|
|
|
|
|
Hi,
I have not tried writing / reading directly to/from sectors. Basically the In and out buffer for the DeviceIOControl is the exact buffer size needed to perform the command specified. So the size of the buffer will be different for different IOCTL's.
I remember seeing some code to read CD sectors in the code project. It should have the sample code and you can modify it. Most of these are standardised code so that device driver + firmware should support it.
Some sample code and it is from code project.
bool DiskSectorWinNT::Open(char *vol)
{
char szDrive[10];
sprintf(szDrive, "\\\\.\\%c:", vol[0]);
m_hDisk = ::CreateFile(
szDrive,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
return m_hDisk != INVALID_HANDLE_VALUE;
}
void DiskSectorWinNT::Close()
{
if (m_hDisk != INVALID_HANDLE_VALUE)
::CloseHandle(m_hDisk);
}
bool DiskSectorWinNT::ReadSector (DWORD sector, char *Buffer, int sectorSize)
{
DWORD read = 0;
if (::SetFilePointer(m_hDisk, sector, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
return false;
if (!::ReadFile(m_hDisk, Buffer, sectorSize, &read, NULL))
return false;
return true;
}
bool DiskSectorWinNT::WriteSector(DWORD sector, char *Buffer, int sectorSize)
{
DWORD wrote = 0;
if (::SetFilePointer(m_hDisk, sector, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
return false;
if (!::WriteFile(m_hDisk, Buffer, sectorSize, &wrote, NULL))
return false;
return true;
}
Thanks,
Saneesh
Saneesh
|
|
|
|
|
I need to write a simple console app. in c++ to interogate the HDD temperature sensor (via SMART). Can anybody give me some pointers on line/s of code needed to accomplish that and what #includes are needed.
|
|
|
|
|
You can use this code and then use only the hard drive temperature information from this one. It is pretty simple. Download the code and check it.
Saneesh
|
|
|
|
|
Your code is too involved for me to simply reverse engineer like that. I presume there are a couple of #includes followed by a function call to activate SMART then retrieve data from it. What call/function should I be looking for??
|
|
|
|
|
You need to look into the class named CSmartReader (SmartReader.cpp). Follow steps as below.
1) Create an object of class CSmartReader say oSmartReader
2) Call oSmartReader.ReadSMARTValuesForAllDrives()
3) Now assuming that you have only one hard drive
pDriveInfo=m_oSmartReader.GetDriveInfo(0);
pSmartInfo=m_oSmartReader.GetSMARTValue(pDriveInfo->m_ucDriveIndex,194);
pSmartInfo->m_ucValue will give you the temperature.
Thanks,
Saneesh
Saneesh
|
|
|
|
|
Nice one Saneesh...
BesRegs
|
|
|
|