Changeset 22 in ntrip
- Timestamp:
- Apr 27, 2005, 12:31:12 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ntripserver/NtripLinuxServer.c
r21 r22 41 41 */ 42 42 43 /* $Id: NtripLinuxServer.c,v 1. 9 2005/04/19 11:28:17stoecker Exp $43 /* $Id: NtripLinuxServer.c,v 1.10 2005/04/27 08:32:43 stoecker Exp $ 44 44 * Changes - Version 0.7 45 45 * Sep 22 2003 Steffen Tschirpke <St.Tschirpke@actina.de> … … 96 96 #define NTRIP_PORT 80 97 97 98 int ttybaud = 19200;99 char *ttyport= "/dev/gps";100 char *filepath= "/dev/stdin";101 enum MODE mode = INFILE;98 static int ttybaud = 19200; 99 static const char *ttyport = "/dev/gps"; 100 static const char *filepath = "/dev/stdin"; 101 static enum MODE mode = INFILE; 102 102 103 103 /* Forward references */ 104 int openserial(u_char * tty, int blocksz, int ttybaud);105 void send_receive_loop(int socket, int fd);106 void usage(int);104 static int openserial(const char * tty, int blocksz, int baud); 105 static void send_receive_loop(int sock, int fd); 106 static void usage(int); 107 107 108 108 /* … … 126 126 int main(int argc, char **argv) 127 127 { 128 u_char *ttyin = ttyport;129 128 int c, gpsfd = -1; 130 129 int size = 2048; /* for setting send buffer size */ … … 132 131 unsigned int out_port = 0; 133 132 unsigned int in_port = 0; 134 c har *mountpoint = NULL;135 c har *password = "";136 c har *initfile = NULL;133 const char *mountpoint = NULL; 134 const char *password = ""; 135 const char *initfile = NULL; 137 136 int sock_id; 138 137 char szSendBuffer[BUFSZ]; … … 152 151 { 153 152 memset((char *) &out_addr, 0x00, sizeof(out_addr)); 154 memcpy(&out_addr.sin_addr, outhost->h_addr, outhost->h_length);153 memcpy(&out_addr.sin_addr, outhost->h_addr, (size_t)outhost->h_length); 155 154 } 156 155 … … 176 175 } 177 176 break; 178 case 'i': /* gps serial tty in*/179 tty in= optarg;177 case 'i': /* gps serial ttyport */ 178 ttyport = optarg; 180 179 break; 181 180 case 'b': /* serial ttyin speed */ … … 195 194 } 196 195 memset((char *) &out_addr, 0x00, sizeof(out_addr)); 197 memcpy(&out_addr.sin_addr, outhost->h_addr, outhost->h_length);196 memcpy(&out_addr.sin_addr, outhost->h_addr, (size_t)outhost->h_length); 198 197 break; 199 198 case 'p': /* http server port */ … … 226 225 } 227 226 memset((char *) &in_addr, 0x00, sizeof(in_addr)); 228 memcpy(&in_addr.sin_addr, inhost->h_addr, inhost->h_length);227 memcpy(&in_addr.sin_addr, inhost->h_addr, (size_t)inhost->h_length); 229 228 break; 230 229 case 'P': /* port */ … … 297 296 case SERIAL: /* open serial port */ 298 297 { 299 gpsfd = openserial(tty in, 1, ttybaud);298 gpsfd = openserial(ttyport, 1, ttybaud); 300 299 if(gpsfd < 0) 301 300 { 302 301 exit(1); 303 302 } 304 printf("serial input: device = %s, speed = %d\n", tty in, ttybaud);303 printf("serial input: device = %s, speed = %d\n", ttyport, ttybaud); 305 304 } 306 305 break; … … 336 335 while((i = fread(buffer, 1, sizeof(buffer), fh)) > 0) 337 336 { 338 if((send(gpsfd, buffer, i, 0)) != i)337 if((send(gpsfd, buffer, (size_t)i, 0)) != i) 339 338 { 340 339 perror("ERROR: sending init file"); … … 397 396 strcat(szSendBuffer, "\0"); 398 397 nBufferBytes = strlen(szSendBuffer); 399 if((send(sock_id, szSendBuffer, nBufferBytes, 0)) != nBufferBytes)398 if((send(sock_id, szSendBuffer, (size_t)nBufferBytes, 0)) != nBufferBytes) 400 399 { 401 400 fprintf(stderr, "ERROR: could not send to caster\n"); … … 426 425 } 427 426 428 void send_receive_loop(int socket, int fd)427 static void send_receive_loop(int sock, int fd) 429 428 { 430 429 char buffer[BUFSZ] = { 0 }; … … 450 449 } 451 450 /* send data */ 452 if((i = send(socket, buffer, nBufferBytes, MSG_DONTWAIT)) != nBufferBytes) 451 if((i = send(sock, buffer, (size_t)nBufferBytes, MSG_DONTWAIT)) 452 != nBufferBytes) 453 453 { 454 454 if(i < 0 && errno != EAGAIN) 455 455 { 456 456 perror("WARNING: could not send data - retry connection"); 457 close(sock et);457 close(sock); 458 458 sleep(5); 459 459 return; … … 461 461 else if(i) 462 462 { 463 memmove(buffer, buffer+i, nBufferBytes-i);463 memmove(buffer, buffer+i, (size_t)(nBufferBytes-i)); 464 464 nBufferBytes -= i; 465 465 } … … 482 482 * unsigned char name of the appropriate serial port. 483 483 * blocksz : integer : Block size for port I/O 484 * ttybaud :integer : Baud rate for port I/O484 * baud : integer : Baud rate for port I/O 485 485 * 486 486 * Return Value: … … 492 492 */ 493 493 494 int openserial(u_char * tty, int blocksz, int ttybaud)494 static int openserial(const char * tty, int blocksz, int baud) 495 495 { 496 496 int fd; … … 525 525 */ 526 526 527 switch ( ttybaud)527 switch (baud) 528 528 { 529 529 case 300: 530 ttybaud = B300;530 baud = B300; 531 531 break; 532 532 case 1200: 533 ttybaud = B1200;533 baud = B1200; 534 534 break; 535 535 case 2400: 536 ttybaud = B2400;536 baud = B2400; 537 537 break; 538 538 case 4800: 539 ttybaud = B4800;539 baud = B4800; 540 540 break; 541 541 case 9600: 542 ttybaud = B9600;542 baud = B9600; 543 543 break; 544 544 case 19200: 545 ttybaud = B19200;545 baud = B19200; 546 546 break; 547 547 case 38400: 548 ttybaud = B38400;548 baud = B38400; 549 549 break; 550 550 #ifdef B57600 551 551 case 57600: 552 ttybaud = B57600;552 baud = B57600; 553 553 break; 554 554 #endif 555 555 #ifdef B115200 556 556 case 115200: 557 ttybaud = B115200;557 baud = B115200; 558 558 break; 559 559 #endif 560 560 #ifdef B230400 561 561 case 230400: 562 ttybaud = B230400;562 baud = B230400; 563 563 break; 564 564 #endif 565 565 default: 566 566 fprintf(stderr, "WARNING: Baud settings not useful, using 19200\n"); 567 ttybaud = B19200;567 baud = B19200; 568 568 break; 569 569 } 570 570 #endif 571 571 572 if(cfsetispeed(&termios, ttybaud) != 0)572 if(cfsetispeed(&termios, baud) != 0) 573 573 { 574 574 perror("ERROR: setting serial speed with cfsetispeed"); 575 575 return (-1); 576 576 } 577 if(cfsetospeed(&termios, ttybaud) != 0)577 if(cfsetospeed(&termios, baud) != 0) 578 578 { 579 579 perror("ERROR: setting serial speed with cfsetospeed"); … … 607 607 */ 608 608 609 void usage(int rc)609 static void usage(int rc) 610 610 { 611 611 fprintf(stderr, "Usage: %s [OPTIONS]\n", VERSION);
Note:
See TracChangeset
for help on using the changeset viewer.