gets function giving problem Ameya Hardikar
Dear All,
I am trying to read some float values/strings from a serial port. A VB based front end application sends me these values over a serial port.The communication between the front end application and firmware is ok. i.e. I am able to read single characters send by application and application is able to read values which my firmware is sending. But whenever I try to read values from serial port using gets function or scanf function then sometimes it works and sometimes not. And when it works 'gets' does not assigns all values received to the string variable. e.g. if i am receiving "Ameya" then only "mey" is received. At the same time this code works fine on a keil debugger. I am using customized forms of putchar() and _getkey() functions... Also I have tried sending CR/LF characters from VB application for which gets waits..but the problem still persists. I am wondering if it is working with keil debugger what could be problem..? Please help me ..
"Are you trying to process data in the interupt? If not you need to."
No! You should not try to process it in the interrupt!
The interrupt should do just the minimum to snatch it from the UART and put it into a buffer - the actual processing should be done in the main code...
This is well illustrated in the interrupt-driven serial examples provided by Keil; eg, http://www.keil.com/download/docs/200.asp