Changeset 45 in ntrip
- Timestamp:
- Jul 27, 2006, 11:54:39 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ntripserver/NtripLinuxServer.c
r34 r45 41 41 */ 42 42 43 /* $Id: NtripLinuxServer.c,v 1.1 5 2006/04/27 09:44:27stoecker Exp $43 /* $Id: NtripLinuxServer.c,v 1.16 2006/05/24 10:12:52 stoecker Exp $ 44 44 * Changes - Version 0.7 45 45 * Sep 22 2003 Steffen Tschirpke <St.Tschirpke@actina.de> … … 77 77 * 78 78 * Changes - Version 0.14 79 * Apr 27 2006 Dirk Stoecker <soft@dstoecker.de> 79 * May 16 2006 Andrea Stuerze <andrea.stuerze@bkg.bund.de> 80 * - bug fix in base64_encode-function 81 * 82 * Changes - Version 0.15 83 * Jun 02 2006 Georg Weber <georg.weber@bkg.bund.de> 84 * - modification for SISNeT 3.1 protocol 85 * 86 * Changes - Version 0.16 87 * Jul 06 2006 Andrea Stuerze <andrea.stuerze@bkg.bund.de> 88 * - more flexible caster's response 89 * 90 * Changes - Version 0.17 91 * Jul 27 2006 Dirk Stoecker <soft@dstoecker.de> 80 92 * - fixed some problems with caster download 93 * - some minor cosmetic changes 81 94 * 82 95 */ … … 108 121 CASTER = 6}; 109 122 110 #define VERSION "NTRIP NtripServerLinux/0.1 3"123 #define VERSION "NTRIP NtripServerLinux/0.17" 111 124 #define BUFSZ 1024 112 125 … … 129 142 static const char *filepath = "/dev/stdin"; 130 143 static enum MODE mode = INFILE; 131 static int sisnet v3 = 0;144 static int sisnet = 31; 132 145 static int gpsfd = -1; 133 146 134 147 /* Forward references */ 135 148 static int openserial(const char * tty, int blocksz, int baud); 136 static void send_receive_loop(int sock, int fd , int sisnet);149 static void send_receive_loop(int sock, int fd); 137 150 static void usage(int); 138 151 static int encode(char *buf, int size, const char *user, const char *pwd); … … 227 240 break; 228 241 case 'V': 229 if(!strcmp("3.0", optarg)) sisnetv3 = 1; 230 else if(strcmp("2.1", optarg)) 242 if(!strcmp("3.0", optarg)) sisnet = 30; 243 else if(!strcmp("3.1", optarg)) sisnet = 31; 244 else if(!strcmp("2.1", optarg)) sisnet = 20; 245 else 231 246 { 232 247 fprintf(stderr, "ERROR: unknown SISNeT version %s\n", optarg); 233 248 usage(-2); 234 249 } 250 break; 235 251 case 'b': /* serial ttyin speed */ 236 252 ttybaud = atoi(optarg); … … 341 357 case INFILE: 342 358 { 343 gpsfd = open(filepath, O_RDONLY); 344 if(!gpsfd) 359 if((gpsfd = open(filepath, O_RDONLY)) < 0) 345 360 { 346 361 perror("ERROR: opening input file"); … … 406 421 inport, stream_name ? "stream = " : "", stream_name ? stream_name : "", 407 422 initfile ? ", initfile = " : "", initfile ? initfile : "", 408 bindmode ? " 423 bindmode ? "binding mode" : ""); 409 424 410 425 if(bindmode) … … 533 548 char buffer[1024]; 534 549 535 i = snprintf(buffer, sizeof(buffer), sisnet v3? "AUTH,%s,%s\r\n"550 i = snprintf(buffer, sizeof(buffer), sisnet >= 30 ? "AUTH,%s,%s\r\n" 536 551 : "AUTH,%s,%s", sisnetuser, sisnetpassword); 537 552 if((send(gpsfd, buffer, (size_t)i, 0)) != i) … … 540 555 exit(1); 541 556 } 542 i = sisnet v3? 7 : 5;557 i = sisnet >= 30 ? 7 : 5; 543 558 if((j = recv(gpsfd, buffer, i, 0)) != i && strncmp("*AUTH", buffer, 5)) 544 559 { … … 553 568 fprintf(stderr, "\n"); 554 569 exit(1); 570 } 571 if(sisnet >= 31) 572 { 573 if((send(gpsfd, "START\r\n", 7, 0)) != i) 574 { 575 perror("ERROR: sending start command"); 576 exit(1); 577 } 555 578 } 556 579 } … … 615 638 nBufferBytes = recv(sock_id, szSendBuffer, sizeof(szSendBuffer), 0); 616 639 szSendBuffer[nBufferBytes] = '\0'; 617 if( strcmp(szSendBuffer, "OK\r\n"))640 if(!strstr(szSendBuffer, "OK")) 618 641 { 619 642 char *a; … … 629 652 } 630 653 printf("connection successfull\n"); 631 send_receive_loop(sock_id, gpsfd , mode == SISNET);654 send_receive_loop(sock_id, gpsfd); 632 655 } 633 656 exit(0); 634 657 } 635 658 636 static void send_receive_loop(int sock, int fd , int sisnet)659 static void send_receive_loop(int sock, int fd) 637 660 { 638 661 char buffer[BUFSZ] = { 0 }; … … 647 670 if(!nBufferBytes) 648 671 { 649 if( sisnet)672 if(mode == SISNET && sisnet <= 30) 650 673 { 651 674 int i; … … 655 678 select(0, 0, 0, 0, &tv); 656 679 memcpy(sisnetbackbuffer, buffer, sizeof(sisnetbackbuffer)); 657 i = (sisnet v3? 5 : 3);680 i = (sisnet >= 30 ? 5 : 3); 658 681 if((send(gpsfd, "MSG\r\n", i, 0)) != i) 659 682 { … … 667 690 { 668 691 printf("WARNING: no data received from input\n"); 692 sleep(3); 669 693 continue; 670 694 } … … 676 700 /* we can compare the whole buffer, as the additional bytes 677 701 remain unchanged */ 678 if( sisnet&& !memcmp(sisnetbackbuffer, buffer, sizeof(sisnetbackbuffer)))702 if(mode == SISNET && !memcmp(sisnetbackbuffer, buffer, sizeof(sisnetbackbuffer))) 679 703 { 680 704 nBufferBytes = 0; … … 885 909 fprintf(stderr, " -u username\n"); 886 910 fprintf(stderr, " -l password\n"); 887 fprintf(stderr, " -V version [2.1 or 3.0] (default: 2.1)\n");911 fprintf(stderr, " -V version [2.1, 3.0 or 3.1] (default: 3.1)\n"); 888 912 fprintf(stderr, " Mode = caster:\n"); 889 913 fprintf(stderr, " -P SourceCaster port (default: %d)\n", NTRIP_PORT);
Note:
See TracChangeset
for help on using the changeset viewer.