Question

I am currently working on a windows mobile application for Motorola MC9500 which has Windows Mobile 6.5. I have tried Symbol's EMDK library to access inbuilt motion sensor of the device without any luck.

The EMDK for .NET v2.7 has Symbol.Sensor class library in it which is supposed to be accessing all inbuilt sensors, but I have no idea how to work with it.

Symbol.Sensor.SensorManager manager = new Symbol.Sensor.SensorManager();

I get a MissingMethodException exception here, saying... "Can't find PInvoke DLL SensorsAPI.dll."

What should I do to access the motion sensor using C# ?

If there is any other alternative, please tell.

Was it helpful?

Solution 2

Well this is the conclusion I reached so far... The sensors of Motorola MC9500 is not programmatically accessible.

OTHER TIPS

I will post a dllImport example as continue of comments of @HemendraSharma. The above code is written for mobile devices and is used to change system hour.

using System;
using System.Runtime.InteropServices;

namespace changeHour
{   

public class cDateTime  
{       

    [StructLayout(LayoutKind.Sequential)]       
    private struct SystemTime
    {           
        public ushort uYear;            
        public ushort uMonth;           
        public ushort uDayOfWeek;           
        public ushort uDay;         
        public ushort uHour;            
        public ushort uMinute;          
        public ushort uSecond;          
        public ushort uMilliseconds;            

        public SystemTime(
            ushort uYear, 
            ushort uMonth, 
            ushort uDay, 
            ushort uHour, 
            ushort uMinute, 
            ushort uSecond)
        {               
            this.uYear = uYear;             
            this.uMonth = uMonth;               
            this.uDayOfWeek = 0;                
            this.uDay = uDay;               
            this.uHour = uHour;             
            this.uMinute = uMinute;             
            this.uSecond = uSecond;             
            this.uMilliseconds = 0;         
        }       
    }       

    [DllImport("Coredll.dll")]          
    private static extern bool SetLocalTime(ref SystemTime st);

           [DllImport("Coredll.dll")]           
           private static extern uint SetSystemTime(ref SystemTime st);     



    public static bool SetDateTime(
        int iYear, 
        int iMonth, 
        int iDay, 
        int iHour, 
        int iMinute, 
        int iSecond)        
           {            
        SystemTime st = 
            new SystemTime
            (
            Convert.ToUInt16(iYear), 
            Convert.ToUInt16(iMonth), 
            Convert.ToUInt16(iDay), 
            Convert.ToUInt16(iHour), 
            Convert.ToUInt16(iMinute), 
            Convert.ToUInt16(iSecond)
            );          
        return SetLocalTime(ref st);        
    }

    public static uint SetDateTimeSystem(
        int iYear,
        int iMonth,
        int iDay,
        int iHour,
        int iMinute,
        int iSecond)
    {
        SystemTime st =
            new SystemTime
            (
            Convert.ToUInt16(iYear),
            Convert.ToUInt16(iMonth),
            Convert.ToUInt16(iDay),
            Convert.ToUInt16(iHour),
            Convert.ToUInt16(iMinute),
            Convert.ToUInt16(iSecond)
            );
        return SetSystemTime(ref st);
    }       


    public static bool SetDateTime(DateTime dt)     
    {           
        return SetDateTime
            (
            dt.Year, 
            dt.Month, 
            dt.Day, 
            dt.Hour, 
            dt.Minute, 
            dt.Second
            );      
    }       


    public static bool SetDate(int iYear, int iMonth, int iDay)
    {           
        DateTime dt = DateTime.Now;         
        return SetDateTime(
            iYear, 
            iMonth, 
            iDay, 
            dt.Hour, 
            dt.Minute, 
            dt.Second);     
    }       

    public static bool SetDate(DateTime date)       
    {           DateTime time = DateTime.Now;           
        return SetDateTime(
            date.Year, 
            date.Month, 
            date.Day, 
            time.Hour, 
            time.Minute, 
            time.Second);       
    }       

    public static bool SetTime(int iHour, int iMinute, int iSecond)
    {           
        DateTime dt = DateTime.Now;         
        return SetDateTime(
            dt.Year, 
            dt.Month, 
            dt.Day, 
            iHour, 
            iMinute, 
            iSecond);       
    }       


    public static bool SetTime(DateTime time)       
    {           
        DateTime date = DateTime.Now;           
        return SetDateTime(
            date.Year, 
            date.Month, 
            date.Day, 
            time.Hour, 
            time.Minute, 
            time.Second);       
    }       

}
 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top