• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscapheguic翻訳omegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

Commit MetaInfo

Revisiona743fed942fd8ded140f3463b47fa3a21e6d17b6 (tree)
Time2020-10-15 06:36:31
AuthorSASANO Takayoshi <uaa@uaa....>
CommiterSASANO Takayoshi

Log Message

Merge remote-tracking branch 'upstream/master'

Change Summary

Incremental Difference

--- a/dmonitor.h
+++ b/dmonitor.h
@@ -112,6 +112,7 @@ int hole_punch_port;
112112 char hole_punch_server[128];
113113
114114 unsigned char inet_frame_id[2];
115+unsigned char inet_frame_id_save[2];
115116 struct timeval inet_recv_time;
116117 struct timeval inet_recv_time_save;
117118 struct timeval inet_recv_timeout;
@@ -199,7 +200,6 @@ unsigned char MD5_dmonitor[32];
199200
200201 char rig_type;
201202
202-int dvap_send_header_sw;
203203 char dvap_first_voice_pkt;
204204
205205 time_t dest_keep_alive_send_time;
@@ -297,4 +297,5 @@ time_t lcd_time_save;
297297 /* misc */
298298 char voice_packet_save[15];
299299 int hole_punchd_recvd;
300+int send_header_sw;
300301 time_t msg_send_set_time;
--- a/dmonitor_utils.c
+++ b/dmonitor_utils.c
@@ -13,7 +13,8 @@ int send_dest_keep_alive(void);
1313 int node_usb_init (void);
1414 void node_close (void);
1515 void lcd_write(void);
16-
16+int node_space_check (int length);
17+int check_getFifo(void);
1718 extern char dummy_frame_1[12];
1819 extern char dummy_frame_2[12];
1920 extern char dummy_frame_3[12];
@@ -360,6 +361,12 @@ int send_rig (void)
360361 int length;
361362 int rate;
362363
364+ if (rig_type == NODE)
365+ {
366+ length = check_getFifo();
367+ if (!node_space_check (length)) return TRUE;
368+ }
369+
363370 length = getFifo (&send_buff[3]);
364371 if (length == 0)
365372 {
@@ -374,7 +381,7 @@ int send_rig (void)
374381 }
375382 else if (length == 13)
376383 {
377- #if 0
384+ #if 0
378385 syslog (LOG_DEBUG, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x",
379386 send_buff[3], send_buff[4], send_buff[5], send_buff[6], send_buff[7], send_buff[8], send_buff[9], send_buff[10],
380387 send_buff[11], send_buff[12], send_buff[13], send_buff[14], send_buff[15]);
@@ -445,12 +452,25 @@ void LastFrameSend (void)
445452
446453 }
447454
455+int check_getFifo (void)
456+{
457+ struct FifoPkt *tmp;
458+
459+ if (Rp->next == NULL) return 0;
460+ tmp = Rp->next;
461+ return tmp->length;
462+}
463+
448464 int getFifo (char pkt[])
449465 {
450466 struct FifoPkt *tmp;
451467 int len;
452468
453- if (Rp->next == NULL) return 0;
469+ if (Rp->next == NULL)
470+ {
471+ Fifo_cnt = 0;
472+ return 0;
473+ }
454474 tmp = Rp;
455475 Rp = Rp->next;
456476 len = Rp->length;
@@ -466,7 +486,7 @@ int getFifo (char pkt[])
466486 void putFifo (int len, unsigned char pkt[])
467487 {
468488 struct FifoPkt *ret;
469-
489+//syslog(LOG_DEBUG, "putFifo %d %2.2x %2.2x %2.2x", len, pkt[0], pkt[1], pkt[2]);
470490 #ifdef _DEBUG
471491 syslog (LOG_INFO, "putFifo len:%d %2.2x", len, pkt[0]);
472492 #endif
@@ -705,6 +725,7 @@ void jitter_buff_init(void)
705725 int n;
706726
707727 jitter_rd_pnt = 0;
728+ jitter_wr_pnt = 0;
708729 jitter_wr_cnt = 0;
709730
710731 for (n = 0 ; n < 21 ; n++)
@@ -717,6 +738,7 @@ void jitter_buff_init(void)
717738
718739 void jitter_put (unsigned char buff[])
719740 {
741+ //if (rig_last_frame_send) return;
720742 jitter_wr_pnt = buff[0] & 0x1f;
721743 if (jitter_wr_pnt > 20) return;
722744 if (jitter_wr_pnt)
@@ -726,7 +748,8 @@ void jitter_put (unsigned char buff[])
726748 jitter_wr_cnt++;
727749 if (jitter_wr_cnt < 0) jitter_wr_pnt = 0;
728750 #ifdef _DEBUG_JITTER
729- syslog (LOG_INFO, "jitter put %d %d", jitter_wr_pnt, jitter_wr_cnt);
751+ syslog (LOG_INFO, "jitter put %d %d %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x", jitter_wr_pnt, jitter_wr_cnt,
752+ buff[0], buff[1], buff[2], buff[3], buff[4], buff[5], buff[6],buff[7],buff[8],buff[9],buff[10], buff[11],buff[12]);
730753 #endif
731754 jitter_putFifo();
732755 }
@@ -734,7 +757,9 @@ void jitter_put (unsigned char buff[])
734757 void jitter_putFifo (void)
735758 {
736759 int k, n;
760+ int jitter_n;
737761
762+ if (jitter_buff[jitter_wr_pnt][0] == 0xff) return;
738763 if ((jitter_buff[jitter_wr_pnt][0] != 0xff) && (jitter_buff[jitter_wr_pnt][0] & 0x40))
739764 {
740765 #ifdef _DEBUG_JITTER
@@ -757,10 +782,12 @@ void jitter_putFifo (void)
757782 }
758783 putFifo (13, &jitter_buff[jitter_wr_pnt][0]);
759784 jitter_buff[jitter_wr_pnt][0] = 0xff;
760- jitter_rd_pnt++;
785+ //jitter_rd_pnt++;
786+ //jitter_wr_pnt = jitter_rd_pnt;
761787 if (jitter_rd_pnt > 20) jitter_rd_pnt = 0;
762788 digitalWrite (INET_LED, 0);
763789 digitalWrite (RIG_LED, 0);
790+ rig_last_frame_send = TRUE;
764791 return;
765792 }
766793 while (jitter_buff[jitter_rd_pnt][0] != 0xff)
@@ -769,6 +796,7 @@ void jitter_putFifo (void)
769796 jitter_buff[jitter_rd_pnt][0] = 0xff;
770797 if (jitter_rd_pnt == 0) memcpy (&jitter_buff[jitter_rd_pnt][1], NullVoice, 12);
771798 else memcpy (&jitter_buff[jitter_rd_pnt][1], NullVoice1, 12);
799+ //jitter_wr_pnt = jitter_rd_pnt;
772800 jitter_rd_pnt++;
773801 if (jitter_rd_pnt > 20) jitter_rd_pnt = 0;
774802 jitter_wr_cnt--;
@@ -802,18 +830,19 @@ void jitter_putFifo (void)
802830 }
803831 if (n > 4)
804832 {
805- while (jitter_rd_pnt != jitter_wr_pnt)
833+ jitter_n = jitter_rd_pnt;
834+ while (jitter_n != jitter_wr_pnt)
806835 {
807- if (jitter_buff[jitter_rd_pnt][0] == 0xff) inet_read_drop_cnt++;
808- jitter_buff[jitter_rd_pnt][0] = jitter_rd_pnt;
809- putFifo (13, &jitter_buff[jitter_rd_pnt][0]);
810- jitter_buff[jitter_rd_pnt][0] = 0xff;
811- if (jitter_rd_pnt == 0) memcpy (&jitter_buff[jitter_rd_pnt][1], NullVoice, 12);
812- else memcpy (&jitter_buff[jitter_rd_pnt][1], NullVoice1, 12);
813- jitter_rd_pnt++;
814- if (jitter_rd_pnt > 20) jitter_rd_pnt = 0;
836+ if (jitter_buff[jitter_n][0] == 0xff) inet_read_drop_cnt++;
837+ jitter_buff[jitter_n][0] = jitter_n;
838+ putFifo (13, &jitter_buff[jitter_n][0]);
839+ jitter_buff[jitter_n][0] = 0xff;
840+ if (jitter_n == 0) memcpy (&jitter_buff[jitter_n][1], NullVoice, 12);
841+ else memcpy (&jitter_buff[jitter_n][1], NullVoice1, 12);
842+ jitter_n++;
843+ if (jitter_n > 20) jitter_n = 0;
815844 }
816- jitter_wr_cnt = 0;
845+ //jitter_wr_cnt = 0;
817846 }
818847 }
819848
@@ -833,7 +862,6 @@ void drop_rate_print (void)
833862 sprintf (str, "drop packet rate %d,%02d%% (%ld/%ld)",
834863 rate/100, rate%100, inet_read_drop_cnt, inet_read_cnt);
835864 drop_rate_msg (str);
836- jitter_rd_pnt = 0;
837865 digitalWrite (INET_LED, 0);
838866 digitalWrite (RIG_LED, 0);
839867 }
@@ -902,3 +930,4 @@ int ja_check (unsigned char callsign[])
902930 }
903931 return FALSE;
904932 }
933+
--- a/dstar_data.c
+++ b/dstar_data.c
@@ -51,6 +51,7 @@ void short_msg_wrt (void)
5151
5252 void alt_header_set (unsigned char buff[], unsigned char alt_hdr[], int inet)
5353 {
54+return;
5455 if ((inet_frame_id[0] == 0x00) && (inet_frame_id[1] == 0x00))
5556 {
5657 syslog (LOG_INFO, "alter header set");
@@ -62,29 +63,12 @@ void alt_header_set (unsigned char buff[], unsigned char alt_hdr[], int inet)
6263 if (((buff[7] & ZR) && !memcmp (area_call, &alt_hdr[11], 8)) || scan_sw
6364 || ((buff[7] & GW) && !memcmp (area_call, &alt_hdr[3], 8)))
6465 {
65- memcpy (inet_frame_id, &buff[14], 2);
66+ memcpy (inet_frame_id_save, &buff[14], 2);
6667 send_buff[0] = 0x29;
6768 send_buff[1] = 0x20,
6869 memcpy (&send_buff[2], alt_hdr, 39);
6970 send_buff[41] = 0xff;
7071 header_store (send_buff);
71- putFifo (42, send_buff);
72- recv_frame_seq = 20;
73- gettimeofday (&inet_recv_time, NULL);
74- rig_last_frame_send = FALSE;
75- inet_read_cnt = 0;
76- inet_read_drop_cnt = 0;
77- jitter_max = 0;
78- jitter_min = 500000;
79- jitter_ave = 0;
80- #ifdef _SPECIFICATION_CHECK
81- memset (voice_packet_save, 0xff, 15);
82- #endif
83- memset (short_msg, 0x20, 20);
84- memcpy (used_call, &alt_hdr[27], 8);
85- memcpy (used_call2, &alt_hdr[35], 4);
86- short_msg_wrt();
87- send_msg_sw = FALSE;
8872 }
8973 if (!scan_sw)
9074 {
@@ -143,46 +127,9 @@ void dstar_data (unsigned char string[], int inet)
143127 memcpy (&short_msg[15], &data_temp[0], 5);
144128 short_msg_wrt();
145129 break;
146-
147- case 0x51:
148- n = (string[16] - code_sq) / 2 - 1;
149- if (n != 8) break;
150- alt_header[40] = data_temp[0];
151- crc_dstar_ffff = 0xffff;
152- for (n = 0 ; n < 39 ; n++)
153- {
154- crc_dstar_ffff = update_crc_dstar (crc_dstar_ffff, alt_header[n]);
155- }
156- crc_dstar_ffff = result_crc_dstar(crc_dstar_ffff);
157- if ((alt_header[39] == (crc_dstar_ffff >> 8)) && (alt_header[40] == (crc_dstar_ffff & 0xff)))
158- {
159- //syslog (LOG_INFO, "crc ok");
160- alt_header_set (string, alt_header, inet);
161- }
162- #if 0
163- syslog (LOG_INFO, "%4.4x", crc_dstar_ffff);
164- syslog (LOG_INFO, "%2.2x %2.2x %2.2x %36.36s %2.2x %2.2x",
165- alt_header[0], alt_header[1], alt_header[2],
166- &alt_header[3], alt_header[39], alt_header[40]);
167- #endif
168- break;
169-
170- case 0xc2:
171- code_sq = 2;
172- break;
173-
174- case 0x55:
175- n = (string[16] - code_sq) / 2 - 1;
176- if ((n < 0) || (n > 7)) break;
177- memcpy (&alt_header[n*5], &data_temp[0], 5);
178- break;
179130 }
180131 }
181132 }
182- else
183- {
184- code_sq = 0;
185- }
186133 }
187134
188135 void rig_alt_header_set (unsigned char alt_hdr[])
@@ -191,6 +138,7 @@ void rig_alt_header_set (unsigned char alt_hdr[])
191138 unsigned short int crc;
192139
193140 if (!rig_status_check()) return;
141+ if (send_header_sw) return;
194142
195143 if (!scan_sw) syslog (LOG_NOTICE, "Alt header %8.8s from rig", &alt_hdr[27]);
196144 else
@@ -262,4 +210,74 @@ void rig_alt_header_set (unsigned char alt_hdr[])
262210 seq = 0;
263211 }
264212
213+void dstar_alt_header (unsigned char string[], int inet)
214+{
215+ unsigned short int crc_dstar_ffff;
216+ int n;
217+
218+ if (string[16] != 0)
219+ {
220+ if (string[16] & 0x40) // Last Frame
221+ {
222+ return;
223+ }
224+
225+ if (string[16] % 2)
226+ {
227+ mini_header
228+ = string[26] ^ 0x70;
229+ data_temp[0]
230+ = string[27] ^ 0x4f;
231+ data_temp[1]
232+ = string[28] ^ 0x93;
233+ }
234+ else
235+ {
236+ data_temp[2]
237+ = string[26] ^ 0x70;
238+ data_temp[3]
239+ = string[27] ^ 0x4f;
240+ data_temp[4]
241+ = string[28] ^ 0x93;
242+ switch (mini_header)
243+ {
244+ case 0x51:
245+ n = (string[16] - code_sq) / 2 - 1;
246+ if (n != 8) break;
247+ alt_header[40] = data_temp[0];
248+ crc_dstar_ffff = 0xffff;
249+ for (n = 0 ; n < 39 ; n++)
250+ {
251+ crc_dstar_ffff = update_crc_dstar (crc_dstar_ffff, alt_header[n]);
252+ }
253+ crc_dstar_ffff = result_crc_dstar(crc_dstar_ffff);
254+ if ((alt_header[39] == (crc_dstar_ffff >> 8)) && (alt_header[40] == (crc_dstar_ffff & 0xff)))
255+ {
256+ //syslog (LOG_INFO, "crc ok");
257+ alt_header_set (string, alt_header, inet);
258+ }
259+ #if 0
260+ syslog (LOG_INFO, "%4.4x", crc_dstar_ffff);
261+ syslog (LOG_INFO, "%2.2x %2.2x %2.2x %36.36s %2.2x %2.2x",
262+ alt_header[0], alt_header[1], alt_header[2],
263+ &alt_header[3], alt_header[39], alt_header[40]);
264+ #endif
265+ break;
266+
267+ case 0xc2:
268+ code_sq = 2;
269+ break;
265270
271+ case 0x55:
272+ n = (string[16] - code_sq) / 2 - 1;
273+ if ((n < 0) || (n > 7)) break;
274+ memcpy (&alt_header[n*5], &data_temp[0], 5);
275+ break;
276+ }
277+ }
278+ }
279+ else
280+ {
281+ code_sq = 0;
282+ }
283+}
--- a/dvap.c
+++ b/dvap.c
@@ -9,6 +9,7 @@ void send_dvap_keep_alive(void);
99 int inet_send_buff_set(void);
1010 void inet_led_onoff(void);
1111 void dstar_data(unsigned char string[], int inet);
12+void dstar_alt_header (unsigned char string[], int inet);
1213 void short_msg_wrt (void);
1314 void send_msg (unsigned char str[], unsigned char my2[]);
1415 int cmd_check (unsigned char cmd[]);
@@ -633,6 +634,7 @@ void dvap_send_header (void)
633634 memcpy (used_call, &inet_send_buff[44], 8);
634635 memcpy (used_call2, &inet_send_buff[52], 4);
635636 short_msg_wrt ();
637+ send_header_sw = TRUE;
636638 if (gw_on)
637639 {
638640 memcpy (&inet_send_buff[20], zone_call, 8);
@@ -662,8 +664,13 @@ void dvap_send_header (void)
662664 void dvap_send_voice (void)
663665 {
664666 int length;
665-
666- //if (!dvap_voice_send_sw) return;
667+ if (!send_header_sw)
668+ {
669+ inet_send_buff[16] = dvap_voice[4];
670+ memcpy (&inet_send_buff[17], &dvap_voice[6], 12);
671+ dstar_alt_header (inet_send_buff, FALSE);
672+ return;
673+ }
667674
668675 inet_send_buff[9] = 0x13;
669676 inet_send_buff[4] = (m_seq >> 8) & 0xff;
@@ -724,7 +731,7 @@ void dvap_write (int fd, unsigned char buff[], int length)
724731
725732 if (length == 42)
726733 {
727- if (!dvap_send_header_sw)
734+ if (!send_header_sw)
728735 {
729736 time(&dvap_keep_alive);
730737 dvap_send_pkt[0] = 0x2f;
@@ -736,9 +743,10 @@ void dvap_write (int fd, unsigned char buff[], int length)
736743 memcpy (&dvap_send_pkt[6], &buff[2], 41);
737744 dvap_send_pkt[6] &= 0x07;
738745 ret = write (fd, dvap_send_pkt, 47);
739- dvap_send_pkt[4] = 0x00;
746+ //dvap_send_pkt[4] = 0x00;
740747 dvap_send_pkt[5]++;
741- dvap_send_header_sw = TRUE;
748+
749+ send_header_sw = TRUE;
742750 dvap_first_voice_pkt = TRUE;
743751 syslog (LOG_DEBUG, "to DVAP rpt2:%8.8s rpt1:%8.8s ur:%8.8s my:%8.8s my2:%4.4s", &buff[5], &buff[13],&buff[21], &buff[29], &buff[37]);
744752 #ifdef _DEBUG_DVAP_SEND
@@ -753,7 +761,7 @@ syslog (LOG_DEBUG, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x
753761 }
754762 else if (length == 17)
755763 {
756- if (dvap_send_header_sw)
764+ if (send_header_sw)
757765 {
758766
759767 if (!dvap_first_voice_pkt || !memcmp (&buff[13], resync , 3))
@@ -761,17 +769,18 @@ syslog (LOG_DEBUG, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x
761769 time(&dvap_keep_alive);
762770 dvap_send_pkt[0] = 0x12;
763771 dvap_send_pkt[1] = 0xc0;
772+ dvap_send_pkt[4] = buff[3];
764773 memcpy (&dvap_send_pkt[6], &buff[4], 12);
765774 if ((dvap_send_pkt[4] & 0x40) ||
766775 (!memcmp (&dvap_send_pkt[6], &lastframe[3], 3) && !memcmp (&dvap_send_pkt[15], lastframe, 3)))
767776 {
768- dvap_send_pkt[4] |= 0x40;
769- dvap_send_header_sw = FALSE;
777+ dvap_send_pkt[5] |= 0x40;
778+ send_header_sw = FALSE;
770779 }
771780 ret = write (fd, dvap_send_pkt, 18);
772781 dvap_send_pkt[5]++;
773- dvap_send_pkt[4]++;
774- if (dvap_send_pkt[4] == 21) dvap_send_pkt[4] = 0;
782+ //dvap_send_pkt[4]++;
783+ //if (dvap_send_pkt[4] == 21) dvap_send_pkt[4] = 0;
775784 dvap_first_voice_pkt = FALSE;
776785 #ifdef _DEBUG_DVAP_SEND
777786 syslog (LOG_DEBUG, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x",
--- a/dvmega.h
+++ b/dvmega.h
@@ -24,6 +24,7 @@ int dvmega_last_frame_sw;
2424 int dvmega_sw;
2525 int dvmega_gw_resp_sw;
2626 int dvmega_NoRespReply_sw;
27+int dvmega_send_header_sw;
2728
2829 //unsigned char dvmega_squelch;
2930
--- a/dvmega_utils.c
+++ b/dvmega_utils.c
@@ -8,6 +8,7 @@ void inet_led_onoff(void);
88 int inet_send_buff_set(void);
99 void short_msg_wrt(void);
1010 void dstar_data (unsigned char string[], int inet);
11+void dstar_alt_header (unsigned char string[], int inet);
1112 void rig_buff_reset (int length);
1213 unsigned short int crc_calc (unsigned char string[], int length);
1314 int cmd_check (unsigned char cmd[]);
@@ -17,7 +18,7 @@ int rig_status_check (void);
1718 char lastframe1[3] = {0x55, 0x55, 0x55};
1819 char lastframe2[3] = {0x55, 0xc8, 0x7a};
1920 int dvmega_last_frame_sw;
20-
21+extern unsigned char resync[];
2122
2223 void dvmega_write (int fd, unsigned char buff[], int length)
2324 {
@@ -148,6 +149,7 @@ void dvmega_read (void)
148149 if (memcmp (&inet_send_buff[36], "CQCQCQ ", 8)) gw_on = TRUE;
149150 if (send_sw && !rig_send_sw)
150151 {
152+ send_header_sw = TRUE;
151153 memset (inet_frame_id, 0xff, 2);
152154 dvmega_last_frame_sw = FALSE;
153155 in_addr.sin_port = htons(dest_inet_port);
@@ -196,6 +198,16 @@ void dvmega_read (void)
196198 break;
197199
198200 case DVMEGA_DSTAR_DATA:
201+ if (!memcmp (&rig_buff[12], resync, 3)) dvmega_frame_seq = 0;
202+ if (!send_header_sw)
203+ {
204+ inet_send_buff[16] = dvmega_frame_seq;
205+ dvmega_frame_seq++;
206+ if (dvmega_frame_seq > 20) dvmega_frame_seq = 0;
207+ memcpy (&inet_send_buff[17], &rig_buff[3], 12);
208+ dstar_alt_header (inet_send_buff, FALSE);
209+ break;
210+ }
199211 #ifdef _DEBUG_DVMEGA
200212 syslog (LOG_DEBUG, "data %2.2x %d %2.2x %2.2x %2.2x %2.2x",
201213 rig_buff[0], rig_buff[1], rig_buff[2], rig_buff[3], rig_buff[4], rig_buff[5]);
@@ -250,7 +262,6 @@ void dvmega_read (void)
250262 in_addr.sin_addr.s_addr = inet_addr(dest_address);
251263 sendto (in_addr_sock, inet_send_buff, 29, MSG_DONTWAIT,
252264 (struct sockaddr *)&in_addr, sizeof(in_addr));
253- dstar_data (inet_send_buff, FALSE);
254265 }
255266 m_seq++;
256267 m_seq &= 0xffff;
@@ -260,6 +271,7 @@ void dvmega_read (void)
260271 #ifdef _DEBUG_DVMEGA
261272 syslog (LOG_DEBUG, "EOT");
262273 #endif
274+ send_header_sw = FALSE;
263275 if (!dvmega_last_frame_sw)
264276 {
265277 if (send_sw)
--- a/from_node.c
+++ b/from_node.c
@@ -7,6 +7,7 @@ void inet_led_onoff (void);
77 int inet_send_buff_set (void);
88 void short_msg_wrt (void);
99 void dstar_data (unsigned char string[], int inet);
10+void dstar_alt_header (unsigned char string[], int inet);
1011 unsigned short int crc_calc (char str[], int length);
1112 int cmd_check (unsigned char cmd[]);
1213 int rig_status_check(void);
@@ -112,6 +113,7 @@ void header_read_from_node(void) /* read from rig (DV packet) */
112113 m_seq++;
113114 m_seq &= 0xffff;
114115 HeaderLength = 41;
116+ send_header_sw = TRUE;
115117 voice_pnt = 12;
116118 seq = 0;
117119 }
@@ -144,7 +146,6 @@ int voice_read_from_node()
144146 ret = usb_control_msg(udev, 0xC0, GET_DATA, 0, 0, usb.buffer, read_len, 200);
145147 if (ret > 0)
146148 {
147- //gettimeofday(&Node_InTime, NULL);
148149 for (i = 0 ; i < ret; i++)
149150 {
150151 node_voice_save[voice_pnt] = usb.buffer[i];
@@ -169,7 +170,7 @@ int voice_read_from_node()
169170 seq++;
170171 if (seq > 20) seq = 0;
171172 memcpy (&inet_send_buff[17], node_voice_save, 12);
172- if (send_sw && !rig_send_sw && node_voice_send_sw)
173+ if (send_sw && !rig_send_sw && send_header_sw)
173174 {
174175 in_addr.sin_port = htons(dest_inet_port);
175176 in_addr.sin_addr.s_addr = inet_addr(dest_address);
@@ -177,6 +178,9 @@ int voice_read_from_node()
177178 (struct sockaddr *)&in_addr, sizeof(in_addr));
178179 dstar_data (inet_send_buff, FALSE);
179180 }
181+ else
182+ dstar_alt_header (inet_send_buff, FALSE);
183+
180184 m_seq++;
181185 m_seq &= 0xffff;
182186 }
@@ -198,6 +202,7 @@ int voice_read_from_node()
198202 memset (inet_frame_id, 0x00, 2);
199203 frameID = 0;
200204 HeaderLength = 0;
205+ send_header_sw = FALSE;
201206 node_voice_send_sw = FALSE;
202207 digitalWrite (RIG_LED, 0);
203208 digitalWrite (INET_LED, 0);
--- a/inet_read.c
+++ b/inet_read.c
@@ -9,9 +9,9 @@ void jitter_put (unsigned char str[]);
99 void rig_send_check(void);
1010 void called_msg (char call1[], char call2[]);
1111 void dstar_data (unsigned char string[], int inet);
12+void dstar_alt_header (unsigned char string[], int inet);
1213 void short_msg_wrt (void);
13-
14-//unsigned char recvBuff[256];
14+void jitter_buff_init (void);
1515
1616 char dummy_frame_1[12] = {
1717 0x73, 0x44, 0x1a, 0x72, 0x31, 0x3c, 0xa7, 0x53, 0x02, 0x55, 0x55, 0x55};
@@ -40,6 +40,7 @@ void rig_fifo_check (void)
4040
4141 void dummy_last_frame (void)
4242 {
43+ if (rig_last_frame_send) return;
4344 recvBuff[16] = jitter_rd_pnt;
4445 memcpy (&recvBuff[17], dummy_frame_1, 12);
4546 jitter_put (&recvBuff[16]);
@@ -61,7 +62,7 @@ void dummy_last_frame (void)
6162 digitalWrite (RIG_LED, 0);
6263 rig_last_frame_send = TRUE;
6364 drop_rate_print();
64- dvap_send_header_sw = FALSE;
65+ send_header_sw = FALSE;
6566 }
6667
6768 void inet_read (void)
@@ -180,6 +181,7 @@ void inet_read (void)
180181 || ((recvBuff[7] & GW) && !memcmp (area_call, &recvBuff[20], 8)))
181182 {
182183 memcpy (inet_frame_id, &recvBuff[14], 2);
184+ memcpy (inet_frame_id_save, &recvBuff[14], 2);
183185 send_buff[0] = 0x29;
184186 send_buff[1] = 0x20,
185187 memcpy (&send_buff[2], &recvBuff[17], 39);
@@ -194,6 +196,7 @@ void inet_read (void)
194196 jitter_max = 0;
195197 jitter_min = 500000;
196198 jitter_ave = 0;
199+ jitter_buff_init();
197200 #ifdef _SPECIFICATION_CHECK
198201 memset (voice_packet_save, 0xff, 15);
199202 #endif
@@ -201,8 +204,8 @@ void inet_read (void)
201204 memcpy (used_call, &recvBuff[44], 8);
202205 memcpy (used_call2, &recvBuff[52], 4);
203206 short_msg_wrt();
204- send_msg_sw = FALSE;
205207 beep_sw = OFF;
208+ send_header_sw = TRUE;
206209 }
207210 if (!scan_sw)
208211 {
@@ -218,11 +221,12 @@ void inet_read (void)
218221 }
219222 else if (length == 29)
220223 {
221- if (!memcmp (&inet_frame_id, &recvBuff[14], 2))
224+ if (send_header_sw && !memcmp (&inet_frame_id, &recvBuff[14], 2) && (inet_frame_id[0] != 0x00) && (inet_frame_id[1] != 0x00))
222225 {
223226 #ifdef _SPECIFICATIO_CHECK
224227 if (!memcmp (&recvBuff[14], voice_packet_save, 15))
225- syslog (LOG_INFO, "Dup. packet (maybe loop) from %2.2x %2.2x %2.2x", recvBuff[14], recvBuff[15], recvBuff[16]);
228+ syslog (LOG_INFO, "Dup. packet (maybe loop) from %2.2x %2.2x %2.2x",
229+ recvBuff[14], recvBuff[15], recvBuff[16]);
226230 memcpy (voice_packet_save, &recvBuff[14], 15);
227231 #endif
228232 #ifdef _DEBUG
@@ -233,11 +237,14 @@ void inet_read (void)
233237 if (recvBuff[16] & 0x40)
234238 {
235239 memcpy (&recvBuff[17], dummy_frame_3, 12);
240+ jitter_put (&recvBuff[16]);
236241 memset (inet_frame_id, 0x00, 2);
242+ memset (inet_frame_id_save, 0x00, 2);
237243 digitalWrite (INET_LED, 0);
238244 digitalWrite (RIG_LED, 0);
239245 rig_last_frame_send = TRUE;
240246 drop_rate_print();
247+ send_header_sw = FALSE;
241248 rig_send_check();
242249 }
243250 inet_recv_time_save.tv_sec = inet_recv_time.tv_sec;
@@ -253,10 +260,10 @@ void inet_read (void)
253260 syslog (LOG_INFO, "insert dummy_last_frame");
254261 dummy_last_frame();
255262 }
256- #ifdef _SPECIFICATION_CHECK
263+ //#ifdef _SPECIFICATION_CHECK
257264 if (t_sub > 300) syslog (LOG_INFO, "long interval %ld.%03ld Sec. seq:%2.2x", t_sub / 1000, t_sub % 1000, recvBuff[16]);
258265 //if (t_sub < 2) syslog (LOG_INFO, "short interval %ld mSec.", t_sub);
259- #endif
266+ //#endif
260267 if (!memcmp (&recvBuff[17] , dummy_frame_3, 3) && !memcmp (&recvBuff[26], &dummy_frame_3[9], 3))
261268 {
262269 recvBuff[16] |= 0x40;
@@ -269,14 +276,76 @@ void inet_read (void)
269276 recvBuff[16], recvBuff[26] ^ 0x70, recvBuff[27] ^ 0x4f, recvBuff[28] ^ 0x93, recvBuff[26] ^ 0x70, recvBuff[27] ^ 0x4f, recvBuff[28] ^ 0x93);
270277 #endif
271278 }
272- else
279+ else if ((recvBuff[16] == 0) && !send_header_sw && !memcmp (&inet_frame_id_save, &recvBuff[14], 2))
273280 {
274- dstar_data (recvBuff, TRUE);
281+ if ((inet_frame_id[0] == 0x00) && (inet_frame_id[1] == 0x00))
282+ {
283+ syslog (LOG_DEBUG, "same frame ID");
284+ memcpy (inet_frame_id, inet_frame_id_save, 2);
285+ putFifo (42, header_save);
286+ recv_frame_seq = 20;
287+ gettimeofday (&inet_recv_time, NULL);
288+ rig_last_frame_send = FALSE;
289+ inet_read_cnt = 0;
290+ inet_read_drop_cnt = 0;
291+ jitter_max = 0;
292+ jitter_min = 500000;
293+ jitter_ave = 0;
294+ jitter_buff_init();
295+ #ifdef _SPECIFICATION_CHECK
296+ memset (voice_packet_save, 0xff, 15);
297+ #endif
298+ memset (short_msg, 0x20, 20);
299+ short_msg_wrt();
300+ send_msg_sw = FALSE;
301+ beep_sw = OFF;
302+ send_header_sw = TRUE;
303+ inet_read_cnt++;
304+ if (recvBuff[16] == 0x00) inet_led_onoff();
305+ if (recvBuff[16] & 0x40)
306+ {
307+ memcpy (&recvBuff[17], dummy_frame_3, 12);
308+ memset (inet_frame_id, 0x00, 2);
309+ memset (inet_frame_id_save, 0x00, 2);
310+ digitalWrite (INET_LED, 0);
311+ digitalWrite (RIG_LED, 0);
312+ rig_last_frame_send = TRUE;
313+ drop_rate_print();
314+ send_header_sw = FALSE;
315+ rig_send_check();
316+ }
317+ inet_recv_time_save.tv_sec = inet_recv_time.tv_sec;
318+ inet_recv_time_save.tv_usec = inet_recv_time.tv_usec;
319+ gettimeofday (&inet_recv_time, NULL);
320+ timersub (&inet_recv_time, &inet_recv_time_save, &time_sub);
321+ t_sub = time_sub.tv_sec * 1000 + time_sub.tv_usec / 1000;
322+ if (t_sub > jitter_max) jitter_max = t_sub;
323+ if (t_sub & (t_sub < jitter_min)) jitter_min = t_sub;
324+ jitter_ave += (t_sub - 20);
325+ if (timercmp (&time_sub, &inet_recv_timeout, >) && !(recvBuff[16] & 0x40))
326+ {
327+ syslog (LOG_INFO, "insert dummy_last_frame");
328+ dummy_last_frame();
329+ }
330+ //#ifdef _SPECIFICATION_CHECK
331+ if (t_sub > 300) syslog (LOG_INFO, "long interval %ld.%03ld Sec. seq:%2.2x", t_sub / 1000, t_sub % 1000, recvBuff[16]);
332+ //if (t_sub < 2) syslog (LOG_INFO, "short interval %ld mSec.", t_sub);
333+ //#endif
334+ if (!memcmp (&recvBuff[17] , dummy_frame_3, 3) && !memcmp (&recvBuff[26], &dummy_frame_3[9], 3))
335+ {
336+ recvBuff[16] |= 0x40;
337+ memset (inet_frame_id, 0x00, 2);
338+ }
339+ jitter_put (&recvBuff[16]);
340+ if (!scan_sw) dstar_data (recvBuff, TRUE);
341+ }
275342 }
343+ dstar_alt_header (recvBuff, TRUE);
276344 }
277345 else if (length == 32)
278346 {
279- if (!memcmp (inet_frame_id, &recvBuff[14], 2))
347+ if (send_header_sw && !memcmp (&inet_frame_id, &recvBuff[14], 2) && (inet_frame_id[0] != 0x00) && (inet_frame_id[1] != 0x00))
348+ //if ((recvBuff[16] == 0) && !send_header_sw && !memcmp (&inet_frame_id_save, &recvBuff[14], 2))
280349 {
281350 #ifdef _SPECIFICATION_CHECK
282351 syslog (LOG_INFO, "Packet length wrong (32 bytes) from %8.8s", &header_save[29]);
@@ -315,6 +384,7 @@ void inet_read (void)
315384 recvBuff[16] |= 0x40;
316385 memcpy (&recvBuff[17], dummy_frame_3, 12);
317386 memset (inet_frame_id, 0x00, 2);
387+ memset (inet_frame_id_save, 0x00, 2);
318388 inet_recv_time_save.tv_sec = inet_recv_time.tv_sec;
319389 inet_recv_time_save.tv_usec = inet_recv_time.tv_usec;
320390 gettimeofday (&inet_recv_time, NULL);
--- a/main.c
+++ b/main.c
@@ -1,7 +1,7 @@
11 #include "dmonitor.h"
22
33 void send_keep_alive(void);
4-void send_dest_keep_alive(void);
4+int send_dest_keep_alive(void);
55 void inet_read(void);
66 void init(void);
77 void handler (void);
@@ -13,6 +13,8 @@ int rig_status_check (void);
1313 int dvap_status_check (void);
1414 int dvmega_status_check (void);
1515 int node_status_check (void);
16+int rig_read(void);
17+int node_space_check (int length);
1618
1719 void rig_close (void);
1820 void connected_table_clean(void);
@@ -88,6 +90,7 @@ int main(int argc, char *argv[])
8890 beep_sw = OFF;
8991 scan_stop_sw = FALSE;
9092 lcd_time_save = 0;
93+ send_header_sw = FALSE;
9194
9295 openlog ("dmonitor", LOG_CONS | LOG_PID, LOG_LOCAL0);
9396
@@ -291,7 +294,6 @@ int main(int argc, char *argv[])
291294 if (rig_type == DVAP) dvap_conf();
292295 else if (rig_type == DVMEGA) dvmega_conf();
293296 else if (rig_type == NODE) node_conf();
294- dvap_send_header_sw = FALSE;
295297 dvap_first_voice_pkt = FALSE;
296298
297299 for (k = 0 ; k < 2 ; k++)
@@ -375,7 +377,7 @@ top:
375377 time (&msg_send_set_time);
376378 syslog (LOG_INFO,
377379 "Not Connected to %8.8s", area_call);
378- error_msg ("ERROR接続できまません");
380+ error_msg ("ERROR接続できません");
379381
380382 sleep (15);
381383 break;
@@ -398,24 +400,39 @@ top:
398400 }
399401 if(rig_send_sw)
400402 {
401- gettimeofday (&c_time, NULL);
402- timeradd (&rig_send_time, &rig_send_time_20mSec, &temp_time);
403- if (timercmp (&c_time, &temp_time, >))
403+ if (rig_type == NODE)
404404 {
405- if (send_rig())
405+ if (node_space_check (15))
406406 {
407- rig_send_time.tv_sec = temp_time.tv_sec;
408- rig_send_time.tv_usec = temp_time.tv_usec;
407+ if (!send_rig())
408+ {
409+ syslog (LOG_INFO, "Empty of the jitter buffer");
410+ LastFrameSend();
411+ }
409412 }
410- else
413+ }
414+ else
415+ {
416+ gettimeofday (&c_time, NULL);
417+ timeradd (&rig_send_time, &rig_send_time_20mSec, &temp_time);
418+ if (timercmp (&c_time, &temp_time, >))
411419 {
412- syslog (LOG_INFO, "Empty of the jitter buffer");
413- LastFrameSend();
420+ if (send_rig())
421+ {
422+ rig_send_time.tv_sec = temp_time.tv_sec;
423+ rig_send_time.tv_usec = temp_time.tv_usec;
424+ }
425+ else
426+ {
427+ syslog (LOG_INFO, "Empty of the jitter buffer");
428+ LastFrameSend();
429+ }
414430 }
415431 }
416432 }
417433 if ((inet_frame_id[0] != 0xff) || (inet_frame_id[1] != 0xff))
418434 {
435+//syslog (LOG_DEBUG, "%2.2x %2.2x", inet_frame_id[0], inet_frame_id[1]);
419436 if ((inet_frame_id[0] != 0x00) || (inet_frame_id[1] != 0x00))
420437 {
421438 gettimeofday (&c_time, NULL);
@@ -424,10 +441,11 @@ top:
424441 {
425442 syslog (LOG_INFO, "insert dummy_last_frame");
426443 dummy_last_frame();
427- #ifdef _SPECIFICATION_CHECK
444+ //#ifdef _SPECIFICATION_CHECK
428445 timersub (&c_time, &inet_recv_time, &temp_time);
429446 syslog (LOG_INFO, "long interval %ld.%03ld Sec.", temp_time.tv_sec, temp_time.tv_usec/1000);
430- #endif
447+ //#endif
448+ gettimeofday (&inet_recv_time, NULL);
431449 }
432450 }
433451 }
@@ -454,14 +472,14 @@ skip:
454472 beep_sw = OFF;
455473 }
456474 #endif
457- if (send_msg_sw && (!scan_sw || scan_stop_sw))
475+ if (send_msg_sw && (!scan_sw || scan_stop_sw)) /* send replay message for cmd */
458476 {
459477 if (((rig_type == ICOM) && rig_status_check())
460478 || ((rig_type == DVAP) && dvap_status_check())
461479 || ((rig_type == DVMEGA) && dvmega_status_check())
462480 || ((rig_type == NODE) && node_status_check()))
463481 {
464- if (frameID == 0)
482+ if ((frameID == 0) && (inet_frame_id[0] == 0x00) && (inet_frame_id[1] == 0x00))
465483 {
466484 send_msg(msg_temp, mycall2);
467485 if (reboot_sw)
--- a/rig_read.c
+++ b/rig_read.c
@@ -23,6 +23,7 @@ void dvap_write (int fd, unsigned char buff[], int length);
2323 void dvmega_write (int fd, unsigned char buff[], int length);
2424 void node_write (unsigned char buff[], int length);
2525 void dstar_data (unsigned char string[], int inet);
26+void dstar_alt_header (unsigned char string[], int inet);
2627 void short_msg_wrt (void);
2728 void rig_not_connect_msg (void);
2829 int dvmega_init (void);
@@ -271,6 +272,7 @@ void rig(void)
271272 break;
272273
273274 case NODE_INIT_DONE:
275+ gettimeofday (&inet_recv_time, NULL);
274276 rig_state = HOLE_PUNCH_WAIT;;
275277 break;
276278
@@ -429,6 +431,7 @@ int rig_read (void)
429431 if (memcmp (&inet_send_buff[36], "CQCQCQ ", 8)) gw_on = TRUE;
430432 if (send_sw && !rig_send_sw)
431433 {
434+ send_header_sw = TRUE;
432435 memset (inet_frame_id, 0xff, 2);
433436 in_addr.sin_port = htons(dest_inet_port);
434437 in_addr.sin_addr.s_addr = inet_addr(dest_address);
@@ -489,7 +492,7 @@ int rig_read (void)
489492 }
490493 if (rig_buff[3] & 0x40) memset (&rig_buff[13], 0x55, 3);
491494 memcpy (&inet_send_buff[16], &rig_buff[3], 13);
492- if (send_sw)
495+ if (send_sw && send_header_sw)
493496 {
494497 in_addr.sin_port = htons(dest_inet_port);
495498 in_addr.sin_addr.s_addr = inet_addr(dest_address);
@@ -497,10 +500,13 @@ int rig_read (void)
497500 (struct sockaddr *)&in_addr, sizeof(in_addr));
498501 dstar_data (inet_send_buff, FALSE);
499502 }
503+ else
504+ dstar_alt_header (inet_send_buff, FALSE);
500505 if (rig_buff[3] & 0x40)
501506 {
502507 memset (inet_frame_id, 0x00, 2);
503508 frameID = 0;
509+ send_header_sw = FALSE;
504510 digitalWrite (RIG_LED, 0);
505511 digitalWrite (INET_LED, 0);
506512 }
@@ -572,7 +578,6 @@ void rig_write (int length, unsigned char buff[])
572578 }
573579 else if (rig_type == NODE)
574580 {
575-
576581 node_write (buff, length);
577582 }
578583
--- a/rpt_conn.h
+++ b/rpt_conn.h
@@ -144,7 +144,7 @@ unsigned char MD5_dmonitor[32];
144144
145145 char rig_type;
146146
147-int dvap_send_header_sw;
147+//int send_header_sw;
148148 char dvap_first_voice_pkt;
149149
150150 time_t dest_keep_alive_send_time;
--- a/rpt_conn_dvap.c
+++ b/rpt_conn_dvap.c
@@ -563,60 +563,51 @@ void dvap_write (int fd, unsigned char buff[], int length)
563563
564564 if (length == 42)
565565 {
566- if (!dvap_send_header_sw)
567- {
568- time(&dvap_keep_alive);
569- dvap_send_pkt[0] = 0x2f;
570- dvap_send_pkt[1] = 0xa0;
571- tmp = rand() & 0xffff;
572- memcpy (&dvap_send_pkt[2], &tmp, 2);
573- dvap_send_pkt[4] = 0x80;
574- dvap_send_pkt[5] = 0x00;
575- memcpy (&dvap_send_pkt[6], &buff[2], 41);
576- dvap_send_pkt[6] &= 0x07;
577- ret = write (fd, dvap_send_pkt, 47);
578- dvap_send_pkt[4] = 0x00;
579- dvap_send_pkt[5]++;
580- dvap_send_header_sw = TRUE;
581- dvap_first_voice_pkt = TRUE;
582- syslog (LOG_DEBUG, "to DVAP rpt2:%8.8s rpt1:%8.8s ur:%8.8s my:%8.8s my2:%4.4s", &buff[5], &buff[13],&buff[21], &buff[29], &buff[37]);
583-#if 0
584-syslog (LOG_DEBUG, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x",
566+ time(&dvap_keep_alive);
567+ dvap_send_pkt[0] = 0x2f;
568+ dvap_send_pkt[1] = 0xa0;
569+ tmp = rand() & 0xffff;
570+ memcpy (&dvap_send_pkt[2], &tmp, 2);
571+ dvap_send_pkt[4] = 0x80;
572+ dvap_send_pkt[5] = 0x00;
573+ memcpy (&dvap_send_pkt[6], &buff[2], 41);
574+ dvap_send_pkt[6] &= 0x07;
575+ ret = write (fd, dvap_send_pkt, 47);
576+ dvap_send_pkt[4] = 0x00;
577+ dvap_send_pkt[5]++;
578+ dvap_first_voice_pkt = TRUE;
579+ syslog (LOG_DEBUG, "to DVAP rpt2:%8.8s rpt1:%8.8s ur:%8.8s my:%8.8s my2:%4.4s", &buff[5], &buff[13],&buff[21], &buff[29], &buff[37]);
580+#if 0
581+sysog (LOG_DEBUG, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x",
585582 dvap_send_pkt[0],dvap_send_pkt[1],dvap_send_pkt[2],dvap_send_pkt[3], dvap_send_pkt[4],dvap_send_pkt[5],dvap_send_pkt[6], dvap_send_pkt[7],dvap_send_pkt[8],dvap_send_pkt[9], dvap_send_pkt[10],dvap_send_pkt[11],dvap_send_pkt[12], dvap_send_pkt[13],dvap_send_pkt[14],dvap_send_pkt[15]);
586583 syslog (LOG_DEBUG, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x",
587584 dvap_send_pkt[16],dvap_send_pkt[17],dvap_send_pkt[18],dvap_send_pkt[19], dvap_send_pkt[20],dvap_send_pkt[21],dvap_send_pkt[22], dvap_send_pkt[23],dvap_send_pkt[24],dvap_send_pkt[25], dvap_send_pkt[26],dvap_send_pkt[27],dvap_send_pkt[28], dvap_send_pkt[29],dvap_send_pkt[30],dvap_send_pkt[31]);
588585 syslog (LOG_DEBUG, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x",
589586 dvap_send_pkt[32],dvap_send_pkt[33],dvap_send_pkt[34],dvap_send_pkt[35], dvap_send_pkt[36],dvap_send_pkt[37],dvap_send_pkt[38], dvap_send_pkt[39],dvap_send_pkt[40],dvap_send_pkt[41], dvap_send_pkt[42],dvap_send_pkt[43],dvap_send_pkt[44], dvap_send_pkt[45],dvap_send_pkt[46],dvap_send_pkt[47]);
590587 #endif
591- }
592588 }
593589 else if (length == 17)
594590 {
595- if (dvap_send_header_sw)
596- {
597-
598- if (!dvap_first_voice_pkt || !memcmp (&buff[13], resync , 3))
599- {
600- time(&dvap_keep_alive);
601- dvap_send_pkt[0] = 0x12;
602- dvap_send_pkt[1] = 0xc0;
603- memcpy (&dvap_send_pkt[6], &buff[4], 12);
604- if ((dvap_send_pkt[4] & 0x40) ||
605- (!memcmp (&dvap_send_pkt[6], &lastframe[3], 3) && !memcmp (&dvap_send_pkt[15], lastframe, 3)))
606- {
607- dvap_send_pkt[4] |= 0x40;
608- dvap_send_header_sw = FALSE;
609- }
610- ret = write (fd, dvap_send_pkt, 18);
611- dvap_send_pkt[5]++;
612- dvap_send_pkt[4]++;
613- if (dvap_send_pkt[4] == 21) dvap_send_pkt[4] = 0;
614- dvap_first_voice_pkt = FALSE;
591+ if (!dvap_first_voice_pkt || !memcmp (&buff[13], resync , 3))
592+ {
593+ time(&dvap_keep_alive);
594+ dvap_send_pkt[0] = 0x12;
595+ dvap_send_pkt[1] = 0xc0;
596+ memcpy (&dvap_send_pkt[6], &buff[4], 12);
597+ if ((dvap_send_pkt[4] & 0x40) ||
598+ (!memcmp (&dvap_send_pkt[6], &lastframe[3], 3) && !memcmp (&dvap_send_pkt[15], lastframe, 3)))
599+ {
600+ dvap_send_pkt[4] |= 0x40;
601+ }
602+ ret = write (fd, dvap_send_pkt, 18);
603+ dvap_send_pkt[5]++;
604+ dvap_send_pkt[4]++;
605+ if (dvap_send_pkt[4] == 21) dvap_send_pkt[4] = 0;
606+ dvap_first_voice_pkt = FALSE;
615607 #if 0
616608 syslog (LOG_DEBUG, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x",
617609 dvap_send_pkt[0], dvap_send_pkt[1], dvap_send_pkt[2], dvap_send_pkt[3], dvap_send_pkt[4], dvap_send_pkt[5], dvap_send_pkt[6], dvap_send_pkt[7], dvap_send_pkt[8], dvap_send_pkt[9], dvap_send_pkt[10], dvap_send_pkt[11], dvap_send_pkt[12], dvap_send_pkt[13], dvap_send_pkt[14], dvap_send_pkt[15], dvap_send_pkt[16], dvap_send_pkt[17]);
618610 #endif
619- }
620611 }
621612 }
622613 else
--- /dev/null
+++ b/rpt_conn_lcd.c
@@ -0,0 +1,33 @@
1+#include "rpt_conn.h"
2+
3+//USE WIRINGPI PIN NUMBERS
4+#define LCD_RS 10 //Register select pin GPIO10
5+#define LCD_E 9 //Enable Pin GPIO9
6+#define LCD_D4 11 //Data pin 4 GPIO11
7+#define LCD_D5 25 //Data pin 5 GPIO25
8+#define LCD_D6 8 //Data pin 6 GPIO8
9+#define LCD_D7 7 //Data pin 7 GPIO7
10+
11+void lcdPosition (int handle, int x, int y);
12+
13+void lcd_init()
14+{
15+ lcd = lcdInit (4, 20, 4, LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7,
16+ 0, 0, 0, 0);
17+ usleep (50);
18+ lcdClear (lcd);
19+ usleep (3000);
20+}
21+
22+void lcd_write (void)
23+{
24+ if (lcd_type == LCD_20x4)
25+ {
26+ lcdPosition (lcd, 0, 3);
27+ msg_temp [20] = 0x00;
28+ lcdPuts (lcd, msg_temp);
29+ }
30+ else if (lcd_type == LCD_16x2)
31+ {
32+ }
33+}
--- a/rpt_conn_send_msg.c
+++ b/rpt_conn_send_msg.c
@@ -5,55 +5,65 @@ void rig_send_check (void);
55 int send_rig(void);
66 void rig_write (int length, char str[]);
77
8-unsigned char status_msg[13][17] =
8+unsigned char status_msg[21][13] =
99 {
10- 0x10, 0x22, 0x00, 0x00, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x55, 0x2d, 0x16, 0xff,
11- 0x10, 0x22, 0x01, 0x01, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5, 0xff,
12- 0x10, 0x22, 0x02, 0x02, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5, 0xff,
13- 0x10, 0x22, 0x03, 0x03, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5, 0xff,
14- 0x10, 0x22, 0x04, 0x04, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5, 0xff,
15- 0x10, 0x22, 0x05, 0x05, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5, 0xff,
16- 0x10, 0x22, 0x06, 0x06, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5, 0xff,
17- 0x10, 0x22, 0x07, 0x07, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5, 0xff,
18- 0x10, 0x22, 0x08, 0x08, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5, 0xff,
19- 0x10, 0x22, 0x09, 0x09, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5, 0xff,
20- 0x10, 0x22, 0x0a, 0x0a, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5, 0xff,
21- 0x10, 0x22, 0x0b, 0x0b, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x55, 0x55, 0x55, 0xff,
22- 0x10, 0x22, 0x0c, 0x4c, 0x55, 0xc8, 0x7a, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x55, 0x55, 0x55, 0xff};
10+ 0x00, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x55, 0x2d, 0x16,
11+ 0x01, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
12+ 0x02, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
13+ 0x03, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
14+ 0x04, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
15+ 0x05, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
16+ 0x06, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
17+ 0x07, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
18+ 0x08, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
19+ 0x09, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
20+ 0x0a, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
21+ 0x0b, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
22+ 0x0c, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
23+ 0x0d, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
24+ 0x0e, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
25+ 0x0f, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
26+ 0x10, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
27+ 0x11, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
28+ 0x12, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x16, 0x29, 0xf5,
29+ 0x13, 0x9e, 0x8d, 0x32, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x55, 0x55, 0x55,
30+ 0x54, 0x55, 0xc8, 0x7a, 0x88, 0x26, 0x1a, 0x3f, 0x61, 0xe8, 0x55, 0x55, 0x55};
31+
2332
24-void send_msg (unsigned char string[], unsigned char my2[], unsigned char flag)
33+void send_msg (unsigned char string[], unsigned char my2[])
2534 {
35+ char hdr_buff[42];
36+ struct timeval temp_time;
2637 int n;
27- unsigned char hdr_buff[42];
2838
29- status_msg[3][13] = 0x70 ^ 0x40;
30- status_msg[3][14] = 0x4f ^ string[0];
31- status_msg[3][15] = 0x93 ^ string[1];
32- status_msg[4][13] = 0x70 ^ string[2];
33- status_msg[4][14] = 0x4f ^ string[3];
34- status_msg[4][15] = 0x93 ^ string[4];
35- status_msg[5][13] = 0x70 ^ 0x41;
36- status_msg[5][14] = 0x4f ^ string[5];
37- status_msg[5][15] = 0x93 ^ string[6];
38- status_msg[6][13] = 0x70 ^ string[7];
39- status_msg[6][14] = 0x4f ^ string[8];
40- status_msg[6][15] = 0x93 ^ string[9];
41- status_msg[7][13] = 0x70 ^ 0x42;
42- status_msg[7][14] = 0x4f ^ string[10];
43- status_msg[7][15] = 0x93 ^ string[11];
44- status_msg[8][13] = 0x70 ^ string[12];
45- status_msg[8][14] = 0x4f ^ string[13];
46- status_msg[8][15] = 0x93 ^ string[14];
47- status_msg[9][13] = 0x70 ^ 0x43;
48- status_msg[9][14] = 0x4f ^ string[15];
49- status_msg[9][15] = 0x93 ^ string[16];
50- status_msg[10][13] = 0x70 ^ string[17];
51- status_msg[10][14] = 0x4f ^ string[18];
52- status_msg[10][15] = 0x93 ^ string[19];
39+ status_msg[5][10] = 0x70 ^ 0x40;
40+ status_msg[5][11] = 0x4f ^ string[0];
41+ status_msg[5][12] = 0x93 ^ string[1];
42+ status_msg[6][10] = 0x70 ^ string[2];
43+ status_msg[6][11] = 0x4f ^ string[3];
44+ status_msg[6][12] = 0x93 ^ string[4];
45+ status_msg[7][10] = 0x70 ^ 0x41;
46+ status_msg[7][11] = 0x4f ^ string[5];
47+ status_msg[7][12] = 0x93 ^ string[6];
48+ status_msg[8][10] = 0x70 ^ string[7];
49+ status_msg[8][11] = 0x4f ^ string[8];
50+ status_msg[8][12] = 0x93 ^ string[9];
51+ status_msg[9][10] = 0x70 ^ 0x42;
52+ status_msg[9][11] = 0x4f ^ string[10];
53+ status_msg[9][12] = 0x93 ^ string[11];
54+ status_msg[10][10] = 0x70 ^ string[12];
55+ status_msg[10][11] = 0x4f ^ string[13];
56+ status_msg[10][12] = 0x93 ^ string[14];
57+ status_msg[11][10] = 0x70 ^ 0x43;
58+ status_msg[11][11] = 0x4f ^ string[15];
59+ status_msg[11][12] = 0x93 ^ string[16];
60+ status_msg[12][10] = 0x70 ^ string[17];
61+ status_msg[12][11] = 0x4f ^ string[18];
62+ status_msg[12][12] = 0x93 ^ string[19];
5363
5464 hdr_buff[0] = 0x29;
5565 hdr_buff[1] = 0x20,
56- hdr_buff[2] = flag;
66+ hdr_buff[2] = 0x00;
5767 hdr_buff[3] = 0x00;
5868 hdr_buff[4] = 0x00;
5969 memcpy (&hdr_buff[5], "DIRECT ", 8);
@@ -63,15 +73,14 @@ void send_msg (unsigned char string[], unsigned char my2[], unsigned char flag)
6373 memcpy (&hdr_buff[37], my2, 4);
6474 hdr_buff[41] = 0xff;
6575
66- rig_write (42, hdr_buff);
76+ rig_write (42, hdr_buff);
6777
68- usleep (30000);
69- for (n = 0 ; n < 13 ; n++)
78+ usleep (300000);
79+ for (n = 0 ; n < 21 ; n++)
7080 {
71- rig_write (17, &status_msg[n][0]);
72- usleep (20000);
81+ rig_write (17, &status_msg[n][0]);
82+ usleep (20000);
7383 }
74-
7584 send_msg_sw = FALSE;
7685 }
7786
--- a/send_msg.c
+++ b/send_msg.c
@@ -43,30 +43,30 @@ void send_msg (unsigned char string[], unsigned char my2[])
4343 send_msg_sw = FALSE;
4444 return;
4545 }
46- status_msg[3][10] = 0x70 ^ 0x40;
47- status_msg[3][11] = 0x4f ^ string[0];
48- status_msg[3][12] = 0x93 ^ string[1];
49- status_msg[4][10] = 0x70 ^ string[2];
50- status_msg[4][11] = 0x4f ^ string[3];
51- status_msg[4][12] = 0x93 ^ string[4];
52- status_msg[5][10] = 0x70 ^ 0x41;
53- status_msg[5][11] = 0x4f ^ string[5];
54- status_msg[5][12] = 0x93 ^ string[6];
55- status_msg[6][10] = 0x70 ^ string[7];
56- status_msg[6][11] = 0x4f ^ string[8];
57- status_msg[6][12] = 0x93 ^ string[9];
58- status_msg[7][10] = 0x70 ^ 0x42;
59- status_msg[7][11] = 0x4f ^ string[10];
60- status_msg[7][12] = 0x93 ^ string[11];
61- status_msg[8][10] = 0x70 ^ string[12];
62- status_msg[8][11] = 0x4f ^ string[13];
63- status_msg[8][12] = 0x93 ^ string[14];
64- status_msg[9][10] = 0x70 ^ 0x43;
65- status_msg[9][11] = 0x4f ^ string[15];
66- status_msg[9][12] = 0x93 ^ string[16];
67- status_msg[10][10] = 0x70 ^ string[17];
68- status_msg[10][11] = 0x4f ^ string[18];
69- status_msg[10][12] = 0x93 ^ string[19];
46+ status_msg[5][10] = 0x70 ^ 0x40;
47+ status_msg[5][11] = 0x4f ^ string[0];
48+ status_msg[5][12] = 0x93 ^ string[1];
49+ status_msg[6][10] = 0x70 ^ string[2];
50+ status_msg[6][11] = 0x4f ^ string[3];
51+ status_msg[6][12] = 0x93 ^ string[4];
52+ status_msg[7][10] = 0x70 ^ 0x41;
53+ status_msg[7][11] = 0x4f ^ string[5];
54+ status_msg[7][12] = 0x93 ^ string[6];
55+ status_msg[8][10] = 0x70 ^ string[7];
56+ status_msg[8][11] = 0x4f ^ string[8];
57+ status_msg[8][12] = 0x93 ^ string[9];
58+ status_msg[9][10] = 0x70 ^ 0x42;
59+ status_msg[9][11] = 0x4f ^ string[10];
60+ status_msg[9][12] = 0x93 ^ string[11];
61+ status_msg[10][10] = 0x70 ^ string[12];
62+ status_msg[10][11] = 0x4f ^ string[13];
63+ status_msg[10][12] = 0x93 ^ string[14];
64+ status_msg[11][10] = 0x70 ^ 0x43;
65+ status_msg[11][11] = 0x4f ^ string[15];
66+ status_msg[11][12] = 0x93 ^ string[16];
67+ status_msg[12][10] = 0x70 ^ string[17];
68+ status_msg[12][11] = 0x4f ^ string[18];
69+ status_msg[12][12] = 0x93 ^ string[19];
7070
7171 hdr_buff[0] = 0x29;
7272 hdr_buff[1] = 0x20,
@@ -82,7 +82,6 @@ void send_msg (unsigned char string[], unsigned char my2[])
8282
8383 putFifo(42, hdr_buff);
8484
85- usleep (300000);
8685 for (n = 0 ; n < 21 ; n++)
8786 {
8887 putFifo (13, &status_msg[n][0]);
@@ -103,7 +102,6 @@ void send_msg (unsigned char string[], unsigned char my2[])
103102 break;
104103 }
105104 }
106- sleep (1);
107105 send_msg_sw = FALSE;
108106 }
109107
--- a/send_node.c
+++ b/send_node.c
@@ -27,13 +27,14 @@ void node_header_send (unsigned char header[])
2727 header[1] = 0x00;
2828 header[2] = 0x00;
2929 usb_control_msg(udev, 0x40, SET_FLAGS, 0, 0, header, 3, 100);
30-
30+#if 0
3131 usb_control_msg(udev, 0xc0, GET_REMAINSPACE, 0, 0, (char *)&len ,1, 100);
3232 while (len < 95)
3333 {
34- usleep (100000);
34+ usleep (2000);
3535 usb_control_msg(udev, 0xc0, GET_REMAINSPACE, 0, 0, (char *)&len ,1, 100);
3636 }
37+#endif
3738 usb_control_msg(udev, 0x40, SET_PTT, ON, 0, NULL, 0, 100);
3839 }
3940
@@ -46,18 +47,22 @@ void node_voice_send (unsigned char voice[])
4647 syslog (LOG_DEBUG, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x",
4748 voice[0], voice[1], voice[2], voice[3], voice[4], voice[5], voice[6], voice[7], voice[8], voice[9], voice[10], voice[11]);
4849 #endif
50+#if 0
4951 usb_control_msg(udev, 0xc0, GET_REMAINSPACE, 0, 0, (char *)&len ,1, 100);
5052 while (len < 12)
5153 {
52- usleep (20000);
54+ usleep (2000);
5355 usb_control_msg(udev, 0xc0, GET_REMAINSPACE, 0, 0, (char *)&len ,1, 100);
5456 }
57+#endif
5558 ret = usb_control_msg(udev, 0x40, PUT_DATA, 0, 0, voice, 12, 100);
59+#if 0
5660 while (ret < 0)
5761 {
58- usleep (2000);
62+ usleep (200);
5963 ret = usb_control_msg(udev, 0x40, PUT_DATA, 0, 0, voice, 12, 100);
6064 }
65+#endif
6166 }
6267
6368 void node_last_send (unsigned char voice[])
@@ -66,18 +71,22 @@ void node_last_send (unsigned char voice[])
6671 unsigned char len;
6772
6873 memcpy (&voice[9], lastframe, 6);
74+#if 0
6975 usb_control_msg(udev, 0xc0, GET_REMAINSPACE, 0, 0, (char *)&len ,1, 100);
7076 while (len < 15)
7177 {
72- usleep (20000);
78+ usleep (2000);
7379 usb_control_msg(udev, 0xc0, GET_REMAINSPACE, 0, 0, (char *)&len ,1, 100);
7480 }
81+#endif
7582 ret = usb_control_msg(udev, 0x40, PUT_DATA, 0, 0, voice, 15, 100);
83+#if 0
7684 while (ret < 0)
7785 {
78- usleep (2000);
86+ usleep (200);
7987 ret = usb_control_msg(udev, 0x40, PUT_DATA, 0, 0, voice, 15, 100);
8088 }
89+#endif
8190 /* PTT OFF */
8291 ret = usb_control_msg(udev, 0x40, SET_PTT, OFF, 0, NULL, 0, 100);
8392 frameID = 0;
@@ -91,10 +100,19 @@ void node_write (unsigned char str[], int length)
91100 }
92101 else if (length == 17)
93102 {
94-//syslog(LOG_DEBUG," %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x", str[4], str[5], str[6], str[13], str[14], str[15]);
95103 if ((str[3] & 0x40)
96104 || !memcmp (&str[13], &lastframe[3], 3)
97105 || !memcmp (&str[4], &lastframe[3], 3)) node_last_send (&str[4]);
98106 else node_voice_send (&str[4]);
99107 }
100108 }
109+
110+int node_space_check (int length)
111+{
112+ unsigned char len;
113+
114+ usb_control_msg(udev, 0xc0, GET_REMAINSPACE, 0, 0, (char *)&len , 1, 100);
115+ if (len < length) return FALSE;
116+ return TRUE;
117+}
118+