Feb 13, 2002 #1 qweas Programmer Feb 12, 2002 42 GB Is it possible to read information from ports to C++ and if so how can this be done, please give a step by step guide. Thank you
Is it possible to read information from ports to C++ and if so how can this be done, please give a step by step guide. Thank you
Feb 13, 2002 #2 Jeffray Programmer Jan 29, 2002 144 CA #include <conio.h> HANDLE hCOM=CreateFile("COM1",GENERIC_READ ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); if (hCOM!=INVALID_HANDLE_VALUE){ dcb.DCBlength = sizeof ( DCB ) ; dcb.BaudRate = 9600 ; dcb.fBinary = TRUE ; dcb.fParity = 0; dcb.fOutxCtsFlow = 0; // CTS output flow control dcb.fOutxDsrFlow = 0; // DSR output flow control dcb.fDtrControl = 1; // DTR flow control type dcb.fDsrSensitivity = 0; // DSR sensitivity dcb.fTXContinueOnXoff = 0; // XOFF continues Tx dcb.fOutX = 1; // XON/XOFF output flow control dcb.fInX = 1; // XON/XOFF input flow control dcb.fErrorChar = 0; // enable error replacement dcb.fNull = 0; // enable null stripping dcb.fRtsControl = 1; // RTS flow control dcb.fAbortOnError = 0; // abort reads/writes on error dcb.XonLim = 2048; // transmit XON threshold dcb.XoffLim = 512; // transmit XOFF threshold dcb.ByteSize = 8; // number of bits/byte, 4-8 dcb.Parity = NOPARITY; // 0-4=no,odd,even,mark,space dcb.StopBits = ONESTOPBIT; // 0,1,2 = 1, 1.5, 2 dcb.XonChar = 17; // Tx and Rx XON character dcb.XoffChar = 19; // Tx and Rx XOFF character dcb.ErrorChar = 0; // error replacement character dcb.EofChar = 0; // end of input character dcb.EvtChar = 0; // received event character SetCommState(hCOM, &dcb)); char buffer[30]; DWORD nb; OVERLAPPED ov; ReadFile(hCOM,buffer,sizeof(buffer),&nb,&ov); CloseHandle(hCOM); } Upvote 0 Downvote
#include <conio.h> HANDLE hCOM=CreateFile("COM1",GENERIC_READ ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); if (hCOM!=INVALID_HANDLE_VALUE){ dcb.DCBlength = sizeof ( DCB ) ; dcb.BaudRate = 9600 ; dcb.fBinary = TRUE ; dcb.fParity = 0; dcb.fOutxCtsFlow = 0; // CTS output flow control dcb.fOutxDsrFlow = 0; // DSR output flow control dcb.fDtrControl = 1; // DTR flow control type dcb.fDsrSensitivity = 0; // DSR sensitivity dcb.fTXContinueOnXoff = 0; // XOFF continues Tx dcb.fOutX = 1; // XON/XOFF output flow control dcb.fInX = 1; // XON/XOFF input flow control dcb.fErrorChar = 0; // enable error replacement dcb.fNull = 0; // enable null stripping dcb.fRtsControl = 1; // RTS flow control dcb.fAbortOnError = 0; // abort reads/writes on error dcb.XonLim = 2048; // transmit XON threshold dcb.XoffLim = 512; // transmit XOFF threshold dcb.ByteSize = 8; // number of bits/byte, 4-8 dcb.Parity = NOPARITY; // 0-4=no,odd,even,mark,space dcb.StopBits = ONESTOPBIT; // 0,1,2 = 1, 1.5, 2 dcb.XonChar = 17; // Tx and Rx XON character dcb.XoffChar = 19; // Tx and Rx XOFF character dcb.ErrorChar = 0; // error replacement character dcb.EofChar = 0; // end of input character dcb.EvtChar = 0; // received event character SetCommState(hCOM, &dcb)); char buffer[30]; DWORD nb; OVERLAPPED ov; ReadFile(hCOM,buffer,sizeof(buffer),&nb,&ov); CloseHandle(hCOM); }
Feb 14, 2002 #3 Foada Programmer Feb 4, 2002 1,110 US See thread222-210585, thread222-211360, or thread222-212155 Anything is possible, the problem is I only have one lifetime. Upvote 0 Downvote
See thread222-210585, thread222-211360, or thread222-212155 Anything is possible, the problem is I only have one lifetime.