[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Serial port ttys0 and ttys2




I made a new c program (See the file attached).

If you send a file about 1Mbytes on the ttyS0 with minicom program, the 
number of byte receive is correct (And, simultaneously you can send a 
file by ftp, make a connection by Telnet or browse the boa Http server ...).

If you send a file about 1Mbytes on the ttyS2 with minicom program, the 
number of byte receive is not correct (I have only one Telnet connection 
to the axis board ! / I don't use Ftp or Http in the same time).

I think there is a problem with the ttyS2 !

I comment the line agetty on /dev/console in the inittab file,

The .config file is like this :

CONFIG_ETRAX_DEBUG_PORT_NULL=y
CONFIG_ETRAX_RESCUE_SER0=y
...
CONFIG_ETRAX_SERIAL=y
# CONFIG_ETRAX_SERIAL_FAST_TIMER is not set
CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST=y
CONFIG_ETRAX_SERIAL_PORT0=y
# CONFIG_ETRAX_SER0_DTR_RI_DSR_CD_ON_PB is not set
# CONFIG_ETRAX_SERIAL_PORT1 is not set
CONFIG_ETRAX_SERIAL_PORT2=y
# CONFIG_ETRAX_SER2_DTR_RI_DSR_CD_ON_PA is not set
# CONFIG_ETRAX_SERIAL_PORT3 is not set
# CONFIG_ETRAX_RS485 is not set
# CONFIG_ETRAX_SYNCHRONOUS_SERIAL is not set
# CONFIG_ETRAX_PARPORT is not set
...

Jonas Holmberg a écrit:
> On Thu, Aug 12, 2004 at 02:43:37PM +0200, Frossard Philippe wrote:
> 
>>We made a program for checking the serial port. The program store 
>>received data in a file (in the /tmp directory). The program run at 
>>115200 bauds and it run very well on the ttys0.
>>
>>But, with the same program we have a problem on the ttys2. The received 
>>data are not complet (The program lost some data).
>>
>>We have a .config file like this (Axis Developer Board LX) :
>>
>>I don't know what to do with CONFIG_ETRAX_RESCUE_SER2=y
> 
> 
> Turn it off. That feature (serial port rescue upload of firmware) 
> wasn't ever used, I think.
> 
> 
>>And, I made a link /dev/console -> /dev/null
> 
> 
> Also check that you don't start agetty on /dev/ttyS2. IIRC it was 
> started in /etc/inittab on older devboard_lx releases. Just comment 
> that line out or remove it completely (in case you have it).
> 
> /Jonas
> 

-- 
Philippe Frossard
/****************************************************************************/
/*
 * Comm.c : Communication process
 *
 * To do :
 *
 * V1.00 02/02/2004 PF Initial version
 *
 */
/****************************************************************************/

/********** C Includes ******************************************************/

#include <signal.h>                                   /* Signal definitions */
#include <sys/types.h>                              /* Defined system types */
#include <sys/stat.h>                /* File stat structure and definitions */
#include <stdio.h>                     /* Standard input/output definitions */
#include <string.h>                          /* String function definitions */
#include <unistd.h>                   /* UNIX standard function definitions */
#include <stdlib.h>                           /* Standard library functions */
#include <time.h>                                        /* Times functions */
#include <ctype.h>                                                       /* */
#include <errno.h>                              /* Error number definitions */
#include <termios.h>                  /* POSIX terminal control definitions */
#include <fcntl.h>                              /* File control definitions */

/*** Constant definitions ***************************************************/

#define MAX_READ_BUFFER              8192
#define MAX_WRITE_BUFFER             8192
#define MESSAGE_AT_STARTUP           "Begin of process (Comm) ...\n"
#define MESSAGE_AT_SHUTDOWN          "End of process (Comm) ...\n"

/*** Logical definitions ****************************************************/

#define TRUE                                        1
#define FALSE                                       0

/*** Type definitions *******************************************************/

#define UCHAR unsigned char
#define UINT  unsigned int

/*** Function prototypes ****************************************************/

int main (void);                                            /* Main program */

/****************************************************************************/
//
// main    - Main program
// Params  : None
// Returns : Nothing
//
/****************************************************************************/

int main (void)
{
  UCHAR ucEndFlag;
  int iFileDescriptor;
  struct termios tConf;
  UCHAR ucReadBuffer[MAX_READ_BUFFER];
  int iRead;
  UINT i;
  UINT counter;

  /* Initialise */
  ucEndFlag = FALSE;
  counter = 0;
  /* Initialise */
  iRead = 0;
  /* Display message */
  printf(MESSAGE_AT_STARTUP);

  /* Open automate communication */
  if ((iFileDescriptor = open("/dev/ttyS2", O_RDWR | O_NOCTTY | O_NONBLOCK)) != -1)
  {
    /* Get the current options for the port */
    if (tcgetattr(iFileDescriptor, &tConf) != -1)
    {
      /* Enable the receiver and set local mode */
      tConf.c_cflag |= (CLOCAL | CREAD);
      /* Set 8N1 */
      tConf.c_cflag &= ~PARENB;
      tConf.c_cflag &= ~CSTOPB;
      tConf.c_cflag &= ~CSIZE;
      tConf.c_cflag |= CS8;
      /* Disable hardware flow control */
      tConf.c_cflag &= ~CRTSCTS;
      tConf.c_iflag &= ~IXON;
      tConf.c_iflag &= ~IXOFF;
      /* Select raw input/output */
      tConf.c_lflag &= ~(ICANON | ECHO | ISIG);
      tConf.c_oflag &= ~OPOST;
      /* Set speed */
      cfsetospeed(&tConf, B115200);
      cfsetispeed(&tConf, B115200);
      /* Set the new options for the port */
      tcsetattr(iFileDescriptor, TCSANOW, &tConf);
    }
    else
    {
      /* Initialise */
      ucEndFlag = TRUE;
    }
  }
  else
  {
    /* Initialise */
    ucEndFlag = TRUE;
  }

  /* Loop */
  do
  {
    /* Wait some times */
    usleep(5000);

    /* Read bytes from a file */
    if ((iRead = read(iFileDescriptor, ucReadBuffer, MAX_READ_BUFFER)) > 0)
    {
      /* For each element */
      for (i=0 ; i<iRead ; i++)
      {
        /* Tests for printing character */
	if (ucReadBuffer[i] == 'z')
	{
          /* Initialise */
          ucEndFlag = TRUE;
	}
        /* Initialise */
        counter++;
      }
    }

  } while (!ucEndFlag);

  /* Check file descriptor */
  if (iFileDescriptor != -1)
  {
    /* Close a file */
    close(iFileDescriptor);
  }

  /* Display message */
  printf(MESSAGE_AT_SHUTDOWN);
  printf("Counter : %d", counter);

  /* All done */
  exit(EXIT_SUCCESS);
}

/****************************************************************************/