Changeset 2273 in ntrip
- Timestamp:
- Jan 21, 2010, 10:00:49 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ntripserver/ntripserver.c
r1883 r2273 1 #define WINDOWSVERSION 1 2 /* 2 * $Id: ntripserver.c,v 1.4 8 2009/04/27 09:47:59stoecker Exp $3 * $Id: ntripserver.c,v 1.49 2009/09/07 13:26:36 stoecker Exp $ 3 4 * 4 5 * Copyright (c) 2003...2007 … … 37 38 38 39 /* CVS revision and version */ 39 static char revisionstr[] = "$Revision: 1.4 8$";40 static char datestr[] = "$Date: 2009/0 4/27 09:47:59$";40 static char revisionstr[] = "$Revision: 1.49 $"; 41 static char datestr[] = "$Date: 2009/09/07 13:26:36 $"; 41 42 42 43 #include <ctype.h> … … 111 112 112 113 static int ttybaud = 19200; 114 #ifndef WINDOWSVERSION 113 115 static const char *ttyport = "/dev/gps"; 116 #else 117 static const char *ttyport = "COM1"; 118 #endif 114 119 static const char *filepath = "/dev/stdin"; 115 120 static enum MODE inputmode = INFILE; … … 171 176 * 172 177 */ 173 174 178 int main(int argc, char **argv) 175 179 { … … 1843 1847 static HANDLE openserial(const char * tty, int baud) 1844 1848 { 1845 DCB dcb;1846 COMMTIMEOUTS cmt;1847 1849 char compath[15] = ""; 1848 1850 1849 1851 snprintf(compath, sizeof(compath), "\\\\.\\%s", tty); 1850 /*** opening the serial port ***/ 1851 gps_serial = CreateFile(compath, GENERIC_READ | GENERIC_WRITE, 0, 0, 1852 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); 1853 if(gps_serial == INVALID_HANDLE_VALUE) 1852 if((gps_serial = CreateFile(compath, GENERIC_WRITE|GENERIC_READ 1853 , 0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) 1854 1854 { 1855 1855 fprintf(stderr, "ERROR: opening serial connection\n"); 1856 1856 return (INVALID_HANDLE_VALUE); 1857 1857 } 1858 /*** configuring the serial port ***/ 1859 FillMemory(&dcb, sizeof(dcb), 0); 1860 dcb.DCBlength = sizeof(dcb); 1861 if(!GetCommState(gps_serial, &dcb)) 1858 1859 DCB dcb; 1860 memset(&dcb, 0, sizeof(dcb)); 1861 char str[100]; 1862 snprintf(str,sizeof(str), 1863 "baud=%d parity=N data=8 stop=1 xon=off octs=off rts=off", 1864 baud); 1865 1866 COMMTIMEOUTS ct = {1000, 1, 0, 0, 0}; 1867 1868 if(!BuildCommDCB(str, &dcb)) 1862 1869 { 1863 1870 fprintf(stderr, "ERROR: get serial attributes\n"); 1864 1871 return (INVALID_HANDLE_VALUE); 1865 1872 } 1866 switch (baud) 1867 { 1868 case 110: 1869 baud = CBR_110; 1870 break; 1871 case 300: 1872 baud = CBR_300; 1873 break; 1874 case 600: 1875 baud = CBR_600; 1876 break; 1877 case 1200: 1878 baud = CBR_1200; 1879 break; 1880 case 2400: 1881 baud = CBR_2400; 1882 break; 1883 case 4800: 1884 baud = CBR_4800; 1885 break; 1886 case 9600: 1887 baud = CBR_9600; 1888 break; 1889 case 14400: 1890 baud = CBR_14400; 1891 break; 1892 case 19200: 1893 baud = CBR_19200; 1894 break; 1895 case 38400: 1896 baud = CBR_38400; 1897 break; 1898 case 56000: 1899 baud = CBR_56000; 1900 break; 1901 case 57600: 1902 baud = CBR_57600; 1903 break; 1904 case 115200: 1905 baud = CBR_115200; 1906 break; 1907 case 128000: 1908 baud = CBR_128000; 1909 break; 1910 case 256000: 1911 baud = CBR_256000; 1912 break; 1913 default: 1914 fprintf(stderr, "WARNING: Baud settings not useful, using 19200\n"); 1915 baud = CBR_19200; 1916 break; 1917 } 1918 dcb.BaudRate = baud; 1919 dcb.ByteSize = 8; 1920 dcb.StopBits = ONESTOPBIT; 1921 dcb.Parity = NOPARITY; 1922 if(!GetCommState(gps_serial, &dcb)) 1923 { 1924 fprintf(stderr, "ERROR: get serial attributes\n"); 1873 else if(!SetCommState(gps_serial, &dcb)) 1874 { 1875 fprintf(stderr, "ERROR: set serial attributes\n"); 1925 1876 return (INVALID_HANDLE_VALUE); 1926 1877 } 1927 FillMemory(&cmt, sizeof(cmt), 0); 1928 cmt.ReadIntervalTimeout = 1000; 1929 cmt.ReadTotalTimeoutMultiplier = 1; 1930 cmt.ReadTotalTimeoutConstant = 0; 1931 if(!SetCommTimeouts(gps_serial, &cmt)) 1878 else if(!SetCommTimeouts(gps_serial, &ct)) 1932 1879 { 1933 1880 fprintf(stderr, "ERROR: set serial timeouts\n"); 1934 1881 return (INVALID_HANDLE_VALUE); 1935 1882 } 1883 1936 1884 return (gps_serial); 1937 } /* openserial */1885 } 1938 1886 #endif 1939 1887 … … 1985 1933 fprintf(stderr, " mandatory\n\n"); 1986 1934 fprintf(stderr, " <InputMode> = 1 (Serial Port):\n"); 1987 fprintf(stderr, " -i <Device> Serial input device, default: /dev/gps, mandatory if\n");1935 fprintf(stderr, " -i <Device> Serial input device, default: %s, mandatory if\n", ttyport); 1988 1936 fprintf(stderr, " <InputMode>=1\n"); 1989 1937 fprintf(stderr, " -b <BaudRate> Serial input baud rate, default: 19200 bps, mandatory\n"); … … 2002 1950 fprintf(stderr, " <InputMode> = 3 (File):\n"); 2003 1951 fprintf(stderr, " -s <File> File name to simulate stream by reading data from (log)\n"); 2004 fprintf(stderr, " file, default is /dev/stdin, mandatory for <InputMode> = 3\n\n");1952 fprintf(stderr, " file, default is %s, mandatory for <InputMode> = 3\n\n", filepath); 2005 1953 fprintf(stderr, " <InputMode> = 4 (SISNeT Data Server):\n"); 2006 1954 fprintf(stderr, " -H <SisnetHost> SISNeT Data Server name or address,\n");
Note:
See TracChangeset
for help on using the changeset viewer.