Home/Support/Support Forum/Problems with serial ports
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Problems with serial ports

0 votes
Hello. My problem is that when I try to read the serial port I don't receive any data from my PC. I configured the ports, as seen in the attached file. And the error that I get with perror's function in read is "Resource temporally unavailable". Besides, I've noticed that when I run the program (attached file) the configuration that I have made him to serial ports is not done, because I'm connected via ssh to the IP of ConectCore 9c and I do an instruction of the system to know the configuration of the port and I get different speed, input, etc

Attached file:
Note:I have also tested with FD_ZERO, FD_SET, and the function "select"
int main(void)
{
int fd,nbytes;
char buf[255];
struct termios options;

fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
fcntl(fd, F_SETFL, 0);

tcgetattr(fd, &options);

cfsetispeed(&options, B115200);
cfsetospeed(&options, B115200);

options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~PARENB
options.c_cflag &= ~CSTOPB
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;

options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);

options.c_oflag &= ~OPOST;

tcsetattr(fd, TCSANOW, &options);

nbytes = read(fd, buf,255);

return 1;
}

Thank you very much. I await your response.
asked Feb 1, 2010 in Linux by anagil New to the Community (2 points)
recategorized Dec 3, 2013 by tuxembb

Please log in or register to answer this question.

...