ts-7000
[Top] [All Lists]

[ts-7000] Serial port configuration problem TS-7250

To:
Subject: [ts-7000] Serial port configuration problem TS-7250
From: "Tony Williams" <>
Date: Fri, 16 Jun 2006 17:56:45 -0000
I wish to use the com2 port on the TS-7250 to communicate with a 
linear scale at 115200 buad 8-N-1.

I commented out the line in inittab for console port on ttyAM1.

The program listing below works fine for baud rates 9600,19200 and 
38400. However it fails for baud rates 57600 and 115200.

I connected an led up to the transmit pin and at 38400 buad and 128 
bytes of tramitted data the transmit time is less than 1 second. 
(maybe around a quarter second). However when I change 

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

to use the 57600 buad rate the transmit time goes to 3 seconds and at 
115200 buad rate the transmit time goes to 6 seconds.

Any help will be greatly appreciated.  Full program listed below.

Tony

#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <asm/ioctls.h>

int main(void)
{
// Open serial port ttyAM1 Serial Port
// 
int fd,n,i;
struct termios options;
char buf[255],*bufptr;

fd =  open ("/dev/ttyAM1", O_RDWR | O_NOCTTY | O_NONBLOCK | O_NDELAY);
  if (fd == -1) 
    {
      perror ("Open port /dev/ttyAM1 failure\n");
      exit (-1);
    }
 tcgetattr(fd,&options); 
 /* Set Baud rate to 115200 
*******************************************/
 cfsetispeed(&options, B57600);
 cfsetospeed(&options, B57600);
 /* Set Parity to 8-N-1 
***********************************************/
 options.c_cflag &= ~PARENB;
 options.c_cflag &= ~CSTOPB;
 options.c_cflag &= ~CSIZE;
 options.c_cflag |= CS8;
 /* Enable the receiver and set local mode 
****************************/
 options.c_cflag |= ( CLOCAL | CREAD);
 /* Set Flow control to none 
******************************************/
 options.c_cflag &= ~(IXON | IXOFF | IXANY);
 /* Set read to raw input 
*********************************************/
 //options.c_lflag &= (ICANON | ECHO | ECHOE | ISIG);
 /* Set Raw Output
 options.c_oflag &= ~OPOST;
 /* Write options 
*****************************************************/
 tcsetattr(fd,TCSANOW,&options);

 n = write(fd,"Hello World Hello World Hello World 
XXXXXXXXXXXXXXXXXXX 
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
ZZ\r\n",128);
 printf("Bytes written %i\n",n);

 /* Read input until CR or NL or Buffer full 
**************************/
i = 1;
buf[0] = 0;
 while (i == 1)
        {
        n = read(fd,buf,255);
        //printf("buf = %s n = %i\n",buf,n);
        if (n > 0)
                break;
        }

 printf("Result is n = %i char = %s\n",n,buf);
 close(fd);
  
}











------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Groups gets a make over. See the new email design.
http://us.click.yahoo.com/XISQkA/lOaOAA/yQLSAA/CFFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU