janizary
04/02/2008, 15:40
Linux da c ile seri portta veri yazdırabiliyorum fakat veri okurken çoğunlukla hatalı geliyor. Kodda ne gibi sorun var çözemedim. Ayrıca seri portlarla ilgili elinde döküman olan varsa yollarsanız sevinirim.
int porttan_oku(int fd)
{
char buf[255];
int res=read(fd,buf,255);
if (res < 0) {
if (errno == EAGAIN) {
printf("\nSERIAL EAGAIN ERROR\n");
return 0;
} else {
printf("SERIAL read error %d %s\n", errno, strerror(errno));
return 0;
}
}
int a=0;
printf("portdan okunan: ");
for(a=0; a<res; a++)
{
printf("%c",buf[a]);
}
printf("\n");
return 1;
}
int porttan_oku(int fd)
{
char buf[255];
int res=read(fd,buf,255);
if (res < 0) {
if (errno == EAGAIN) {
printf("\nSERIAL EAGAIN ERROR\n");
return 0;
} else {
printf("SERIAL read error %d %s\n", errno, strerror(errno));
return 0;
}
}
int a=0;
printf("portdan okunan: ");
for(a=0; a<res; a++)
{
printf("%c",buf[a]);
}
printf("\n");
return 1;
}