48 static int writen(
int fd,
char *ptr,
int nbytes);
52 static int STAR2kPortFD;
53 static int STAR2kConnectFlag = 0;
55 static char STAR2kOpStat = 0;
66 char initCmd[] = { 0x0D, 0x00 };
68 fprintf(stderr,
"Connecting to port: %s\n", port);
70 if (STAR2kConnectFlag != 0)
75 STAR2kPortFD = open(port, O_RDWR);
76 if (STAR2kPortFD == -1)
79 tcgetattr(STAR2kPortFD, &tty);
80 cfsetospeed(&tty, (speed_t)B9600);
81 cfsetispeed(&tty, (speed_t)B9600);
82 tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8;
86 tty.c_cflag |= CLOCAL | CREAD;
89 tty.c_iflag &= ~(IXON | IXOFF | IXANY);
90 tty.c_cflag &= ~(PARENB | PARODD);
91 tcsetattr(STAR2kPortFD, TCSANOW, &tty);
95 tcflush(STAR2kPortFD, TCIOFLUSH);
100 writen(STAR2kPortFD, initCmd, 2);
113 if (direction ==
NORTH)
117 else if (direction ==
EAST)
121 else if (direction ==
SOUTH)
125 else if (direction ==
WEST)
130 writen(STAR2kPortFD, &STAR2kOpStat, 1);
135 if (direction ==
NORTH)
139 else if (direction ==
EAST)
143 else if (direction ==
SOUTH)
147 else if (direction ==
WEST)
151 else if (direction ==
ALL)
156 writen(STAR2kPortFD, &STAR2kOpStat, 1);
163 if (STAR2kConnectFlag == 1)
166 STAR2kConnectFlag = 0;
171 static int writen(
int fd,
char *ptr,
int nbytes)
177 nwritten = write(
fd, ptr, nleft);
183 return (nbytes - nleft);
int ConnectSTAR2k(char *port)
void DisconnectSTAR2k(void)
void StopPulse(int direction)
void StartPulse(int direction)