32 Commits

Author SHA1 Message Date
Gerolf Ziegenhain
cc3bf0ae5a typo 2015-07-07 19:54:19 +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
fbd96d2495 doc 2015-02-16 18:39:55 +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
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
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
6 changed files with 110 additions and 78 deletions

2
.gitignore vendored
View File

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

View File

@@ -1,4 +1,4 @@
SRC = irmc.c SRC = irmc.c cwprotocol.c
OBJ = ${SRC:.c=.o} OBJ = ${SRC:.c=.o}
LDFLAGS = -L/usr/local/lib -L/opt/local/lib -lm -lmorse LDFLAGS = -L/usr/local/lib -L/opt/local/lib -lm -lmorse
CFLAGS = -I/usr/local/include -I/opt/local/include -Wall CFLAGS = -I/usr/local/include -I/opt/local/include -Wall
@@ -21,9 +21,8 @@ irmc: ${OBJ}
@echo CC -o $@ @echo CC -o $@
@${CC} -o $@ ${OBJ} ${LDFLAGS} @${CC} -o $@ ${OBJ} ${LDFLAGS}
hex: ${OBJ} java:
@echo avr-gcc -o $@ java -jar test/MorseKOB.jar
avr-gcc -o $@ ${OBJ} ${LDFLAGS}
clean: clean:
@echo cleaning @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

@@ -35,42 +35,13 @@
#define MAXDATASIZE 1024 // max number of bytes we can get at once #define MAXDATASIZE 1024 // max number of bytes we can get at once
// Structures for the packets: unsigned short command #include "cwprotocol.h"
#define DIS 0x0002 // disconnect struct command_packet_format connect_packet = {CON, DEFAULT_CHANNEL};
#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;
struct command_packet_format disconnect_packet = {DIS, 0}; struct command_packet_format disconnect_packet = {DIS, 0};
struct data_packet_format id_packet; struct data_packet_format id_packet;
struct data_packet_format rx_data_packet; struct data_packet_format rx_data_packet;
struct data_packet_format tx_data_packet; struct data_packet_format tx_data_packet;
int serial_status = 0, fd_serial, fd_socket, numbytes; int serial_status = 0, fd_serial, fd_socket, numbytes;
int tx_sequence = 0, rx_sequence; int tx_sequence = 0, rx_sequence;
@@ -192,7 +163,7 @@ txloop (void)
if(tx_timeout > TX_TIMEOUT) return; if(tx_timeout > TX_TIMEOUT) return;
} }
key_press_t1 = fastclock(); key_press_t1 = fastclock();
if(tx_data_packet.n == 50) { if(tx_data_packet.n == SIZE_CODE) {
printf("irmc: warning packet is full.\n"); printf("irmc: warning packet is full.\n");
return; return;
} }
@@ -296,7 +267,7 @@ int main(int argc, char *argv[])
char hostname[64]; char hostname[64];
char port[16]; char port[16];
int channel; int channel;
char id[128]; char id[SIZE_ID];
char serialport[64]; char serialport[64];
if (argc < 4) { if (argc < 4) {
@@ -307,35 +278,14 @@ int main(int argc, char *argv[])
snprintf(hostname, 64, argv[1], "%s"); snprintf(hostname, 64, argv[1], "%s");
snprintf(port, 16, argv[2], "%s"); snprintf(port, 16, argv[2], "%s");
channel = atoi(argv[3]); channel = atoi(argv[3]);
if(argc > 4) snprintf(id, 128, argv[4], "%s"); if(argc > 4) snprintf(id, SIZE_ID, argv[4], "%s");
else snprintf(id, 128, "irmc"); else snprintf(id, SIZE_ID, "irmc");
if(argc > 5) snprintf(serialport, 64, argv[5], "%s"); if(argc > 5) snprintf(serialport, 64, argv[5], "%s");
id_packet.command = DAT; prepare_id (&id_packet, id);
id_packet.length = 492; prepare_tx (&tx_data_packet, id);
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; connect_packet.channel = channel;
signal(SIGINT, inthandler); signal(SIGINT, inthandler);
memset(&hints, 0, sizeof hints); memset(&hints, 0, sizeof hints);
@@ -398,7 +348,7 @@ int main(int argc, char *argv[])
printf("version: %s\n", rx_data_packet.status); printf("version: %s\n", rx_data_packet.status);
printf("n: %i\n", rx_data_packet.n); printf("n: %i\n", rx_data_packet.n);
printf("code:\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 #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);
@@ -419,19 +369,19 @@ int main(int argc, char *argv[])
if(audio_status == 1) if(audio_status == 1)
{ {
int length = rx_data_packet.code[i]; int length = rx_data_packet.code[i];
if(length == 0 || abs(length) > 2000) { if(length == 0 || abs(length) > 2000) {
} }
else else
{ {
if(length < 0) { if(length < 0) {
beep(0.0, abs(length)/1000.); beep(0.0, abs(length)/1000.);
} }
else else
{ {
beep(1000.0, length/1000.); beep(1000.0, length/1000.);
} }
} }
} }
break; break;
} }

BIN
src/test/MorseKOB.jar Executable file

Binary file not shown.