URL
https://opencores.org/ocsvn/eco32/eco32/trunk
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 prev, curr;
|
unsigned char prev, curr;
|
int count, errors;
|
int count, errors;
|
|
|
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);
|
count = 0;
|
count = 0;
|
errors = 0;
|
errors = 0;
|
while (!serialRcv(&prev)) ;
|
while (!serialRcv(&prev)) ;
|
count++;
|
count++;
|
while (count < 100000) {
|
while (count < 100000) {
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.