C++ Open the COM Port on Windows CE Device
-
Hello I'm trying to open the COM Port on a Windows CE Device in C++ but without any success I'm sure that the port exist and available becaus I can use it from cSharp To do it with C++ I'm trying to use the CreateFile method The first issue was that CreateFile needs a LPCWSTR And as it is a long time that I did'nt work with C++ in Windows I had to find ho to assign a LPCWSTR Pointer So here is my attempt But it give an Error 2 during execution NB : I've also tryed different declaration of the Com port but with the same bad result
wchar_t tt[]=L"COM5";
wchar_t tt[]=L"COM5\0";
wchar_t tt[]=L"COM5:";
wchar_t tt[]=L"COM5:\0";}I can't believe that there is no way to open the Com port on Win CE in cSharp Thanks for any help
wchar_t tt[]=L"COM5";
int len=0;
int result=0;
char *buffer;
DWORD dw;hComm = CreateFile( tt,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
NULL,
NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
dw=GetLastError();
} -
Hello I'm trying to open the COM Port on a Windows CE Device in C++ but without any success I'm sure that the port exist and available becaus I can use it from cSharp To do it with C++ I'm trying to use the CreateFile method The first issue was that CreateFile needs a LPCWSTR And as it is a long time that I did'nt work with C++ in Windows I had to find ho to assign a LPCWSTR Pointer So here is my attempt But it give an Error 2 during execution NB : I've also tryed different declaration of the Com port but with the same bad result
wchar_t tt[]=L"COM5";
wchar_t tt[]=L"COM5\0";
wchar_t tt[]=L"COM5:";
wchar_t tt[]=L"COM5:\0";}I can't believe that there is no way to open the Com port on Win CE in cSharp Thanks for any help
wchar_t tt[]=L"COM5";
int len=0;
int result=0;
char *buffer;
DWORD dw;hComm = CreateFile( tt,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
NULL,
NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
dw=GetLastError();
}As far as I know,
CreateFile
's first argument must be aLPCTSTR
.THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
As far as I know,
CreateFile
's first argument must be aLPCTSTR
.THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
Great ! You help me a lot 1- It is LPCTSTR indeed 2- The column is required This is working
LPCTSTR portname = L"COM5:";
int len=0;
int result=0;
char *buffer;
DWORD dw;hComm = CreateFile( portname,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
NULL,
NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
dw=GetLastError();
int uu=5;
} -
Great ! You help me a lot 1- It is LPCTSTR indeed 2- The column is required This is working
LPCTSTR portname = L"COM5:";
int len=0;
int result=0;
char *buffer;
DWORD dw;hComm = CreateFile( portname,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
NULL,
NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
dw=GetLastError();
int uu=5;
}The correct way to set the
LPCTSTR
is:LPCTSRT portname = _T("COM5:");
As far as I know, the column is NOT required. By the way, you are welcome.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
The correct way to set the
LPCTSTR
is:LPCTSRT portname = _T("COM5:");
As far as I know, the column is NOT required. By the way, you are welcome.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
Hi,
CPallini wrote:
As far as I know, the column is NOT required.
It is required. Alternatively the full device namespace path can be used: "\\\\.\\COM1" Best Wishes, -David Delaune
Randor wrote:
It is required
Is it a
CE
thing or this very MSDN example[^] is wrong?THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
Randor wrote:
It is required
Is it a
CE
thing or this very MSDN example[^] is wrong?THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
It is quite specific under CE http://msdn.microsoft.com/en-us/library/aa517318.aspx[^] Could not be more clear => When lpFileName points to a COM port to open, you must include a colon after the name. For example, specify COM1: to open that port. When using IrCOMM, specify COM3:.
In vino veritas
-
It is quite specific under CE http://msdn.microsoft.com/en-us/library/aa517318.aspx[^] Could not be more clear => When lpFileName points to a COM port to open, you must include a colon after the name. For example, specify COM1: to open that port. When using IrCOMM, specify COM3:.
In vino veritas
OK, got it, thank you very much. By the way: Microsoft, oh my God! :-)
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite