Hi to all! I'm trying to communicate Windows and Palm OS applications using
serial manager.
I'm using the following code on the PC side:
HANDLE hComm = CreateFile(_T("COM1"), GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, NULL);
if (hComm == INVALID_HANDLE_VALUE)
{
cout << _T("Error: cannot connect to the COM port\n");
return;
}
COMMTIMEOUTS ct;
ct.ReadIntervalTimeout = 1000;
ct.ReadTotalTimeoutMultiplier = 1000;
ct.ReadTotalTimeoutConstant = 0;
ct.WriteTotalTimeoutMultiplier = 0;
ct.WriteTotalTimeoutConstant = 0;
SetCommTimeouts(hComm, &ct);
DCB dcb;
ZeroMemory(&dcb, sizeof(dcb));
dcb.DCBlength = sizeof(dcb);
dcb.BaudRate = CBR_9600;
dcb.fBinary = TRUE;
dcb.ByteSize = 8;
dcb.StopBits = ONESTOPBIT;
SetCommState(hComm, &dcb);
TCHAR szBuffer[1024];
DWORD dwNumBytes;
const int nPacketSize = 10;
if (ReadFile(hComm, szBuffer, nPacketSize, &dwNumBytes, NULL))
{
szBuffer[dwNumBytes] = _T('\0');
cout << _T("Success: ") << szBuffer << endl;
}
else
{
cout << _T("Error: cannot read data\n");
}
Here the code on the Palm side:
SrmOpen(0x8000, 9600, & wPortID);
DWord dwFlags = serSettingsFlagBitsPerChar8 | serSettingsFlagStopBits1;
Word wValueSize = sizeof(DWord);
SrmControl(wPortID, srmCtlSetFlags, &dwFlags, &wValueSize);
const Char szMessage[] = "9876543210";
DWord dwNumBytes = StrLen(szMessage);
SrmSend(wPortID, (void*)szMessage, dwNumBytes, NULL);
I'm testing this code on the Palm OS Emulator (version is 3.0a7). The PC
side receives corrupted bytes.
Please help.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/