Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

pmacexec.c File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "pmac.h"

Include dependency graph for pmacexec.c:

Include dependency graph

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main int    argc,
char **    argv
 

Definition at line 15 of file pmacexec.c.

00016 {
00017   char cmd[PMAC_MSG_LEN];
00018   char buff[PMAC_MSG_LEN];
00019   int dperr;
00020 
00021   /* initialize cmd to "" */
00022   cmd[0] = '\0';
00023 
00024   /* get DP RAM */
00025   pmac_init();
00026 
00027   /* send A (abort), CLOSE, and DELETE ROT commands to
00028      board, in case the board was left with rotary buffer
00029      open and running */
00030 #if 0
00031   if ((dperr = pmac_writemsg("A\xD", buff, PMAC_MSG_LEN)) != PMAC_ACK)
00032   {
00033     pmac_print_error(dperr, buff);
00034   }
00035   else
00036     fputs(buff, stderr);
00037 
00038   if ((dperr = pmac_writemsg("CLOSE\xD", buff, PMAC_MSG_LEN)) != PMAC_ACK)
00039   {
00040     pmac_print_error(dperr, buff);
00041   }
00042   else
00043     fputs(buff, stderr);
00044 
00045   if ((dperr = pmac_writemsg("DELETE ROT\xD", buff, PMAC_MSG_LEN)) != PMAC_ACK)
00046   {
00047     pmac_print_error(dperr, buff);
00048   }
00049   else
00050     fputs(buff, stderr);
00051 #endif
00052   /* read and send terminal input */
00053   while (!feof(stdin))
00054   {
00055     if (argc > 1)
00056     {
00057       printf("pmac> ");
00058       fflush(stdout);
00059     }
00060     if (fgets(cmd, 80, stdin) == NULL)
00061       break;
00062 
00063     /* FIXME */
00064     if (argc == 1)
00065     {
00066       printf("%s", cmd);
00067     }
00068 
00069     /* replace \n from fgets() with NULL */
00070     cmd[strlen(cmd)-1]=0;
00071     /* write the message */
00072     if ((dperr = pmac_writemsg(cmd, buff, PMAC_MSG_LEN)) != PMAC_ACK)
00073     {
00074       pmac_print_error(dperr, buff);
00075     }
00076     else
00077     {
00078       if (buff[0] != 0)
00079       {
00080         /* there's a reply */
00081         printf("%s\n", buff);
00082       }
00083     }
00084   }
00085 
00086   pmac_exit();
00087 
00088   exit(0);
00089 }


Generated on Sun Dec 2 15:57:28 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001