fixed serial port reading and interface setup bugs.

now crashes when trying to tick packet radio interface.
This commit is contained in:
gardners 2013-02-05 06:33:52 +10:30 committed by Jeremy Lakeman
parent 7287a2d599
commit a4bfdc6c75
2 changed files with 16 additions and 11 deletions

View File

@ -454,14 +454,19 @@ overlay_interface_init(const char *name, struct in_addr src_addr, struct in_addr
if (interface->type!=OVERLAY_INTERFACE_PACKETRADIO) {
interface->alarm.function=overlay_dummy_poll;
dummy_poll_stats.name="overlay_dummy_poll";
} else {
interface->alarm.function=overlay_packetradio_poll;
dummy_poll_stats.name="overlay_packetradio_poll";
}
interface->alarm.alarm=gettime_ms()+10;
interface->alarm.deadline=interface->alarm.alarm;
interface->alarm.stats=&dummy_poll_stats;
schedule(&interface->alarm);
} else {
interface->alarm.function=overlay_packetradio_poll;
dummy_poll_stats.name="overlay_packetradio_poll";
interface->alarm.poll.events=POLLIN;
watch(&interface->alarm);
if (config.debug.packetradio)
DEBUGF("Watching file descriptor #%d for packet radio interface",
interface->alarm.poll.fd);
}
interface->state=INTERFACE_STATE_UP;
if (interface->type!=OVERLAY_INTERFACE_PACKETRADIO)

View File

@ -17,8 +17,6 @@ int overlay_packetradio_setup_port(overlay_interface *interface)
{
struct termios t;
set_nonblock(interface->alarm.poll.fd);
tcgetattr(interface->alarm.poll.fd, &t);
// XXX Speed and options should be configurable
cfsetispeed(&t, B57600);
@ -29,11 +27,11 @@ int overlay_packetradio_setup_port(overlay_interface *interface)
t.c_cflag &= ~CSIZE;
t.c_cflag |= CS8;
// Disable CTS/RTS flow control (for now)
// Enable CTS/RTS flow control (for now)
#ifndef CNEW_RTSCTS
t.c_cflag &= ~CRTSCTS;
t.c_cflag |= CRTSCTS;
#else
t.c_cflag &= ~CNEW_RTSCTS;
t.c_cflag |= CNEW_RTSCTS;
#endif
// and software flow control
t.c_iflag &= ~(IXON | IXOFF | IXANY);
@ -44,6 +42,8 @@ int overlay_packetradio_setup_port(overlay_interface *interface)
tcsetattr(interface->alarm.poll.fd, TCSANOW, &t);
set_nonblock(interface->alarm.poll.fd);
return 0;
}
@ -165,7 +165,7 @@ void overlay_packetradio_poll(struct sched_ent *alarm)
interface->last_tick_ms=now;
}
schedule(alarm);
watch(alarm);
return ;
}