fd_ttyS0 = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY);tcgetattr(fd_ttyS0, &options);cfsetispeed(&options, B19200);options.c_cflag |= (CLOCAL | CREAD | PARENB);tcsetattr(fd_ttyS0, TCSAFLUSH, &options);fcntl(fd_ttyS0, F_SETFL, FNDELAY);...read(fd_ttyS0, &buff[0], sizerequest);
read(fd_ttyS0, NULL, sizerequest);
port = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); SetupComm (port, 2048, 2048); GetCommState (port, &dcb); dcb.ByteSize = 8; dcb.Parity = EVENPARITY; dcb.BaudRate = CBR_19200; dcb.StopBits = ONESTOPBIT; SetCommState (port, &dcb); GetCommTimeouts (port, &time); time.ReadTotalTimeoutConstant = 0; SetCommTimeouts (port, &time); while (true) { WriteFile(port, &data[0], 8, &RetDat, NULL); }
fd_ttyS0 = open("/dev/ttyS0", O_RDWR| O_NOCTTY | O_NDELAY); tcgetattr(fd_ttyS0, &options); cfsetispeed(&options, B19200); cfsetospeed(&options, B19200); options.c_cflag |= (CLOCAL | CREAD | CS8 | PARENB); options.c_lflag &= ~(ICANON | ECHO | ECHOE); options.c_oflag &= ~(OPOST); options.c_iflag &= ~(INLCR | IGNCR | ICRNL); tcsetattr(fd_ttyS0, TCSAFLUSH, &options); fcntl(fd_ttyS0, F_SETFL, FNDELAY); ... timeout.tv_sec = 3; timeout.tv_usec = 100; memset(&buff[0], 0, SizeBuf); FD_SET(fd_ttyS0, &readfs); select(fd_ttyS0, &readfs, NULL, NULL, &timeout); read(fd_ttyS0, &buff[0], SizeBuf);