//edited 02/06/99 Matt Mueller - added the standard ath stuff, since the baud=0 didn't work for my modem void com_port_hangup() { struct termios save, temp; if (!commlib_initialised) return; com_write("+++",3); tcgetattr(fd, &save); tcgetattr(fd, &temp); cfsetispeed(&temp, B0); cfsetospeed(&temp, B0); tcsetattr(fd, TCSANOW, &temp); sleep(1); tcsetattr(fd, TCSANOW, &save); com_write("ath0\r\n",5); com_flushbuffers();//this should (hopefully?) clear out the OK and such. //end edit -MM }
int serial_putchar (uint16_t port, char byte) { if (port >= 4) return -1; com_write (com_io_ports[port], byte); return 0; }
void ProcessIORequest(int device){ if(device == 1){ if(TerminalQueue->head->requestType == READ){ trm_read(TerminalQueue->head->buffer, TerminalQueue->head->count); }else if(TerminalQueue->head->requestType == WRITE){ trm_write(TerminalQueue->head->buffer, TerminalQueue->head->count); }else if(TerminalQueue->head->requestType == CLEAR){ trm_clear(); }else if(TerminalQueue->head->requestType == GOTOXY){ trm_gotoxy(0,0); } }else if(device == 2){ if(Com_PortQueue->head->requestType == READ){ com_read(Com_PortQueue->head->buffer, Com_PortQueue->head->count); }else if(Com_PortQueue->head->requestType == WRITE){ com_write(Com_PortQueue->head->buffer, Com_PortQueue->head->count); } } }
unsigned long sendprocess(void* com, int control, int len, unsigned char *str) { memset(senddata, 0x00, SENDLEN); senddata[0] = 0x1b; senddata[1] = control; unsigned int sendlen; switch (control) { case 1: standlen = 24; sendlen = 2; break; case 0x02: case 0x22: case 0x42: case 0x52: senddata[2] = len; memcpy(senddata + 3, str, len); standlen = 3; sendlen = 3 + len; break; case 3: sendlen = 2; break; case 4: sendlen = 2; standlen = 2; break; case 5: sendlen = 2; standlen = 2; break; case 6: break; default: break; } return com_write(com, senddata, sendlen); }
void main() { int e_flag; /* event flag */ int rc; /* function return code */ char buffer[BUFLEN+2]; /* general buffer */ char prompt[BUFLEN+2]; /* prompt buffer */ int prlen; int length; long tstart; /* open com port */ rc = com_open( (int*) &e_flag, 1200); if ( rc != 0) { printf("\nOPEN failed!\n"); printf("error code = %d\n",rc); abort_test(); } /* setup prompt string */ strcpy(prompt, "\r\nEnter string: "); prlen = strlen(prompt); /* prompt and read until "quit" is typed */ buffer[0] = NULCH; while (strcmp(buffer,"quit\r\n") != 0) { /* display the prompt */ e_flag = 0; rc = com_write((char*) prompt, (int*) &prlen); if (rc != 0) { printf("\nerror displaying prompt!\n"); printf("error code = %d\n",rc); abort_test(); } /* loop until output is done */ tstart = time(NULL); while (e_flag == 0) { if ((time(NULL) - tstart) > WR_TIME_LIMIT) { printf("\ntimeout on prompt\n"); printf("event flag not set\n"); exit(); } } /* read a string */ length = BUFLEN-1; e_flag = 0; rc = com_read((char*) buffer, (int*) &length); if (rc != 0) { printf("\nerror reading string!\n"); printf("error code = %d\n",rc); abort_test(); } /* loop until input is done */ tstart = time(NULL); while (e_flag == 0) { if ((time(NULL) - tstart) > RD_TIME_LIMIT) { printf("\ntimeout on input\n"); printf("event flag not set\n"); abort_test(); } } /* display the input string */ e_flag = 0; if (buffer[length-1] == '\n') { buffer[length-1] = NULCH; length--; } strcat(buffer,"\r\n"); length = length + 2; printf("%s",buffer); rc = com_write((char*) buffer, (int*) &length); if (rc != 0) { printf("\nerror displaying string!\n"); printf("error code = %d\n",rc); abort_test(); } /* loop until output is done */ tstart = time(NULL); while (e_flag == 0) { if ((time(NULL) - tstart) > WR_TIME_LIMIT) { printf("\ntimeout on output\n"); printf("event flag not set\n"); abort_test(); } } } /* end of while loop */ /* print final message */ e_flag = 0; length = 29; printf("\nEnd of Com Driver IO Test\n"); rc = com_write((char*) "\r\nEnd of Com Driver IO Test\r\n", (int*) &length); if (rc != 0) { printf("\nWRITE error on final message!\n"); printf("error code = %d\n",rc); abort_test(); } /* loop until output is done */ tstart = time(NULL); while (e_flag == 0) { if ((time(NULL) - tstart) > WR_TIME_LIMIT) { printf("\ntimeout on final message\n"); printf("event flag not set\n"); abort_test(); } } /* close the com port */ rc = com_close(); if ( rc != 0) { printf("\nCLOSE failed!\n"); printf("error code = %d\n",rc); exit(); } printf("Test completed successfully!\n"); }
void main(void) { int e_flag; /* event flag */ int ix; /* loop index */ int rc; /* function return code */ char buffer[BUFLEN]; /* output buffer */ int length; long tstart; /* open com port */ rc = com_open( (int *) &e_flag, 1200); if ( rc != 0) { printf("\nOPEN failed!\n"); printf("error code = %d\n",rc); abort_test(); } /* fill buffer with Xs */ for (ix=0; ix<BUFLEN; ix++) buffer[ix] = 'X'; /* insert test string */ strcpy(buffer,"This is a test of com driver output "); strcat(buffer,"abcdefghijklmnopqrstuvwxyz 0123456789\012\015"); length = strlen(buffer); /* output test string the specified number of times */ for (ix=1; ix<=REPEAT_COUNT; ix++) { e_flag = 0; rc = com_write((char *) buffer, (int *) &length); if (rc != 0) { printf("\nWRITE error!\n"); printf("error code = %d\n",rc); abort_test(); } /* loop until output is done */ tstart = time(NULL); while (e_flag == 0) { if ((time(NULL) - tstart) > TIME_LIMIT) { printf("\nTIMEOUT: event flag not set\n"); abort_test(); } } } /* output final message */ e_flag = 0; length = 31; rc = com_write((char *) "End of Com Driver Output Test\012\015", (int *) &length); if (rc != 0) { printf("\nWRITE error on final message!\n"); printf("error code = %d\n",rc); abort_test(); } /* loop until output is done */ tstart = time(NULL); while (e_flag == 0) { if ((time(NULL) - tstart) > TIME_LIMIT) { printf("\nTIMEOUT: event flag not set\n"); abort_test(); } } /* close the com port */ rc = com_close(); if ( rc != 0) { printf("\nCLOSE failed!\n"); printf("error code = %d\n",rc); exit(); } printf("Test completed successfully!\n"); }