This commit is contained in:
Gerolf Ziegenhain 2016-10-05 21:27:37 +02:00
parent df63fe0359
commit 3b4a4607e0
2 changed files with 15 additions and 12 deletions

View File

@ -97,34 +97,39 @@ int prepare_text2morse (int wpm)
return 0; return 0;
} }
int clean_pkg () int clean_tx (void)
{ {
int i; int i;
for (i=0; i<SIZE_CODE; i++) for (i=0; i<SIZE_CODE; i++)
{
tx_data_packet.code[i] = 0; tx_data_packet.code[i] = 0;
} for (i=0; i<SIZE_STATUS; i++)
tx_data_packet.status[i] = ' ';
tx_data_packet.n = 0; tx_data_packet.n = 0;
sprintf(tx_data_packet.status, "");
return 0; return 0;
} }
// FIXME: This function is really nasty, even for this code :)
int char2morse(int ff) int char2morse(int ff)
{ {
//send_unlatch(); clean_tx();
//clean_pkg();
int c, d, e; int c, d, e;
int a=0, b=0;
int i=0; int i=0;
int k=0;
c=ff; c=ff;
tx_sequence++; tx_sequence++;
tx_data_packet.sequence = tx_sequence; tx_data_packet.sequence = tx_sequence;
// why? because!!! // why? because!!!
// http://stackoverflow.com/questions/1352587/convert-a-string-into-morse-code/1355594^ // http://stackoverflow.com/questions/1352587/convert-a-string-into-morse-code/1355594^
for(;c= c?c:(c=toupper(getchar())-32)?c<0?1:"\x95#\x8CKa`^ZRBCEIQiw#S#nx(37+$6-2&@/4)'18=,*%.:0;?5" [c-12]-34:-3;c/=2) { for(;c= c?c:(c=a=toupper(getchar())-32)?c<0?1:"\x95#\x8CKa`^ZRBCEIQiw#S#nx(37+$6-2&@/4)'18=,*%.:0;?5" [c-12]-34:-3;c/=2) {
// for(;c= c?c:(c=43-32)?c<0?1:"\x95#\x8CKa`^ZRBCEIQiw#S#nx(37+$6-2&@/4)'18=,*%.:0;?5" [c-12]-34:-3;c/=2) {
e=d; e=d;
if (a!=b) {
tx_data_packet.status[k] = a+32; //putchar (a+32);
k++;
}
b=a;
d=(c/2?46-c%2:32); d=(c/2?46-c%2:32);
//putchar (d); //putchar (d);
if (d == ' ' && e == ' ') break; if (d == ' ' && e == ' ') break;
@ -143,13 +148,11 @@ c=ff;
} }
tx_data_packet.code[i] = -1*morse_timing.dot_len; tx_data_packet.code[i] = -1*morse_timing.dot_len;
i++; i++;
tx_data_packet.n = i;//-2; tx_data_packet.n = i;
for(i = 0; i < TX_RETRIES; i++) for(i = 0; i < TX_RETRIES; i++)
send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0); send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
tx_data_packet.n = 0; tx_data_packet.n = 0;
// send_latch();
return 0; return 0;
} }

View File

@ -47,6 +47,7 @@ struct data_packet_format{
/* Define functions provided by cwprotocol */ /* 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);
int clean_tx (void);
void identifyclient (void); void identifyclient (void);
int send_latch (void); int send_latch (void);
int send_unlatch (void); int send_unlatch (void);
@ -73,4 +74,3 @@ struct morse_timig_format {
int prepare_text2morse (int wpm); int prepare_text2morse (int wpm);
int char2morse(int ff); int char2morse(int ff);