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

Subversion Repositories logicprobe

[/] [logicprobe/] [trunk/] [src/] [pc/] [receive.c] - Diff between revs 10 and 11

Show entire file | Details | Blame | View Log

Rev 10 Rev 11
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"
 
 
 
 
 
static int debug = 0;
static int debug = 0;
 
 
static FILE *diskFile = NULL;
static FILE *diskFile = NULL;
static int sfd = 0;
static int sfd = 0;
static struct termios origOptions;
static struct termios origOptions;
Line 44... Line 41...
  }
  }
  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 91...
 
 
int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
  unsigned char b;
  unsigned char b;
  int i, j;
  int i, j;
 
 
  if (argc != 2) {
  if (argc != 3) {
    printf("Usage: %s <data_file>\n", argv[0]);
    printf("Usage: %s <serial_port> <data_file>\n", argv[0]);
    exit(1);
    exit(1);
  }
  }
  diskFile = fopen(argv[1], "wb");
  serialOpen(argv[1]);
 
  serialRcv(&b);
 
  diskFile = fopen(argv[2], "wb");
  if (diskFile == NULL) {
  if (diskFile == NULL) {
    error("cannot open data file %s for write", argv[1]);
    error("cannot open data file %s for write", argv[2]);
  }
  }
  serialOpen();
 
  serialRcv(&b);
 
  for (i = 0; i < 512; i++) {
  for (i = 0; i < 512; i++) {
    if (debug) {
    if (debug) {
      printf("%03d:  ", i);
      printf("%03d:  ", i);
    }
    }
    for (j = 0; j < 16; j++) {
    for (j = 0; j < 16; j++) {
      while (!serialRcv(&b)) ;
      while (!serialRcv(&b)) ;
      if (fwrite(&b, 1, 1, diskFile) != 1) {
      if (fwrite(&b, 1, 1, diskFile) != 1) {
        error("cannot write to data file %s", argv[1]);
        error("cannot write to data file %s", argv[2]);
      }
      }
      if (debug) {
      if (debug) {
        printf("%02X  ", b);
        printf("%02X  ", b);
      }
      }
    }
    }

powered by: WebSVN 2.1.0

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