Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authenticated: #28823953 From: Moritz Herrmann To: cygwin AT cygwin DOT com Subject: 1.5.18: get strange characters from rs232-port on a Windows XP machine Date: Mon, 8 Aug 2005 17:14:50 +0200 User-Agent: KMail/1.8.1 MIME-Version: 1.0 Message-Id: <200508081714.50312.MoritzHerrmann05@gmx.de> Content-Type: Multipart/Mixed; boundary="Boundary-00=_qb39Cl3/ZBVHaKK" X-Y-GMX-Trusted: 0 X-Virus-Checked: Checked by ClamAV on sourceware.org --Boundary-00=_qb39Cl3/ZBVHaKK Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi guys I'm working on a little c program to receive and save strings from the=20 serial-port into a local file on a Windows XP/2003 Server machine. The program is working very well on a linux machine but if I try to run it= =20 under windows I just get stupid characters like: 0x11 =E2=97=84 0x6 =E2=99=A0 0x7 0x1f =E2=96=BC 0x7f =E2=8C=82 what I really wanted to get is this: 0x2 =E2=98=BB 0x4a J 0x55 U 0x53 S 0x54 T 0x49 I 0x4e N 0x20 0x54 T 0x49 I 0x4d M 0x42 B 0x45 E 0x52 R 0x4c L 0x41 A 0x4b K 0x45 E 0x20 0x2f / 0x20 0x52 R 0x6f o 0x63 c 0x6b k 0x20 0x79 y 0x6f o 0x75 u 0x72 r 0x20 0x62 b 0x6f o 0x64 d 0x79 y 0x3 =E2=99=A5 but I only get the right chars when I open a windows Hyperterminal and clos= e=20 it before I start my program.=20 After a week of searching around the internet you are my last hope. the rs232.c file Is my program-code: and cygcheck.out is the output of "cygcheck -s -v -r" thank you for help moe --Boundary-00=_qb39Cl3/ZBVHaKK Content-Type: text/plain; charset="utf-8"; name="cygcheck.out" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cygcheck.out" Cygwin Configuration Diagnostics Current System Time: Fri Aug 05 13:30:33 2005 Windows XP Professional Ver 5.1 Build 2600 Service Pack 2 Path: C:\Programme\cygwin\usr\local\bin C:\Programme\cygwin\bin C:\Programme\cygwin\bin C:\Programme\cygwin\usr\X11R6\bin c:\WINDOWS\system32 c:\WINDOWS c:\WINDOWS\System32\Wbem c:\Programme\NTP\bin Output from C:\Programme\cygwin\bin\id.exe (nontsec) UID: 500(Administrator) GID: 513(Kein) 0(root) 513(Kein) 544(Administratoren) 545(Benutzer) 1005(Debuggerbenutzer) Output from C:\Programme\cygwin\bin\id.exe (ntsec) UID: 500(Administrator) GID: 513(Kein) 0(root) 513(Kein) 544(Administratoren) 545(Benutzer) 1005(Debuggerbenutzer) SysDir: C:\WINDOWS\system32 WinDir: C:\WINDOWS USER = `Administrator' PWD = `/home/Administrator/test' HOME = `/home/Administrator' MAKE_MODE = `unix' HOMEPATH = `\Dokumente und Einstellungen\Administrator' MANPATH = `/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/man' APPDATA = `C:\Dokumente und Einstellungen\Administrator\Anwendungsdaten' HOSTNAME = `like152' TERM = `cygwin' PROCESSOR_IDENTIFIER = `x86 Family 15 Model 2 Stepping 7, GenuineIntel' WINDIR = `C:\WINDOWS' OLDPWD = `/home/Administrator' USERDOMAIN = `LIKE152' OS = `Windows_NT' ALLUSERSPROFILE = `C:\Dokumente und Einstellungen\All Users' TEMP = `/cygdrive/c/DOKUME~1/ADMINI~1/LOKALE~1/Temp' COMMONPROGRAMFILES = `C:\Programme\Gemeinsame Dateien' USERNAME = `Administrator' PROCESSOR_LEVEL = `15' FP_NO_HOST_CHECK = `NO' SYSTEMDRIVE = `C:' USERPROFILE = `C:\Dokumente und Einstellungen\Administrator' PS1 = `\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ ' LOGONSERVER = `\\LIKE152' PROCESSOR_ARCHITECTURE = `x86' !C: = `C:\Programme\cygwin\bin' SHLVL = `1' PATHEXT = `.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH' HOMEDRIVE = `C:' PROMPT = `$P$G' COMSPEC = `C:\WINDOWS\system32\cmd.exe' TMP = `/cygdrive/c/DOKUME~1/ADMINI~1/LOKALE~1/Temp' SYSTEMROOT = `C:\WINDOWS' PRINTER = `LaserJet1' CVS_RSH = `/bin/ssh' PROCESSOR_REVISION = `0207' INFOPATH = `/usr/local/info:/usr/share/info:/usr/info:' PROGRAMFILES = `C:\Programme' NUMBER_OF_PROCESSORS = `1' SESSIONNAME = `Console' COMPUTERNAME = `LIKE152' _ = `/usr/bin/cygcheck.exe' POSIXLY_CORRECT = `1' HKEY_CURRENT_USER\Software\Cygnus Solutions HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2 (default) = `/cygdrive' cygdrive flags = 0x00000022 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/ (default) = `C:\Programme\cygwin' flags = 0x00000002 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/usr/bin (default) = `C:\Programme\cygwin/bin' flags = 0x00000002 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/usr/lib (default) = `C:\Programme\cygwin/lib' flags = 0x00000002 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options a: fd N/A N/A c: hd NTFS 14998Mb 44% CP CS UN PA FC WinXP d: hd NTFS 23164Mb 5% CP CS UN PA FC data e: cd N/A N/A f: fd FAT32 1979Mb 3% CP UN USBSTICK C:\Programme\cygwin / user binmode C:\Programme\cygwin/bin /usr/bin user binmode C:\Programme\cygwin/lib /usr/lib user binmode . /cygdrive user binmode,cygdrive Found: C:\Programme\cygwin\bin\awk.exe Found: C:\Programme\cygwin\bin\bash.exe Found: C:\Programme\cygwin\bin\cat.exe Found: C:\Programme\cygwin\bin\cp.exe Found: C:\Programme\cygwin\bin\cpp.exe Found: C:\Programme\cygwin\bin\find.exe Found: C:\Programme\cygwin\bin\gcc.exe Not Found: gdb Found: C:\Programme\cygwin\bin\grep.exe Found: C:\Programme\cygwin\bin\ld.exe Found: C:\Programme\cygwin\bin\ls.exe Found: C:\Programme\cygwin\bin\make.exe Found: C:\Programme\cygwin\bin\mv.exe Found: C:\Programme\cygwin\bin\rm.exe Found: C:\Programme\cygwin\bin\sed.exe Found: C:\Programme\cygwin\bin\sh.exe Found: C:\Programme\cygwin\bin\tar.exe 56k 2005/07/09 C:\Programme\cygwin\bin\cygbz2-1.dll - os=4.0 img=1.0 sys=4.0 "cygbz2-1.dll" v0.0 ts=2005/7/9 7:09 18k 2004/07/06 C:\Programme\cygwin\bin\cygcharset-1.dll - os=4.0 img=1.0 sys=4.0 "cygcharset-1.dll" v0.0 ts=2004/7/6 20:09 7k 2003/10/19 C:\Programme\cygwin\bin\cygcrypt-0.dll - os=4.0 img=1.0 sys=4.0 "cygcrypt-0.dll" v0.0 ts=2003/10/19 9:57 858k 2005/04/11 C:\Programme\cygwin\bin\cygcrypto-0.9.7.dll - os=4.0 img=1.0 sys=4.0 "cygcrypto-0.9.7.dll" v0.0 ts=2005/4/11 20:21 1042k 2005/07/07 C:\Programme\cygwin\bin\cygcrypto-0.9.8.dll - os=4.0 img=1.0 sys=4.0 "cygcrypto-0.9.8.dll" v0.0 ts=2005/7/7 11:06 380k 2002/07/24 C:\Programme\cygwin\bin\cygdb-3.1.dll - os=4.0 img=1.0 sys=4.0 "cygdb-3.1.dll" v0.0 ts=2002/7/24 18:24 831k 2003/09/20 C:\Programme\cygwin\bin\cygdb-4.1.dll - os=4.0 img=1.0 sys=4.0 "cygdb-4.1.dll" v0.0 ts=2003/9/20 23:51 895k 2004/04/28 C:\Programme\cygwin\bin\cygdb-4.2.dll - os=4.0 img=1.0 sys=4.0 "cygdb-4.2.dll" v0.0 ts=2004/4/27 17:31 965k 2005/05/14 C:\Programme\cygwin\bin\cygdb-4.3.dll - os=4.0 img=1.0 sys=4.0 "cygdb-4.3.dll" v0.0 ts=2005/5/14 14:37 326k 2002/06/26 C:\Programme\cygwin\bin\cygdb2.dll - os=4.0 img=1.0 sys=4.0 "cygdb2.dll" v0.0 ts=2002/6/26 19:48 487k 2002/07/24 C:\Programme\cygwin\bin\cygdb_cxx-3.1.dll - os=4.0 img=1.0 sys=4.0 "cygdb_cxx-3.1.dll" v0.0 ts=2002/7/24 18:25 1080k 2003/09/20 C:\Programme\cygwin\bin\cygdb_cxx-4.1.dll - os=4.0 img=1.0 sys=4.0 "cygdb_cxx-4.1.dll" v0.0 ts=2003/9/20 23:53 1156k 2004/04/28 C:\Programme\cygwin\bin\cygdb_cxx-4.2.dll - os=4.0 img=1.0 sys=4.0 "cygdb_cxx-4.2.dll" v0.0 ts=2004/4/27 17:35 1240k 2005/05/14 C:\Programme\cygwin\bin\cygdb_cxx-4.3.dll - os=4.0 img=1.0 sys=4.0 "cygdb_cxx-4.3.dll" v0.0 ts=2005/5/14 14:41 174k 2004/10/14 C:\Programme\cygwin\bin\cygexpat-0.dll - os=4.0 img=1.0 sys=4.0 "cygexpat-0.dll" v0.0 ts=2004/10/14 10:34 40k 2005/07/10 C:\Programme\cygwin\bin\cygform-8.dll - os=4.0 img=1.0 sys=4.0 "cygform-8.dll" v0.0 ts=2005/7/10 5:29 45k 2001/04/25 C:\Programme\cygwin\bin\cygform5.dll - os=4.0 img=1.0 sys=4.0 "cygform5.dll" v0.0 ts=2001/4/25 7:28 35k 2002/01/09 C:\Programme\cygwin\bin\cygform6.dll - os=4.0 img=1.0 sys=4.0 "cygform6.dll" v0.0 ts=2002/1/9 7:03 48k 2003/08/09 C:\Programme\cygwin\bin\cygform7.dll - os=4.0 img=1.0 sys=4.0 "cygform7.dll" v0.0 ts=2003/8/9 11:25 28k 2003/07/20 C:\Programme\cygwin\bin\cyggdbm-3.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm-3.dll" v0.0 ts=2003/7/20 9:58 30k 2003/08/11 C:\Programme\cygwin\bin\cyggdbm-4.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm-4.dll" v0.0 ts=2003/8/11 4:12 19k 2003/03/22 C:\Programme\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm.dll" v0.0 ts=2002/2/20 4:05 15k 2003/07/20 C:\Programme\cygwin\bin\cyggdbm_compat-3.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm_compat-3.dll" v0.0 ts=2003/7/20 10:00 15k 2003/08/11 C:\Programme\cygwin\bin\cyggdbm_compat-4.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm_compat-4.dll" v0.0 ts=2003/8/11 4:13 17k 2001/06/28 C:\Programme\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0 "cyghistory4.dll" v0.0 ts=2001/1/7 5:34 29k 2003/08/10 C:\Programme\cygwin\bin\cyghistory5.dll - os=4.0 img=1.0 sys=4.0 "cyghistory5.dll" v0.0 ts=2003/8/11 1:16 24k 2005/07/29 C:\Programme\cygwin\bin\cyghistory6.dll - os=4.0 img=1.0 sys=4.0 "cyghistory6.dll" v0.0 ts=2005/7/29 5:57 991k 2004/07/06 C:\Programme\cygwin\bin\cygiconv-2.dll - os=4.0 img=1.0 sys=4.0 "cygiconv-2.dll" v0.0 ts=2004/7/6 20:10 22k 2001/12/13 C:\Programme\cygwin\bin\cygintl-1.dll - os=4.0 img=1.0 sys=4.0 "cygintl-1.dll" v0.0 ts=2001/12/13 10:28 37k 2003/08/10 C:\Programme\cygwin\bin\cygintl-2.dll - os=4.0 img=1.0 sys=4.0 "cygintl-2.dll" v0.0 ts=2003/8/10 23:50 54k 2004/07/06 C:\Programme\cygwin\bin\cygintl-3.dll - os=4.0 img=1.0 sys=4.0 "cygintl-3.dll" v0.0 ts=2004/7/6 19:51 21k 2001/06/20 C:\Programme\cygwin\bin\cygintl.dll - os=4.0 img=1.0 sys=4.0 "cygintl.dll" v0.0 ts=2001/6/20 19:09 21k 2005/07/10 C:\Programme\cygwin\bin\cygmenu-8.dll - os=4.0 img=1.0 sys=4.0 "cygmenu-8.dll" v0.0 ts=2005/7/10 5:28 26k 2001/04/25 C:\Programme\cygwin\bin\cygmenu5.dll - os=4.0 img=1.0 sys=4.0 "cygmenu5.dll" v0.0 ts=2001/4/25 7:27 20k 2002/01/09 C:\Programme\cygwin\bin\cygmenu6.dll - os=4.0 img=1.0 sys=4.0 "cygmenu6.dll" v0.0 ts=2002/1/9 7:03 29k 2003/08/09 C:\Programme\cygwin\bin\cygmenu7.dll - os=4.0 img=1.0 sys=4.0 "cygmenu7.dll" v0.0 ts=2003/8/9 11:25 67k 2005/07/10 C:\Programme\cygwin\bin\cygncurses++-8.dll - os=4.0 img=1.0 sys=4.0 "cygncurses++-8.dll" v0.0 ts=2005/7/10 5:29 156k 2001/04/25 C:\Programme\cygwin\bin\cygncurses++5.dll - os=4.0 img=1.0 sys=4.0 "cygncurses++5.dll" v0.0 ts=2001/4/25 7:29 175k 2002/01/09 C:\Programme\cygwin\bin\cygncurses++6.dll - os=4.0 img=1.0 sys=4.0 "cygncurses++6.dll" v0.0 ts=2002/1/9 7:03 225k 2005/07/10 C:\Programme\cygwin\bin\cygncurses-8.dll - os=4.0 img=1.0 sys=4.0 "cygncurses-8.dll" v0.0 ts=2005/7/10 5:15 226k 2001/04/25 C:\Programme\cygwin\bin\cygncurses5.dll - os=4.0 img=1.0 sys=4.0 "cygncurses5.dll" v0.0 ts=2001/4/25 7:17 202k 2002/01/09 C:\Programme\cygwin\bin\cygncurses6.dll - os=4.0 img=1.0 sys=4.0 "cygncurses6.dll" v0.0 ts=2002/1/9 7:03 224k 2003/08/09 C:\Programme\cygwin\bin\cygncurses7.dll - os=4.0 img=1.0 sys=4.0 "cygncurses7.dll" v0.0 ts=2003/8/9 11:24 11k 2005/07/10 C:\Programme\cygwin\bin\cygpanel-8.dll - os=4.0 img=1.0 sys=4.0 "cygpanel-8.dll" v0.0 ts=2005/7/10 5:28 15k 2001/04/25 C:\Programme\cygwin\bin\cygpanel5.dll - os=4.0 img=1.0 sys=4.0 "cygpanel5.dll" v0.0 ts=2001/4/25 7:27 12k 2002/01/09 C:\Programme\cygwin\bin\cygpanel6.dll - os=4.0 img=1.0 sys=4.0 "cygpanel6.dll" v0.0 ts=2002/1/9 7:03 19k 2003/08/09 C:\Programme\cygwin\bin\cygpanel7.dll - os=4.0 img=1.0 sys=4.0 "cygpanel7.dll" v0.0 ts=2003/8/9 11:24 62k 2003/12/11 C:\Programme\cygwin\bin\cygpcre-0.dll - os=4.0 img=1.0 sys=4.0 "cygpcre-0.dll" v0.0 ts=2003/12/11 18:01 63k 2003/04/11 C:\Programme\cygwin\bin\cygpcre.dll - os=4.0 img=1.0 sys=4.0 "cygpcre.dll" v0.0 ts=2003/4/11 10:31 9k 2003/12/11 C:\Programme\cygwin\bin\cygpcreposix-0.dll - os=4.0 img=1.0 sys=4.0 "cygpcreposix-0.dll" v0.0 ts=2003/12/11 18:01 61k 2003/04/11 C:\Programme\cygwin\bin\cygpcreposix.dll - os=4.0 img=1.0 sys=4.0 "cygpcreposix.dll" v0.0 ts=2003/4/11 10:31 1248k 2005/07/28 C:\Programme\cygwin\bin\cygperl5_8.dll - os=4.0 img=1.0 sys=4.0 "cygperl5_8.dll" v0.0 ts=2005/7/28 11:23 22k 2002/06/09 C:\Programme\cygwin\bin\cygpopt-0.dll - os=4.0 img=1.0 sys=4.0 "cygpopt-0.dll" v0.0 ts=2002/6/9 7:45 108k 2001/06/28 C:\Programme\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0 sys=4.0 "cygreadline4.dll" v0.0 ts=2001/1/7 5:34 148k 2003/08/10 C:\Programme\cygwin\bin\cygreadline5.dll - os=4.0 img=1.0 sys=4.0 "cygreadline5.dll" v0.0 ts=2003/8/11 1:16 144k 2005/07/29 C:\Programme\cygwin\bin\cygreadline6.dll - os=4.0 img=1.0 sys=4.0 "cygreadline6.dll" v0.0 ts=2005/7/29 5:57 171k 2005/04/11 C:\Programme\cygwin\bin\cygssl-0.9.7.dll - os=4.0 img=1.0 sys=4.0 "cygssl-0.9.7.dll" v0.0 ts=2005/4/11 20:21 217k 2005/07/07 C:\Programme\cygwin\bin\cygssl-0.9.8.dll - os=4.0 img=1.0 sys=4.0 "cygssl-0.9.8.dll" v0.0 ts=2005/7/7 11:07 60k 2005/07/09 C:\Programme\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0 "cygz.dll" v0.0 ts=2005/7/9 4:27 1265k 2005/07/03 C:\Programme\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0 "cygwin1.dll" v0.0 ts=2005/7/3 2:30 Cygwin DLL version info: DLL version: 1.5.18 DLL epoch: 19 DLL bad signal mask: 19005 DLL old termios: 5 DLL malloc env: 28 API major: 0 API minor: 132 Shared data: 4 DLL identifier: cygwin1 Mount registry: 2 Cygnus registry name: Cygnus Solutions Cygwin registry name: Cygwin Program options name: Program Options Cygwin mount registry name: mounts v2 Cygdrive flags: cygdrive flags Cygdrive prefix: cygdrive prefix Cygdrive default prefix: Build date: Sat Jul 2 20:30:04 EDT 2005 Shared id: cygwin1S4 No Cygwin services found. Cygwin Package Information Last downloaded files to: D:\temp\cygwin Last downloaded files from: ftp://ftp.sunsite.utk.edu/pub/cygwin Package Version _update-info-dir 00286-1 alternatives 1.3.20a-1 ash 20040127-3 autoconf 2.59-2 autoconf2.1 2.13-1 autoconf2.5 2.59-1 automake1.9 1.9.5-2 base-files 3.5-1 base-passwd 2.2-1 bash 3.0-11 binutils 20050610-1 bzip2 1.0.3-1 coreutils 5.3.0-9 crypt 1.1-1 cygrunsrv 1.10-1 cygutils 1.2.9-1 cygwin 1.5.18-1 cygwin-doc 1.4-2 db2 2.7.7-4 db3.1 3.1.17-2 db4.1 4.1.25-1 db4.2 4.2.52-1 db4.3 4.3.28-1 diffutils 2.8.7-1 editrights 1.01-1 expat 1.95.8-1 findutils 20041227-1 gawk 3.1.5-1 gcc-core 3.4.4-1 gcc-g++ 3.4.4-1 gcc-mingw-core 20050522-1 gcc-mingw-g++ 20050522-1 gdbm 1.8.3-7 grep 2.5.1a-2 groff 1.18.1-2 gzip 1.3.5-1 less 381-1 libbz2_1 1.0.3-1 libcharset1 1.9.2-1 libdb2 2.7.7-4 libdb2-devel 2.7.7-4 libdb3.1 3.1.17-2 libdb3.1-devel 3.1.17-2 libdb4.1 4.1.25-1 libdb4.1-devel 4.1.25-1 libdb4.2 4.2.52-1 libdb4.2-devel 4.2.52-1 libdb4.3 4.3.28-1 libdb4.3-devel 4.3.28-1 libgdbm 1.8.0-5 libgdbm-devel 1.8.3-7 libgdbm3 1.8.3-3 libgdbm4 1.8.3-7 libiconv 1.9.2-1 libiconv2 1.9.2-1 libintl 0.10.38-3 libintl1 0.10.40-1 libintl2 0.12.1-3 libintl3 0.14.1-1 libncurses5 5.2-1 libncurses6 5.2-8 libncurses7 5.3-4 libncurses8 5.4-2 libpcre 4.1-1 libpcre0 4.5-1 libpopt0 1.6.4-4 libreadline4 4.1-2 libreadline5 4.3-5 libreadline6 5.0-4 login 1.9-7 m4 1.4.3-1 make 3.80-1 man 1.5p-1 mingw-runtime 3.7-1 mktemp 1.5-3 ncurses 5.4-2 openssl 0.9.8-2 openssl097 0.9.7g-1 perl 5.8.7-3 postgresql 7.4.5-1 readline 5.0-4 sed 4.1.4-1 tar 1.13.25-7 termcap 20050421-1 terminfo 5.4_20041009-1 texinfo 4.8-1 vim 6.3-1 w32api 3.2-1 which 1.7-1 zlib 1.2.2-2 Use -h to see help about each section --Boundary-00=_qb39Cl3/ZBVHaKK Content-Type: text/x-csrc; charset="utf-8"; name="rs232.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rs232.c" // transportation of the playing Title of the "digitalen Campusradio bit eXpress" to the Internet #include #include #include #include #include #include #include // modem #define MODEMDEVICE "com2" //#define MODEMDEVICE "/dev/ttyS0" // output-files #define PLAY "aktuell.txt" #define HISTORY "older.txt" int main() { // global variables int fd, result, start, pos; FILE *fd2, *fd3; char str[2], title[200]; struct termios termios_p; time_t t; struct tm tm; // Modem fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) {printf("could not open serialport"); return -1;}; fcntl(fd, F_SETFL, 0); //get the current options tcgetattr(fd, &termios_p); cfsetispeed(&termios_p, B9600); cfsetospeed(&termios_p, B9600); termios_p.c_cflag |= (CLOCAL | CREAD); termios_p.c_cflag &= ~PARENB; // parity no termios_p.c_cflag &= ~CSTOPB; // stop bit 1 termios_p.c_cflag &= ~CSIZE; // Mask the character size bits termios_p.c_cflag |= CS8; // Select 8 data bits termios_p.c_cflag &= ~CRTSCTS; // disable hardware flow control termios_p.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // RAW Input termios_p.c_oflag &= ~OPOST; // RAW output //set the options tcsetattr(fd, TCSANOW, &termios_p); tcflush(fd,TCIOFLUSH); start = 0; pos = 0; while(1) { result = read(fd, str, 1); if(result != -1) { printf("0x%x %c\n", str[0], str[0]); if(str[0] == 0x02) {start = 1; pos = 0;} else if (str[0] == 0x03) {start = 0; title[pos] = '\0'; // write to file fd2 (now playing title) fd2 = fopen(PLAY, "w"); if (fd2 < 0) {printf("error open file %d\n"), PLAY; return -1;} fprintf(fd2, "%s", &title[2]); fclose(fd2); // write to file fd3 (history file) fd3 = fopen(HISTORY, "a"); if (fd3 < 0) {printf("error open file %d\n"), HISTORY; return -1;} time(&t); localtime_r(&t, &tm); fprintf(fd3, "%d-%02d-%02d %02d:%02d:%02d %s\n", 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, &title[2]); fclose(fd3); } else {if (start = 1) {title[pos++] = str[0];}} } } } --Boundary-00=_qb39Cl3/ZBVHaKK Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --Boundary-00=_qb39Cl3/ZBVHaKK--