Guest_imported
New member
- Jan 1, 1970
- 0
Who could let me know which are the right command to communicate using a serial port???
Thanks a lottttt
Thanks a lottttt
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
std::ofstream OFile; // stream set up
//OFile.open("Label.dat"); // For Testing
//OFile.open("LPT1:"); // LPT port
OFile.open("COM1:"); // COM 1 port
DCB dcb;
HANDLE hCom;
DWORD dwError;
BOOL fSuccess;
hCom = CreateFile("COM1",
GENERIC_READ | GENERIC_WRITE,
0, /* comm devices must be opened w/exclusive-access */
NULL, /* no security attrs */
OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */
0, /* not overlapped I/O */
NULL /* hTemplate must be NULL for comm devices */
);
if (hCom == INVALID_HANDLE_VALUE) {
dwError = GetLastError();
/* handle error */
}
/*
* Omit the call to SetupComm to use the default queue sizes.
* Get the current configuration.
*/
fSuccess = GetCommState(hCom, &dcb);
if (!fSuccess) {
/* Handle the error. *
}
/* Fill in the DCB: baud=9600, 8 data bits, no parity, 1 stop bit. */
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
fSuccess = SetCommState(hCom, &dcb);
if (!fSuccess) {
/* Handle the error. *
}