pratiken
Newbie level 5
- Joined
- Mar 13, 2014
- Messages
- 9
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 85
Hey guys,
I don't totally understand why my emulator is doing this.
I can successfully connect to my PIC18F2550 device via serial COM port using Putty.
The issue is that it records every keystroke before hitting enter, even if I use the backspace due to a typo.
For example, "Command 1"
If I type "Command 1" without any mistakes, it's fine and the command is executed.
If I make a typo and hit backspace to fix, then press Enter, the command is not recognized even though I had "Command 1" entered in terminal.
Somehow, it's picking up all keystrokes prior to the Enter key. Any ideas why this would be?
Thanks for any help!!!
I don't totally understand why my emulator is doing this.
I can successfully connect to my PIC18F2550 device via serial COM port using Putty.
The issue is that it records every keystroke before hitting enter, even if I use the backspace due to a typo.
For example, "Command 1"
If I type "Command 1" without any mistakes, it's fine and the command is executed.
If I make a typo and hit backspace to fix, then press Enter, the command is not recognized even though I had "Command 1" entered in terminal.
Somehow, it's picking up all keystrokes prior to the Enter key. Any ideas why this would be?
Thanks for any help!!!
Code:
/********************************************************************
* Function: void ProcessIO(void)
* Overview: This function is a place holder for other user
* routines. It is a mixture of both USB and
* non-USB tasks.
*******************************************************************/
void ProcessIO(void)
{
BYTE numBytesRead;
// User Application USB tasks
if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;
if (USBUSARTIsTxTrfReady())
{
numBytesRead = getsUSBUSART(USB_Out_Buffer, 64);
if (numBytesRead != 0)
{
if (USB_Out_Buffer[0] == '\r') //Received ENTER? Ues-> End of Command
{
command_recvd = 0x01;
Command[pos++] = '\0';
putUSBUSART((char*) USB_Out_Buffer, 1);
pos = 0;
} else { Command[pos++] = USB_Out_Buffer[0]; Command[pos]='\0';} //No:- Store Character to String
if (command_recvd == 0x01)
{
if (strcmp((char*) Command, (char*) "Command 1") == 0)
{
// COMMAND CODE HERE
}
else
{
InvalidCommand = 0x01;
}
Command[0]='\0';
if (InvalidCommand ==0x00) { sprintf(output_message, "\r\nCommand Sent...!!!!\r\n");} else {
InvalidCommand=0x00;
sprintf(output_message, "\r\nInvalid Command..!!\r\n");}
putUSBUSART((char*) output_message, sizeof (output_message));
command_recvd = 0x00;
}
}
}
CDCTxService();
}