All of lore.kernel.org
 help / color / mirror / Atom feed
From: darshan.ghumare@gmail.com
To: linux-c-programming@vger.kernel.org
Subject: Not able to upgrade firmware through serial port
Date: Tue, 12 Oct 2010 01:40:22 -0400	[thread overview]
Message-ID: <8239415.11286862022251.JavaMail.root@wombat> (raw)


Hi,

   This is Darshan (darshan.ghumare@gmail.com).
   I have a Linux based board which has one serial port (so, stdin == stdout == stderr == /dev/ttyS0). I want to send Firmware over a serial port using Y-Modem protocol. But, when I poll on given fd (after sending ASCII 'C') its got time out. Please tell me what could be problem here. I am using HyperTerminal which is connected to my board's serial port. So, neither the HyperTerminal (only when it has launched dialogue box to send firmware to the board using Y-Modem) able to read data send by the board nor board able to read data send by the HyperTerminal. But when I type on HyperTeminal then the board got the key-strokes (thats why I can atleast browse through the GUI).
   The same serial port is being used to render (VT100 based) GUI. I have managed to disable printk(s) after user-mode is up & running.
   Yes one more thing, I have also tried rz(1) but still facing the same problem.

    My current serial port settings is,

int serial_init()
{
     int serial_port_fd = -1;
     tcflag_t serial_baud =  B115200;
     struct termios old_attr,new_attr;

    memset(&new_attr,'0',sizeof(new_attr));
    memset(&old_attr,'0',sizeof(old_attr));

    serial_port_fd = open(SERIAL_PORT,O_RDWR | O_NOCTTY);
    if(serial_port_fd == -1) {
        log_msg(MODULE("serial_init : %s"),strerror(errno));
        return -1;
    }

    if(tcgetattr(serial_port_fd,&old_attr) == -1) {
        log_msg(MODULE("serial_init : %s"),strerror(errno));
        close(serial_port_fd);
        serial_port_fd = -1;
        return -1;
    }

    new_attr.c_cflag = serial_baud | CRTSCTS | CLOCAL | CREAD | CS8;
    new_attr.c_iflag = IGNPAR; //| ICRNL;
    new_attr.c_cc[VEOF] = 4;
    new_attr.c_cc[VMIN] = 1;

    if(tcflush(serial_port_fd,TCIOFLUSH) == -1) {
        log_msg(MODULE("serial_init : %s"),strerror(errno));
        close(serial_port_fd);
        serial_port_fd = -1;
        return -1;
    }

    if(tcsetattr(serial_port_fd,TCSANOW,&new_attr) == -1) {
        log_msg(MODULE("serial_init : %s"),strerror(errno));
        close(serial_port_fd);
        serial_port_fd = -1;
        return -1;
    }

    if(set_nonblocking(serial_port_fd) == -1) {
        log_msg(MODULE("serial_init : Not able to set fd non-blocking"));
        close(serial_port_fd);
        serial_port_fd = -1;
        return -1;
    }

    if(init_pollfd_slot(SERV_SERIAL_CONN,serial_port_fd,(POLLIN | POLLRDNORM | POLLRDBAND)) != 0) {
        log_msg("%s: Not able to init pollfd slots.\n",__FUNCTION__);
        close(serial_port_fd);
        serial_port_fd = -1;
        return -1;
    }
    dup(0);
    dup(0);
    printf("(%s:%d)%d END\n", __FUNCTION__, __LINE__, fcntl(serial_port_fd, F_GETFL));
    return 0;
}


    Thank you in anticipation.

Regards
Darshan


--
This message was sent on behalf of darshan.ghumare@gmail.com at openSubscriber.com
http://www.opensubscriber.com/messages/linux-c-programming@vger.kernel.org/topic.html

                 reply	other threads:[~2010-10-12  5:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8239415.11286862022251.JavaMail.root@wombat \
    --to=darshan.ghumare@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.