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

pmacexec.c

Go to the documentation of this file.
00001 
00002 #include <stdio.h>
00003 #include <string.h>
00004 #include <stdlib.h>
00005 #include "pmac.h"
00006 
00007 /*
00008   Modification history:
00009 
00010   15-Feb-1995  Fred Proctor added call to pmac_print_error
00011   ??? Fred Proctor created
00012   */
00013 
00014 /* any cmd-line args mean print prompt; if none, don't */
00015 int main(int argc, char **argv)
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:56:51 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001