Je développe actuellement une petite application pour point d'acces à architecture MIPS.
voici le code qui me pose probleme :
/* Standard input/output definitions */
#include /* POSIX terminal control definitions */
#include
#include /* File control definitions */
int initport (int fd)
{
struct termios options;
// Récuperation d'options courante
tcgetattr(fd, &options);
// Vitesse In/out.
cfsetispeed(&options, B9600);
cfsetospeed(&options, B9600);
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
// Applique la nouvelle config
tcsetattr(fd, TCSANOW, &options);
return 1;
}
int main ()
{
int fd;
fd = open("/dev/tts/0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) {
perror("Impossible d'ouvrir le port /dev/ttys/0 - ");
return 1;
} else {
fcntl(fd, F_SETFL, 0);
}
initport(fd);
write(fd, "test", 4);
close(fd);
return 0;
}
[/code]
À la compilation, pas de soucis, tout se passe bien. Mais quand je lance mon programme via SSH sur le point d'acces, il me dit :
[quote"OpenWRT"]./serial: ./serial: 4: Syntax error: "(" unexpected[/quote]
C'est étrange puis-ce que ce que je lui donne est déjà compilé... Pourquoi me renvoie-t-il ça? D'autant plus que je ne vois pas d'où peut provenir l'erreur.
J'ai pensé à un bug du cross-compilateur qui me donnerait des binaires porteurs de messages psychedéliques (la vérité est ailleur!) mais je n'y crois pas trop.
Mon point d'acces est sous OpenWrt
Pourriez vous m'aider à y voir plus clair ?
merci, ++ Tixlegeek.