Connecting to COM port
-
Hi all, I want to write the data to COM Port using embeddedVC++ 4.0 .But nothing comes on COM port, code is as follows. If i debug the application it shows COM port is opened successfully,number of Bytes written is also correct Do i need to do some settings in emulator to make it connect to com port?? same code works fine in VC++6.0. //// wchar_t rightString[80]; wcscpy(rightString,_T("Hello")); DCB m_DCB; m_DCB.DCBlength = sizeof(m_DCB); m_DCB.BaudRate = 9600; m_DCB.ByteSize = 8; m_DCB.fBinary = TRUE; m_DCB.Parity = NOPARITY; m_DCB.StopBits = ONESTOPBIT; m_DCB.fParity = TRUE; m_DCB.fNull = FALSE; m_DCB.XonChar = 0x11; m_DCB.XoffChar = 0x13; m_DCB.XonLim = 80; m_DCB.XoffLim = 200; m_DCB.fAbortOnError = TRUE; m_DCB.fOutX = false; m_DCB.fInX = false; HANDLE m_hPort = CreateFile(_T("COM1:"), GENERIC_READ | GENERIC_WRITE, 0,NULL, OPEN_EXISTING, 0, NULL); SetCommState(m_hPort,&m_DCB); if(m_hPort == NULL) AfxMessageBox(_T("Can not open port")); else if(WriteFile(m_hPort, rightString, 10, &BytesWritten, NULL)) AfxMessageBox(_T("Successfully written")); CloseHandle(m_hPort); /// Thanks in Advance Tushar Mahajan
-
Hi all, I want to write the data to COM Port using embeddedVC++ 4.0 .But nothing comes on COM port, code is as follows. If i debug the application it shows COM port is opened successfully,number of Bytes written is also correct Do i need to do some settings in emulator to make it connect to com port?? same code works fine in VC++6.0. //// wchar_t rightString[80]; wcscpy(rightString,_T("Hello")); DCB m_DCB; m_DCB.DCBlength = sizeof(m_DCB); m_DCB.BaudRate = 9600; m_DCB.ByteSize = 8; m_DCB.fBinary = TRUE; m_DCB.Parity = NOPARITY; m_DCB.StopBits = ONESTOPBIT; m_DCB.fParity = TRUE; m_DCB.fNull = FALSE; m_DCB.XonChar = 0x11; m_DCB.XoffChar = 0x13; m_DCB.XonLim = 80; m_DCB.XoffLim = 200; m_DCB.fAbortOnError = TRUE; m_DCB.fOutX = false; m_DCB.fInX = false; HANDLE m_hPort = CreateFile(_T("COM1:"), GENERIC_READ | GENERIC_WRITE, 0,NULL, OPEN_EXISTING, 0, NULL); SetCommState(m_hPort,&m_DCB); if(m_hPort == NULL) AfxMessageBox(_T("Can not open port")); else if(WriteFile(m_hPort, rightString, 10, &BytesWritten, NULL)) AfxMessageBox(_T("Successfully written")); CloseHandle(m_hPort); /// Thanks in Advance Tushar Mahajan
HI My experience is that the emulators do not connect to the COM ports, you must test on a real device. Make sure you get a device that supports RS232 serial connections !! I found out the hard way that some do not ! Dell Axim X5 does and the HP IPAQ 4000 series and above should also. G. Weideman