Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug logging some CC messages, adding unit logging #181

Merged
merged 22 commits into from
Mar 11, 2021

Conversation

rosecitytransit
Copy link
Contributor

-Changed logging of non-repetitive control channel messages from trace to debug level (based on what I've seen for P25, there may be others that are repetitive too)

-Added unit logging to radiolist.json in the capture directory

-Added commented-out code that could run an external command when a radio's state/channel changes.

Note that it would probably be best to make these configuration options,

updating master branch for change staging
For those who want to see what the control channel is putting out.  Repetitive "meta" system messages (as seen on the P25 system I monitor) left at trace level.  Also, added ability to respond to location registration acknowledgements.
creates a radiolist.json file in the capture directory consisting of radio ID/talkgroup pairs, and also added commented-out code to run an external command whenever a radio's state/channel changes.  Radios that have been turned off are set to talkgroup -1 in the list.

Also changed logging level to debug to capture more control channel messages

Notes: List file will only get updated every 3 minutes, and that it may be better to write changes directly to it instead of keeping the list in memory.  These should also really be configuration options.
@rosecitytransit
Copy link
Contributor Author

rosecitytransit commented Mar 7, 2021

This was never merged so I updated it to work with the current version. Note that the config file entry is not hooked up as I am unsure how to access it in the contexts it is needed, so as is it'll always run onunitchange.sh.

in main.cc, the lines beginning with sprintf(shell_command, "onunitchange.sh %li should be something like sprintf(shell_command, "%s %li on &", sys->get_onunitchange_file, unit);.

Even better, to support multiple systems, would be something like sprintf(shell_command, "%s %s %li on &", this->get_onunitchange_file, sys->get_short_name(), unit); along with making the config a global option.

If someone could tell me the proper way of doing that it would be greatly appreciated, as I have other changes I'd like to work on getting ready next.

@rosecitytransit
Copy link
Contributor Author

rosecitytransit commented Mar 8, 2021

OK, I think I have this all ready to go. @robotastic you want to merge it?

@robotastic
Copy link
Collaborator

Thanks - let me go give it a check tonight!

@rosecitytransit
Copy link
Contributor Author

rosecitytransit commented Mar 8, 2021 via email

@robotastic
Copy link
Collaborator

The changes look good to me! Could you add in an example script that people could use to get started? You can add it to the /examples folder.

It might make the most sense to ultimately track the Unit changes in a DB. It would be easier to do the report generation and analysis over time... and no C++ to worry about!

@rosecitytransit
Copy link
Contributor Author

rosecitytransit commented Mar 9, 2021 via email

@rosecitytransit
Copy link
Contributor Author

rosecitytransit commented Mar 10, 2021

I got to thinking that a simple sed script would work, so here's a prototype/draft of one that updates both a status file (a CSV containing radio ID,time stamp,action,talk group,acknowledgement response time stamp (if most recent action) as well as a daily log file. Note that there may be an issue with the log file being in the recording directory before the first call of the day:

#!/bin/bash
printf -v TRDATE '%(%Y/%-m/%-d)T'
printf -v NOWTIME '%(%s)T'
SHORTNAME=$1
RADIOID=$2
ACTION=$3
TALKGROUP=$4
if $3 != "ackresp"
sed <capture_dir>/$1/radiolist.csv 's/^$RADIOID,(.*)/$RADIOID,$NOWTIME,$ACTION,$TALKGROUP,/'
elif
sed <capture_dir>/$1/radiolist.csv 's/$RADIOID,(\d+),([on|join|off|call]),(\d+),(\d+)/$RADIOID,$1,$2,$3,$NOWTIME'
done
echo "$2,$3,$4" >> <capture_dir>/$1/$TRDATE/radiolog.csv

@robotastic robotastic merged commit ee51584 into TrunkRecorder:master Mar 11, 2021
@robotastic
Copy link
Collaborator

Thanks! having a simple script will at least help people get started. I merged everything in and added a note in the readme.

@rosecitytransit
Copy link
Contributor Author

Just FYI, the sample script was just a draft and wasn't complete working code as-is. I can flesh it out if you don't want to. Also, I see you added a section to the read me, but you didn't delete mine (if you are wanting yours).

@robotastic
Copy link
Collaborator

I had totally missed that in the readme!
I just switched it to your description.

If you are able to fill out the script a little, that would be great. It doesn't have to be anything fancy. I am a bad Bash scripter. What you have already written, is next level for me.

@robotastic robotastic mentioned this pull request Mar 12, 2021
@kcwebby
Copy link

kcwebby commented Mar 12, 2021

Just FYI, the sample script was just a draft and wasn't complete working code as-is. I can flesh it out if you don't want to. Also, I see you added a section to the read me, but you didn't delete mine (if you are wanting yours).

This is kind of cool -- What is the chance you would share the template for your PHP files as well? You've shown the world the awesomeness, now we must have it :)

The bash script doesn't work, but I think I understand the intent and can fix that if I can find the time to actually sit and code.

Thanks for the commits!

@rosecitytransit
Copy link
Contributor Author

Well, thanks. The PHP script I use is at https://github.com/rosecitytransit/trunk-recorder/blob/oldtrimetscanner/unitreg.php It's not totally useful to others since it uses an API related to the radio system I record.

I'm adding an updated draft to the opened issue.

robotastic added a commit that referenced this pull request Mar 28, 2021
Finished unit logging script (fixes #181, can close #440)
@jgarvas
Copy link

jgarvas commented May 10, 2021

@rosecitytransit Can you explain what output this might generate? I have a custom unitlog script that I meant to submit a pull request for over a year ago and I just never could figure out how to do it. custom TR code will generate four different events: on, off, tg, tx. Some of them just provide the radio ID and the event, others include the talk group. It allows me to maintain a realtime database of every radio in the system, what talk group they're currently on, if they powered off, etc.

I'm curious if there is a way to supplement what you did with my login somehow so as not to break what you're doing, but offer the same functionality? My code also generates these events even if the talk group in question is encrypted. If it happens, it logs it.

Here is a log as an example:

Radio ID 54638 cmd: tx tg: 54638
Radio ID 45525 cmd: tx tg: 45525
Radio ID 62562 cmd: tx tg: 62562
Radio ID 49520 cmd: tx tg: 49520
Radio ID 14494 cmd: tx tg: 14494
Radio ID 14470 cmd: tx tg: 14470
Radio ID 62561 cmd: tx tg: 62561
Radio ID 62562 cmd: tx tg: 62562
Radio ID 7735812 cmd: on tg: 0
Radio ID 7735812 cmd: on tg: 0
Radio ID 7735812 cmd: tg tg: 62927
Radio ID 7735812 cmd: tg tg: 62927
Radio ID 62624 cmd: tx tg: 62624
Radio ID 7740199 cmd: on tg: 0
Radio ID 7740199 cmd: on tg: 0
Radio ID 7740199 cmd: tg tg: 62525
Radio ID 7740199 cmd: tg tg: 62525
Radio ID 14494 cmd: tx tg: 14494
Radio ID 8675309 cmd: off tg: 88888888
Radio ID 8675309 cmd: off tg: 88888888
Radio ID 1891505 cmd: on tg: 0
Radio ID 1891505 cmd: on tg: 0
Radio ID 1891505 cmd: tg tg: 14490
Radio ID 1891505 cmd: tg tg: 14490
Radio ID 62562 cmd: tx tg: 62562
Radio ID 7731703 cmd: on tg: 0
Radio ID 7731703 cmd: on tg: 0
Radio ID 7731703 cmd: tg tg: 45525
Radio ID 7731703 cmd: tg tg: 45525

@rosecitytransit
Copy link
Contributor Author

rosecitytransit commented May 11, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants