Click to See Complete Forum and Search --> : USB - RS232 and Embedded VC++
jhreich
July 8th, 2002, 09:28 AM
Hello all,
I just got started on an application to use a PDA (Palm or another
handheld device) as a remote control for a hardware tool that is micro-proocessor controlled and that allows serial communication with a standard RS232 interface. I need some tips to get started.
I know my first steps are to get:
1. Serial Communication protocol for the hardware tool
2. Embedded Visual Tools installed
If someone can post any tips or links or samples, I would really
appreicate it.
thanks, J.
undiwahn
July 10th, 2002, 03:43 PM
It depends on what platform you're programming from -- Palm and PocketPC, for instance, tackle RS232 differently -- although I believe both treat it as opening a file on the standard filesystem, though.
Can you give us any more details on what exactly you need?
jhreich
July 11th, 2002, 04:01 PM
thanks undiwahn for your reply.
For now, I will be using PocketPC as the deployment platform.
thanks, Jamil
undiwahn
July 11th, 2002, 04:29 PM
Then yes, you treat reading from the COM port as reading from a file -- but you must set up the COM port first. So:
m_hCommPort = CreateFile (m_ucInterface, // Port Name (Unicode compatible)
GENERIC_READ | GENERIC_WRITE, // Open for Read-Write
0, // COM port cannot be shared
NULL, // Always NULL for Windows CE
OPEN_EXISTING, // For communication resource
0, // Non-overlapped operation only
NULL); // Always NULL for Windows CE
COMMTIMEOUTS ct;
ct.ReadIntervalTimeout = 100;
ct.ReadTotalTimeoutMultiplier = 10;
ct.ReadTotalTimeoutConstant = 10;
ct.WriteTotalTimeoutMultiplier = 10;
ct.WriteTotalTimeoutConstant = 1000;
if(!SetCommTimeouts(m_hCommPort, &ct))
{
MessageBox(NULL,(_T("Setting comm. timeouts.")), (_T("Error")), MB_OK);
return 3;
}
DCB dcb;
dcb.DCBlength = sizeof(DCB);
if(!GetCommState(m_hCommPort, &dcb))
{
MessageBox(NULL,(_T("Getting Comms. State.")), (_T("Error")), MB_OK);
return 4;
}
dcb.BaudRate = m_iBaudRate; // set baud rate to what we want
dcb.fOutxCtsFlow = TRUE;
dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
dcb.fDtrControl = DTR_CONTROL_ENABLE;
dcb.fOutxDsrFlow = FALSE;
dcb.fOutX = FALSE; // no XON/XOFF control
dcb.fInX = FALSE;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
if(!SetCommState(m_hCommPort, &dcb))
{
MessageBox(NULL,(_T("Setting Comms. State.")), (_T("Error")), MB_OK);
return 5;
}
jhreich
July 12th, 2002, 09:55 AM
Do I have to use Win32 on Windows CE?
Does the MS Comm control work with EVC?
undiwahn
July 12th, 2002, 10:30 AM
Yeah, you have to use Win32 API calls (Or a wrapper thereof). As for the MS Comm control, I've used it (fairly successfully) in EVB, but not tried it in EVC.
jhreich
July 24th, 2002, 04:40 PM
I am writing EVC code to allows serial communication between
a PDA (Palm) and a serial device. I haven't got the PDA yet but
I need to test my code using the emulator.
Would the Palm emulator know about my PC serial ports?
I am using the MSCEComm ActiveX control and the call
SetPortOpen(TRUE) on the C++ wrapper class is coming back
with 'Port Not Available' error.
Any ideas are greatly appreciated.
thanks, Jamil
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.