1 /* Possibly the dumbest terminal program in existance... */
\r
2 /* Simply here to demo the MMURTL device drive interface for comms */
\r
3 /* Build with MakeIT.Bat, use CM32 and DASM separately:
\r
12 #include "\OSSOURCE\MDevDrv.h"
\r
13 #include "\OSSOURCE\MJob.h"
\r
14 #include "\OSSOURCE\MKbd.h"
\r
15 #include "\OSSOURCE\MTimer.h"
\r
16 #include "\OSSOURCE\MVid.h"
\r
17 #include "\OSSOURCE\RS232.h"
\r
19 #define NORMVID BRITEWHITE|BGBLUE
\r
20 #define CLIVID WHITE|BGBLACK
\r
24 struct statRecC com;
\r
26 /*****************************************************/
\r
27 /*****************************************************/
\r
28 /*****************************************************/
\r
29 /*****************************************************/
\r
36 unsigned char b, lastb;
\r
40 SetNormVid(NORMVID);
\r
43 printf(" Terminally DUMB, Dumb Terminal Program\r\n");
\r
44 printf(" (MMURTL Comms Device Driver demo) \r\n");
\r
46 /* Get the 64 byte device status block which is specific to the
\r
47 RS-232 device driver. The structure is defined in commdrv.h
\r
50 erc = DeviceStat(6, &com, 64, &i);
\r
56 printf("Error on Device Stat: %d\r\n", erc);
\r
60 /* set the params in the block */
\r
62 com.Baudrate = 9600;
\r
63 com.parity = NO_PAR;
\r
67 /* View other params which we could set, but should already be
\r
68 defaulted with standard values when driver was initialized.
\r
71 printf("IRQNum: %d\r\n", com.IRQNum);
\r
72 printf("IOBase: %d\r\n", com.IOBase);
\r
73 printf("sXBuf: %d\r\n", com.XBufSize);
\r
74 printf("sRBuf: %d\r\n", com.RBufSize);
\r
75 printf("RTimeO: %d\r\n", com.RTimeOut);
\r
76 printf("XTimeO: %d\r\n", com.XTimeOut);
\r
78 /* Set the params we changed with a DeviceInit */
\r
80 erc = DeviceInit(6, &com, 64);
\r
85 printf("Error on Device Init: %d\r\n", erc);
\r
89 /* If device init went OK, we open the comms port */
\r
92 /* device, dOpNum, dLBA, dnBlocks, pData */
\r
93 erc = DeviceOp(6, CmdOpenC, 0, 0, &i);
\r
99 printf("OpenCommC ERROR: %d \r\n", erc);
\r
103 printf("Communications Port Initialized.\r\n");
\r
107 /* This is it... */
\r
112 if (!ReadKbd(&key, 0)) /* no wait */
\r
117 { /* ALT key is down */
\r
118 switch (toupper(b))
\r
121 /* device, dOpNum, dLBA, dnBlocks, pData */
\r
122 erc = DeviceOp(6, CmdCloseC, 0, 0, &i);
\r
123 SetNormVid(CLIVID);
\r
132 /* device, dOpNum, dLBA, dnBlocks, pData */
\r
133 erc = DeviceOp(6, CmdWriteB, 0, 0, &b);
\r
135 printf("WriteByteCError: %d \r\n", erc);
\r
141 erc = DeviceOp(6, CmdWriteB, 0, 0, &b);
\r
146 /* device, dOpNum, dLBA, dnBlocks, pData */
\r
147 erc = DeviceOp(6, CmdReadB, 0, 0, &b);
\r
150 TTYOut (&b, 1, NORMVID);
\r
151 /* add a LF if it's not there after a CR... */
\r
152 if ((lastb == 0x0D) && (b != 0x0A))
\r
153 TTYOut ("\n", 1, NORMVID);
\r