47 Commits
v0.2 ... v0.2.2

Author SHA1 Message Date
Gerolf Ziegenhain
cc3bf0ae5a typo 2015-07-07 19:54:19 +02:00
Gerolf Ziegenhain
bc62081ced typo 2015-07-07 19:53:40 +02:00
Gerolf Ziegenhain
24a5afa697 add screenshot 2015-04-29 21:37:50 +02:00
Gerolf Ziegenhain
7305e8a723 add osx screenshot 2015-04-29 21:36:28 +02:00
Gerolf Ziegenhain
aa596c0c66 add screenshot on osx 2015-04-29 21:35:08 +02:00
Gerolf Ziegenhain
2d8ca13a22 rm old posting 2015-03-04 20:10:57 +01:00
Gerolf Ziegenhain
f05f4ae2f7 add pins 2015-02-16 21:32:13 +01:00
Gerolf Ziegenhain
2f88687332 added test cases 2015-02-16 21:00:42 +01:00
Gerolf Ziegenhain
98d3b54d82 merged from dev 2015-02-16 18:41:26 +01:00
Gerolf Ziegenhain
fbd96d2495 doc 2015-02-16 18:39:55 +01:00
Gerolf Ziegenhain
0ccfe55978 wip 2015-02-15 13:13:49 +01:00
Gerolf Ziegenhain
eb1c87cb37 wip 2015-02-15 13:13:22 +01:00
Gerolf Ziegenhain
67acd163b6 wip 2015-02-15 13:11:40 +01:00
Gerolf Ziegenhain
2c71fe456d add doc by Les Kerr 2015-02-15 11:45:47 +01:00
8cH9azbsFifZ
0519826df2 Update README.md 2015-02-15 09:34:43 +01:00
Gerolf Ziegenhain
e4a61ba4a9 code quality warning 2015-02-15 09:27:13 +01:00
Gerolf Ziegenhain
251fa57b32 add java morsekob for testing 2015-02-07 21:23:58 +01:00
Gerolf Ziegenhain
b075427a3c more information on ext. hw 2015-02-07 21:21:33 +01:00
Gerolf Ziegenhain
77dc0cf117 formatting 2015-02-07 20:54:54 +01:00
Gerolf Ziegenhain
9319409282 wip 2015-02-03 23:29:32 +01:00
Gerolf Ziegenhain
572c6d93ac added jar for testing 2015-02-03 23:20:40 +01:00
Gerolf Ziegenhain
dd0881a5d4 added wikipedia section 2015-02-03 22:47:12 +01:00
Gerolf Ziegenhain
d73eb66b99 network trace for debug 2015-01-06 00:18:10 +01:00
Gerolf Ziegenhain
ae779dc2f5 magic numbers 2015-01-04 15:32:43 +01:00
Gerolf Ziegenhain
f028280963 cleanup 2015-01-04 15:29:26 +01:00
Gerolf Ziegenhain
765cb854ed initialization of packets 2015-01-04 15:26:52 +01:00
Gerolf Ziegenhain
12f2d905ce started separating protocol. 2015-01-04 15:02:18 +01:00
Gerolf Ziegenhain
1140c99193 started separating protocol. 2015-01-04 15:02:03 +01:00
Gerolf Ziegenhain
272d03cbc8 merged from master 2015-01-04 14:44:17 +01:00
Gerolf Ziegenhain
d2f8a0b65f merged from master 2015-01-04 14:43:50 +01:00
Gerolf Ziegenhain
87dbb05d3e merged from master 2015-01-04 14:43:28 +01:00
Gerolf Ziegenhain
9599bae5a8 merged from master 2015-01-04 14:43:06 +01:00
Gerolf Ziegenhain
dccf7e6cfc documented structures 2015-01-04 14:39:51 +01:00
Gerolf Ziegenhain
b20d4efe9e removed unused structure 2015-01-04 14:36:48 +01:00
Gerolf Ziegenhain
e0471a4c62 added dg6fl 2015-01-04 13:25:38 +01:00
Gerolf Ziegenhain
24a74dbd55 added changelog 2015-01-04 13:24:47 +01:00
Gerolf Ziegenhain
cb783b97e1 added description of the protocol 2015-01-04 13:22:32 +01:00
Gerolf Ziegenhain
45716af4f9 magic number - sizes of packets 2015-01-04 13:21:35 +01:00
Gerolf Ziegenhain
9d540cf369 magic number - sizes of packets 2015-01-04 13:19:56 +01:00
Gerolf Ziegenhain
a2200a4aa6 added links to usb serial drivers 2015-01-04 10:22:13 +01:00
Gerolf Ziegenhain
182be32401 added authors file 2015-01-04 10:19:11 +01:00
Gerolf Ziegenhain
adeba195f6 merged makefiles 2015-01-03 23:00:47 +01:00
Gerolf Ziegenhain
0424b7e2d3 removed obsolete files 2015-01-03 22:59:08 +01:00
Gerolf Ziegenhain
87f8437b87 modified for wheezy - without sound.c 2015-01-03 22:58:48 +01:00
Gerolf Ziegenhain
ecce799bb7 add osx build 2015-01-03 22:45:02 +01:00
Gerolf Ziegenhain
a4bbec6497 osx port 2015-01-03 22:38:23 +01:00
Gerolf Ziegenhain
325d794b7c compile instructions debian 2015-01-03 22:36:21 +01:00
11 changed files with 171 additions and 149 deletions

2
.gitignore vendored
View File

@@ -1 +1,3 @@
.DS_Store
irmc
irmc.o

8
AUTHORS Normal file
View File

@@ -0,0 +1,8 @@
Fernan Bolando (VE4FEB)
Gerolf Ziegenhain (DG6FL)
MorseKOB:
Lex Kerr
CWCom Protocol:
John Samien (VK1EME)

View File

@@ -1,14 +1,12 @@
irmc - Internet Relay Morse Code
================================
# What is IRMC?
IRMC stands for Internet Relay Morse Code. 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.
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.
## Why morse code over IP?
Why not? A number of different approaches for CW over IP exist. An early implementation has been the CWCom protocol,
which has been the basis for Morse KOB, a ready-to-use software. Both chat programs have been written for CW exclusively and are compatible. An alternative implementation in C exists as well as a port to the ATMEL AVR Microcontroller.
Besides a variety of other approaches exist, for example an IRC plugin ([CWirc](http://myspace.voo.be/pcoupard/cwirc/)), a [JavaScript implementation](http://morsecode.me), a [bandwidth-eating UDP implementation](http://hans.liss.pp.se/node/343), a [chat for iOS](http://pignology.net/cwwithme.html) or a modulated CW over IP using Mumble ([iCW](https://sites.google.com/site/icwoip/)).
![Screenshot on OSX](/doc/screenshot.png?raw=true "Screenshot")
# How to build?
@@ -38,13 +36,16 @@ 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).
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 with MorseKOB 3.0 (Java)
This [software](http://kob.sdf.org/morsekob/morsekob30/MorseKOB.jar) will run on
Linux, Windows and OSX. With the [RXTX software](http://morsekob.org/morsekob30/help.htm)
for Java (i.e. librxtxSerial.jnilib on OSX) it is even possible to connect to external hardware.
NB: before you transmit make sure you uncheck the "circuit closer".
## 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:
@@ -54,45 +55,34 @@ The usage is: `irmc [hostname] [port] [channel] [id] [serialport`
For example:
`./irmc mtc-kob.dyndns.org 7890 103 MyID /dev/tty.usbserial´
## Morse KOB Servers
* faeroes.sdf.org 7890
* mtc-kob.dyndns.org 7890
A current list of servers if provided on the [MorseKOB Website](http://mtc-kob.dyndns.org).
## Hardware interface options
A good description on how to build differnt 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).
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 :)
# References
## Original post by Fernan Bolando (VE4FEB)
Copied on 20150103 from http://fernski.blogspot.de/2013/03/internet-relay-morsecode.html
> I have been using cwcom to practice sending morsecode, unfortunately my main computer at home is running openbsd and it has gotten harder to gain access to a reliable MS Windows machine. So I wrote my own client that works on openbsd.
> This is written in C and although not tested it should compile under other OS. If any one wants to try it and send me feedback. you can download version 0.01 here http://fernan.bitbucket.org/irmc.tgz
> Les Kerr of https://home.comcast.net/~morsekob/ has been very patient in answering my questions regarding the cwcom protocol and setting up a test server during debugging.
>
> There are few difference between this and the official cwcom client
> 1. It is a command line tool
> 2. It does not send the characters of the message to the receivers screen.
> 3. It does not translate CW for you. You can try fldigi if you just want see the transmission.
> 4. Tone pitch is currently hard coded to 650Hz
> 5. It does not have a way to show you who is listening.
>
> Bugs:
> There are a few that I am working on right now, but feel free to send me feedback if you get a chance to try it out.
>
> File(s)
> http://fernan.bitbucket.org/irmc.tgz
> The following people have helped me a lot to learn the protocols and setting up test servers.
> Les Kerr - https://home.comcast.net/~morsekob/
> Bob Denny - http://morse-rss-news.sourceforge.net/
> John Samin - http://www.mrx.com.au/
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
# Changelog
* 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.
## Resources
* CWCom, John Samin (VK1EME): http://www.mrx.com.au/d_cwcom.htm
* Morse KOB, Les Kerr: https://sites.google.com/site/morsekob/ and http://kob.sdf.org/morsekob/
* Relay server for CW communicator and morse KOB: http://morsecode.dc3.com:7890
* Sources for the Relay Server: http://sourceforge.net/projects/morse-rss-news/
* MorseKOB for AT Mega, Fernan Bolando (VE4FEB): http://fernski.blogspot.de/2013/05/sending-morsecode-via-atmega.html

BIN
doc/cwcom.pdf Normal file

Binary file not shown.

BIN
doc/loopinterface.pdf Normal file

Binary file not shown.

BIN
doc/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -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
View 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
View 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);

View File

@@ -31,56 +31,18 @@
#include <mach/mach.h>
#endif
#define DEBUG 0
#define MAXDATASIZE 1024 // max number of bytes we can get at once
#define DIS 0x0002
#define DAT 0x0003
#define CON 0x0004
#define ACK 0x0005
#define DEBUG 0
struct command_packet_format{
unsigned short command;
unsigned short channel;
};
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];
};
struct code_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 a3[128];
char a4[8];
};
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_speaker, fd_serial, fd_socket, numbytes;
int serial_status = 0, fd_serial, fd_socket, numbytes;
int tx_sequence = 0, rx_sequence;
double tx_timeout = 0;
@@ -154,22 +116,23 @@ void *get_in_addr(struct sockaddr *sa)
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, sizeof(connect_packet), 0);
send(fd_socket, &id_packet, 496, 0);
send(fd_socket, &connect_packet, SIZE_COMMAND_PACKET, 0);
send(fd_socket, &id_packet, SIZE_DATA_PACKET, 0);
}
// disconnect from the server
void
inthandler(int sig)
{
signal(sig, SIG_IGN);
send(fd_socket, &disconnect_packet, sizeof(disconnect_packet), 0);
send(fd_socket, &disconnect_packet, SIZE_COMMAND_PACKET, 0);
close(fd_socket);
close(fd_speaker);
close(fd_serial);
exit(1);
}
@@ -200,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;
}
@@ -226,7 +189,7 @@ commandmode(void)
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, 496, 0);
for(i = 0; i < 5; i++) send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
tx_data_packet.n = 0;
return 0;
}
@@ -237,7 +200,7 @@ commandmode(void)
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, 496, 0);
for(i = 0; i < 5; i++) send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
tx_data_packet.n = 0;
return 0;
}
@@ -304,7 +267,7 @@ 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) {
@@ -315,34 +278,13 @@ int main(int argc, char *argv[])
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 > 4) snprintf(id, SIZE_ID, argv[4], "%s");
else snprintf(id, SIZE_ID, "irmc");
if(argc > 5) snprintf(serialport, 64, argv[5], "%s");
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;
connect_packet.channel = channel;
prepare_id (&id_packet, id);
prepare_tx (&tx_data_packet, id);
connect_packet.channel = channel;
signal(SIGINT, inthandler);
@@ -397,8 +339,8 @@ int main(int argc, char *argv[])
if(tx_timer == 0)
if((numbytes = recv(fd_socket, buf, MAXDATASIZE-1, 0)) == -1)
usleep(250);
if(numbytes == 496 && tx_timer == 0){
memcpy(&rx_data_packet, buf, 496);
if(numbytes == SIZE_DATA_PACKET && tx_timer == 0){
memcpy(&rx_data_packet, buf, SIZE_DATA_PACKET);
#if DEBUG
printf("length: %i\n", rx_data_packet.length);
printf("id: %s\n", rx_data_packet.id);
@@ -406,7 +348,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);
@@ -427,19 +369,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;
}
@@ -451,7 +393,7 @@ beep(1000.0, length/1000.);
if(tx_data_packet.n > 1 ){
tx_sequence++;
tx_data_packet.sequence = tx_sequence;
for(i = 0; i < 5; i++) send(fd_socket, &tx_data_packet, 496, 0);
for(i = 0; i < 5; i++) send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
#if DEBUG
printf("irmc: sent data packet.\n");
#endif
@@ -482,7 +424,7 @@ beep(1000.0, length/1000.);
}
} /* End of mainloop */
send(fd_socket, &disconnect_packet, sizeof(disconnect_packet), 0);
send(fd_socket, &disconnect_packet, SIZE_COMMAND_PACKET, 0);
close(fd_socket);
close(fd_serial);

BIN
src/test/MorseKOB.jar Executable file

Binary file not shown.