avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avrdude-dev] Re: FIXED: was avrdude prb [RE: [avr-gcc-list] printf_P +


From: Theodore A. Roth
Subject: [avrdude-dev] Re: FIXED: was avrdude prb [RE: [avr-gcc-list] printf_P + PSTR("\n\r") does not seem towork,however ("\r\n") is okay]
Date: Thu, 12 Aug 2004 15:18:57 -0700 (PDT)

On Thu, 12 Aug 2004, E. Weddington wrote:

> Theodore A. Roth wrote:
>
> >I have this nagging feeling that you have exposed a bug in avrdude. I
> >suspect that you are using avrdude on windows that avrdude is opening
> >the binary file for reading using
> >
> >  fopen (file, "r");
> >
> >when it should be using
> >
> >  fopen (file, "rb");
> >
> >If memory serves, "r" and "rb" are the same on most Unix systems, but
> >have a subtle difference on Windows (end-of-line translation?). Any
> >windows experts care to comment on this?
> >
> >
> Hmm. It looks  like this was supposed to be taken care of. See fileio.c,
> function fileio() (line 890 according to 4.4.0 sources). There's a
> conditional compilation for Windows.
>
> I've also CC'd avrdude-dev.

I think that's just another case of an #if that should not even be
there.

>From the man page for fopen(3) on linux:

 The mode string can also include the letter  ``b''  either  as  a  last
 character  or  as a character between the characters in any of the two-
 character strings described above.  This is strictly for  compatibility
 with  ANSI  X3.159-1989  (``ANSI  C'')  and has no effect; the ``b'' is
 ignored on all POSIX conforming systems, including Linux.  (Other  sys-
 tems  may treat text files and binary files differently, and adding the
 ``b'' may be a good idea if you do I/O to a binary file and expect that
 your program may be ported to non-Unix environments.)

If it's a binary file, just use "wb" or "rb" on all systems.

$ grep -n fopen *.c
fileio.c:834:  f = fopen(fname, "r");
fileio.c:979:      f = fopen(fname, fio.mode);
main.c:159:  f = fopen(file, "r");

The first one in fileio.c should probably be "rb" (it's in the
fmt_autodetect function).

The one is main is probably ok (it's reading the config file).

Is there any chance that there could be some sort of translation going
on with either the serial or parallel port interfaces?

In ser_win32.c, I see this to open the serial port:

    hComPort = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
                OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);


---
Ted Roth
PGP Key ID: 0x18F846E9
Jabber ID: address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]