delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/10/14/04:00:11

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-ID: <434f657b$0$177$cc7c7865@news.luth.se>
From: Martin Str|mberg <ams AT speedy DOT ludd DOT ltu DOT se>
Subject: Re: reading from com1: => driving me nuts
Newsgroups: comp.os.msdos.djgpp
References: <1h4c4cp.1b942cr1g5grtnN%muellernick AT gmx DOT de>
User-Agent: tin/1.4.6-20020816 ("Aerials") (UNIX) (NetBSD/1.6Q (alpha))
Date: 14 Oct 2005 07:59:55 GMT
Lines: 36
NNTP-Posting-Host: speedy.ludd.ltu.se
X-Trace: 1129276795 news.luth.se 177 130.240.16.13
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Nick Muller <muellernick AT gmx DOT de> wrote:
> So now I want to establish a communication from within my C-program
> (using djgpp, of course). I do the following:

> set propper params with MODE com1:blablabla


> FILE* file;
> int c;

> file = fopen("com1:", "ab");
> if (file != NULL) {
>   while ((c = fgetc(file)) != EOF)
>     printf("%i ", c);
> }

> What is happening?
> I can send characters to the uC that are propperly understood and the uC
> is sending the answer. **BUT** I always get 16382 CHR0 on the DOS-side.
> If the uC is not answering, I get 0 characters from file.

One thing that is a little strange to me is that you've opened the
device in append mode, which means that you seek on a device. I
haven't messed with devices (and serial ports) so I could be wrong,
but does a device support seeking? Does some? Does serial ports?

> Oh, if it makes a difference, I (currently) let my program run in a
> DOS-box under Win XP pro.

Again I haven't done any serial port programming, but isn't WINDOWS
NT/2000/XP DOS emulation a little weird with regards to any ports?


Right,

						MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019