AnsweredAssumed Answered

STM32L152C6 USB-FS virtual COM port

Question asked by mihaylov.kaloyan on Aug 15, 2013
Latest reply on Aug 16, 2013 by mihaylov.kaloyan
Hello. I am using the MCU with the USB-FS library. I ran the examples successfully and I can send and receive characters via PuTTY. I've also hardcoded several messages in the program, so I can debug it easily.
Now I'm trying to parse some of the sent strings, however I have strange problem.

When the letters are send, I put them in cumulative array. Then with for loop I'm searching for space or \r symbol, so I can parse the first word (which I'll use later as a command send to the MCU). When the string doesn't match any of the commands, messache should be print (like commands are: cmd1 cmd2).

However, in the PuTTY window I'm getting only emtpy spaces or new lines. If I force send the (wrong) command many times, I get only part of the error message. The tricky part is that if I step the program with the debugger, I'm getting all the messages exactly the way I want.

I'm retargeting printf directly: printf(char const *data, ...) {
02.  //if( bDeviceState == UNCONNECTED ) return 0;
03.  uint8_t size = strlen( data );
04.  if( size < 64 ) {
05.    while( bDeviceState != CONFIGURED ) {}
06.    CDC_Send_DATA( (unsigned char*) data, size );
07.  }
08.  return 0;

Any ideas are welcome!