serial port communication!
Which OS? Under WIndows you would use CreateFile for opening the port and WriteFile/ReadFile for sending and receiving data.
Otherwise you would use the standard file functions like _open, _read and _write.
HTH,
Pat.
Otherwise you would use the standard file functions like _open, _read and _write.
HTH,
Pat.
It is simple, working example, but read little more about COM, sometimes it is rather strange device :)
Lekha
DCB dcb;COMMTIMEOUTS ct;HANDLE port;dcb.DCBlength = sizeof( DCB );BuildCommDCB( "baud=9600 parity=N data=8 stop=1", &dcb );dcb.fNull = TRUE;dcb.fOutxCtsFlow = 0; // No CTS output flow controldcb.fOutxDsrFlow = 0; // No DSR output flow controlct.ReadIntervalTimeout = 10; // Timeout between 2 bytesct.ReadTotalTimeoutMultiplier = ct.ReadTotalTimeoutConstant = 0;ct.WriteTotalTimeoutMultiplier = ct.WriteTotalTimeoutConstant = 0;port = CreateFile( "COM1", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );SetCommState( port, &dcb );SetCommTimeouts( port, &ct );WriteFile( port, "XEP", 3, &bc, NULL );ReadFile( port, buffer, 1, &bc, NULL ); // Eat ACKCloseHandle( port );
Lekha
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement