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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [hwtests/] [serial/] [pc2fpga/] [send.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 47... Line 45...
  }
  }
  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 94... Line 92...
  return n == 1;
  return n == 1;
}
}
 
 
 
 
int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
 
  char *serialPort;
  unsigned char curr;
  unsigned char curr;
  int count;
  int count;
 
 
  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);
  curr = 0;
  curr = 0;
  count = 0;
  count = 0;
  while (count < 100000) {
  while (count < 100000) {
    while (!serialSnd(curr)) ;
    while (!serialSnd(curr)) ;
    curr = (curr + 1) & 0xFF;
    curr = (curr + 1) & 0xFF;

powered by: WebSVN 2.1.0

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