Board index » Visual Studio » BUG in VC++6.0???: Multi-Port Serial Communications Card Problem

BUG in VC++6.0???: Multi-Port Serial Communications Card Problem

Visual Studio285
I have an 8 port serial communications card in a WindowsNT system installed as COM3, COM4, ... COM10. I can use any of the eight ports using the WindowsNT hyperterminal utility



I am using Visual C++ 6.0 with MFC and attempting to open different ports with the following statement



m_commhandle = CreateFile((LPCTSTR)m_port, GENERIC_READ|GENERIC_WRITE,0, NULL, OPEN_EXISTING, 0,NULL)



This statement works for all of the ports EXCEPT COM10. GetLastError() returns a 2 (ERROR_FILE_NOT_FOUND). In DEBUG, m_port contains "COM10", but the CreateFile(...) still fails. Hyperterminal is not running when I a making these tests, but when I am not debugging my code, and hyperterminal is loaded, it has no problem opening and communicating over COM10, too



Is this a BUG in VC++C6.0


-
 

Re:BUG in VC++6.0???: Multi-Port Serial Communications Card Problem

"TLNA" <anonymous@discussions.microsoft.com>wrote in message

Quote
I have an 8 port serial communications card in a WindowsNT system

installed as COM3, COM4, ... COM10. I can use any of the eight ports using

the WindowsNT hyperterminal utility.

Quote


I am using Visual C++ 6.0 with MFC and attempting to open different ports

with the following statement:



m_commhandle = CreateFile((LPCTSTR)m_port, GENERIC_READ|GENERIC_WRITE,0,

NULL, OPEN_EXISTING, 0,NULL);



This statement works for all of the ports EXCEPT COM10. GetLastError()

returns a 2 (ERROR_FILE_NOT_FOUND). In DEBUG, m_port contains "COM10", but

the CreateFile(...) still fails. Hyperterminal is not running when I a

making these tests, but when I am not debugging my code, and hyperterminal

is loaded, it has no problem opening and communicating over COM10, too!

Quote


Is this a BUG in VC++C6.0?







TLNA,



The string should be "COM10:" not "COM10".





-

Re:BUG in VC++6.0???: Multi-Port Serial Communications Card Problem

"COM10:" fails with a GetLastError() of 123 (ERROR_INVALID_NAME

"COM10" still fails with a GetLastError() of 2 (ERROR_FILE_NOT_FOUND



For reference

"COM6" succeeds in opening and running properl

"COM6:" also succeeds in opening and running properly

-

Re:BUG in VC++6.0???: Multi-Port Serial Communications Card Problem

No it shouldn't!



To access COM ports past 9 you must specify the name like this \\.\COM10,

which becomes "\\\\.\\COM10" when specified in C++. This works for COM 1 to

9 as well, so there is no need to special case it.



Best Regards

Julian N.



"Trevor" <trevor@nospam.com>wrote in message

Quote
"TLNA" <anonymous@discussions.microsoft.com>wrote in message

news:C06E10DC-D4CD-4BB9-AAEA-6F6FE0AA62CF@microsoft.com...

>I have an 8 port serial communications card in a WindowsNT system

installed as COM3, COM4, ... COM10. I can use any of the eight ports using

the WindowsNT hyperterminal utility.

>

>I am using Visual C++ 6.0 with MFC and attempting to open different

ports

with the following statement:

>

>m_commhandle = CreateFile((LPCTSTR)m_port, GENERIC_READ|GENERIC_WRITE,0,

NULL, OPEN_EXISTING, 0,NULL);

>

>This statement works for all of the ports EXCEPT COM10. GetLastError()

returns a 2 (ERROR_FILE_NOT_FOUND). In DEBUG, m_port contains "COM10", but

the CreateFile(...) still fails. Hyperterminal is not running when I a

making these tests, but when I am not debugging my code, and hyperterminal

is loaded, it has no problem opening and communicating over COM10, too!

>

>Is this a BUG in VC++C6.0?

>

>



TLNA,



The string should be "COM10:" not "COM10".









-

Re:BUG in VC++6.0???: Multi-Port Serial Communications Card Problem

Hi,

MSDN says in article Q115831 how to specify COM ports larger than 10.



Use this format in your CreateFile:

CreateFile("\\\\.\\COM10",fdwAccess...

This also works for COM ports 0 to 9.



HTH,

Wolfgang



"TLNA" <anonymous@discussions.microsoft.com>schrieb im Newsbeitrag

Quote
"COM10:" fails with a GetLastError() of 123 (ERROR_INVALID_NAME)

"COM10" still fails with a GetLastError() of 2 (ERROR_FILE_NOT_FOUND)



For reference:

"COM6" succeeds in opening and running properly

"COM6:" also succeeds in opening and running properly





-

Re:BUG in VC++6.0???: Multi-Port Serial Communications Card Problem

Julian,

Your suggestion works! Fantastic

Thank you very much

Tom

-

Re:BUG in VC++6.0???: Multi-Port Serial Communications Card Problem

Wolfgang

Thank you for the information. It solved my problem! Also, thank you for the MSDN article number

Regards

Tom

-