• R/O
  • HTTP
  • SSH
  • HTTPS

rpi-dmonitor: Commit


Commit MetaInfo

Revision4464397ff1bd739b7e0e8d8a2cc3a72a73d7edb6 (tree)
Zeit2019-10-11 10:48:02
AutorSatoshi Yasuda <7m3tjz@jarl...>
CommiterSatoshi Yasuda

Log Message

modified: dmonitor_utils.c
modified: inet_read.c
modified: main.c
modified: repeater_mon.c
modified: rig_read.c

Ändern Zusammenfassung

Diff

--- a/config.h
+++ b/config.h
@@ -86,7 +86,7 @@
8686 #define PACKAGE_NAME "dmonitor"
8787
8888 /* Define to the full name and version of this package. */
89-#define PACKAGE_STRING "dmonitor 01.14"
89+#define PACKAGE_STRING "dmonitor 01.15"
9090
9191 /* Define to the one symbol short name of this package. */
9292 #define PACKAGE_TARNAME "dmonitor"
@@ -95,10 +95,10 @@
9595 #define PACKAGE_URL ""
9696
9797 /* Define to the version of this package. */
98-#define PACKAGE_VERSION "01.14"
98+#define PACKAGE_VERSION "01.15"
9999
100100 /* Define to 1 if you have the ANSI C header files. */
101101 #define STDC_HEADERS 1
102102
103103 /* Version number of package */
104-#define VERSION "01.14"
104+#define VERSION "01.15"
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
11 #! /bin/sh
22 # Guess values for system-dependent variables and create Makefiles.
3-# Generated by GNU Autoconf 2.69 for dmonitor 01.14.
3+# Generated by GNU Autoconf 2.69 for dmonitor 01.15.
44 #
55 # Report bugs to <7m3tjz@jarl.com>.
66 #
@@ -580,8 +580,8 @@ MAKEFLAGS=
580580 # Identity of this package.
581581 PACKAGE_NAME='dmonitor'
582582 PACKAGE_TARNAME='dmonitor'
583-PACKAGE_VERSION='01.14'
584-PACKAGE_STRING='dmonitor 01.14'
583+PACKAGE_VERSION='01.15'
584+PACKAGE_STRING='dmonitor 01.15'
585585 PACKAGE_BUGREPORT='7m3tjz@jarl.com'
586586 PACKAGE_URL=''
587587
@@ -1277,7 +1277,7 @@ if test "$ac_init_help" = "long"; then
12771277 # Omit some internal or obsolete options to make the list less imposing.
12781278 # This message is too long to be a string in the A/UX 3.1 sh.
12791279 cat <<_ACEOF
1280-\`configure' configures dmonitor 01.14 to adapt to many kinds of systems.
1280+\`configure' configures dmonitor 01.15 to adapt to many kinds of systems.
12811281
12821282 Usage: $0 [OPTION]... [VAR=VALUE]...
12831283
@@ -1344,7 +1344,7 @@ fi
13441344
13451345 if test -n "$ac_init_help"; then
13461346 case $ac_init_help in
1347- short | recursive ) echo "Configuration of dmonitor 01.14:";;
1347+ short | recursive ) echo "Configuration of dmonitor 01.15:";;
13481348 esac
13491349 cat <<\_ACEOF
13501350
@@ -1435,7 +1435,7 @@ fi
14351435 test -n "$ac_init_help" && exit $ac_status
14361436 if $ac_init_version; then
14371437 cat <<\_ACEOF
1438-dmonitor configure 01.14
1438+dmonitor configure 01.15
14391439 generated by GNU Autoconf 2.69
14401440
14411441 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1804,7 +1804,7 @@ cat >config.log <<_ACEOF
18041804 This file contains any messages produced by compilers while
18051805 running configure, to aid debugging if configure makes a mistake.
18061806
1807-It was created by dmonitor $as_me 01.14, which was
1807+It was created by dmonitor $as_me 01.15, which was
18081808 generated by GNU Autoconf 2.69. Invocation command line was
18091809
18101810 $ $0 $@
@@ -2670,7 +2670,7 @@ fi
26702670
26712671 # Define the identity of the package.
26722672 PACKAGE='dmonitor'
2673- VERSION='01.14'
2673+ VERSION='01.15'
26742674
26752675
26762676 cat >>confdefs.h <<_ACEOF
@@ -4768,7 +4768,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
47684768 # report actual input values of CONFIG_FILES etc. instead of their
47694769 # values after options handling.
47704770 ac_log="
4771-This file was extended by dmonitor $as_me 01.14, which was
4771+This file was extended by dmonitor $as_me 01.15, which was
47724772 generated by GNU Autoconf 2.69. Invocation command line was
47734773
47744774 CONFIG_FILES = $CONFIG_FILES
@@ -4834,7 +4834,7 @@ _ACEOF
48344834 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
48354835 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
48364836 ac_cs_version="\\
4837-dmonitor config.status 01.14
4837+dmonitor config.status 01.15
48384838 configured by $0, generated by GNU Autoconf 2.69,
48394839 with options \\"\$ac_cs_config\\"
48404840
--- a/dmonitor_utils.c
+++ b/dmonitor_utils.c
@@ -7,6 +7,7 @@ void LastFrameSend (void);
77 void rig_led_onoff(void);
88 void inet_led_onoff(void);
99 void buff_hold_size (int n);
10+void rig_send_check (void);
1011
1112 int rig_open(void)
1213 {
@@ -46,7 +47,7 @@ void rig_close (void)
4647 {
4748 tcsetattr (rig_fd, TCSANOW, &save_attr);
4849 FD_CLR (rig_fd, &fd_save);
49- close (rig_fd);
50+ //close (rig_fd);
5051 rig_fd = -1;
5152 if(!scan_sw) syslog (LOG_INFO, "RIG(ID-xxPlus) close.");
5253 else fprintf (status_fd, "RIG(ID-xxPlus) close.\n");
@@ -224,45 +225,28 @@ int send_rig (void)
224225 send_buff[0] = 0x10;
225226 send_buff[1] = 0x22;
226227 send_buff[2] = seq & 0xff;
227- //seq++;
228- //seq &= 0xff;
229228 if ((seq % 5) == 0) rig_led_onoff();
230229 send_buff[16] = 0xff;
231230 rig_write (17, send_buff);
232231 if (send_buff[3] & 0x40)
233232 {
234- //memset (inet_frame_id, 0x00, 2);
235- rig_send_sw = FALSE;
236233 if (inet_read_cnt)
237234 {
238235 rate = (inet_read_drop_cnt * 10000) / inet_read_cnt;
239236 syslog(LOG_INFO, "drop pakcet rate %d.%02d%% (%ld/%ld)", rate/100, rate%100, inet_read_drop_cnt, inet_read_cnt);
240237 }
241- rig_last_frame_send = TRUE;
242- inet_read_cnt = 0;
243- inet_read_drop_cnt = 0;
244- rig_ack_wait = TRUE;
245238 }
246239 last_frame_seq = send_buff[3];
247240 last_frame_seq &= 0x1f;
248241 }
249- else
250- {
251- if (!rig_last_frame_send)
252- {
253- LastFrameSend();
254- memset (inet_frame_id, 0x00, 2);
255- digitalWrite (RIG_LED, 0);
256- rig_send_sw = FALSE;
257- }
258- }
259242 return TRUE;
260243 }
261244
262245 void LastFrameSend (void)
263246 {
264247 int rate;
265-
248+
249+//syslog(LOG_INFO, "LastFrameSend");
266250 send_buff[0] = 0x10;
267251 send_buff[1] = 0x22;
268252 send_buff[2] = seq;
@@ -312,6 +296,7 @@ void putFifo (int len, unsigned char pkt[])
312296 {
313297 struct FifoPkt *ret;
314298
299+//syslog(LOG_INFO, "putFifo %d %2.2x", len, pkt[0]);
315300 ret = malloc (sizeof(struct FifoPkt) - 1024 + len);
316301 if (ret == NULL)
317302 {
@@ -326,10 +311,9 @@ void putFifo (int len, unsigned char pkt[])
326311 Fifo_cnt++;
327312 if (len == 13)
328313 {
329- if ((pkt[0] & 0x40) && !rig_send_sw)
314+ if (pkt[0] & 0x40)
330315 {
331- rig_send_sw = TRUE;
332- gettimeofday (&rig_send_time, NULL);
316+ rig_send_check();
333317 memset (inet_frame_id, 0x00, 2);
334318 }
335319 }
--- a/inet_read.c
+++ b/inet_read.c
@@ -29,10 +29,27 @@ void rig_send_check (void)
2929 {
3030 rig_send_sw = TRUE;
3131 gettimeofday (&rig_send_time, NULL);
32- //send_rig_header();
3332 }
3433 }
3534
35+void dummy_last_frame (void)
36+{
37+ recvBuff[16] = recv_frame_seq;
38+ memcpy (&recvBuff[17], NullVoice, 12);
39+ memcpy (&recvBuff[26], LastFrame0, 3);
40+ putFifo (13, &recvBuff[16]);
41+ recvBuff[16]++;
42+ if (recvBuff[16] > 20) recvBuff[16] = 0;
43+ recvBuff[16] |= 0x40;
44+ memcpy (&recvBuff[17], LastFrame1, 3);
45+ putFifo (13, &recvBuff[16]);
46+ memset (inet_frame_id, 0x00, 2);
47+ rig_send_check();
48+ digitalWrite (INET_LED, 0);
49+ digitalWrite (RIG_LED, 0);
50+ rig_last_frame_send = TRUE;
51+}
52+
3653 void frame_seq_check (void)
3754 {
3855 unsigned char dummy[13];
@@ -42,32 +59,20 @@ void frame_seq_check (void)
4259 recv_frame_seq++;
4360 if (recv_frame_seq > 20) recv_frame_seq = 0;
4461 if (recv_frame_seq == ((recvBuff[16]) & 0x1f)) return;
45- temp1 = recv_frame_seq & 0x1f;
62+ temp1 = recv_frame_seq;
4663 temp2 = 0;
4764 while (temp1 != (recvBuff[16] & 0x1f))
4865 {
66+//syslog (LOG_INFO, "seq %2.2x %2.2x", temp1, recvBuff[16] & 0x1f);
4967 temp2++;
5068 temp1++;
5169 if (temp1 > 20) temp1 = 0;
5270 }
53- if (temp2 > 3)
71+
72+ if (temp2 > 5)
5473 {
5574 syslog (LOG_INFO, "Many packets droped %d", temp2);
56- recvBuff[16] = recv_frame_seq;
57- memcpy (&recvBuff[17], NullVoice, 12);
58- memcpy (&recvBuff[26], LastFrame0, 3);
59- putFifo (13, &recvBuff[16]);
60- recvBuff[16]++;
61- if (recvBuff[16] > 20) recvBuff[16] = 0;
62- recvBuff[16] |= 0x40;
63- memcpy (&recvBuff[17], LastFrame1, 3);
64- putFifo (13, &recvBuff[16]);
65- memset (inet_frame_id, 0x00, 2);
66- gettimeofday (&inet_recv_time, NULL);
67- rig_send_check();
68- digitalWrite (INET_LED, 0);
69- digitalWrite (RIG_LED, 0);
70- rig_last_frame_send = TRUE;
75+ dummy_last_frame();
7176 return;
7277 }
7378 //syslog (LOG_INFO, "Frame Seq. Recv:%2.2x Save:%2.2x", recvBuff[16], recv_frame_seq);
@@ -142,9 +147,9 @@ void inet_read(void)
142147 //if (inet_m_save != 1) syslog(LOG_ERR, "sequence error recv:%d save:%d", inet_m, inet_m_save);
143148 inet_m_save = inet_m;
144149 }
145-
146150 if (recvBuff[13] == 0xff) return;
147151 gettimeofday (&inet_time, NULL);
152+syslog(LOG_INFO, "length:%d %2.2x %2.2x %2.2x", length, recvBuff[14], recvBuff[15], recvBuff[16]);
148153 if (length == 58)
149154 {
150155 if ((inet_frame_id[0] == 0x00) && (inet_frame_id[1] == 0x00))
@@ -152,8 +157,7 @@ void inet_read(void)
152157 if (((recvBuff[7] & ZR) && !memcmp (area_call, &recvBuff[28], 8)) || scan_sw
153158 || ((recvBuff[7] & GW) && !memcmp (area_call, &recvBuff[20], 8)))
154159 {
155- inet_frame_id[0] = recvBuff[14];
156- inet_frame_id[1] = recvBuff[15];
160+ memcpy (inet_frame_id, &recvBuff[14], 2);
157161 send_buff[0] = 0x29;
158162 send_buff[1] = 0x20,
159163 memcpy (&send_buff[2], &recvBuff[17], 39);
@@ -188,7 +192,7 @@ void inet_read(void)
188192 if ((recvBuff[16] & 0x40)
189193 || ((recvBuff[26] == 0x55) && (recvBuff[27] == 0x55) && (recvBuff[28] == 0x55)))
190194 {
191- memset (inet_frame_id, 0x00, 2);
195+ //memset (inet_frame_id, 0x00, 2);
192196 rig_send_check();
193197 digitalWrite (INET_LED, 0);
194198 digitalWrite (RIG_LED, 0);
--- a/main.c
+++ b/main.c
@@ -18,10 +18,11 @@ void buff_hold_size (int n);
1818 void dmonitor_close(void);
1919 void send_rig_init(void);
2020 int getFifo (unsigned char str[]);
21+void dummy_last_frame (void);
2122
2223 time_t send_time;
2324
24-char recvBuff[256];
25+unsigned char recvBuff[256];
2526
2627 int main(int argc, char *argv[])
2728 {
@@ -43,6 +44,7 @@ int main(int argc, char *argv[])
4344 struct timeval temp_time;
4445
4546 struct timeval rig_send_time_20mSec;
47+ struct timeval rig_send_timeout;
4648
4749 ret = nice (-15);
4850 send_sw = FALSE;
@@ -124,6 +126,9 @@ int main(int argc, char *argv[])
124126 rig_send_time_20mSec.tv_sec = 0;
125127 rig_send_time_20mSec.tv_usec = 20000;
126128
129+ rig_send_timeout.tv_sec = 0;
130+ rig_send_timeout.tv_usec = fifo_hold * 20000;
131+
127132 rig_send_time.tv_sec = 0;
128133 rig_send_time.tv_usec = 0;
129134
@@ -191,10 +196,21 @@ int main(int argc, char *argv[])
191196 rig_send_time.tv_usec = temp_time.tv_usec;
192197 }
193198 }
199+ if ((inet_frame_id[0] != 0x00) || (inet_frame_id[1] != 0x00))
200+ {
201+ timeradd (&inet_recv_time, &rig_send_timeout, &temp_time);
202+ if (timercmp (&c_time, &temp_time, >))
203+ {
204+syslog(LOG_INFO, "debug dummy_last_frame");
205+ dummy_last_frame();
206+ }
207+ }
194208 }
195209 else
196210 {
197211 fifo_hold = fifo_new_hold;
212+ rig_send_timeout.tv_sec = 0;
213+ rig_send_timeout.tv_usec = fifo_hold * 20000;
198214 }
199215 if (scan_sw)
200216 {
@@ -204,16 +220,12 @@ int main(int argc, char *argv[])
204220 skip:
205221 if (sig_term) break;
206222 }
223+
207224 if (!rig_last_frame_send)
208225 {
209226 recv_frame_seq = last_frame_seq;
210227 LastFrameSend();
211228 }
212- if (rig_fd > 0)
213- {
214- send_rig_init();
215- rig_close();
216- }
217229 connected_table_clean();
218230 error_msg_clean();
219231 dmonitor_close();
--- a/repeater_mon.c
+++ b/repeater_mon.c
@@ -207,6 +207,26 @@ mast_close:
207207 }
208208 }
209209 }
210+
211+void down_msg (void)
212+{
213+ html_fd = fopen (MON_HTML_TEMP, "w");
214+ html_active_fd = fopen (ACTIVE_HTML_TEMP, "w");
215+ fprintf (html_fd, "\n<!DOCTYPE html>\n<HTML lang=\"ja\">\n\n");
216+ fprintf (html_fd, "<head>\n");
217+ fprintf (html_fd, "<title>Multi Forward running Repeater</title>\n");
218+ fprintf (html_fd, "<meta charset=\"UTF-8\">\n");
219+ fprintf (html_fd, "<script type=\"text/javascript\">\n");
220+ fprintf (html_fd, "<!--\n");
221+ fprintf (html_fd, "</head>\n");
222+ fprintf (html_fd, "<BODY style=\"background-color:#ffffcc;\">\n");
223+ fprintf (html_fd, "<center>\n");
224+ fprintf (html_fd, "hole_punch サーバがダウンしています<br>\n");
225+ fprintf (html_fd, "<a href=https://d-star.at.webry.info>D-STAR技術情報</a><br>もしくは<br><a href=https://blog.goo.ne.jp/jarl_lab2>D-STAR NEWS</a><br>\n");
226+ fprintf (html_fd, "を見てく下さい</br>\n");
227+ fprintf (html_fd, "</center>\n<</html>\n\n");
228+ fclose (html_fd);
229+}
210230
211231 void main(int argc, char** argv)
212232 {
@@ -249,7 +269,10 @@ void main(int argc, char** argv)
249269 sleep (1);
250270 }
251271 else
272+ {
273+ down_msg();
252274 return;
275+ }
253276 }
254277 }
255278
@@ -264,13 +287,13 @@ void main(int argc, char** argv)
264287 //printf("Content-type: text/html\n\n");
265288 html_fd = fopen (MON_HTML_TEMP, "w");
266289 html_active_fd = fopen (ACTIVE_HTML_TEMP, "w");
267- fprintf (html_fd, "<!DOCTYPE html>\n<HTML lang=\"ja\">\n");
290+ fprintf (html_fd, "\n<!DOCTYPE html>\n\n");
268291 fprintf (html_fd, "<head>\n");
269292 fprintf (html_fd, "<title>Multi Forward running Repeater</title>\n");
270293 fprintf (html_fd, "<meta charset=\"UTF-8\">\n");
271294 //fprintf (html_fd, "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n");
272295 //fprintf (html_fd, "<meta http-equiv=\"Cache-Control\" content=\"no-cache\">\n");
273- fprintf (html_fd, "<meta http-equiv=\"refresh\" content=\"5;URL=./repeater_mon.html\">\n");
296+ fprintf (html_fd, "<meta http-equiv=\"refresh\" content=\"5;URL='./repeater_mon.html'\">\n");
274297 fprintf (html_fd, "<script type=\"text/javascript\">\n");
275298 fprintf (html_fd, "<!--\n");
276299 fprintf (html_fd, "var area;\n");
@@ -324,13 +347,13 @@ void main(int argc, char** argv)
324347 fprintf (html_fd, "<BODY onload=\"disp_reload()\" style=\"background-color:#ffffcc;\">\n");
325348 fprintf (html_fd, "<center>\n");
326349
327- fprintf (html_active_fd, "<!DOCTYPE html>\n<HTML lang=\"ja\">\n");
350+ fprintf (html_active_fd, "\n<!DOCTYPE html>\n\n");
328351 fprintf (html_active_fd, "<head>\n");
329352 fprintf (html_active_fd, "<title>Multi Forward Active Repeater</title>\n");
330353 fprintf (html_active_fd, "<meta charset=\"UTF-8\">\n");
331354 //fprintf (html_active_fd, "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n");
332355 //fprintf (html_active_fd, "<meta http-equiv=\"Cache-Control\" content=\"no-cache\">\n");
333- fprintf (html_active_fd, "<meta http-equiv=\"refresh\" content=\"5;URL=./repeater_active.html\">\n");
356+ fprintf (html_active_fd, "<meta http-equiv=\"refresh\" content=\"5;URL='./repeater_active.html'\">\n");
334357 fprintf (html_active_fd, "<script type=\"text/javascript\">\n");
335358 fprintf (html_active_fd, "<!--\n");
336359 //fprintf (html_active_fd, "<table border=\"1\" style=\"font-size:0.9em;\">\n");
@@ -377,6 +400,7 @@ void main(int argc, char** argv)
377400 if (buff_pnt < 0) buff_pnt = 0;
378401 }
379402 next:
403+ send(sd, "END", 3, 0);
380404 close (sd);
381405 if (col > COL)
382406 {
--- a/rig_read.c
+++ b/rig_read.c
@@ -9,7 +9,7 @@ int rig_open (void);
99 void sind_rig_alive (void);
1010 void rig_reinit (void);
1111 int rig_status (void);
12-void rig_write (int length, char buff[]);
12+void rig_write (int length, unsigned char buff[]);
1313 void rig_led_onoff(void);
1414 void inet_led_onoff(void);
1515
@@ -288,11 +288,12 @@ int rig_read (void)
288288 return TRUE;
289289 }
290290
291-void rig_write (int length, char buff[])
291+void rig_write (int length, unsigned char buff[])
292292 {
293293 int ret;
294294
295295 ret = write (rig_fd, buff, length);
296+ //if (length > 3) syslog (LOG_INFO, "rig_write %d %d %2.2x", length, ret, buff[3]);
296297 }
297298
298299 void send_rig_init (void)
Show on old repository browser