E ai gente!
Estou perguntando à lista porque nenhuma outra deu resposta. Peguei todo tipo de documento sobre comunicação serial em linguagem C, mas até agora não funcionou. Os dados não são recebidos pelo outro micro, mas com echo msg > /dev/ttyS1 e cat /dev/ttyS1 funciona perfeitamente. Onde estou errando, onde encontrar exemplos que funcionem? O codigo logo abaixo que estou rodando com modificações: #include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <termios.h> int abre_porta (void) { int fd; /* Descricao de arquivo pra porta */ fd = open ("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) perror ("abre_porta: Não pôde abrir porta - "); else fcntl (fd, F_SETFL, 0); return (fd); } int main (int argc, char **argv) { int fd = abre_porta (); struct termios options, old; char buf; tcgetattr (fd, &old); /* Obtendo opções */ tcgetattr (fd, &options); /* Obtendo opções */ cfsetispeed(&options, B115200); /* Mudando velocidade */ cfsetospeed(&options, B115200); options.c_cflag |= (/*CLOCAL |*/ CREAD); options.c_cflag &= ~CSIZE; /* Mask the character size bits */ options.c_cflag |= CS8; /* Select 8 data bits */ options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); tcsetattr(fd, TCSANOW, &options); /* Ativa mudanças */ /* Loop principal while (buf != EOF)*/ { /*buf = getchar();*/ if (write (fd, "Teste.\r", 7) < 7) fputs ("Nao enviou nada!", stdout); } /* Loop principal */ fcntl (fd, F_SETFL, 0); tcsetattr(fd, TCSANOW, &old); /* Ativa mudanças */ close (fd); }