aravinrjn47
Newbie level 2
- Joined
- Feb 8, 2015
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 40
Code C - [expand] 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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 /************************************************************************ ; S0_ECHO.C returns the character recieved for AE88 03-30-97 * ; * ; Module:s0_echo. ; * ; DESCRIPTION: ; This program use SER0 to echo back any characters recieved ; connect PC COM1/2 to SER0. Setup PC windows TERMINAL to 19200 ; Every character typed from PC will echo back from SER0 ; Set PC1 windows TERMINAL(19200, 8, N, 1) ; ************************************************************************/ #include "ae.h" #include "ser0.h" #include <string.h> #include <stdlib.h> #include <float.h> #include <stdio.h> #include <dos.h> #include <math.h> #include <embedded.h> #define MAXISIZE 4096 #define MAXOSIZE 4096 unsigned char ser0_in_buf[MAXISIZE]; unsigned char ser0_out_buf[MAXOSIZE]; int isize,osize; int j,l; int ndig,dec,sign; unsigned int n; extern COM ser0_com; COM * c0; unsigned char mode, baud; char String[50]; char Value[25]; char First[50]; char Last[50]; char *ptr; char Space = 32; char Return = 13; char sendd[25]; int cou; int Command; void interrupt far int2_isr(void); void interrupt far int4_isr(void); void Split_String(char *str) { strcpy(First,""); ptr = strchr(str,Space); strncpy(First,str,ptr-str); First[ptr-str] = '\0'; strrev(str); strcpy(Last,""); ptr = strchr(str,Space); strncpy(Last,str,ptr-str); Last[ptr-str] = '\0'; strrev(Last); strrev(str); } void interrupt far int2_isr(void) { disable(); Command = 3; // enable(); /* Issue non Specific EOI for the interrupt */ outport(0xff22,0x8000); } void interrupt far int4_isr(void) { disable(); Command = 2; enable(); /* Issue non Specific EOI for the interrupt */ outport(0xff22,0x8000); } void main(void) { delay_ms(1000); ae_init(); ndig = 5; // dec = 5; c0 = &ser0_com; baud = 8; /* 9600 baud */ isize=MAXISIZE; osize=MAXOSIZE; j=0x55; l = 50; // STRING LENGTH s0_init(baud,ser0_in_buf,isize,ser0_out_buf,osize,c0); Command = 0; n = 0; delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); delay_ms(1000); int2_init(1,int2_isr); int4_init(1,int4_isr); strcpy(sendd,"ATD96********;"); delay_ms(10000); /* cou = strlen(sendd); puts0(sendd,cou,c0); delay_ms(500); putser0('\15',c0); */ while(1) { if (Command == 3) { delay_ms(25000); if(Command != 2) { putsers0(sendd,c0); delay_ms(500); putser0('\15',c0); } else { Command = 0; } /* n++; sprintf(Value, " %d \n",n); putsers0(Value, c1); Command = 0; */ enable(); } delay_ms(200); if( serhit0(c0) ) { /* hit by PC1 */ j = getsers0(c0,l,String); // get the string // putsers0(String,c1); } delay_ms(10); } }
Last edited by a moderator: