add hook for transmitting packet via packet radio interface.

make serial port non-blocking (which for some reason has also
killed our ability to read from it :/).
This commit is contained in:
gardners 2013-02-05 06:19:48 +10:30 committed by Jeremy Lakeman
parent 0268ccd21a
commit 7287a2d599
3 changed files with 18 additions and 1 deletions

View File

@ -670,7 +670,9 @@ overlay_broadcast_ensemble(int interface_number,
return WHYF("Cannot send to interface %s as it is down", interface->name); return WHYF("Cannot send to interface %s as it is down", interface->name);
} }
if (interface->fileP) if (interface->type==OVERLAY_INTERFACE_PACKETRADIO) {
return overlay_packetradio_tx_packet(interface_number,recipientaddr,bytes,len);
} else if (interface->fileP)
{ {
struct dummy_packet packet={ struct dummy_packet packet={

View File

@ -16,6 +16,9 @@
int overlay_packetradio_setup_port(overlay_interface *interface) int overlay_packetradio_setup_port(overlay_interface *interface)
{ {
struct termios t; struct termios t;
set_nonblock(interface->alarm.poll.fd);
tcgetattr(interface->alarm.poll.fd, &t); tcgetattr(interface->alarm.poll.fd, &t);
// XXX Speed and options should be configurable // XXX Speed and options should be configurable
cfsetispeed(&t, B57600); cfsetispeed(&t, B57600);
@ -40,6 +43,7 @@ int overlay_packetradio_setup_port(overlay_interface *interface)
t.c_oflag &= ~OPOST; t.c_oflag &= ~OPOST;
tcsetattr(interface->alarm.poll.fd, TCSANOW, &t); tcsetattr(interface->alarm.poll.fd, TCSANOW, &t);
return 0; return 0;
} }
@ -166,3 +170,11 @@ void overlay_packetradio_poll(struct sched_ent *alarm)
return ; return ;
} }
int overlay_packetradio_tx_packet(int interface_number,
struct sockaddr_in *recipientaddr,
unsigned char *bytes,int len)
{
if (config.debug.packetradio) DEBUGF("Sending packet of %d bytes",len);
return 0;
}

View File

@ -753,6 +753,9 @@ int fd_poll();
void overlay_interface_discover(struct sched_ent *alarm); void overlay_interface_discover(struct sched_ent *alarm);
void overlay_packetradio_poll(struct sched_ent *alarm); void overlay_packetradio_poll(struct sched_ent *alarm);
int overlay_packetradio_setup_port(overlay_interface *interface); int overlay_packetradio_setup_port(overlay_interface *interface);
int overlay_packetradio_tx_packet(int interface_number,
struct sockaddr_in *recipientaddr,
unsigned char *bytes,int len);
void overlay_dummy_poll(struct sched_ent *alarm); void overlay_dummy_poll(struct sched_ent *alarm);
void overlay_route_tick(struct sched_ent *alarm); void overlay_route_tick(struct sched_ent *alarm);
void server_config_reload(struct sched_ent *alarm); void server_config_reload(struct sched_ent *alarm);