This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Trouble using scanf

Hallo to everyone.
I still use CARM and there's a bug using scanf:

    scanf("%c",&my_key);


if PC sends CHR$(0) to the ADuC microcontroller the scanf does'nt change the content of "my_key".
So i get the last received again

My fix-up is:

    my_key = 0;
    scanf("%c",&my_key);


Now i can receive a CHR$(0) also.

Is this a known bug or a feature? :-)

I have some additional trouble when the ADuC sends a string to PC, for example

    printf("A 37 180\n");


The string is always similar:
A letter (A-Z) and two numbers closed with \n

Sometimes the PC is loosing a number of my string :-(

I'am despaired, yes of course maybee i could fix it with some checksum-handshake-algorithm...

I'am using only RX & TX.

CTS & RTS are connected.
DCD & DTR & DSR are connected.

On PC-side i use INT14h Function 0..3
to handle RS232. Baudrate is 115200

Ideas welcome

0