24 Commits
v0.3 ... v0.3.3

Author SHA1 Message Date
Gerolf Ziegenhain
183e60aa16 adjust interface number 2016-10-03 16:30:35 +02:00
Gerolf Ziegenhain
fde22697d8 cleanup beep buzzer 2016-10-03 16:26:58 +02:00
Gerolf Ziegenhain
5286a77c70 reduced docu 2016-10-03 16:25:37 +02:00
Gerolf Ziegenhain
b29dc7281a cleanup beep 2016-10-03 16:23:41 +02:00
Gerolf Ziegenhain
ac49de555a new beep without jitter 2016-10-03 16:18:56 +02:00
Gerolf Ziegenhain
07d5b97912 wip 2016-10-03 16:15:34 +02:00
Gerolf Ziegenhain
b8603fd9d0 wip 2016-10-03 16:13:59 +02:00
Gerolf Ziegenhain
6d8fee68f4 example 2016-10-03 16:02:17 +02:00
Gerolf Ziegenhain
9838719a50 protocol 2016-09-24 17:03:30 +02:00
Gerolf Ziegenhain
c12478241a rename 2016-09-24 16:56:31 +02:00
Gerolf Ziegenhain
5842d754da wip 2016-09-24 16:55:57 +02:00
Gerolf Ziegenhain
54cb98634e sort functions 2016-09-24 16:55:36 +02:00
Gerolf Ziegenhain
0252a2803b wip 2016-09-24 16:34:20 +02:00
Gerolf Ziegenhain
2445a111f3 sort headers 2016-09-24 16:28:30 +02:00
Gerolf Ziegenhain
d91a7b2a29 wip 2016-09-24 16:21:29 +02:00
Gerolf Ziegenhain
910b60eb37 rm commandmode 2016-09-24 15:59:41 +02:00
Gerolf Ziegenhain
8f7648f7f6 redo commandmode 2016-09-24 15:58:47 +02:00
Gerolf Ziegenhain
7b8e7a5e18 add morse lib 2016-09-23 22:33:19 +02:00
Gerolf Ziegenhain
405634e645 rm osx dir 2016-09-23 22:32:24 +02:00
Gerolf Ziegenhain
ba4e67f0a4 add paex_sine.c 2015-07-08 23:24:41 +02:00
Gerolf Ziegenhain
36fa067cc5 cleanup 2015-07-08 22:38:29 +02:00
Gerolf Ziegenhain
c464cc7dcb moip hp 2015-07-08 21:42:28 +02:00
Gerolf Ziegenhain
5295c33b74 add reference to moip website 2015-07-08 21:41:53 +02:00
Gerolf Ziegenhain
b3bed56197 rm old screenshot 2015-07-08 21:40:30 +02:00
9 changed files with 335 additions and 150 deletions

View File

@@ -1,38 +1,6 @@
irmc - Internet Relay Morse Code irmc - Internet Relay Morse Code
================================ ================================
IRMC stands for Internet Relay Morse Code and is an implementation of [MOIP](https://github.com/8cH9azbsFifZ/moip). IRMC stands for Internet Relay Morse Code and is an implementation of [MOIP](http://8ch9azbsfifz.github.io/moip/).
It implements the [CWCom protocol](http://kob.sdf.org/morsekob/docs/cwcom.pdf)
as adopted by [MorseKOB](http://kob.sdf.org/morsekob/docs/history.pdf).
# How to build?
## Install dependency: morse keyer library
```
wget https://github.com/8cH9azbsFifZ/morse/archive/v0.1.tar.gz
tar xzf v0.1.tar.gz
cd morse-0.1
libtoolize
./autogen.sh
./configure --with-portaudio
make
sudo make install
```
## Debian (Wheezy)
Some dependencies have to be installed:
```
apt-get install -y alsa-oss oss-compat build-essential autoconf libao-dev libtool
```
Afterwards compilation with `make` should work. If something went wrong, you may have
to adjust your `LD_LIBRARY_PATH`. Alternatively try:
```
LD_LIBRARY_PATH=/usr/local/lib ./irmc mtc-kob.dyndns.org 7890 33 123
```
## OSX (Yosemite)
Compilation with make :)
For the USB serial devices you need a PL2303 driver
(i.e. [PL2303_Serial-USB_on_OSX_Lion.pkg](http://changux.co/osx-installer-to-pl2303-serial-usb-on-osx-lio/)).
# Hardware interface options # Hardware interface options
A good description on how to build different interfaces (telegraph key, sounder or both) A good description on how to build different interfaces (telegraph key, sounder or both)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

BIN
lib/morse-0.1.tar.gz Normal file

Binary file not shown.

View File

@@ -1,7 +1,7 @@
SRC = irmc.c cwprotocol.c SRC = irmc.c cwprotocol.c beep.c
OBJ = ${SRC:.c=.o} OBJ = ${SRC:.c=.o}
LDFLAGS = -L/usr/local/lib -L/opt/local/lib -lm -lmorse LDFLAGS = -lportaudio -lpthread -lm
CFLAGS = -I/usr/local/include -I/opt/local/include -Wall CFLAGS = -Wall
INSTALLDIR = ${HOME}/bin INSTALLDIR = ${HOME}/bin
all: options irmc all: options irmc

182
src/beep.c Normal file
View File

@@ -0,0 +1,182 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h> // for usleep()
#include <portaudio.h>
#include "beep.h"
// http://stackoverflow.com/questions/7678470/generating-sound-of-a-particular-frequency-using-gcc-in-ubuntu
static PaStream *stream;
static paTestData data;
/* This routine will be called by the PortAudio engine when audio is needed.
** It may called at interrupt level on some machines so don't do anything
** that could mess up the system like calling malloc() or free().
*/
static int patestCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo* timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData )
{
paTestData *data = (paTestData*)userData;
uint8_t *out = (uint8_t*)outputBuffer;
unsigned long i;
uint32_t freq = data->freq;
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
for( i=0; i<framesPerBuffer; i++ )
{
if(data->up_count > 0 && data->total_count == data->up_count) {
*out++ = 0x00;
continue;
}
data->total_count++;
if(freq != data->prev_freq) {
data->counter = 0;
}
if(freq) {
int overflow_max = SAMPLE_RATE / freq;
uint32_t data_cnt = data->counter % overflow_max;
if(data_cnt > overflow_max/2)
*out++ = 0xff;
else {
*out++ = 0x00;
}
data->counter++;
}
else {
data->counter = 0;
*out++ = 0;
}
data->prev_freq = freq;
}
return paContinue;
}
void buzzer_set_freq(int frequency)
{
data.up_count = 0; // do not stop!
data.freq = frequency;
}
void buzzer_beep(int frequency, int msecs)
{
data.total_count = 0;
data.up_count = SAMPLE_RATE * msecs / 1000;
data.freq = frequency;
}
int buzzer_start(void)
{
PaStreamParameters outputParameters;
PaError err;
err = Pa_Initialize();
if( err != paNoError ) goto error;
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
outputParameters.channelCount = 1; /* stereo output */
outputParameters.sampleFormat = paUInt8; /* 32 bit floating point output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
err = Pa_OpenStream(
&stream,
NULL, /* no input */
&outputParameters,
SAMPLE_RATE,
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
&data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
return err;
error:
Pa_Terminate();
fprintf( stderr, "An error occured while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
}
int buzzer_stop()
{
PaError err = 0;
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
Pa_Terminate();
return err;
error:
Pa_Terminate();
fprintf( stderr, "An error occured while using the portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
}
void msleep(int d){
usleep(d*1000);
}
int beep(double freq_hz, double duration_sec)
{
buzzer_set_freq(freq_hz);
msleep(duration_sec*1000.);
buzzer_set_freq(0.);
return 0;
}
int beep_init()
{
buzzer_start();
return 0;
}
int beep_test(void)
{
// notes frequency chart: http://www.phy.mtu.edu/~suits/notefreqs.html
buzzer_start();
buzzer_set_freq(261);
msleep(250);
buzzer_set_freq(0);
msleep(250);
buzzer_set_freq(329);
msleep(250);
buzzer_set_freq(349);
msleep(250);
buzzer_set_freq(392);
msleep(250);
buzzer_set_freq(440);
msleep(250);
buzzer_set_freq(494);
msleep(250);
buzzer_beep(523, 200);
msleep(250);
buzzer_stop();
return 0;
}

32
src/beep.h Normal file
View File

@@ -0,0 +1,32 @@
#include <stdio.h>
#include <math.h>
#include "portaudio.h"
#define NUM_SECONDS (5)
#define SAMPLE_RATE (44100)
#define FRAMES_PER_BUFFER (64)
#ifndef M_PI
#define M_PI (3.14159265)
#endif
typedef struct
{
uint32_t total_count;
uint32_t up_count;
uint32_t counter;
uint32_t prev_freq;
uint32_t freq;
} paTestData;
void buzzer_set_freq(int frequency);
void buzzer_beep(int frequency, int msecs);
int buzzer_start(void);
int buzzer_stop();
void msleep(int d);
int beep_test(void);
// compatibility to old interface
int beep(double freq_hz, double duration_sec);
int beep_init();

View File

@@ -1,6 +1,17 @@
#include <stdio.h> #include <stdio.h>
#include <sys/socket.h>
#include "cwprotocol.h" #include "cwprotocol.h"
/* Global variables */
struct command_packet_format connect_packet = {CON, DEFAULT_CHANNEL};
struct command_packet_format disconnect_packet = {DIS, 0};
struct data_packet_format id_packet;
struct data_packet_format rx_data_packet;
struct data_packet_format tx_data_packet;
int tx_sequence = 0, rx_sequence;
int fd_socket;
int prepare_id (struct data_packet_format *id_packet, char *id) int prepare_id (struct data_packet_format *id_packet, char *id)
{ {
id_packet->command = DAT; id_packet->command = DAT;
@@ -34,3 +45,40 @@ int prepare_tx (struct data_packet_format *tx_packet, char *id)
return 0; return 0;
} }
// connect to server and send my id.
void identifyclient(void)
{
tx_sequence++;
id_packet.sequence = tx_sequence;
send(fd_socket, &connect_packet, SIZE_COMMAND_PACKET, 0);
send(fd_socket, &id_packet, SIZE_DATA_PACKET, 0);
}
int send_latch (void)
{
int i;
tx_sequence++;
tx_data_packet.sequence = tx_sequence;
tx_data_packet.code[0] = -1;
tx_data_packet.code[1] = 1;
tx_data_packet.n = 2;
for(i = 0; i < 5; i++) send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
tx_data_packet.n = 0;
return 0;
}
int send_unlatch (void)
{
int i;
tx_sequence++;
tx_data_packet.sequence = tx_sequence;
tx_data_packet.code[0] = -1;
tx_data_packet.code[1] = 2;
tx_data_packet.n = 2;
for(i = 0; i < 5; i++) send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
tx_data_packet.n = 0;
return 0;
}

View File

@@ -1,4 +1,4 @@
#define INTERFACE_VERSION "irmc v0.02" #define INTERFACE_VERSION "irmc v0.3.3"
// Structures for the packets: unsigned short command // Structures for the packets: unsigned short command
#define DIS 0x0002 // disconnect #define DIS 0x0002 // disconnect
@@ -32,7 +32,7 @@ struct data_packet_format{
unsigned int a23; unsigned int a23;
signed int code[SIZE_CODE]; signed int code[SIZE_CODE];
unsigned int n; unsigned int n;
char status[SIZE_STATUS]; /* This is called version in MorseKob */ char status[SIZE_STATUS]; /* This is called version in MorseKob, in cwcom this transmits the sent character?! */
char a4[8]; char a4[8];
}; };
@@ -40,6 +40,23 @@ struct data_packet_format{
// Define the packets used // Define the packets used
#define DEFAULT_CHANNEL 103 #define DEFAULT_CHANNEL 103
/* Define functions provided by cwprotocol */
int prepare_id (struct data_packet_format *id_packet, char *id); int prepare_id (struct data_packet_format *id_packet, char *id);
int prepare_tx (struct data_packet_format *tx_packet, char *id); int prepare_tx (struct data_packet_format *tx_packet, char *id);
void identifyclient (void);
int send_latch (void);
int send_unlatch (void);
/* Define external struct for global variables */
extern struct command_packet_format connect_packet;
extern struct command_packet_format disconnect_packet;
extern struct data_packet_format id_packet;
extern struct data_packet_format rx_data_packet;
extern struct data_packet_format tx_data_packet;
extern int tx_sequence, rx_sequence;
extern int fd_socket;

View File

@@ -9,17 +9,10 @@
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/ioctl.h>
#include <math.h> #include <math.h>
#include <fcntl.h> #include <fcntl.h>
#include <morse/beep.h> #include <pthread.h>
#ifdef __MACH__
#define LIBOSS_INTERNAL
#include <liboss/soundcard.h> //will not be used for audio any more
#else
#include <linux/ioctl.h>
#include <asm-generic/ioctl.h>
#include <asm-generic/termios.h>
#endif
#include <signal.h> #include <signal.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <time.h> #include <time.h>
@@ -27,23 +20,22 @@
#include <stdio.h> #include <stdio.h>
#ifdef __MACH__ #ifdef __MACH__
#include <mach/clock.h> #include <mach/clock.h>
#include <mach/mach.h> #include <mach/mach.h>
#else
#include <linux/ioctl.h>
#include <asm-generic/ioctl.h>
#include <asm-generic/termios.h>
#endif #endif
#define DEBUG 0 //#define DEBUG 1
#define MAXDATASIZE 1024 // max number of bytes we can get at once #define MAXDATASIZE 1024 // max number of bytes we can get at once
#include "cwprotocol.h" #include "cwprotocol.h"
struct command_packet_format connect_packet = {CON, DEFAULT_CHANNEL}; #include "beep.h"
struct command_packet_format disconnect_packet = {DIS, 0};
struct data_packet_format id_packet;
struct data_packet_format rx_data_packet;
struct data_packet_format tx_data_packet;
int serial_status = 0, fd_serial, fd_socket, numbytes; int serial_status = 0, fd_serial, numbytes;
int tx_sequence = 0, rx_sequence;
double tx_timeout = 0; double tx_timeout = 0;
long tx_timer = 0; long tx_timer = 0;
@@ -51,13 +43,18 @@ long tx_timer = 0;
#define TX_TIMEOUT 240.0 #define TX_TIMEOUT 240.0
#define KEEPALIVE_CYCLE 100 #define KEEPALIVE_CYCLE 100
/* TX Methods */
#define TX_NONE 0
#define TX_SERIAL 1
#define TX_KEYBOARD 2
long key_press_t1; long key_press_t1;
long key_release_t1; long key_release_t1;
int last_message = 0; int last_message = 0;
char last_sender[16]; char last_sender[16];
/* settings */ /* settings */
int translate = 0; int translate = 1;
int audio_status = 1; int audio_status = 1;
/* portable time, as listed in https://gist.github.com/jbenet/1087739 */ /* portable time, as listed in https://gist.github.com/jbenet/1087739 */
@@ -73,12 +70,10 @@ void current_utc_time(struct timespec *ts) {
#else #else
clock_gettime(CLOCK_REALTIME, ts); clock_gettime(CLOCK_REALTIME, ts);
#endif #endif
} }
/* a better clock() in milliseconds */ /* a better clock() in milliseconds */
long long fastclock(void)
fastclock(void)
{ {
struct timespec t; struct timespec t;
long r; long r;
@@ -102,7 +97,6 @@ int kbhit (void)
select (STDIN_FILENO+1, &rdfs, NULL, NULL, &tv); select (STDIN_FILENO+1, &rdfs, NULL, NULL, &tv);
return FD_ISSET(STDIN_FILENO, &rdfs); return FD_ISSET(STDIN_FILENO, &rdfs);
} }
@@ -116,19 +110,9 @@ void *get_in_addr(struct sockaddr *sa)
return &(((struct sockaddr_in6*)sa)->sin6_addr); return &(((struct sockaddr_in6*)sa)->sin6_addr);
} }
// connect to server and send my id.
void
identifyclient(void)
{
tx_sequence++;
id_packet.sequence = tx_sequence;
send(fd_socket, &connect_packet, SIZE_COMMAND_PACKET, 0);
send(fd_socket, &id_packet, SIZE_DATA_PACKET, 0);
}
// disconnect from the server // disconnect from the server
void void inthandler(int sig)
inthandler(int sig)
{ {
signal(sig, SIG_IGN); signal(sig, SIG_IGN);
send(fd_socket, &disconnect_packet, SIZE_COMMAND_PACKET, 0); send(fd_socket, &disconnect_packet, SIZE_COMMAND_PACKET, 0);
@@ -137,8 +121,7 @@ inthandler(int sig)
exit(1); exit(1);
} }
void void txloop (void)
txloop (void)
{ {
key_press_t1 = fastclock(); key_press_t1 = fastclock();
tx_timeout = 0; tx_timeout = 0;
@@ -170,64 +153,8 @@ txloop (void)
} }
} }
int
commandmode(void)
{
char cmd[32];
int i;
last_message = 0; /* reset status message */ void message(int msg)
printf(".");
fgets(cmd, 32, stdin);
if(strncmp(cmd, ".", 1) == 0){
printf("\n");
return 1;
}
if((strncmp(cmd, "latch", 3)) == 0){
tx_sequence++;
tx_data_packet.sequence = tx_sequence;
tx_data_packet.code[0] = -1;
tx_data_packet.code[1] = 1;
tx_data_packet.n = 2;
for(i = 0; i < 5; i++) send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
tx_data_packet.n = 0;
return 0;
}
if((strncmp(cmd, "unlatch", 3)) == 0){
tx_sequence++;
tx_data_packet.sequence = tx_sequence;
tx_data_packet.code[0] = -1;
tx_data_packet.code[1] = 2;
tx_data_packet.n = 2;
for(i = 0; i < 5; i++) send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
tx_data_packet.n = 0;
return 0;
}
if((strncmp(cmd, "ton", 3)) == 0){
translate = 1;
return 0;
}
if((strncmp(cmd, "toff", 3)) == 0){
translate = 0;
return 0;
}
if((strncmp(cmd, "aon", 3)) == 0){
audio_status = 1;
return 0;
}
if((strncmp(cmd, "aoff", 3)) == 0){
audio_status = 0;
return 0;
}
printf("?\n");
return 0;
}
void
message(int msg)
{ {
switch(msg){ switch(msg){
case 1: case 1:
@@ -257,6 +184,8 @@ message(int msg)
fflush(0); fflush(0);
} }
/* Main Loop */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char buf[MAXDATASIZE]; char buf[MAXDATASIZE];
@@ -269,13 +198,14 @@ int main(int argc, char *argv[])
int channel; int channel;
char id[SIZE_ID]; char id[SIZE_ID];
char serialport[64]; char serialport[64];
int tx_method = TX_NONE;
// Set default values // Set default values
snprintf(hostname, 64, "mtc-kob.dyndns.org"); snprintf(hostname, 64, "mtc-kob.dyndns.org");
snprintf(port, 16, "7890"); snprintf(port, 16, "7890");
channel = 103; channel = 103;
snprintf(id, SIZE_ID, "irmc-default"); snprintf(id, SIZE_ID, "irmc-default");
snprintf(serialport, 64, "/dev/tty.usbserial"); snprintf(serialport, 64, "");
// Read commandline // Read commandline
opterr = 0; opterr = 0;
@@ -307,7 +237,7 @@ int main(int argc, char *argv[])
fprintf(stderr, " -p [port] Port of morsekob server. Default: %s\n", port); fprintf(stderr, " -p [port] Port of morsekob server. Default: %s\n", port);
fprintf(stderr, " -c [channel] Channel. Default: %d\n", channel); fprintf(stderr, " -c [channel] Channel. Default: %d\n", channel);
fprintf(stderr, " -i [id] My ID. Default: %s\n", id); fprintf(stderr, " -i [id] My ID. Default: %s\n", id);
fprintf(stderr, " -s [serialport] Serial port device name. Default: %s\n", serialport); fprintf(stderr, " -s [serialport] Serial port device name. Example: /dev/tty.usbserial Default: \"%s\"\n", serialport);
return 1; return 1;
default: default:
abort (); abort ();
@@ -350,7 +280,6 @@ int main(int argc, char *argv[])
break; break;
} }
fcntl(fd_socket, F_SETFL, O_NONBLOCK); fcntl(fd_socket, F_SETFL, O_NONBLOCK);
if (p == NULL) { if (p == NULL) {
fprintf(stderr, "Failed to connect.\n"); fprintf(stderr, "Failed to connect.\n");
@@ -361,10 +290,15 @@ int main(int argc, char *argv[])
s, sizeof s); s, sizeof s);
fprintf(stderr, "Connected to %s.\n", s); fprintf(stderr, "Connected to %s.\n", s);
beep_init(); beep_init();
fd_serial = open(serialport, O_RDWR | O_NOCTTY | O_NDELAY); if ((strcmp (serialport, "")) != 0)
if(fd_serial == -1) { tx_method = TX_SERIAL;
fprintf(stderr,"Unable to open serial port %s.\n", serialport);
} if (tx_method == TX_SERIAL) {
fd_serial = open(serialport, O_RDWR | O_NOCTTY | O_NDELAY);
if(fd_serial == -1) {
fprintf(stderr,"Unable to open serial port %s.\n", serialport);
}
}
freeaddrinfo(servinfo); /* all done with this structure */ freeaddrinfo(servinfo); /* all done with this structure */
key_release_t1 = fastclock(); key_release_t1 = fastclock();
@@ -377,6 +311,7 @@ int main(int argc, char *argv[])
usleep(250); usleep(250);
if(numbytes == SIZE_DATA_PACKET && tx_timer == 0){ if(numbytes == SIZE_DATA_PACKET && tx_timer == 0){
memcpy(&rx_data_packet, buf, SIZE_DATA_PACKET); memcpy(&rx_data_packet, buf, SIZE_DATA_PACKET);
#if DEBUG #if DEBUG
printf("length: %i\n", rx_data_packet.length); printf("length: %i\n", rx_data_packet.length);
printf("id: %s\n", rx_data_packet.id); printf("id: %s\n", rx_data_packet.id);
@@ -386,6 +321,7 @@ int main(int argc, char *argv[])
printf("code:\n"); printf("code:\n");
for(i = 0; i < SIZE_CODE; i++)printf("%i ", rx_data_packet.code[i]); printf("\n"); for(i = 0; i < SIZE_CODE; i++)printf("%i ", rx_data_packet.code[i]); printf("\n");
#endif #endif
if(rx_data_packet.n > 0 && rx_sequence != rx_data_packet.sequence){ if(rx_data_packet.n > 0 && rx_sequence != rx_data_packet.sequence){
message(2); message(2);
if(translate == 1){ if(translate == 1){
@@ -435,11 +371,13 @@ int main(int argc, char *argv[])
#endif #endif
tx_data_packet.n = 0; tx_data_packet.n = 0;
} }
ioctl(fd_serial,TIOCMGET, &serial_status); if (tx_method == TX_SERIAL) {
if(serial_status & TIOCM_DSR){ ioctl(fd_serial,TIOCMGET, &serial_status);
txloop(); if(serial_status & TIOCM_DSR){
tx_timer = TX_WAIT; txloop();
message(1); tx_timer = TX_WAIT;
message(1);
}
} }
if(keepalive_t < 0 && tx_timer == 0){ if(keepalive_t < 0 && tx_timer == 0){
@@ -456,13 +394,13 @@ int main(int argc, char *argv[])
if(kbhit() && tx_timer == 0){ if(kbhit() && tx_timer == 0){
getchar(); /* flush the buffer */ getchar(); /* flush the buffer */
if(commandmode()== 1)break;
} }
} /* End of mainloop */ } /* End of mainloop */
send(fd_socket, &disconnect_packet, SIZE_COMMAND_PACKET, 0); send(fd_socket, &disconnect_packet, SIZE_COMMAND_PACKET, 0);
close(fd_socket); close(fd_socket);
close(fd_serial); close(fd_serial);
buzzer_stop();
exit(0); exit(0);
} }