With the code below I am trying to send "AT\r" to the modem and I am expecting "OK\r" back but I am not getting it, I am getting "AT\r" back. Any ideas or pointers? Also I know I am opening the correct device and I have tested the modem in windows using hyperterminal and I do get "OK\r" back. Thanks

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include "sort.h"

int init_modem(int fd);

int main(int argc, char** argv)
    int fd;
    struct termios options;

    fd = open(argv[1], O_RDWR | O_NOCTTY | O_NDELAY);
    fcntl(fd, F_SETFL, 0);

    tcgetattr(fd, &options);

    options.c_cflag |= (CLOCAL | CREAD);
    options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
    options.c_oflag &= ~OPOST;
    options.c_cc[VMIN] = 3;
    options.c_cc[VTIME] = 10;

    tcsetattr(fd, TCSANOW, &options);

    printf("Return: %d\n", init_modem(fd));

    return 0;

int init_modem(int fd)
    char buffer[4];
    char *bufptr;
    int num;

        if(write(fd, "AT\r", 3) < 3)

        num = read(fd, buffer, 3);

        buffer[3] = '\0';

        printf("Number: %d\n", num);
        printf("Buffer: %s\n", buffer);