Create serial port connection in XP Embedded

G

Guest

Hi everybody,
I am new in serial port connection. How do you create and established a
serial port communication with a gprs modem (via a serail port)? I found
these api functions. How they are used? please show codes how to use them.
Thanks.

[DllImport("kernel32.dll")]

private static extern Boolean GetCommProperties(IntPtr hFile, out COMMPROP
cp);

[DllImport("kernel32.dll")]

private static extern Boolean GetCommModemStatus(IntPtr hFile, out UInt32
lpModemStat);

[DllImport("kernel32.dll")]

private static extern Boolean GetCommState(IntPtr hFile, ref DCB lpDCB);

[DllImport("kernel32.dll")]

private static extern Boolean SetCommState(IntPtr hFile, [In] ref DCB lpDCB);

[DllImport("kernel32.dll", SetLastError=true)]

private static extern IntPtr CreateFile(String lpFileName, UInt32
dwDesiredAccess, UInt32 dwShareMode, IntPtr lpSecurityAttributes, UInt32
dwCreationDisposition, UInt32 dwFlagsAndAttributes, IntPtr hTemplateFile);

[DllImport("kernel32.dll")]

private static extern Boolean CloseHandle(IntPtr hObject);

[DllImport("kernel32.dll", SetLastError=true)]

private static extern Boolean ReadFile(IntPtr hFile, [Out] Byte[] lpBuffer,
UInt32 nNumberOfBytesToRead, out UInt32 nNumberOfBytesRead, IntPtr
lpOverlapped);

[DllImport("kernel32.dll", SetLastError=true)]

private static extern Boolean WriteFile(IntPtr fFile, Byte[] lpBuffer,
UInt32 nNumberOfBytesToWrite, out UInt32 lpNumberOfBytesWritten, IntPtr
lpOverlapped);

[DllImport("kernel32.dll")]

private static extern Boolean CancelIo(IntPtr hFile);

[DllImport("kernel32.dll")]

private static extern Boolean TransmitCommChar(IntPtr hFile, Byte cChar);

[DllImport("kernel32.dll")]

internal static extern Boolean SetupComm(IntPtr hFile, UInt32 dwInQueue,
UInt32 dwOutQueue);

den2005
 
K

KM

Den,

If you search MSDN you will find the function descriptions and lots of code
samples on how to use the APIs.

You may get better reply if you post the questions to other, more
appropriate newsgroups (like Win32 programming, etc.)

KM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top