Tuesday, August 5, 2008

S60 Programming

--------------------Getting System Information through S60--------------------------

How to access the HAL (Hardware Abstraction Layer) for getting system information? Here we are going to explore this. First we need to understand what is HAL and how kernel uses this layer and what is the necessity of HAL layer?
1. What is HAL layer?
Layer means some set of code will be used as an interface between two objects. Here HAL layer is used between user/kernel and HW.

2. What is the necessity of this layer?
For each device there should be an instance to communicate. HAL is the place to store those instances so that kernel can use those instances to communicate. We are registering device driver instance that is very close to HW so they named it as HAL (Hardware Abstraction Layer).
Header File: hal.h
Library: hal.lib
Class Names HAL & HALData
Function static IMPORT_C TInt Get(TAttribute aAttribute, TInt &aValue);

The above function is used to get information about the system like RAM , LCD, ect…
1. For getting Free RAM information
TInt aFreeRamSize;
HAL::Get(HALData::EMemoryRAMFree, aFreeRamSize);

This will return in bytes we need to convert into KB or MB or anything.

2. Example code


void FreeRamInfo()
{
TBuf<50> str;
TBuf<10> freeram;
char text[10];
TInt aFreeRamSize;
CAknInformationNote* informationNote;
informationNote = new ( ELeave ) CAknInformationNote;


_ LIT(aFreeRamSizeFMT, "%S %d Bytes");
freeram.Copy(_L(“Free RAM”
HAL::Get(HALData::EMemoryRAMFree, aFreeRamSize);
str.Format(aFreeRamSizeFMT, &freeram, aFreeRamSize);
informationNote->ExecuteLD( *str );
}

We can get below information using HAL class.

EAccessoryPower, EBacklight, EBacklightState, ECPU, ECPUABI, ECPUABI_ARM4, ECPUABI_ARM5T, ECPUABI_ARMI, ECPUABI_MCORE, ECPUABI_MSVC, ECPUABI_THUMB, ECPUABI_X86, ECPUArch, ECPUSpeed, ECPU_ARM, ECPU_MCORE, ECPU_X86, ECaseState, ECaseSwitch, ECaseSwitchDisplayOff, ECaseSwitchDisplayOn, EClipboardDrive, ECustomRestart, ECustomRestartReason, EDebugPort, EDeviceFamily, EDeviceFamilyRev, EDeviceFamily_Crystal, EDeviceFamily_Pearl, EDeviceFamily_Quartz, EDisplayBitsPerPixel, EDisplayBrightness, EDisplayBrightnessMax, EDisplayColors, EDisplayContrast, EDisplayContrastMax, EDisplayIsMono, EDisplayIsPalettized, EDisplayIsPixelOrderLandscape, EDisplayIsPixelOrderRGB, EDisplayMemoryAddress, EDisplayMode, EDisplayNumModes, EDisplayNumberOfScreens, EDisplayOffsetBetweenLines, EDisplayOffsetToFirstPixel, EDisplayPaletteEntry, EDisplayState, EDisplayXPixels, EDisplayXTwips, EDisplayYPixels, EDisplayYTwips, EFastCounterCountsUp, EFastCounterFrequency, EHardwareFloatingPoint, EIntegratedPhone, EKeyboard, EKeyboardAppKeys, EKeyboardBacklightState, EKeyboardClick, EKeyboardClickState, EKeyboardClickVolume, EKeyboardClickVolumeMax, EKeyboardDeviceKeys, EKeyboardIndex, EKeyboardState, EKeyboard_Full, EKeyboard_Keypad, ELEDmask, ELEDs, ELanguageIndex, ELocaleLoaded, EMachineUid, EMachineUid_Assabet, EMachineUid_Brutus, EMachineUid_CL7211_Eval, EMachineUid_Cogent, EMachineUid_Helen, EMachineUid_IQ80310, EMachineUid_Integrator, EMachineUid_LinkUp, EMachineUid_Lubbock, EMachineUid_OmapH2, EMachineUid_OmapH4, EMachineUid_Series5mx, EMachineUid_Win32Emulator, EMachineUid_WinC, EMachineUid_X86PC, EMachineUid_Zylonite, EManufacturer, EManufacturerHardwareRev, EManufacturerSoftwareBuild, EManufacturerSoftwareRev, EManufacturer_Cirrus, EManufacturer_Cogent, EManufacturer_Ericsson, EManufacturer_Intel, EManufacturer_Linkup, EManufacturer_Motorola, EManufacturer_Nokia, EManufacturer_Panasonic, EManufacturer_Psion, EManufacturer_TexasInstruments, EMaxRAMDriveSize, EMemoryPageSize, EMemoryRAM, EMemoryRAMFree, EMemoryROM, EModel, EMouse, EMouseAcceleration, EMouseButtonState, EMouseButtons, EMouseSpeed, EMouseState, EMouseState_Invisible, EMouseState_Visible, EMouseX, EMouseY, ENanoTickPeriod, ENumHalAttributes, EPen, EPenClick, EPenClickState, EPenClickVolume, EPenClickVolumeMax, EPenDisplayOn, EPenState, EPenX, EPenY, EPointer3D, EPointer3DPhiSupported, EPointer3DPressureSupported, EPointer3DRotationSupported, EPointer3DThetaSupported, EPointer3DZ, EPowerBackup, EPowerBackupStatus, EPowerBackupStatus_Good, EPowerBackupStatus_Low, EPowerBackupStatus_Replace, EPowerBackupStatus_Zero, EPowerBatteryStatus, EPowerBatteryStatus_Good, EPowerBatteryStatus_Low, EPowerBatteryStatus_Replace, EPowerBatteryStatus_Zero, EPowerExternal, EPowerGood, ESettable, ESwitches, ESystemDrive, ESystemException, ESystemStartupReason, ESystemStartupReason_Cold, ESystemStartupReason_Fault, ESystemStartupReason_Warm, ESystemTickPeriod, EValid, TAttribute, TAttributeProperty, TCPU, TCPUABI, TDeviceFamily, TKeyboard, TMachineUid, TManufacturer, TMouseState, TPowerBackupStatus, TPowerBatteryStatus, TSystemStartupReason

No comments: