Ok, working with CDC example that you posted Erich. In trying to understand the code you provided for responding to a string sent from a Terminal program with a string and data:
I am not sure how not to let the input buffer overflow, but all I really want to do is in HyperTerminal or equiv. hit return and retrieve some logged data. With my hack below I am basically returning the same string the entire length of input buffer to Hyperterminal.
Question: How can I empty what Hyperterminal sends [clear the input buffer] and just return a string and the data such as Time_On_Hour?
Basically my program calls your routine periodically to see if data is requested from Hyperterminal then gets back to work.
static void CDC_Run(void) {
int i;
extern uint32_t Time_On_Hours;
unsigned char buf[16];
while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
/* device not enumerated */
LEDR_Neg(); LEDG_Off();
WAIT1_Waitms(10);
}
LEDR_Off(); LEDG_Neg();
if (CDC1_GetCharsInRxBuf()!=0) {
while(CDC1_GetChar(&in_buffer[i])==ERR_OK){i++;}
}
in_buffer[i] = '\0';
(void)CDC1_SendString((unsigned char*)"Time on Hours: "); //do I need this?
(void)CDC1_SendString(in_buffer);
UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"Time_On_Hours ");
UTIL1_strcatNum32u(buf, sizeof(buf), Time_On_Hours);
UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r");
(void)CDC1_SendString(buf);
}