Сам же и отвечу.
Реализовал работу с COM портом с помощью стандартных API Windows.
HANDLE hComm;
LPTSTR lpszPortName = TEXT("COM1:");
hComm = CreateFile( lpszPortName,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
0);
if (INVALID_HANDLE_VALUE == hComm)
{
printf("Unable to open the port");
return FALSE;
}
DCB PortDCB;
PortDCB.DCBlength = sizeof(DCB);
GetCommState(hComm, &PortDCB);
PortDCB.BaudRate = 115200;
if (FALSE == SetCommState(hComm, &PortDCB))
{
printf("\n\nUnable to configure the serial port\n\n");
return FALSE;
}
char * LlpBuffer = new char[6];
LlpBuffer[0] = 'A';
LlpBuffer[1] = 'T';
LlpBuffer[2] = 'I';
LlpBuffer[3] = 0x0d;
LlpBuffer[4] = 0x0a;
LlpBuffer[5] = 0x00;
DWORD lpNumberOfBytesWritten;
WriteFile(
hComm,
LlpBuffer,
4,
&lpNumberOfBytesWritten,
NULL);
printf("\nSent %ld bytes\n -> %s\n\n", lpNumberOfBytesWritten, LlpBuffer);
DWORD lpNumberOfBytesRead;
char* lpBuffer = new char[50];
Sleep(2000);
ReadFile(
hComm,
lpBuffer,
50,
&lpNumberOfBytesRead,
NULL);