Reception with serial port ttyS0

Bas Wijnen wijnen at debian.org
Thu Apr 22 15:41:57 EDT 2010


Hi,

The NanoNote connects the reception of ttyS0 to the same pin that is
used for some keys on the keyboard.  To make those keys work, the
reception is by default disabled.  You can enable it by holding the S
key during power up (so press S and power together to switch on).

Thanks,
Bas

On Thu, Apr 22, 2010 at 01:26:00PM -0500, Jose Luis Cabra Lopez wrote:
> Hi everybody.
> 
> Well, now I'm working with my nanonote with the serial port. I have 2
> programs, the first is for send bytes to my computer (PC) obviously through
> its serial port, this program work perfectly, I run this program in my
> nanonote and works perfectly.
> 
> Actually, my problem is with the reception, when I want to receive
> information through the serial port of my nanonote I don't know what happen.
> I send bytes from my PC to nano and it don't work.
> 
> Attach is my source code of my work for reception.
> 
> Pdt: When I send byte from nano to PC, the program works. But agains it
> don't work.
> 
> Some suggestions?
> Thanks a lot.
> 
> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
> 
> // Librerias
> #include  <sys/types.h>
> #include  <sys/stat.h>
> #include  <fcntl.h>
> #include  <termios.h>
> #include  <stdio.h>
> #include  <stdlib.h> // Ayuda a los exit
> #include  <sys/ioctl.h>
> #include  <string.h> // Para que sira bzero
> 
> // Define generales de configuración
> #define  BAUDRATE B9600
> #define  MODEMDEVICE "/dev/ttyS0"
> #define  _POSIX_SOURCE 1 /* POSIX compliant source */
> #define  FALSE 0
> #define  TRUE 1
> volatile int STOP=FALSE;
> 
> // Programa Principal
> int main()
> {
>   int fd, c, res;
>   struct termios oldtio,newtio;
>   char buf[255];
> // Abriendo el puerto serial con file descriptor
>   fd = open(MODEMDEVICE, O_RDONLY | O_NOCTTY);
>   if (fd <0) {perror(MODEMDEVICE); exit(1); }
> // Configuración del puerto
>   tcgetattr(fd,&oldtio); /* save current port settings */
>   bzero(&newtio, sizeof(newtio));
>   newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
>   newtio.c_iflag = IGNPAR;
>   newtio.c_oflag = 0;
>   /* set input mode (non-canonical, no echo,...) */
>   newtio.c_lflag = 0;
>   newtio.c_cc[VTIME]     = 0;   /* inter-character timer unused */
>   newtio.c_cc[VMIN]      = 5;   /* blocking read until 5 chars received */
>   tcflush(fd, TCIFLUSH);
>   tcsetattr(fd,TCSANOW,&newtio);
> // ciclo de recepción.
>   while (STOP==FALSE) {       /* loop for input */
>     res = read(fd,buf,255);   /* returns after 5 chars have been input */
>     buf[res]=0;               /* so we can printf... */
>     printf(":%s:%d\n", buf, res);
>     if (buf[0]=='z') STOP=TRUE;
>   }
>   tcsetattr(fd,TCSANOW,&oldtio);
> }
> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

> _______________________________________________
> Qi Developer Mailing List
> Mail to list (members only): developer at lists.qi-hardware.com
> Subscribe or Unsubscribe: http://en.qi-hardware.com/mailman/listinfo/developer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.en.qi-hardware.com/pipermail/discussion/attachments/20100422/af77400a/attachment.pgp>


More information about the discussion mailing list


interactive