Error de lectura de serie de Linux

Estoy intentando leer desde mi puerto serie usando el siguiente código C. Puedo escribir con éxito en una computadora que escucha (¡sí!) Pero la lectura arroja un error (Código 11 - Recurso temporalmente no disponible). También he notado que mis mensajes / registros de dmesg no tienen información sobre fallas, etc. Eso está bien.

//A bunch of INCLUDES exist here....the the code

int fd=0;
int status=0;
int running=1;
char buffer[100];
char message[7];

void main(){
    fd = 1;

    fd=open("/dev/ttyM0",O_RDWR | O_NOCTTY);

    if(fd == -1)
    {
        perror("open_port: Unable to open /dev/ttys0");
    }
    else
    {
        while(running<20)
        {
            sprintf(message,"Test%d\r",running);
            status=write(fd,message,6);

            if(status<0)
            {
                printf("Error Writing. Status=%d\n %s\n",errno, strerror(errno));
            }
            status=read(fd,buffer,8);  //This throws an error(11). My connected device is writing "Testing/r"

            if(status<0)
            {
                printf("Error Reading. Status=%d \n%s\n",errno, strerror(errno));
                //close(fd);
                running=running+1;
            }
            else
            {
                printf("%s\n\r",buffer);
            }
            sleep(2);
        }
        close(fd);
    }

} //END MAIN

Estas son mis configuraciones en serie para mi puerto. Estoy intentando leer / escribir a 9600 8 bits, sin paridad, 1 bit de parada. Creo que mi configuración es correcta.

sudo stty -a -F /dev/ttyM0 
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany
-imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

Cualquier ayuda sería muy apreciada. ¡Gracias!

Respuestas a la pregunta(3)

Su respuesta a la pregunta