FreeCalypso > hg > freecalypso-sw
view loadtools/sercomm.c @ 24:9ee91bc6057c
loadagent buglet in the memory dump command argument parsing
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 04 May 2013 04:57:43 +0000 |
parents | fea204bc7674 |
children | 54392d1ea474 |
line wrap: on
line source
/* * This module handles the establishment of serial communication * with the target, i.e., the host-side termios stuff. */ #include <sys/types.h> #include <sys/file.h> #include <sys/ioctl.h> #include <termios.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> char *target_ttydev; int target_fd; struct termios target_termios; open_target_serial() { target_fd = open(target_ttydev, O_RDWR|O_NONBLOCK); if (target_fd < 0) { perror(target_ttydev); exit(1); } target_termios.c_iflag = IGNBRK; target_termios.c_oflag = 0; target_termios.c_cflag = CLOCAL|HUPCL|CREAD|CS8; target_termios.c_lflag = 0; target_termios.c_cc[VMIN] = 1; target_termios.c_cc[VTIME] = 0; /* start at B19200, as that's what we'll need to use initially */ cfsetispeed(&target_termios, B19200); cfsetospeed(&target_termios, B19200); if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) { perror("initial tcsetattr on target"); exit(1); } return 0; } switch_baud_rate(code) { cfsetispeed(&target_termios, code); cfsetospeed(&target_termios, code); if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) { perror("tcsetattr to switch baud rate"); exit(1); } }