linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* upgrade firmware
@ 2010-10-12  5:44 darshan.ghumare
  0 siblings, 0 replies; only message in thread
From: darshan.ghumare @ 2010-10-12  5:44 UTC (permalink / raw)
  To: linux-c-programming


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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-10-12  5:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-12  5:44 upgrade firmware darshan.ghumare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).