Hi,
I have a configuration consisting of:
1. my Atmega168 MCU connected to some servo motors and sensors, and
2. my Linksys WRT54GL router working under OpenWRT Linux WhiteRussian 9.
3. they have a working and tested serial connection.
Now my problem.
I open a file descriptor to my serial port called /dev/tts/1, and read a sensor (the second
sensor commented, as you see bellow). This works perfect. Then I uncomment the next
sensor, but the code continues to behave as if I didn't uncomment it!
If before the reading of the next sensor I first close my original file descriptor and reopen it, it
starts to work right, but this is inefficient, as I have various sensors and it is not logical to open
and close port for each of them!
Reading Ultrasonic first, and then Digital encoders or vice versa makes no difference.
The code in my MCU is fairly simple and tested. It does nothing but read/write as Linux
commands.
How can I approach to reveal where the problem is?
Linux code:
Code:
//motorController opens "/dev/tts/1" serial port.
bzero(buffer,256);
while(1==1)
{
fprintf(motorController, "@sp\n" ); //s:sensor, p:ping.
fscanf(motorController, "%s", buffer);
printf("Ping: %s\n", buffer);
bzero(buffer,256);
/*
fprintf(motorController, "@sel\n" ); //e: encoder, l:left.
fscanf(motorController, "%s", buffer);
printf("Left Encoder: %s\n", buffer);
bzero(buffer,256);
*/
}
fclose(motorController);
return 0;
}