I posted a problem about 'strcmp' in another post earlier today. I programming our robot to use a command line interface to accept commands over the serial port. This is wired to usart1 on a ATMega128 on a Olimex AVR-MT-128 controller with a DB-9 onboard.
Below is each test code and output showing that I get two diff results when using 'strcmp'. I don't know why this is happening.
Basically, 'strcmp' is supposed to return a 0 when the compare is true. This does happen when using 'fgets' to enter a string.
But in my other test code, where I use interrupts on the usart, the 'strcmp' *does not* return a 0 when the compare is true. Instead, it returns a 13. So I had to edit my test code in order to get it to work.
I hope somebody knows about this. In the meantime, I have to use '13' instead of '0' when using 'strcmp', this is how I have to get my robot to work properly.
Sunday, August 1, 2010
C code: Some weirdness with 'strcmp' when using Interrupts with UART
Below is an excerpt from the post I put on AVR Freaks under AVR Forum about this weird problem involving the 'strmp' library function. This was burning my metallic butt all week. I have a simple workaround to continue coding for now. The complete post with test code and display output can be see at this [link] If you night have any suggestions feel free to post here or on AVR Freaks.
Subscribe to:
Post Comments (Atom)
Fixed it !!!
ReplyDeleteYou can see the results at the same link on AVR Freaks
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=96429