aboutsummaryrefslogtreecommitdiff
path: root/comdrtst.c
blob: e5fd8c6f2360e88f89570cec53d8d847301806b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/***********************************************************************
*
*	Name:  comdrtst
*
*	Purpose:  Test program for comdrive read and write
*
*	Algorithm: Tests both comdrive for both input (com_read)
*                  and output (com_write)
*
***************************************************************************/

#include <stdio.h>
#include <dos.h>

extern  int com_read(char far *buff, int far *len);
extern  int com_write(char far *buff, int far *len);


int main()
{
 int e_flag;
 int tmp;
 int rc;
 char buffer[100];
 char prompt[20];

 int length;

 rc = com_open(&e_flag,1200);

 /* if bad return code, display value and exit */
 if (rc != 0)
  {
  printf("\nrc(com_open) = %d",rc);
  exit();
  }

 strcpy(buffer,"");
 while (strcmp(buffer,"quit") != 0)
  {
			 /* command prompt on com port */
    length = 16;
    e_flag = 0;
    rc = com_write("\015\012Enter string: ",&length);

    /* if bad return code, display value and exit */
    if (rc != 0)
    {
       printf("\nrc(com_write) = %x",rc);
       exit();
    }

    /* loop until write complete */
    while (e_flag == 0)
	printf("wait for write\n");

		   /* read string */
    length = 30;
    e_flag = 0;
    rc = com_read(buffer,&length);

		   /* if bad return code, display value and exit */

    if (rc != 0)
    {
       printf("\nrc(com_read) = %x",rc);
       exit();
    }

		 /* loop until read is done */
    while (e_flag == 0)
	printf("wait - reading\n");



    /* display string entered */
    e_flag = 0;
    tmp = 22;
	rc = com_write("\015\012string entered was: ",&tmp);

		   /* if bad return code, display value and exit */
	if (rc != 0)
	{
	printf("\nrc(com_write) = %x",rc);
	exit();
	}

			/* loop until write is done */
	while (e_flag == 0)
	  printf("wait for string to be written\n");


	e_flag = 0;
	rc = com_write(buffer,&length);

	/* if bad return code, display value and exit */
	if (rc != 0)
	{
	   printf("\nrc(com_write) = %x",rc);
	}
	   /* loop until write is done */
	  while (e_flag == 0);
}

  length = 29;
  e_flag = 0;
  rc = com_write ("\015\012Com Driver Test Completed\015\012",&length);

  /* if bad return code, display value and exit */
  if (rc != 0)
   {
   printf("\nrc(com_write) = %x",rc);
   }

  /* loop until last write is done */
  while (e_flag == 0);

  com_close();
  return 0;
 }

int IO_complete(int device, int *stkptr)
{
	 return 0;
}