# SVN changeset patch # User rrojas # Date 2012-11-12 13:24:01.189333 # Revision 9 Index: trunk/magroot/source/magc/test/TestSerial_tx.c =================================================================== diff --git a/trunk/magroot/source/magc/test/TestSerial_tx.c b/trunk/magroot/source/magc/test/TestSerial_tx.c deleted file mode 10644 --- a/trunk/magroot/source/magc/test/TestSerial_tx.c (revision 8) +++ /dev/null (revision 9) @@ -1,75 +0,0 @@ -/* Codigo de prueba para test de puerto serial - utiliza el dispositivo "/dev/ttyS1" - - Creado por: Ricardo V. Rojas - Fecha : Setpiembre 2012 -*/ -#include /* Standard input/output definitions */ -#include /* String function definitions */ -#include /* UNIX standard function definitions */ -#include /* File control definitions */ -#include /* Error number definitions */ -#include /* POSIX terminal control definitions */ - -#define device "/dev/ttyS1" - -//Funcion principal: -int main(void){ - - //Variables a usar: - - //------------------------------ - //Puerto serial: - int ID; - struct termios oldtio,newtio; - //------------------------------ - //Codigo de prueba - static char bufferserial[100]; - int num_byte; - //------------------------------ - - //------------------------------------------ - // Configuracion del puerto seria - ID = open(device,O_RDWR | O_NOCTTY | O_NDELAY); - if (ID < 0){ - perror("Can not open device.\n"); - return -1; - } - fcntl(ID,F_SETFL,0); - //----- - tcgetattr(ID,&oldtio); /*Salvamos configuracion actual del puerto*/ - //Configuratio serial port: "115200,8,N,1" - bzero(&newtio,sizeof(newtio)); /*Limpiamos struct para recibir los nuevos parametros del puerto.*/ - cfsetispeed(&newtio, B115200); - cfsetospeed(&newtio, B115200); - newtio.c_cflag |= (CREAD | CLOCAL); - newtio.c_cflag &= ~PARENB; /*None bit parity*/ - newtio.c_cflag &= ~CSTOPB; /* 1 bit STOP */ - newtio.c_cflag &= ~CSIZE; /* Mask the character size bits */ - newtio.c_cflag |= CS8; /* Select 8 data bits */ - newtio.c_cflag &= ~CRTSCTS; /*Disable flow control*/ - - newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /*Mode Raw input*/ - newtio.c_iflag |= IGNPAR; /*Ignorar bytes con error de paridad*/ - newtio.c_iflag &= ~INPCK; /* deshabiliar check de bit de paridad*/ - newtio.c_iflag &= ~(IXON | IXOFF | IXANY); /*Disable Xon and Xoff*/ - - - newtio.c_oflag &= ~OPOST; /* output in raw mode */ - - newtio.c_cc[VTIME] = 0; - newtio.c_cc[VMIN] = 1; - - tcsetattr(ID,TCSANOW, &newtio); - - printf("-Inicio-\n"); - num_byte = write(ID,"0123456789",10); - num_byte = write(ID,"Ricardo",7); - - printf("byte enviados: %d %n",num_byte); - printf("-Fin-\n"); - - tcsetattr(ID,TCSANOW, &oldtio); - close(ID); - return 0; -}