Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a4eed20392 | ||
|
51528cd34b | ||
|
c37c2b4a0d | ||
|
594bb6006f | ||
|
2d99d0deba | ||
|
49a033f9a3 | ||
|
79b9ab5dc1 | ||
|
a8b5ad29b7 | ||
|
a8468dbe42 | ||
|
d2254a907b | ||
|
cc3bf0ae5a | ||
|
7305e8a723 | ||
|
aa596c0c66 | ||
|
2d8ca13a22 | ||
|
f05f4ae2f7 | ||
|
2f88687332 | ||
|
fbd96d2495 | ||
|
67acd163b6 | ||
|
2c71fe456d | ||
|
e4a61ba4a9 | ||
|
251fa57b32 | ||
|
b075427a3c | ||
|
77dc0cf117 | ||
|
9319409282 | ||
|
572c6d93ac | ||
|
dd0881a5d4 | ||
|
d73eb66b99 | ||
|
ae779dc2f5 | ||
|
f028280963 | ||
|
765cb854ed | ||
|
12f2d905ce | ||
|
1140c99193 | ||
|
272d03cbc8 | ||
|
d2f8a0b65f | ||
|
87dbb05d3e | ||
|
9599bae5a8 | ||
|
adeba195f6 | ||
|
0424b7e2d3 | ||
|
87f8437b87 | ||
|
ecce799bb7 | ||
|
a4bbec6497 | ||
|
325d794b7c |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
.DS_Store
|
||||
irmc
|
||||
*.o
|
||||
|
44
README.md
44
README.md
@@ -1,13 +1,8 @@
|
||||
irmc - Internet Relay Morse Code
|
||||
================================
|
||||
|
||||
IRMC stands for Internet Relay Morse Code and is an implementation of [MOIP](https://github.com/8cH9azbsFifZ/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).
|
||||
You can try out the software in a [browser](http://kob.sdf.org/morsekob/morsekob30/index.htm) using Java.
|
||||
|
||||

|
||||
|
||||
|
||||
# How to build?
|
||||
## Install dependency: morse keyer library
|
||||
@@ -39,50 +34,29 @@ 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/)).
|
||||
|
||||
## Testing
|
||||
./irmc morsecode.dyndns.org 7890 2348 test
|
||||
|
||||
Or you may want to use tcpdump, i.e.:
|
||||
```
|
||||
sudo tcpdump -i all -vvvv "host faeroes.sdf.org"
|
||||
```
|
||||
|
||||
|
||||
# How to use:
|
||||
|
||||
The usage is: `irmc [hostname] [port] [channel] [id] [serialport`
|
||||
|
||||
For example:
|
||||
`./irmc mtc-kob.dyndns.org 7890 103 MyID /dev/tty.usbserial´
|
||||
|
||||
|
||||
## Hardware interface options
|
||||
# Hardware interface options
|
||||
A good description on how to build different interfaces (telegraph key, sounder or both)
|
||||
is given on the [MorseKOB Website](http://kob.sdf.org/morsekob/interface.htm).
|
||||
Landline telegraphs use "closed circuits" for communications; if you have built one at home,
|
||||
you may also use the [loop interface](http://kob.sdf.org/morsekob/docs/loopinterface.pdf).
|
||||
|
||||
Connection of a morse key:
|
||||
Serial PIN: 4 & 6
|
||||
[layout of pins](http://techpubs.sgi.com/library/dynaweb_docs/0650/SGI_Admin/books/MUX_IG/sgi_html/figures/4-2.serial.port.con.gif)
|
||||
Connecting the palm radio: keep an eye on the grounding :)
|
||||
|
||||
|
||||
http://kob.sdf.org/morsekob/interface.htm#portpins
|
||||
RS232 DB9 Function
|
||||
DTR 4 Manual Key / paddle common
|
||||
DSR 6 Manual key / dot paddle
|
||||
CTS 8 Dash paddle
|
||||
RTS 7 Sounder output
|
||||
SG 5 Sounder ground
|
||||
| RS232 | DB9 | Function |
|
||||
| :-------- |:-------| :------ |
|
||||
| DTR | 4 | Manual Key / paddle common|
|
||||
| DSR | 6 | Manual key / dot paddle|
|
||||
| CTS | 8 | Dash paddle|
|
||||
| RTS | 7 | Sounder output|
|
||||
| SG | 5 | Sounder ground|
|
||||
|
||||
|
||||
# Changelog
|
||||
* v0.3 [zip](https://github.com/8cH9azbsFifZ/irmc/archive/v0.3.zip) - commandline option cleanup
|
||||
* v0.2 [zip](https://github.com/8cH9azbsFifZ/irmc/archive/v0.2.zip) - ported to debian wheezy and osx yosemite, DG6FL
|
||||
* v0.1 [zip](https://github.com/8cH9azbsFifZ/irmc/archive/v0.1.zip) - original version, VE7FEB
|
||||
|
||||
Code Quality
|
||||
============
|
||||
This is experimental code.
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
SRC = irmc.c
|
||||
SRC = irmc.c cwprotocol.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
LDFLAGS = -L/usr/local/lib -L/opt/local/lib -lm -lmorse
|
||||
CFLAGS = -I/usr/local/include -I/opt/local/include -Wall
|
||||
@@ -21,9 +21,8 @@ irmc: ${OBJ}
|
||||
@echo CC -o $@
|
||||
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
|
||||
hex: ${OBJ}
|
||||
@echo avr-gcc -o $@
|
||||
avr-gcc -o $@ ${OBJ} ${LDFLAGS}
|
||||
java:
|
||||
java -jar test/MorseKOB.jar
|
||||
|
||||
clean:
|
||||
@echo cleaning
|
||||
|
36
src/cwprotocol.c
Normal file
36
src/cwprotocol.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include "cwprotocol.h"
|
||||
|
||||
int prepare_id (struct data_packet_format *id_packet, char *id)
|
||||
{
|
||||
id_packet->command = DAT;
|
||||
id_packet->length = SIZE_DATA_PACKET_PAYLOAD;
|
||||
snprintf(id_packet->id, SIZE_ID, id, "%s");
|
||||
id_packet->sequence = 0;
|
||||
id_packet->n = 0;
|
||||
snprintf(id_packet->status, SIZE_ID, INTERFACE_VERSION);
|
||||
id_packet->a21 = 1; /* These magic numbers was provided by Les Kerr */
|
||||
id_packet->a22 = 755;
|
||||
id_packet->a23 = 65535;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int prepare_tx (struct data_packet_format *tx_packet, char *id)
|
||||
{
|
||||
int i;
|
||||
|
||||
tx_packet->command = DAT;
|
||||
tx_packet->length = SIZE_DATA_PACKET_PAYLOAD;
|
||||
snprintf(tx_packet->id, SIZE_ID, id, "%s");
|
||||
tx_packet->sequence = 0;
|
||||
tx_packet->n = 0;
|
||||
for(i = 1; i < 51; i++)tx_packet->code[i] = 0;
|
||||
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, "?");
|
||||
|
||||
return 0;
|
||||
}
|
45
src/cwprotocol.h
Normal file
45
src/cwprotocol.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#define INTERFACE_VERSION "irmc v0.02"
|
||||
|
||||
// Structures for the packets: unsigned short command
|
||||
#define DIS 0x0002 // disconnect
|
||||
#define DAT 0x0003
|
||||
#define CON 0x0004 // connect
|
||||
#define ACK 0x0005
|
||||
|
||||
#define SIZE_COMMAND_PACKET 4
|
||||
#define SIZE_DATA_PACKET 496
|
||||
#define SIZE_DATA_PACKET_PAYLOAD 492 // = SIZE_DATA_PACKET - SIZE_COMMAND_PACKET
|
||||
|
||||
#define SIZE_ID 128
|
||||
#define SIZE_STATUS 128
|
||||
#define SIZE_CODE 51
|
||||
|
||||
// This structure will be used to (dis-)connect to KOB servers
|
||||
struct command_packet_format{
|
||||
unsigned short command; // CON / DIS
|
||||
unsigned short channel; // Channel number
|
||||
};
|
||||
|
||||
// This structure will be used for id, rx and tx packets
|
||||
struct data_packet_format{
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
char id[SIZE_ID];
|
||||
char a1[4];
|
||||
unsigned int sequence;
|
||||
unsigned int a21;
|
||||
unsigned int a22;
|
||||
unsigned int a23;
|
||||
signed int code[SIZE_CODE];
|
||||
unsigned int n;
|
||||
char status[SIZE_STATUS]; /* This is called version in MorseKob */
|
||||
char a4[8];
|
||||
|
||||
};
|
||||
|
||||
// Define the packets used
|
||||
#define DEFAULT_CHANNEL 103
|
||||
|
||||
|
||||
int prepare_id (struct data_packet_format *id_packet, char *id);
|
||||
int prepare_tx (struct data_packet_format *tx_packet, char *id);
|
152
src/irmc.c
152
src/irmc.c
@@ -35,42 +35,13 @@
|
||||
|
||||
#define MAXDATASIZE 1024 // max number of bytes we can get at once
|
||||
|
||||
// Structures for the packets: unsigned short command
|
||||
#define DIS 0x0002 // disconnect
|
||||
#define DAT 0x0003
|
||||
#define CON 0x0004 // connect
|
||||
#define ACK 0x0005
|
||||
|
||||
// This structure will be used to (dis-)connect to KOB servers
|
||||
struct command_packet_format{
|
||||
unsigned short command; // CON / DIS
|
||||
unsigned short channel; // Channel number
|
||||
};
|
||||
#define SIZE_COMMAND_PACKET 4
|
||||
// This structure will be used for id, rx and tx packets
|
||||
struct data_packet_format{
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
char id[128];
|
||||
char a1[4];
|
||||
unsigned int sequence;
|
||||
unsigned int a21;
|
||||
unsigned int a22;
|
||||
unsigned int a23;
|
||||
signed int code[51];
|
||||
unsigned int n;
|
||||
char status[128]; /* This is called version in MorseKob */
|
||||
char a4[8];
|
||||
|
||||
};
|
||||
#define SIZE_DATA_PACKET 496
|
||||
|
||||
|
||||
struct command_packet_format connect_packet;
|
||||
#include "cwprotocol.h"
|
||||
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 serial_status = 0, fd_serial, fd_socket, numbytes;
|
||||
int tx_sequence = 0, rx_sequence;
|
||||
|
||||
@@ -192,7 +163,7 @@ txloop (void)
|
||||
if(tx_timeout > TX_TIMEOUT) return;
|
||||
}
|
||||
key_press_t1 = fastclock();
|
||||
if(tx_data_packet.n == 50) {
|
||||
if(tx_data_packet.n == SIZE_CODE) {
|
||||
printf("irmc: warning packet is full.\n");
|
||||
return;
|
||||
}
|
||||
@@ -296,46 +267,61 @@ int main(int argc, char *argv[])
|
||||
char hostname[64];
|
||||
char port[16];
|
||||
int channel;
|
||||
char id[128];
|
||||
char id[SIZE_ID];
|
||||
char serialport[64];
|
||||
|
||||
if (argc < 4) {
|
||||
fprintf(stderr," %i usage: irmc [hostname] [port] [channel] [id] [serialport]\n", argc);
|
||||
exit(1);
|
||||
// Set default values
|
||||
snprintf(hostname, 64, "mtc-kob.dyndns.org");
|
||||
snprintf(port, 16, "7890");
|
||||
channel = 103;
|
||||
snprintf(id, SIZE_ID, "irmc-default");
|
||||
snprintf(serialport, 64, "/dev/tty.usbserial");
|
||||
|
||||
// Read commandline
|
||||
opterr = 0;
|
||||
int c;
|
||||
while ((c = getopt (argc, argv, "h:p:c:i:s:")) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
snprintf(hostname, 64, "%s", optarg);
|
||||
break;
|
||||
case 'p':
|
||||
snprintf(port, 16, "%s", optarg);
|
||||
break;
|
||||
case 'c':
|
||||
channel = atoi (optarg);
|
||||
break;
|
||||
case 'i':
|
||||
snprintf(id, SIZE_ID, "%s", optarg);
|
||||
break;
|
||||
case 's':
|
||||
snprintf(serialport, 64, "%s", optarg);
|
||||
break;
|
||||
case '?':
|
||||
fprintf(stderr, "irmc - Internet Relay Morse Code\n\n");
|
||||
fprintf(stderr, "usage: irmc [arguments]\n\n");
|
||||
fprintf(stderr, "Arguments:\n\n");
|
||||
fprintf(stderr, " -h [hostname] Hostname of morsekob server. Default: %s\n", hostname);
|
||||
fprintf(stderr, " -p [port] Port of morsekob server. Default: %s\n", port);
|
||||
fprintf(stderr, " -c [channel] Channel. Default: %d\n", channel);
|
||||
fprintf(stderr, " -i [id] My ID. Default: %s\n", id);
|
||||
fprintf(stderr, " -s [serialport] Serial port device name. Default: %s\n", serialport);
|
||||
return 1;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(hostname, 64, argv[1], "%s");
|
||||
snprintf(port, 16, argv[2], "%s");
|
||||
channel = atoi(argv[3]);
|
||||
if(argc > 4) snprintf(id, 128, argv[4], "%s");
|
||||
else snprintf(id, 128, "irmc");
|
||||
if(argc > 5) snprintf(serialport, 64, argv[5], "%s");
|
||||
// Preparing connection
|
||||
fprintf(stderr, "irmc - Internet Relay Morse Code\n\n");
|
||||
fprintf(stderr, "Connecting to %s:%s on channel %d with ID %s.\n", hostname, port, channel, id);
|
||||
|
||||
id_packet.command = DAT;
|
||||
id_packet.length = 492;
|
||||
snprintf(id_packet.id, 128, id, "%s");
|
||||
id_packet.sequence = 0;
|
||||
id_packet.n = 0;
|
||||
snprintf(id_packet.status, 128, "irmc v0.02");
|
||||
id_packet.a21 = 1; /* These magic numbers was provided by Les Kerr */
|
||||
id_packet.a22 = 755;
|
||||
id_packet.a23 = 65535;
|
||||
|
||||
tx_data_packet.command = DAT;
|
||||
tx_data_packet.length = 492;
|
||||
snprintf(tx_data_packet.id, 128, id, "%s");
|
||||
tx_data_packet.sequence = 0;
|
||||
tx_data_packet.n = 0;
|
||||
for(i = 1; i < 51; i++)tx_data_packet.code[i] = 0;
|
||||
tx_data_packet.a21 = 0; /* These magic numbers was provided by Les Kerr */
|
||||
tx_data_packet.a22 = 755;
|
||||
tx_data_packet.a23 = 16777215;
|
||||
snprintf(tx_data_packet.status, 128, "?");
|
||||
|
||||
connect_packet.command = CON;
|
||||
prepare_id (&id_packet, id);
|
||||
prepare_tx (&tx_data_packet, id);
|
||||
connect_packet.channel = channel;
|
||||
|
||||
|
||||
signal(SIGINT, inthandler);
|
||||
|
||||
memset(&hints, 0, sizeof hints);
|
||||
@@ -367,17 +353,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
fcntl(fd_socket, F_SETFL, O_NONBLOCK);
|
||||
if (p == NULL) {
|
||||
fprintf(stderr, "irmc: failed to connect\n");
|
||||
fprintf(stderr, "Failed to connect.\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),
|
||||
s, sizeof s);
|
||||
printf("irmc: connected to %s\n", s);
|
||||
fprintf(stderr, "Connected to %s.\n", s);
|
||||
beep_init();
|
||||
fd_serial = open(serialport, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if(fd_serial == -1) {
|
||||
printf("irmc: unable to open serial port.\n");
|
||||
fprintf(stderr,"Unable to open serial port %s.\n", serialport);
|
||||
}
|
||||
freeaddrinfo(servinfo); /* all done with this structure */
|
||||
|
||||
@@ -398,7 +384,7 @@ int main(int argc, char *argv[])
|
||||
printf("version: %s\n", rx_data_packet.status);
|
||||
printf("n: %i\n", rx_data_packet.n);
|
||||
printf("code:\n");
|
||||
for(i = 0; i < 51; 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
|
||||
if(rx_data_packet.n > 0 && rx_sequence != rx_data_packet.sequence){
|
||||
message(2);
|
||||
@@ -419,19 +405,19 @@ int main(int argc, char *argv[])
|
||||
if(audio_status == 1)
|
||||
{
|
||||
|
||||
int length = rx_data_packet.code[i];
|
||||
if(length == 0 || abs(length) > 2000) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(length < 0) {
|
||||
beep(0.0, abs(length)/1000.);
|
||||
}
|
||||
else
|
||||
{
|
||||
beep(1000.0, length/1000.);
|
||||
}
|
||||
}
|
||||
int length = rx_data_packet.code[i];
|
||||
if(length == 0 || abs(length) > 2000) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(length < 0) {
|
||||
beep(0.0, abs(length)/1000.);
|
||||
}
|
||||
else
|
||||
{
|
||||
beep(1000.0, length/1000.);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
BIN
src/test/MorseKOB.jar
Executable file
BIN
src/test/MorseKOB.jar
Executable file
Binary file not shown.
Reference in New Issue
Block a user