wip
This commit is contained in:
parent
8e7ce33e3b
commit
c33910cdbd
@ -68,7 +68,7 @@ int send_latch (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, SIZE_DATA_PACKET, 0);
|
||||
for(i = 0; i < TX_RETRIES; i++) send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
|
||||
tx_data_packet.n = 0;
|
||||
return 0;
|
||||
}
|
||||
@ -81,7 +81,7 @@ int send_unlatch (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, SIZE_DATA_PACKET, 0);
|
||||
for(i = 0; i < TX_RETRIES; i++) send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
|
||||
tx_data_packet.n = 0;
|
||||
return 0;
|
||||
}
|
||||
@ -97,15 +97,58 @@ int prepare_text2morse (int wpm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int char2morse(void)
|
||||
int clean_pkg ()
|
||||
{
|
||||
char c='c', d;
|
||||
// why? because!!!
|
||||
// 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)
|
||||
int i;
|
||||
for (i=0; i<SIZE_CODE; i++)
|
||||
{
|
||||
d=(c/2?46-c%2:32);
|
||||
putchar (d);
|
||||
tx_data_packet.code[i] = 0;
|
||||
}
|
||||
tx_data_packet.n = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int char2morse(int ff)
|
||||
{
|
||||
//send_unlatch();
|
||||
clean_pkg();
|
||||
|
||||
int c, d, e;
|
||||
int i=0;
|
||||
c=ff;
|
||||
tx_sequence++;
|
||||
tx_data_packet.sequence = tx_sequence;
|
||||
|
||||
// why? because!!!
|
||||
// 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=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;
|
||||
d=(c/2?46-c%2:32);
|
||||
putchar (d);
|
||||
if (d == ' ' && e == ' ') break;
|
||||
tx_data_packet.code[i] = -1*morse_timing.dot_len;
|
||||
i++;
|
||||
int j;
|
||||
if (d == '.')
|
||||
j=1;
|
||||
if (d == '-')
|
||||
j=3;
|
||||
if (d == ' ')
|
||||
j=-3;
|
||||
tx_data_packet.code[i] = j*morse_timing.dot_len;
|
||||
i++;
|
||||
//printf ("(%d %d) ",tx_data_packet.code[i-2],tx_data_packet.code[i-1] );
|
||||
}
|
||||
tx_data_packet.code[i] = -1*morse_timing.dot_len;
|
||||
i++;
|
||||
tx_data_packet.n = i;//-2;
|
||||
|
||||
for(i = 0; i < TX_RETRIES; i++)
|
||||
send(fd_socket, &tx_data_packet, SIZE_DATA_PACKET, 0);
|
||||
tx_data_packet.n = 0;
|
||||
|
||||
// send_latch();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -9,7 +9,9 @@
|
||||
#define SIZE_COMMAND_PACKET 4
|
||||
#define SIZE_DATA_PACKET 496
|
||||
#define SIZE_DATA_PACKET_PAYLOAD 492 // = SIZE_DATA_PACKET - SIZE_COMMAND_PACKET
|
||||
#define TX_RETRIES 3 // how often will the udp packet be sent?
|
||||
|
||||
#define TX_RETRIES 5 // how often will the udp packet be sent?
|
||||
#define KEEPALIVE_CYCLE 1000 // how often will the keepalive signals be sent?
|
||||
|
||||
#define SIZE_ID 128
|
||||
#define SIZE_STATUS 128
|
||||
@ -61,7 +63,7 @@ extern int tx_sequence, rx_sequence;
|
||||
extern int fd_socket;
|
||||
|
||||
// Morse Code Sender - Timings
|
||||
#define WPM_DEFAULT 20
|
||||
#define WPM_DEFAULT 40
|
||||
struct morse_timig_format {
|
||||
int wpm;
|
||||
int dot_len, dash_len;
|
||||
@ -69,6 +71,6 @@ struct morse_timig_format {
|
||||
};
|
||||
|
||||
int prepare_text2morse (int wpm);
|
||||
int char2morse(void);
|
||||
int char2morse(int ff);
|
||||
|
||||
|
||||
|
11
src/irmc.c
11
src/irmc.c
@ -35,7 +35,7 @@ double tx_timeout = 0;
|
||||
long tx_timer = 0;
|
||||
#define TX_WAIT 5000
|
||||
#define TX_TIMEOUT 240.0
|
||||
#define KEEPALIVE_CYCLE 100
|
||||
#define BEEP_FREQUENCY 1000.
|
||||
|
||||
/* TX Methods */
|
||||
#define TX_NONE 0
|
||||
@ -320,7 +320,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
beep(1000.0, length/1000.);
|
||||
beep(BEEP_FREQUENCY, length/1000.);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -368,11 +368,10 @@ int main(int argc, char *argv[])
|
||||
if(tx_timer == 0) {
|
||||
keepalive_t--;
|
||||
usleep(50);
|
||||
}
|
||||
|
||||
#ifdef TX_SERIAL
|
||||
}
|
||||
#ifdef TX_KEYBOARD
|
||||
if(kbhit() && tx_timer == 0){
|
||||
char2morse();
|
||||
char2morse(0);
|
||||
}
|
||||
#endif
|
||||
} /* End of mainloop */
|
||||
|
Loading…
Reference in New Issue
Block a user