Compare commits
24 Commits
Author | SHA1 | Date |
---|---|---|
Gerolf Ziegenhain | 2c2ff2d2ed | |
Gerolf Ziegenhain | 4c7442e3ea | |
Gerolf Ziegenhain | 2c7de4792d | |
Gerolf Ziegenhain | 496aa90bfe | |
Gerolf Ziegenhain | 827798b86b | |
Gerolf Ziegenhain | 5f9609ce0c | |
Gerolf Ziegenhain | 75c77b0cac | |
Gerolf Ziegenhain | 7bf9183401 | |
Gerolf Ziegenhain | 746b1dcfe5 | |
Gerolf Ziegenhain | 63300fa955 | |
Gerolf Ziegenhain | a43019e565 | |
Gerolf Ziegenhain | 370858ce8e | |
Gerolf Ziegenhain | a62c28dcdf | |
Gerolf Ziegenhain | d8815db878 | |
Gerolf Ziegenhain | d6d0679fb5 | |
Gerolf Ziegenhain | 9d28c29a51 | |
Gerolf Ziegenhain | 5d1ea8138b | |
Gerolf Ziegenhain | af81f9a084 | |
Gerolf Ziegenhain | 1145e2769e | |
Gerolf Ziegenhain | 516c1b4a57 | |
Gerolf Ziegenhain | 1db2782667 | |
Gerolf Ziegenhain | ba6ece9ddd | |
Gerolf Ziegenhain | 4f9169d026 | |
Gerolf Ziegenhain | e36b01ce41 |
|
@ -5,9 +5,16 @@ IRMC stands for Internet Relay Morse Code and is an implementation of [MOIP](htt
|
|||
# Building
|
||||
## On Linux
|
||||
sudo apt-get install -y alsa-oss oss-compat build-essential autoconf libao-dev libtool libportaudio-dev portaudio19-dev
|
||||
make
|
||||
|
||||
### On Raspi (GPIO Interface)
|
||||
Follow: http://wiringpi.com/download-and-install/
|
||||
make raspi
|
||||
|
||||
|
||||
## On OSX
|
||||
brew install portaudio
|
||||
make
|
||||
|
||||
# Hardware interface options
|
||||
A good description on how to build different interfaces (telegraph key, sounder or both)
|
||||
|
|
|
@ -21,6 +21,10 @@ irmc: ${OBJ}
|
|||
@echo CC -o $@
|
||||
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
|
||||
raspi:
|
||||
@${CC} -c -DRASPI ${CFLAGS} ${SRC}
|
||||
@${CC} -o irmc ${OBJ} ${LDFLAGS} -lwiringPi
|
||||
|
||||
java:
|
||||
java -jar test/MorseKOB.jar
|
||||
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
|
||||
#include "beep.h"
|
||||
|
||||
#ifdef RASPI
|
||||
#define RASPI_AUDIO_LATENCY_FIX (30./5.) // https://app.assembla.com/spaces/portaudio/tickets/246-paex_sine-choppy-on-raspberry-pi---defaultlowoutputlatency-too-low/details
|
||||
#else
|
||||
#define RASPI_AUDIO_LATENCY_FIX (1.)
|
||||
#endif
|
||||
|
||||
// http://stackoverflow.com/questions/7678470/generating-sound-of-a-particular-frequency-using-gcc-in-ubuntu
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "cwprotocol.h"
|
||||
|
||||
/* Global variables */
|
||||
|
@ -41,7 +42,7 @@ int prepare_tx (struct data_packet_format *tx_packet, char *id)
|
|||
tx_packet->a21 = 0; /* These magic numbers was provided by Les Kerr */
|
||||
tx_packet->a22 = 755;
|
||||
tx_packet->a23 = 16777215;
|
||||
snprintf(tx_packet->status, SIZE_STATUS, "?");
|
||||
snprintf(tx_packet->status, SIZE_STATUS, "?"); // this shall include the sent character
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
88
src/irmc.c
88
src/irmc.c
|
@ -16,14 +16,19 @@
|
|||
#include <signal.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
//#define DEBUG 1
|
||||
|
||||
#define MAXDATASIZE 1024 // max number of bytes we can get at once
|
||||
|
||||
#include "cwprotocol.h"
|
||||
#include "beep.h"
|
||||
#include "util.h"
|
||||
|
||||
// http://raspberrypiguide.de/howtos/raspberry-pi-gpio-how-to/
|
||||
#ifdef RASPI
|
||||
#include <wiringPi.h>
|
||||
#define TX_RASPI_PIN 5
|
||||
#endif
|
||||
|
||||
|
||||
int serial_status = 0, fd_serial, numbytes;
|
||||
|
||||
double tx_timeout = 0;
|
||||
|
@ -34,8 +39,9 @@ long tx_timer = 0;
|
|||
|
||||
/* TX Methods */
|
||||
#define TX_NONE 0
|
||||
#define TX_SERIAL 1
|
||||
#define TX_KEYBOARD 2
|
||||
//#define TX_SERIAL 1
|
||||
//#define TX_KEYBOARD 2 // not implemented yet
|
||||
#define TX_RASPI 3
|
||||
|
||||
long key_press_t1;
|
||||
long key_release_t1;
|
||||
|
@ -52,7 +58,9 @@ void inthandler(int sig)
|
|||
signal(sig, SIG_IGN);
|
||||
send(fd_socket, &disconnect_packet, SIZE_COMMAND_PACKET, 0);
|
||||
close(fd_socket);
|
||||
#ifdef TX_SERIAL
|
||||
close(fd_serial);
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -65,18 +73,32 @@ void txloop (void)
|
|||
tx_data_packet.code[tx_data_packet.n - 1] =
|
||||
(int) ((key_press_t1 - key_release_t1) * -1);
|
||||
|
||||
//printf("space: %i\n", tx_data_packet.code[tx_data_packet.n -1]);
|
||||
#ifdef DEBUG
|
||||
printf("space: %i\n", tx_data_packet.code[tx_data_packet.n -1]);
|
||||
#endif
|
||||
#ifdef TX_SERIAL
|
||||
while(serial_status & TIOCM_DSR) ioctl(fd_serial, TIOCMGET, &serial_status);
|
||||
#endif
|
||||
#ifdef RASPI
|
||||
while(digitalRead(TX_RASPI_PIN)==1) { }
|
||||
#endif
|
||||
key_release_t1 = fastclock();
|
||||
|
||||
tx_data_packet.n++;
|
||||
tx_data_packet.code[tx_data_packet.n - 1] =
|
||||
(int) ((key_release_t1 - key_press_t1) * 1);
|
||||
|
||||
//printf("mark: %i\n", tx_data_packet.code[tx_data_packet.n -1]);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("mark: %i\n", tx_data_packet.code[tx_data_packet.n -1]);
|
||||
#endif
|
||||
while(1){
|
||||
#ifdef TX_SERIAL
|
||||
ioctl(fd_serial, TIOCMGET, &serial_status);
|
||||
if(serial_status & TIOCM_DSR) break;
|
||||
#endif
|
||||
#ifdef RASPI
|
||||
if(digitalRead(TX_RASPI_PIN)==1) break;
|
||||
#endif
|
||||
tx_timeout = fastclock() - key_release_t1;
|
||||
if(tx_timeout > TX_TIMEOUT) return;
|
||||
}
|
||||
|
@ -133,7 +155,6 @@ int main(int argc, char *argv[])
|
|||
int channel;
|
||||
char id[SIZE_ID];
|
||||
char serialport[64];
|
||||
int tx_method = TX_NONE;
|
||||
|
||||
// Set default values
|
||||
snprintf(hostname, 64, "mtc-kob.dyndns.org");
|
||||
|
@ -224,21 +245,30 @@ int main(int argc, char *argv[])
|
|||
inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),
|
||||
s, sizeof s);
|
||||
fprintf(stderr, "Connected to %s.\n", s);
|
||||
beep_init();
|
||||
if ((strcmp (serialport, "")) != 0)
|
||||
tx_method = TX_SERIAL;
|
||||
|
||||
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);
|
||||
}
|
||||
#ifdef 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);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RASPI
|
||||
if (wiringPiSetup() == -1)
|
||||
{
|
||||
fprintf(stderr,"Unable to setup wiringPi for PIN %d\n", TX_RASPI_PIN);
|
||||
exit (1);
|
||||
}
|
||||
pinMode(TX_RASPI_PIN, INPUT);
|
||||
#endif
|
||||
|
||||
freeaddrinfo(servinfo); /* all done with this structure */
|
||||
|
||||
key_release_t1 = fastclock();
|
||||
identifyclient();
|
||||
|
||||
|
||||
beep_init();
|
||||
|
||||
/* Main Loop */
|
||||
for(;;) {
|
||||
if(tx_timer == 0)
|
||||
|
@ -306,14 +336,22 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
tx_data_packet.n = 0;
|
||||
}
|
||||
if (tx_method == TX_SERIAL) {
|
||||
ioctl(fd_serial,TIOCMGET, &serial_status);
|
||||
if(serial_status & TIOCM_DSR){
|
||||
txloop();
|
||||
tx_timer = TX_WAIT;
|
||||
message(1);
|
||||
}
|
||||
#ifdef TX_SERIAL
|
||||
ioctl(fd_serial,TIOCMGET, &serial_status);
|
||||
if(serial_status & TIOCM_DSR){
|
||||
txloop();
|
||||
tx_timer = TX_WAIT;
|
||||
message(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RASPI
|
||||
if(digitalRead(5)==1){
|
||||
txloop();
|
||||
tx_timer = TX_WAIT;
|
||||
message(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(keepalive_t < 0 && tx_timer == 0){
|
||||
#if DEBUG
|
||||
|
@ -334,7 +372,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
send(fd_socket, &disconnect_packet, SIZE_COMMAND_PACKET, 0);
|
||||
close(fd_socket);
|
||||
#ifdef TX_SERIAL
|
||||
close(fd_serial);
|
||||
#endif
|
||||
buzzer_stop();
|
||||
|
||||
exit(0);
|
||||
|
|
Loading…
Reference in New Issue