L
lynology
I need help trying to figure why this piece of code gives me a "Bad
File descriptor error" everytime I try to run it and invoke fflush.
This piece of code simple outputs a char string to the output stream.
What ends up happening instead is that when outputting the first
character string to the channel CG_cdukeypad_CHA.Scrpad, its gives the
bad file descriptor error, causing the char string not to output. When
a second char string is received by the pointer and copied to the
channel, the first character string appears on the output stream
without the error message. When the third char string is received, the
second char string appears on the output stream w/o the error msg, so
on and so forth.
Quote:
CG_cdukeypad_CHA.Scrpad is a channel to the output stream.
cdukeypad->Scrpad points to the value that I want to pass to the
output stream.
File descriptor error" everytime I try to run it and invoke fflush.
This piece of code simple outputs a char string to the output stream.
What ends up happening instead is that when outputting the first
character string to the channel CG_cdukeypad_CHA.Scrpad, its gives the
bad file descriptor error, causing the char string not to output. When
a second char string is received by the pointer and copied to the
channel, the first character string appears on the output stream
without the error message. When the third char string is received, the
second char string appears on the output stream w/o the error msg, so
on and so forth.
Quote:
CG_cdukeypad_CHA.Scrpad is a channel to the output stream.
cdukeypad->Scrpad points to the value that I want to pass to the
output stream.
Code:
if (strlen(cdukeypad->Scrpad) > 0){
printf("Character received is %s.\n", cdukeypad->Scrpad);
if (strlen(CG_cdukeypad_CHA.Scrpad) < 25){
strcat(CG_cdukeypad_CHA.Scrpad, cdukeypad->Scrpad);
}
if (fflush(NULL) == EOF){
VP_INFO(("Error writing text to Scratchpad.\n"));
VP_INFO(("Error is %s\n", strerror(errno)));
}
}