ts-7000
[Top] [All Lists]

[ts-7000] TS7260-Reading from /dev/ttyUSB0

To:
Subject: [ts-7000] TS7260-Reading from /dev/ttyUSB0
From: "tsao.terence" <>
Date: Thu, 04 Mar 2010 08:44:03 -0000
Dear Linux masters,

     I am communicating TS7260 with my sensor device using a USB to serial FTDI 
converter.  The sensor uses the uart interface, and the TS7260 uses the USB 
interface.  The sensor device will send TS7260 a packet of data which contains 
512 bytes, aka each packet is 512 bytes.


I had success reading from ttyUSB0 with 9600 and 38400 baudrate, but when I 
jump to 57600 baud, the program just hangs.  I think there might be something 
wrong as I open the USB port, or my receive function has too much software 
overhead.  Anyone here had success reading from the ttyUSB0 port?

Here is my open USB function:
int openUSB()
{
    int fd = open ("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY | O_FSYNC);
    if (fd==-1)
    {
      fprintf(stderr, "open_port: Unable to open /dev/ttyUSB0 -%s \n",
               strerror(errno));
    }

    struct termios options;

    /*Configure port reading*/
    fcntl (fd, F_SETFL, FNDELAY);
    /*Get the current options for the port*/
    tcgetattr(fd, &options);

    /*Set baudrate to 500000Mb*/
    cfsetispeed(&options, B57600);
    cfsetospeed(&options, B57600);

    /*Mark the character size to 8 bits, no parity*/
    options.c_cflag     |= (CLOCAL | CREAD);
    options.c_lflag     &= ~(ICANON | ECHO | ECHOE | ISIG);
    options.c_oflag     &= ~OPOST;
    options.c_iflag     &= ~(IXON | ICRNL);
    options.c_cc[VMIN]  = 0;
    options.c_cc[VTIME] = 0;
    tcsetattr(fd, TCSANOW, &options);
    return fd;
}

Here is my read function:.
unsigned char receivePacket(int fd, unsigned char *buffer)
{

    unsigned int i=0;
    unsigned int left_to_read=520;
    unsigned char byte;
    while(left_to_read>0)
    {
     unsigned char temp = read(fd, &byte, 1);
     if(temp>0)
     {
      left_to_read--;
      buffer[i]=byte;
      printf("%.2x",byte);
      i++;
     }
    }
    return 0;
}



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

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>
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