Code:
int main(int argc, char **argv)
{
FILE *input,*output;
char text[10000];
int i;
input = fopen("/dev/ttyAM2", "r"); //open the terminal keyboard
output = fopen("/dev/ttyAM2", "w"); //open the terminal screen
while(1)
{
// fputc(i, output);
// fputc('\n', output);
fputs("022078176708\n", output); // works only with end of line
sleep(1);
fscanf(input, "%s",text); // worked with fputc(i), + putc('\n')
}
fclose(output);
fclose(input);
return 0;
}
I am trying to receive serial input from a hardware device that transmits ascii data. The problem seems to be that the data does not have any control characters in it and none of the constructs that I have used so far (fscanf, fgetc, fgets, fread or read) seem to be able to see what is in the buffer.
As an experiment I tied the receive and transmit lines together (this is on an embedded Linux system), and send data out on the xmit side and try to read it on the rcv side. It seems that the only way the data makes it through is when there is a newline sent along with the data. Unfortunately the device I need to listen to has no such output.
I know this can be done, but have never seen it. Any ideas would be appreciated.