/var/www/dashboard/mmdvmhost/functions.php
function getYSFGatewayLog() {
This is used twice in this function
| sed '/*Link/d' | tail -1`);
The /* makes everything that follows into a comment, so P25 which I want always shows "Not Linked" on the dashboard
I removed the / to make it | sed '*Link/d' | tail -1`);
and now the commented functions come to life and the dashboard now shows TG 10210 on P25
I don't use YSF so have no idea if I have broken anything in the YSF Area
A proper fix or this sure would be appreciated.
Phil VE3RD
Not Linked - on Pi-Star Dashboard
Re: Not Linked - on Pi-Star Dashboard
Wishful Thinking
The fix was temporary
It did however unlock a few functions that were not operable
The fix was temporary
It did however unlock a few functions that were not operable
Re: Not Linked - on Pi-Star Dashboard
A thought here: the NANO editor seems to have problems (gets confused) displaying (colorizing) code involving back-ticks (`). What may appear to be non-functioning code because it's colored blue may in fact be functional. So be skeptical/careful with groupings/pairings suggested by the colors.
Re: Not Linked - on Pi-Star Dashboard
.... and FWIW, this section of code looks "suspicious":
Like maybe it should be (line 267: $logLines2 instead of $logLines1)?
Code: Select all
$logLines1 = array_filter($logLines1);
if (sizeof($logLines1) == 0) {
if (file_exists(YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log")) {
$logPath2 = YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log";
//$logLines2 = explode("\n", `egrep -h "repeater|Starting|Opening YSF|Disconnect|Connect|Automatic|Disconnecting|Reverting|Linked" $logPath2 | tail -250`);
$logLines1 = preg_split('/\r\n|\r|\n/', `grep -E "onnection to|onnect to|ink|isconnect|Opening YSF network" $logPath2 | sed '/Linked to MMDVM/d' | sed '/Link successful to MMDVM/d' | sed '/*Link/d' | tail -1`);
}
$logLines2 = array_filter($logLines2);
}
if (sizeof($logLines1) == 0) { $logLines = $logLines2; } else { $logLines = $logLines1; }
return array_filter($logLines);
Code: Select all
$logLines1 = array_filter($logLines1);
if (sizeof($logLines1) == 0) {
if (file_exists(YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log")) {
$logPath2 = YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log";
//$logLines2 = explode("\n", `egrep -h "repeater|Starting|Opening YSF|Disconnect|Connect|Automatic|Disconnecting|Reverting|Linked" $logPath2 | tail -250`);
$logLines2 = preg_split('/\r\n|\r|\n/', `grep -E "onnection to|onnect to|ink|isconnect|Opening YSF network" $logPath2 | sed '/Linked to MMDVM/d' | sed '/Link successful to MMDVM/d' | sed '/*Link/d' | tail -1`);
}
$logLines2 = array_filter($logLines2);
}
if (sizeof($logLines1) == 0) { $logLines = $logLines2; } else { $logLines = $logLines1; }
return array_filter($logLines);
Re: Not Linked - on Pi-Star Dashboard
(Sorry, I misspoke: indeed it's the "/*" construct that's throwing off the editor. Thanks for pointing that out. I need to stop speed-reading posts!)
Re: Not Linked - on Pi-Star Dashboard
After almost a full day of playing I found the following
1) Functions.php grabs a new TG from /var/log/pi-star/P25Gateway log file
2) Changing to a new Talk Group resets the Not Linked to show the current TG
3) Keying up on the current TG does NOT reset the Not Linked
4) After approximately an hour the TG will change to Not Linked
I tryed to have functions.php write the tg to a file without success. In a stand alone script it works fine.
if (strpos($logLine,"Linked to")) {
$to = preg_replace('/[^0-9]/', '', substr($logLine, 44, 5));
$to = preg_replace('/[^0-9]/', '', $to);
$num = 0;
$myfile = fopen("/home/pi-star/p25tg.txt", "w");
$num = fwrite($myfile,$to);
fclose($myfile);
The default at time out reads the file and displays it on the dashboard instead of Not Linked
My next step is to write a bash script that will continuously monitor the P25gateway file and write Not Linked to my file when it sees Un Linked
and write the TG when it sees Linked To
It would be beneficial if the TG was written to the log file whenever the radio was keyed on the same tg.
1) Functions.php grabs a new TG from /var/log/pi-star/P25Gateway log file
2) Changing to a new Talk Group resets the Not Linked to show the current TG
3) Keying up on the current TG does NOT reset the Not Linked
4) After approximately an hour the TG will change to Not Linked
I tryed to have functions.php write the tg to a file without success. In a stand alone script it works fine.
if (strpos($logLine,"Linked to")) {
$to = preg_replace('/[^0-9]/', '', substr($logLine, 44, 5));
$to = preg_replace('/[^0-9]/', '', $to);
$num = 0;
$myfile = fopen("/home/pi-star/p25tg.txt", "w");
$num = fwrite($myfile,$to);
fclose($myfile);
The default at time out reads the file and displays it on the dashboard instead of Not Linked
My next step is to write a bash script that will continuously monitor the P25gateway file and write Not Linked to my file when it sees Un Linked
and write the TG when it sees Linked To
It would be beneficial if the TG was written to the log file whenever the radio was keyed on the same tg.
Last edited by VE3RD on Tue Mar 01, 2022 2:42 pm, edited 1 time in total.
Re: Not Linked - on Pi-Star Dashboard
Have you tried writing the data to a file in /tmp storage?
This snippet of code in functions.php works for me:
Using /tmp takes care of the permissions and the data gets "reset" with a reboot or a delete in a nightly/daily script!
This snippet of code in functions.php works for me:
Code: Select all
$DMRq = "/tmp/DMRIdx.dat";
exec("grep -w -m 1 ".$callsign." ".$DMRq,$output);
if (!$output) {
exec("grep -w -m 1 ".$callsign." ".DMRIDDATPATH."/DMRIds.xtd.dat", $output);
if (!$output) {
exec("grep -w -m 1 ".$callsign." ".DMRIDDATPATH."/DMRIds.dat", $output);
if (!$output) {return "?".$callsign."?";}
$output[0] = $output[0]."\t\t\t";
}
$output[0] = strtr($output[0],",","\t");
$fp = fopen($DMRq,"a+");
if ($fp) {
fwrite($fp,$output[0]."\n");
fclose($fp);
}
}
Re: Not Linked - on Pi-Star Dashboard
Thankyou
Writing it to /tmp solved the issue
Writing it to /tmp solved the issue
Re: Not Linked - on Pi-Star Dashboard
BTW/FWIW:
changed to:
You can run this to fix it without digging through the code:
Of course/as usual/in matters such as this: YMMV
Thanks for working on this gateway problem!
The "/" is vital for SED to work properly; the "fix" for this is to change the "*" into its hex equivalent so the code looks "nice" in the editors and the intended functionality is maintained:This is used twice in this function
| sed '/*Link/d' | tail -1`);
The /* makes everything that follows into a comment, so P25 which I want always shows "Not Linked" on the dashboard
I removed the / to make it | sed '*Link/d' | tail -1`);
and now the commented functions come to life and the dashboard now shows TG 10210 on P25
I don't use YSF so have no idea if I have broken anything in the YSF Area
A proper fix or this sure would be appreciated.
Code: Select all
| sed '/Link successful to MMDVM/d' | sed '/*Link/d' | tail -1`);
Code: Select all
| sed '/Link successful to MMDVM/d' | sed '/\x2aLink/d' | tail -1`);
Code: Select all
rpi-rw
sudo sed -i 's/\x2aLink/\\x2aLink/g' /var/www/dashboard/mmdvmhost/functions.php
rpi-ro
Thanks for working on this gateway problem!