Darien Figueroa / Mbed 2 deprecated repo3

Dependencies:   mbed MAX14720 MAX30205 USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FileIODeclarations.cs Source File

FileIODeclarations.cs

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved.
00003 * 
00004 * This software is protected by copyright laws of the United States and
00005 * of foreign countries. This material may also be protected by patent laws
00006 * and technology transfer regulations of the United States and of foreign
00007 * countries. This software is furnished under a license agreement and/or a
00008 * nondisclosure agreement and may only be used or reproduced in accordance
00009 * with the terms of those agreements. Dissemination of this information to
00010 * any party or parties not specified in the license agreement and/or
00011 * nondisclosure agreement is expressly prohibited.
00012 *
00013 * The above copyright notice and this permission notice shall be included
00014 * in all copies or substantial portions of the Software.
00015 *
00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00017 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00019 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00020 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00021 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00022 * OTHER DEALINGS IN THE SOFTWARE.
00023 *
00024 * Except as contained in this notice, the name of Maxim Integrated
00025 * Products, Inc. shall not be used except as stated in the Maxim Integrated
00026 * Products, Inc. Branding Policy.
00027 *
00028 * The mere transfer of this software does not imply any licenses
00029 * of trade secrets, proprietary technology, copyrights, patents,
00030 * trademarks, maskwork rights, or any other form of intellectual
00031 * property whatsoever. Maxim Integrated Products, Inc. retains all
00032 * ownership rights.
00033 *******************************************************************************
00034 */
00035 
00036 using System;
00037 using Microsoft.Win32.SafeHandles; 
00038 using System.Runtime.InteropServices;
00039 //using System.Threading;
00040 
00041 //----------------------------------------------------------------------
00042 // MSVC reports Warning: XML comment is not placed on a valid language element.
00043 // MSVC does not support attaching documentation to namespaces.
00044 // But doxygen does, so this isn't an issue.
00045 //----------------------------------------------------------------------
00046 // warning CS1587: XML comment is not placed on a valid language element
00047 #pragma warning disable 1587
00048 ///  <summary>
00049 /// @file FileIODeclarations.cs
00050 /// @brief API declarations relating to file I/O.
00051 /// 
00052 /// 
00053 ///  </summary>
00054 //----------------------------------------------------------------------
00055 #pragma warning restore 1587
00056 
00057 //------------------------------------------------------------------------------------------
00058 // OS24EVK-59 split into HeartRateApp EXE and MAX30101 DLL.
00059 // Moved all MAX30101 DLL classes into namespace Maxim.MAX30101GUI
00060 // Moved all HeartRateApp GUI classes into namespace Maxim.MAX30101
00061 // OS24EVK-59 Create separate project that builds Maxim.MAX30101GUI DLL library
00062 
00063 // OS24EVK-59 moved class FileIO into namespace Maxim.MAX30101 instead of namespace HeartRateApp
00064 namespace RPCSupport
00065 {   
00066     internal sealed class FileIO 
00067     {
00068         internal const Int32 FILE_FLAG_OVERLAPPED = 0X40000000; 
00069         internal const Int32 FILE_SHARE_READ = 1; 
00070         internal const Int32 FILE_SHARE_WRITE = 2; 
00071         internal const UInt32 GENERIC_READ = 0X80000000; 
00072         internal const UInt32 GENERIC_WRITE = 0X40000000; 
00073         internal const Int32 INVALID_HANDLE_VALUE = -1; 
00074         internal const Int32 OPEN_EXISTING = 3; 
00075         internal const Int32 WAIT_TIMEOUT = 0X102;
00076         internal const Int32 WAIT_OBJECT_0 = 0;         
00077     
00078         [ StructLayout( LayoutKind.Sequential ) ]
00079         internal class SECURITY_ATTRIBUTES  
00080         { 
00081             internal Int32 nLength; 
00082             internal Int32 lpSecurityDescriptor; 
00083             internal Int32 bInheritHandle; 
00084         }    
00085         
00086         [ DllImport( "kernel32.dll", SetLastError=true ) ]
00087         internal static extern bool CancelIo(SafeFileHandle hFile);        
00088         
00089         [ DllImport( "kernel32.dll", CharSet=CharSet.Auto, SetLastError=true ) ]
00090         internal static extern IntPtr CreateEvent(IntPtr SecurityAttributes, Boolean bManualReset, Boolean bInitialState, String lpName);
00091        
00092         [ DllImport( "kernel32.dll", CharSet=CharSet.Auto, SetLastError=true ) ]
00093         internal static extern SafeFileHandle CreateFile(String lpFileName, UInt32 dwDesiredAccess, Int32 dwShareMode, IntPtr lpSecurityAttributes, Int32 dwCreationDisposition, Int32 dwFlagsAndAttributes, Int32 hTemplateFile);
00094 
00095         [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
00096         internal static extern int FormatMessage (Int32 dwFlags, Int32 lpSource, Int32 dwMessageId, Int32 dwLanguageZId, string lpBuffer, Int32 nSize, Int32 Arguments);
00097     
00098         [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
00099         internal static extern bool GetOverlappedResult(SafeFileHandle hFile, IntPtr lpOverlapped, ref Int32 lpNumberOfBytesTransferred, Boolean bWait);       
00100 
00101         [ DllImport( "kernel32.dll", SetLastError=true ) ]
00102         internal static extern bool ReadFile(SafeFileHandle hFile, IntPtr lpBuffer, Int32 nNumberOfBytesToRead, ref Int32 lpNumberOfBytesRead, IntPtr lpOverlapped);
00103 
00104         [DllImport("kernel32.dll", SetLastError = true)]
00105         internal static extern void Sleep(UInt32 dwMilliseconds);
00106 
00107         [ DllImport( "kernel32.dll", SetLastError=true ) ]
00108         internal static extern Int32 WaitForSingleObject(IntPtr hHandle, Int32 dwMilliseconds);        
00109        
00110         [ DllImport( "kernel32.dll", SetLastError=true ) ]
00111         internal static extern bool WriteFile(SafeFileHandle hFile, IntPtr lpBuffer, Int32 nNumberOfBytesToWrite, ref Int32 lpNumberOfBytesWritten, IntPtr lpOverlapped);
00112     }     
00113 }