OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [hwtests/] [serial/] [sertest/] [sertest.c] - Diff between revs 14 and 132

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 14 Rev 132
Line 10... Line 10...
#include <fcntl.h>
#include <fcntl.h>
#include <unistd.h>
#include <unistd.h>
#include <termios.h>
#include <termios.h>
 
 
 
 
#define SERIAL_PORT     "/dev/ttyS0"
 
 
 
#define NUM_TRIES       10
#define NUM_TRIES       10
 
 
#define SYN             0x16
#define SYN             0x16
#define ACK             0x06
#define ACK             0x06
 
 
Line 48... Line 46...
  }
  }
  exit(1);
  exit(1);
}
}
 
 
 
 
void serialOpen(void) {
void serialOpen(char *serialPort) {
  sfd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
  sfd = open(serialPort, O_RDWR | O_NOCTTY | O_NDELAY);
  if (sfd == -1) {
  if (sfd == -1) {
    error("cannot open serial port '%s'", SERIAL_PORT);
    error("cannot open serial port '%s'", serialPort);
  }
  }
  tcgetattr(sfd, &origOptions);
  tcgetattr(sfd, &origOptions);
  currOptions = origOptions;
  currOptions = origOptions;
  cfsetispeed(&currOptions, B38400);
  cfsetispeed(&currOptions, B38400);
  cfsetospeed(&currOptions, B38400);
  cfsetospeed(&currOptions, B38400);
Line 125... Line 123...
  }
  }
}
}
 
 
 
 
int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
 
  char *serialPort;
  int i;
  int i;
 
 
  if (argc != 1) {
  if (argc != 2) {
    printf("Usage: %s\n", argv[0]);
    printf("Usage: %s <serial port>\n", argv[0]);
    exit(1);
    exit(1);
  }
  }
  serialOpen();
  serialPort = argv[1];
 
  serialOpen(serialPort);
  errors = 0;
  errors = 0;
  for (i = 1; i <= 100; i++) {
  for (i = 1; i <= 100; i++) {
    block();
    block();
    if (i % 10 == 0) {
    if (i % 10 == 0) {
      printf("%d bytes, errors = %d\n", i * 1000, errors);
      printf("%d bytes, errors = %d\n", i * 1000, errors);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.