ts-7000
[Top] [All Lists]

[ts-7000] Problem in COM2 programming

To:
Subject: [ts-7000] Problem in COM2 programming
From: "qabid" <>
Date: Mon, 07 Sep 2009 07:16:26 -0000
dear all,
I am working on TS-7300 board and want to test COM2 in loop backback mode. I 
connected pin 2 and 3 of COM2 and tested it with the following piece of code.
--
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 
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\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);

    }
--
I received the following output.
Bytes written -1
Result is n = 1 char =
�*

It looks that write to the port fails. Can anybody help me out?

Saleem




------------------------------------

Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
    
    

<*> 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>
  • [ts-7000] Problem in COM2 programming, qabid <=
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