From: <che...@us...> - 2010-01-10 18:40:29
|
Revision: 3344 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3344&view=rev Author: chemelli_sf Date: 2010-01-10 18:40:19 +0000 (Sun, 10 Jan 2010) Log Message: ----------- Small changes to make easier compare IR501 and IR507 implementations Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501Receiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507Receiver.cs Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501Receiver.cs 2010-01-10 18:19:20 UTC (rev 3343) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR501 Receiver/IR501Receiver.cs 2010-01-10 18:40:19 UTC (rev 3344) @@ -38,8 +38,6 @@ { #region Constants - private const int DeviceBufferSize = 255; - private const string DevicePathVidPid = "vid_147a&pid_e001"; #endregion Constants @@ -163,7 +161,7 @@ //_deviceWatcher.RegisterDeviceRemoval(deviceHandle); - _deviceBuffer = new byte[DeviceBufferSize]; + _deviceBuffer = new byte[255]; _deviceStream = new FileStream(deviceHandle, FileAccess.Read, _deviceBuffer.Length, true); _deviceStream.BeginRead(_deviceBuffer, 0, _deviceBuffer.Length, OnReadComplete, null); } Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507Receiver.cs 2010-01-10 18:19:20 UTC (rev 3343) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR507 Receiver/IR507Receiver.cs 2010-01-10 18:40:19 UTC (rev 3344) @@ -34,13 +34,11 @@ /// <summary> /// IR Server Plugin for the IR507 IR receiver. /// </summary> - [CLSCompliant(false)] public class IR507Receiver : PluginBase, IRemoteReceiver { #region Constants - //const string DeviceID = "vid_0e6a&pid_6002"; // Unknown - private const string DeviceID = "vid_147a&pid_e02a"; + private const string DevicePathVidPid = "vid_147a&pid_e02a"; #endregion Constants @@ -255,6 +253,11 @@ } } + /// <summary> + /// Finds the device. + /// </summary> + /// <param name="classGuid">The class GUID.</param> + /// <returns>Device path.</returns> private static string FindDevice(Guid classGuid) { // 0x12 = DIGCF_PRESENT | DIGCF_DEVICEINTERFACE @@ -278,7 +281,7 @@ if (lastError != 0x0103 && lastError != 0x007E) { Win32.SetupDiDestroyDeviceInfoList(handle); - throw new Win32Exception(Marshal.GetLastWin32Error()); + throw new Win32Exception(lastError); } Win32.SetupDiDestroyDeviceInfoList(handle); @@ -302,8 +305,10 @@ throw new Win32Exception(Marshal.GetLastWin32Error()); } - Win32.DeviceInterfaceDetailData deviceInterfaceDetailData = new Win32.DeviceInterfaceDetailData(); - deviceInterfaceDetailData.Size = 5; + Win32.DeviceInterfaceDetailData deviceInterfaceDetailData = new Win32.DeviceInterfaceDetailData + { + Size = Win32.Check64Bit() ? 8 : 5 + }; if (!Win32.SetupDiGetDeviceInterfaceDetail(handle, ref deviceInterfaceData, ref deviceInterfaceDetailData, cbData, IntPtr.Zero, IntPtr.Zero)) @@ -312,7 +317,7 @@ throw new Win32Exception(Marshal.GetLastWin32Error()); } - if (deviceInterfaceDetailData.DevicePath.IndexOf(DeviceID, StringComparison.OrdinalIgnoreCase) != -1) + if (deviceInterfaceDetailData.DevicePath.IndexOf(DevicePathVidPid, StringComparison.OrdinalIgnoreCase) != -1) { Win32.SetupDiDestroyDeviceInfoList(handle); devicePath = deviceInterfaceDetailData.DevicePath; @@ -324,35 +329,5 @@ } #endregion Implementation - - // #define TEST_APPLICATION in the project properties when creating the console test app ... -#if TEST_APPLICATION - - static void xRemote(string deviceName, string code) - { - Console.WriteLine("Remote: {0}", code); - } - - [STAThread] - static void Main() - { - try - { - IR507Receiver device = new IR507Receiver(); - - device.RemoteCallback += new RemoteHandler(xRemote); - device.Start(); - - Application.Run(); - - device.Stop(); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - -#endif } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |