EliasOenal / multimon-ng

GNU General Public License v2.0
923 stars 206 forks source link

Feature request: FLEX: put group messages in an array/list #123

Closed bierviltje closed 3 years ago

bierviltje commented 5 years ago

As far as I know the Motorola Flex protocol works like this for group messages:

The network transmits an announcement to the corresponding receivers capcodes: "the next message in this group cycle/frame is for you", and then the actual message is send.

Multimon-ng shows this as seperate messages, like it's sent with POCSAG.

This can be problematic when using the piped output in a script (Python in my case). Example: the script gets a piped message with the local fire department capcode that (after filtering) activates a Discord webhook on a Discord channel named "#local". The same script is also looking for a regional FD capcode and activates another Discord webhook that posts on a Discord channel named "#regional". In some cases a FD from another city is needed to respond to a local call and I also want to post that on the "#local" channel after some word filtering on the regional capcode. Here is the problem: in every group message for the local FD, the regional capcode is also included. This will cause posting on the channel "#local" twice.

There are 2 ways to solve this.

1. In my Python script: start with an empty string, put the group cycle/frame number of the first message that pass the filter for the Discord webhook in it. If the next received message contains the same group cycle/frame number: don't let it pass.

Problem with this is: I attach a name label to each message. Depending on the capcode order how the message was composed by the dispatcher: Sometimes it will show the label "Local FD" and sometimes it will show "Regional Code" (just which one comes first).

I also could do word filtering (for my city) on the regional capcode alone without using the local FD capcode, but this ain't something I want because the name labeling is important to me. (there is some additional filtering and usage in my code)

2. Put the output of Multimon-ng optionally in a list style array for group messages. Which makes life much easier for scripters like me.

Instead of feeding the output one by one for each message below:

FLEX: 2019-01-20 03:28:57 1600/2/K/A 07.040 [002029568] ALN message example
FLEX: 2019-01-20 03:28:57 1600/2/K/A 07.040 [000000001] ALN message example
FLEX: 2019-01-20 03:28:57 1600/2/K/A 07.040 [000000002] ALN message example
FLEX: 2019-01-20 03:28:57 1600/2/K/A 07.040 [000000003] ALN message example
FLEX: 2019-01-20 03:28:57 1600/2/K/A 07.040 [000000004] ALN message example

Use something like this:

[[FLEX],[2019-01-20 03:28:57],[1600/2/K/A],[07.040],[002029568,000000001,000000002,000000003,000000004],[ALN],[message example]]

Then a simple if '000000003' in message[4]: will do the job.

rob0101 commented 5 years ago

I'm trying to follow your example and may have mistaken your issue.

Here in South Australia each volunteer fire station is a member of a 'group' (not a FLEX group) and the officers for each group will be sent a copy of each message. So if multiple stations in the group are paged to the same job, the 'group officers' will get paged multiple times with the same message.

We have multiple public web feeds for these messages and I run one of them. Each site has independently chosen to discard duplicate messages within a given timeframe.

I have access to a wipath decoder. The configuration software for it has an option to discard duplicate messages, so it's a common issue.

If this is the same issue you are seeing, then my solution (in Perl) is to keep a key/value pair for all messages. The key is "capcode message" and the value is the current epoch time. Before processing each new message I scan all the old key/value pairs and delete those that are more than 2 minutes old. I then look to see if a key/value pair exists for the current "capcode message" and if it does it's a duplicate and gets discarded. The logic is simple and requires no alarms/timers to keep the key/value pairs fresh.

bierviltje commented 5 years ago

In the Netherlands group officers never get duplicate messages when more than one crew is paged.

Example:

0706001 - Regional monitor code (emergency call center can check if a message is delivered) 0705201 - Group commander 0705205 - Engine 1 (entire crew of engine gets this message) 0505210 - Ladder (entire crew of ladder gets this message) 0505300 - Local monitor code

The paging network transmits it like this:


Hey 0706001, 0705300, 0705210, 0705205, 0705201: look for capcode 2029568 in frame 01.002, this will contain your message.

2029568 01.002 Building fire street city


What multimon-ng does: showing these messages for each capcode on a separate line, like they were sent as separate (non-group) messages over the network.

I noticed these are always sorted in high to low capcode order. I don't know where this takes place. It could be in the dispatchers software, the paging network software or maybe even in multimon-ng.

Fact is: first the capcodes are sent over the network, then the actual message (once). I don't know how multimon-ng handles this. I could be a loop in the code, an array that gets merged with a loop or something else. In case of an array: it would be helpful if the stdout without the merging is optionally available.

About your suggestion: I can't hold values for each message for a given times because 2 reasons: stdout is read line by line and in case of a group message to (let's say) 6 capcodes, 6 lines are added to stdout at once. In this example my script is reading, handling and executing itself 6 times in a couple of milliseconds, while it keeps being fed en reruns by stdout.

The capcode order is a problem in my particular case.

rob0101 commented 5 years ago

Have a look at demod_flex.c lines 563-581

I'm guessing that's the code you'd need to investigate

      if(flex_groupmessage == 1) {
                int groupbit = flex->Decode.capcode-2029568;
                if(groupbit < 0) return;

                int endpoint = flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX];
                for(int g = 1; g <= endpoint;g++)
                {
                        verbprintf(1, "FLEX Group message output: Groupbit: %i Total Capcodes; %i; index %i; Capcode: [%09lld]\n", groupbit, endpoint, g, flex->GroupHandler.GroupCodes[groupbit][g]);

                        verbprintf(0,  "FLEX: %04i-%02i-%02i %02i:%02i:%02i %i/%i/%c/%c %02i.%03i [%09lld] ALN ", gmt->tm_year+1900, gmt->tm_mon+1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec,
                                        flex->Sync.baud, flex->Sync.levels, frag_flag, PhaseNo, flex->FIW.cycleno, flex->FIW.frameno, flex->GroupHandler.GroupCodes[groupbit][g]);

                        verbprintf(0, "%s\n", message);
                }
                // reset the value
                flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX] = 0;
        flex->GroupHandler.GroupFrame[groupbit] = -1;
        flex->GroupHandler.GroupCycle[groupbit] = -1;
        }
bierviltje commented 5 years ago

How I interpret this:

groupbit Decode.capcode-2029568 (knowing it's a group message, group messages starts from this capcode and up).

endpoint groupbit and CAPCODES_INDEX (this contains the group capcode and all paged capcodes).

for loops through endpoint until it returns false (when CAPCODES_INDEX is emptied).

{ } verbprintf(1,) this contains the verbosity 1 output?

Confirmed by running multimon-ng with -v 1:

FLEX: State: FIW
FLEX: State: SYNC2
FLEX: State: DATA
FLEX: Found Short Instruction, Group bit: 0 capcodes in group so far 1, adding Capcode: [001220645]
FLEX: Found Short Instruction, Group bit: 0 capcodes in group so far 2, adding Capcode: [001220499]
FLEX: State: SYNC1
FLEX: State: FIW
FLEX: State: SYNC2
FLEX: State: DATA
FLEX: 2019-01-30 13:57:01 1600/2/K/A 14.042 [002029568] ALN test 145
FLEX Group message output: Groupbit: 0 Total Capcodes; 2; index 1; Capcode: [001220645]
FLEX: 2019-01-30 13:57:01 1600/2/K/A 14.042 [001220645] ALN test 145
FLEX Group message output: Groupbit: 0 Total Capcodes; 2; index 2; Capcode: [001220499]
FLEX: 2019-01-30 13:57:01 1600/2/K/A 14.042 [001220499] ALN test 145
FLEX: State: SYNC1

0 for groupbit looks like a False, but initially it checks for lower than 0. When a message doesn't contains the groupbit, the value is -1. This also happen at the end of the block of code to reset the value. So 0 is actually True, a bit confusing. :)

I think groupbit = 0 for 2029568, 1 for 2029569, 2 for 2029570, 3 for 2029571 and so on.

Groupbit is taken from groupbit Total Capcodes is taken from endpoint (I assume this is the number the for loop, takes from the number of values in arrays [groupbit] and [CAPCODE_INDEX] combined) index is taken from g Capcode is %09lld? Is this taken from flex->GroupHandler.GroupCodes[groupbit][g]?

Same thing happens in verbprintf(0,)

I think I don't need g and endpoint and only need the CAPCODE_INDEX. How can I properly remove the for loop?

Edit: I never used the C language before, apparently it's not possible to printf an entire array without using a loop? Fortunately when I keep g and endpoint and I make a loop, the loops knows how long the array is. Now my goal is not to reloop the message but only loop the CAPCODE_INDEX. I'm not sure if that have to take place before printing or during printing.

Edit2:

When I'm back home I'm going try this...

if(flex_groupmessage == 1) {
    int groupbit = flex->Decode.capcode-2029568;
    if(groupbit < 0) return;

    verbprintf(0, "[FLEX],[%04i-%02i-%02i %02i:%02i:%02i],[%i/%i/%c/%c],[%02i.%03i],[", gmt->tm_year+1900, gmt->tm_mon+1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec,
                   flex->Sync.baud, flex->Sync.levels, frag_flag, PhaseNo, flex->FIW.cycleno, flex->FIW.frameno;)

    int endpoint = flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX];

    for(int g = 1; g <= endpoint;g++)
    {
        verbprintf(0, ",%09lld", flex->GroupHandler.GroupCodes[groupbit][g]);
    }

    verbprintf(0, "],[ALN],[%s]\n", message);

    // reset the value
    flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX] = 0;
    flex->GroupHandler.GroupFrame[groupbit] = -1;
    flex->GroupHandler.GroupCycle[groupbit] = -1;
}

Edit 3:

I got it partially working, output is now:

FLEX: 2019-01-30 19:19:12 1600/2/K/A 04.112 [002029568] ALN P 1 (inci-05) Gebouwbrand (keuken) Friesestraatweg Groningen 011832 011850
[[FLEX],[2019-01-30 19:19:12],[1600/2/K/A],[04.112],[000401998,000400419,000400392,000400389,000400363,000400310,000400276,000400271,000400111,000400021,],[ALN],[P 1 (inci-05) Gebouwbrand (keuken) Friesestraatweg Groningen 011832 011850]]

Notice the double lines. Line 1 is now the non group message with a group code and the group message doesn't contain the group code..

To do:

bierviltje commented 5 years ago

I got the job done. I had to edit a larger block of code. For now I'm not worried about Tone Only and Numeric messages, because my Python script only use Alphanumeric messages.

Now the output is:

[[FLEX], [2019-01-30 21:30:41], [1600/2/K/A], [07.095], [002029568, 001420999, 001420022], [ALN], [B1 AMBU 17122 Maasstadweg 3079DZ Rotterdam ROTTDM bon 13913]]

In demod_flex.c starting at line 557, replace:

        verbprintf(0,  "FLEX: %04i-%02i-%02i %02i:%02i:%02i %i/%i/%c/%c %02i.%03i [%09lld] ALN ", 
                gmt->tm_year+1900, gmt->tm_mon+1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec,
                        flex->Sync.baud, flex->Sync.levels, frag_flag, PhaseNo, flex->FIW.cycleno, flex->FIW.frameno, flex->Decode.capcode);

        verbprintf(0, "%s\n", message);

        if(flex_groupmessage == 1) {
                int groupbit = flex->Decode.capcode-2029568;
                if(groupbit < 0) return;

                int endpoint = flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX];
                for(int g = 1; g <= endpoint;g++)
                {
                        verbprintf(1, "FLEX Group message output: Groupbit: %i Total Capcodes; %i; index %i; Capcode: [%09lld]\n", groupbit, endpoint, g, flex->GroupHandler.GroupCodes[groupbit][g]);

                        verbprintf(0,  "FLEX: %04i-%02i-%02i %02i:%02i:%02i %i/%i/%c/%c %02i.%03i [%09lld] ALN ", gmt->tm_year+1900, gmt->tm_mon+1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec,
                                        flex->Sync.baud, flex->Sync.levels, frag_flag, PhaseNo, flex->FIW.cycleno, flex->FIW.frameno, flex->GroupHandler.GroupCodes[groupbit][g]);

                        verbprintf(0, "%s\n", message);
                }
                // reset the value
                flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX] = 0;
        flex->GroupHandler.GroupFrame[groupbit] = -1;
        flex->GroupHandler.GroupCycle[groupbit] = -1;
        }

For:

        verbprintf(0, "[[FLEX], [%04i-%02i-%02i %02i:%02i:%02i], [%i/%i/%c/%c], [%02i.%03i], [%09lld",
                gmt->tm_year+1900, gmt->tm_mon+1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec,
                        flex->Sync.baud, flex->Sync.levels, frag_flag, PhaseNo, flex->FIW.cycleno, flex->FIW.frameno, flex->Decode.capcode);

        if(flex_groupmessage == 1) {
                int groupbit = flex->Decode.capcode-2029568;
                if(groupbit < 0) return;

                int endpoint = flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX];
                for(int g = 1; g <= endpoint;g++)
                {
                        verbprintf(0, ", %09lld", flex->GroupHandler.GroupCodes[groupbit][g]);
                }

                // reset the value
                flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX] = 0;
                flex->GroupHandler.GroupFrame[groupbit] = -1;
                flex->GroupHandler.GroupCycle[groupbit] = -1;
        } 
        verbprintf(0, "], [ALN], [%s]]\n", message);
bierviltje commented 5 years ago

Things to do:

I could use some help with this.

rob0101 commented 5 years ago

You might want to make the change an option via a command-line flag so the current output is the default and your version can be toggled on only if wanted.

I never encounter group messages, so this section of the code does not affect/interest me.

bierviltje commented 5 years ago

I didn't implement a command line option. I ended up with this code change:

        static char pt_out[4096] = { 0 };
        int pt_offset = sprintf(pt_out, "FLEX|%04i-%02i-%02i %02i:%02i:%02i|%i/%i/%c/%c|%02i.%03i|%09lld",
                        gmt->tm_year+1900, gmt->tm_mon+1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec,
                        flex->Sync.baud, flex->Sync.levels, frag_flag, PhaseNo, flex->FIW.cycleno, flex->FIW.frameno, flex->Decode.capcode);

        if(flex_groupmessage == 1) {
                int groupbit = flex->Decode.capcode-2029568;
                if(groupbit < 0) return;

                int endpoint = flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX];
                for(int g = 1; g <= endpoint;g++)
                {
                        pt_offset += sprintf(pt_out + pt_offset, " %09lld", flex->GroupHandler.GroupCodes[groupbit][g]);
                }

                // reset the value
                flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX] = 0;
                flex->GroupHandler.GroupFrame[groupbit] = -1;
                flex->GroupHandler.GroupCycle[groupbit] = -1;
        } 
        pt_offset += sprintf(pt_out + pt_offset, "|ALN|%s\n", message);
        verbprintf(0, pt_out);

And a simply Python script that works with this modification:

#!/usr/bin/python

import time
import sys
import subprocess
import os
from datetime import datetime
from dateutil import tz

def curtime():
    return time.strftime("%H:%M:%S %Y-%m-%d")

with open("error.txt","a") as file:
    file.write(("#" * 20) + "\n" + curtime() + "\n")

multimon_ng = subprocess.Popen("rtl_fm -f 169.65M -M fm -s 22050 -g 20 | multimon-ng -a FLEX -t raw -",
                               stdout=subprocess.PIPE,
                               stderr=open("error.txt","a"),
                               shell=True)

try:
    while True:
        line = multimon_ng.stdout.readline()
        multimon_ng.poll()

        if line.__contains__("ALN"):

            if line.startswith("FLEX"):

                list = line.split("|", 6)

                timestamp = list[1]
                message = list[6][:-1]
                capcodes_list = list[4].split(" ")
                capcodes_string = list[4]

                utc = datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S")
                utc = utc.replace(tzinfo=tz.tzutc())
                local = utc.astimezone(tz.tzlocal())
                local_time = local.strftime("%d-%m-%Y %H:%M:%S")

                print local_time + ": " +  message
                print capcodes_string + "\n"

except KeyboardInterrupt:
    os.kill(multimon_ng.pid, 9)
bierviltje commented 5 years ago

Reopened to find a better way to print the group message on one line.

I don't think I need the for-loop.

bertinholland commented 5 years ago

@Zanoroy this is a nice request. Can you implement this in the base code multimon-ng?

dejury commented 5 years ago

Would be very nice to have this in the base code.

tomswinkels commented 4 years ago

Any update about this issue?

Zanoroy commented 4 years ago

Wow. I haven't looked at this code in almost a year.

I'll have a look tomorrow or Thursday

On Tue, 21 Jan. 2020, 20:07 Tom Swinkels, notifications@github.com wrote:

Any update about this issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EliasOenal/multimon-ng/issues/123?email_source=notifications&email_token=AB6Q2JOIG76EY34DXRKVU73Q6264VA5CNFSM4GSZIUG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJPCXLI#issuecomment-576596909, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6Q2JKCFFDGBDO32PO3R2LQ6264VANCNFSM4GSZIUGQ .

tomswinkels commented 4 years ago

@Zanoroy did you have check this?

Zanoroy commented 4 years ago

Yeah, I can put this into the main stream of MY version and ask that it be Pulled into EliasOenal's 'Mater' version. I just need to find my older VM.

If I haven't action'd this within a week, please ping me (I'm flat out with my day job and it takes priority sorry).

Cheers

Zanoroy commented 4 years ago

Ok, I have put (copy and pasted with only a little checking) the change into the version available at https://github.com/Zanoroy/multimon-ng

I have NO way of testing this implementation, South Australia does not make use of Flex Groups (although it should. We send so much wasteful 'repeated' messages across the network its not funny).

Once someone has confirmed its working correctly and I don't get bombarded with requests to change the delimiter back to a space. I'll submit a pull request to the main stream.

Cheers

tomswinkels commented 4 years ago

@Zanoroy Very very nice. When i have time i will test it and send you the results! :) I hope this week!

tomswinkels commented 4 years ago

@Zanoroy i think this works great! :)

image
Zanoroy commented 4 years ago

Ok, well I'll give it a week too see if there is any other feedback.

On Tue, 28 Jan. 2020, 18:29 Tom Swinkels, notifications@github.com wrote:

@Zanoroy https://github.com/Zanoroy i think this works great! :)

[image: image] https://user-images.githubusercontent.com/9036151/73245436-7e750500-41ac-11ea-9f4a-2fe96e949611.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EliasOenal/multimon-ng/issues/123?email_source=notifications&email_token=AB6Q2JI76L4NJ5PTYZSGZMLQ77QWPA5CNFSM4GSZIUG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKCL5FY#issuecomment-579124887, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6Q2JIVVQ5E4DNS6XNJ24TQ77QWPANCNFSM4GSZIUGQ .

dejury commented 4 years ago

I'm using this change over 10 months right now, and it works like charm... So I would give it a go!

bierviltje commented 4 years ago

I won't advice to implement my code change because sometimes it will miss single capcode (not group) messages for this reason:

If the network transmits a group message with capcode 2029569 or higher and there's a single capcode message AFTER the group message in the same frame/cycle, this message won't be decoded.

dejury commented 4 years ago

I won't advice to implement my code change because sometimes it will miss single capcode (not group) messages for this reason:

If the network transmits a group message with capcode 2029569 or higher and there's a single capcode message AFTER the group message in the same frame/cycle, this message won't be decoded.

Explains a lot why some "Politie persmeldingen" are missed sometimes, thought it had something to do with the reception.

Zanoroy commented 4 years ago

If you could record some raw audio that contains the issue, that I can test with. I will fix the problem.

On Wed, Jan 29, 2020 at 1:40 AM Jonathan Hafkamp notifications@github.com wrote:

I won't advice to implement my code change because sometimes it will miss single capcode (not group) messages for this reason:

If the network transmits a group message with capcode 2029569 or higher and there's a single capcode message AFTER the group message in the same frame/cycle, this message won't be decoded.

Explains a lot why some "Politie persmeldingen" are missed sometimes, thought it had something to do with the reception.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EliasOenal/multimon-ng/issues/123?email_source=notifications&email_token=AB6Q2JID5BIVGPM3H32QNJLRABDH3A5CNFSM4GSZIUG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKDUTNI#issuecomment-579291573, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6Q2JIAOKT5F43VYXWCCYDRABDH3ANCNFSM4GSZIUGQ .

bertinholland commented 4 years ago

@Zanoroy @bierviltje @dejury

I have implement Version 0.9.3v (28 Jan 2020) on my testlab system and will capture raw files and analyse it and report it. After a day I have enough informationd and time to report.

bertinholland commented 4 years ago

@Zanoroy @bierviltje @dejury Im running flex 0.9.3.v 28 jan 2020 in highest debug level. Also capturing raw files (chunks 30 min raw). I think everything is working fine (groupcode and individual cap messages).

If there is an issue can you report the date / time and copcode and message of the missing message so i can do an analyse and save the raw / debug files? Please give some detailed information.

tomswinkels commented 4 years ago

@bertinholland @Zanoroy

Something is wrong;

image

You see the message 'Kluunpad Zeewolde Ongeval/Wegvervoer/Letsel' 3 times, but there is only one right, the one with capcode 000730316.

Bron: https://112pers.nl/melding/33514657/kluunpad-zeewolde-ongevalwegvervoerletsel

bierviltje commented 4 years ago

This was actually a group message:

20200129_174045

Keep in mind when you use one of the many P2000 monitor websites, that they use PDW in nearly all cases. They also do miss messages sometimes. The screenshot I made is from the p2kflex website and hence they use 2 receivers to minimize decode errors, they do sometimes miss messages too.

tomswinkels commented 4 years ago

@bierviltje thnx, but in my screen you see 2 times 000730000, and not a group.

bertinholland commented 4 years ago

@bierviltje @Zanoroy @dejury @tomswinkels

p2000 mobile reports: 14:25:52 Kluunpad Zeewolde Ongeval/Wegvervoer/Letsel [0730000] Politie Flevoland ( Monitorcode ) [0730316] Politie Flevoland [0730000] Politie Flevoland ( Monitorcode )

multimon-ng reports 2020-01-29 14:25:52: FLEX: BlockInfoWord: (Phase A) BIW:00000C03 AW:01-03 (2 pages) 2020-01-29 14:25:52: FLEX: CAPCODE:00000000000b24cc 2020-01-29 14:25:52: FLEX: Parse Alpha Numeric 2020-01-29 14:25:52: FLEX|2020-01-29 13:25:52|1600/2/K/A|06.069|000730316|ALN|Kluunpad Zeewolde Ongeval/Wegvervoer/Letsel 2020-01-29 14:25:52: FLEX: CAPCODE:00000000000b2390 2020-01-29 14:25:52: FLEX: Parse Alpha Numeric 2020-01-29 14:25:52: FLEX|2020-01-29 13:25:52|1600/2/K/A|06.069|000730000|ALN|Kluunpad Zeewolde Ongeval/Wegvervoer/Letsel 2020-01-29 14:25:52: FLEX: State: SYNC1 2020-01-29 14:25:53: FLEX: SyncInfoWord: sync_code=0x870c baud=1600 levels=2 polarity=POS zero=-0.031288 envelope=0.113734 symrate=1597.685141 2020-01-29 14:25:53: FLEX: State: FIW 2020-01-29 14:25:53: FLEX: FrameInfoWord: cycleno=06 frameno=070 fix3=0x3c time=26:11 2020-01-29 14:25:53: FLEX: State: SYNC2 2020-01-29 14:25:53: FLEX: State: DATA 2020-01-29 14:25:53: FLEX: BlockInfoWord: (Phase A) BIW:00000807 AW:01-02 (1 pages) 2020-01-29 14:25:53: FLEX: CAPCODE:00000000000b2390 2020-01-29 14:25:53: FLEX: Parse Alpha Numeric 2020-01-29 14:25:53: FLEX|2020-01-29 13:25:53|1600/2/K/A|06.070|000730000|ALN|Kluunpad Zeewolde Ongeval/Wegvervoer/Letsel 2020-01-29 14:25:53: FLEX: State: SYNC1 2020-01-29 14:26:47: FLEX: SyncInfoWord: sync_code=0x870c baud=1600 levels=2 polarity=POS zero=-0.031198 envelope=0.113701 symrate=1597.683970 2020-01-29 14:26:47: FLEX: State: FIW 2020-01-29 14:26:47: FLEX: FrameInfoWord: cycleno=06 frameno=099 fix3=0x3c time=27:05 2020-01-29 14:26:47: FLEX: State: SYNC2 2020-01-29 14:26:47: FLEX: State: DATA 2020-01-29 14:26:48: FLEX: BlockInfoWord: (Phase A) BIW:00000807 AW:01-02 (1 pages) 2020-01-29 14:26:48: FLEX: CAPCODE:0000000000175bfb

I see no difference. This is not a group message capcode. The output is the same.

bertinholland commented 4 years ago

can you report an other example with a probably issue so i can check it and analyse it

bertinholland commented 4 years ago

@Zanoroy @bierviltje @dejury Im running version flex 0.9.3.v 28 jan 2020 in highest debug level on my testlab system for 2 days now.

I have done a lot of checks.

The samples results checks (a few 1000) for group and individual flex messages were 100% good.

No differences when I checked (cross count check)

I have no corruptions and timeouts and the same count-check so the new version look great.

Has anyone problems with this new test release 0.9.3? If there are no problems reported the code is ready to integrate in the base release (Zanoroy -> EliasOenal.

Please let me know if you have any issue. I'm running my testlab for a few days.

Zanoroy commented 4 years ago

Thanks for the update.

On Fri, 31 Jan. 2020, 19:41 bertinholland, notifications@github.com wrote:

@Zanoroy https://github.com/Zanoroy @bierviltje https://github.com/bierviltje @dejury https://github.com/dejury Im running version flex 0.9.3.v 28 jan 2020 in highest debug level on my testlab system for 2 days now.

I have done a lot of checks.

The samples results checks (a few 1000) for group and individual flex messages were 100% good.

No differences when I checked (cross count check)

I have no corruptions and timeouts so the new version look great.

Has anyone problems with this new test release 0.9.3. If there are no problems reported the code is ready to integrate in the base release (Zanoroy -> EliasOenal.

Please let me know if you have any issue. I'm running my testlab for a few days.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EliasOenal/multimon-ng/issues/123?email_source=notifications&email_token=AB6Q2JJHJGH2ZIBZ4HAJWHDRAPTMJA5CNFSM4GSZIUG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKOAFVQ#issuecomment-580649686, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6Q2JMGMXCPRRSDUXDLUCLRAPTMJANCNFSM4GSZIUGQ .

jpduhen commented 4 years ago

Many thanks @bierviltje @bertinholland @rob0101: I got my raspberry pi working as a P2000 decoder.

Since I'm not a python-programmer, could any of you help me with "printing" these message-parts into a MQTT message, so I can use them in my home automation (to trigger my lights when I get a alarmcall ;-) )

Any help much appreciated!

tomswinkels commented 4 years ago

I dont no it this is an issue since the changes, but there are somethimes encoding problems;

image
bertinholland commented 4 years ago

@tomswinkels This is not an issue since the last change. My testlab (after change implementation) result is: 2020-02-06 09:42:46 000920110|ALN|A1 Altweertstraat 6845ES Arnhem 16583 2020-02-06 09:43:32 002029568 000126999 000123134 000120194|ALN|A2 (dia: ja) 11134 Rit 16298 Juno Purmerend

Probably an bad signal? Local reception error? PPM not calibrated etc. This is not an multimon-ng issue, probably an radio error I gues.

bertinholland commented 4 years ago

@Zanoroy Thanks for implementation of issue 123. There are no errors after 8 days of testing and checked the feedback. Can you please do a pull request in the base elias relase? Thanks in advance!

Zanoroy commented 4 years ago

Pull request created. Now its up to @EliasOenal Thanks for code, help and especially all the testing

bertinholland commented 4 years ago

I have installed the EliasOenal version (merged version, feature #146) on my production system. A quick analyse look great no issues. I monitor this version a few days . If there are issues I will report it in this issue. When I dont report any problems 20 feb 2020 I think this issue can be closed. Thinks for your implementation!

Zanoroy commented 4 years ago

Cheers mate

On Mon, 17 Feb. 2020, 06:19 bertinholland, notifications@github.com wrote:

I have installed the EliasOenal version (merged version, feature #146 https://github.com/EliasOenal/multimon-ng/pull/146) on my production system. A quick analyse look great no issues. I monitor this version a few days . If there are issues I will report it in this issue. When I dont report any problems 20 feb 2020 I think this issue can be closed. Thinks for your implementation!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EliasOenal/multimon-ng/issues/123?email_source=notifications&email_token=AB6Q2JOBWH6GAAYVBPUZXMLRDGKFDA5CNFSM4GSZIUG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL4QLHA#issuecomment-586745244, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6Q2JJIO5WWB7ELSGXDULLRDGKFDANCNFSM4GSZIUGQ .

bierviltje commented 4 years ago

I'm not sure if the submit still can be editted, but this is what I found running on my Raspberry Pi for over a year now. It's a little bit different from what I posted here a year ago. I'm sorry I didn't post an update of the changes I made myself:

        static char pt_out[4096] = { 0 };
        int pt_offset = sprintf(pt_out, "FLEX|%04i-%02i-%02i %02i:%02i:%02i|%i/%i/%c/%c|%02i.%03i|%09lld",
                        gmt->tm_year+1900, gmt->tm_mon+1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec,
                        flex->Sync.baud, flex->Sync.levels, frag_flag, PhaseNo, flex->FIW.cycleno, flex->FIW.frameno, flex->Decode.capcode);

        if(flex_groupmessage == 1) {
            int groupbit = flex->Decode.capcode-2029568;
            if(groupbit < 0) return;

            int endpoint = flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX];
            for(int g = 1; g <= endpoint;g++)
            {
                verbprintf(1, "FLEX Group message output: Groupbit: %i Total Capcodes; %i; index %i; Capcode: [%09lld]\n", groupbit, endpoint, g, flex->GroupHandler.GroupCodes[groupbit][g]);

                pt_offset += sprintf(pt_out + pt_offset, " %09lld", flex->GroupHandler.GroupCodes[groupbit][g]);
            }

            // reset the value
            flex->GroupHandler.GroupCodes[groupbit][CAPCODES_INDEX] = 0;
            flex->GroupHandler.GroupFrame[groupbit] = -1;
            flex->GroupHandler.GroupCycle[groupbit] = -1;
        }
        pt_offset += sprintf(pt_out + pt_offset, "|ALN|%s\n", message);
        verbprintf(0, pt_out);
}

Edit: nevermind, it seems to be identical in the official release.

bertinholland commented 4 years ago

@bierviltje what is the change in the code you posted a few days ago? Version 0.9.3 is functional allright I guess. Can you please give some extra release note / change information.

bierviltje commented 4 years ago

@bertinholland the only thing I did was comparing the code that is running on my Raspberry Pi with the code I posted 1 year ago.

I don't have release notes or change information. I'm a rookie coder and this was the first time I dived into C with only help from Google and a lot of trial and error to make it work. I already forgot most things I did and how they work.

I occasionally still miss some single non-group messages that are send in the same frame/cycle that also contains group messages with capcode 2029569 or greater.

I think this can be solved by modifying another part of the code instead of my code that basically collect all capcodes in a loop. I think it currently can't keep up with everything resulting in missed single messages.

bertinholland commented 4 years ago

@bierviltje CAn you please give me some examples of missed messages. Please give me the timestamp and capcode and message so I can do some analyse. Thanks!

bierviltje commented 4 years ago

@bertinholland 13:51:44 22-02-20 0736090 Vianen UT Het Slyk Aanrijding letsel

tomswinkels commented 4 years ago

@bertinholland

I also missed sometimes messages with Multimon.

I have total 3 receivers, 2x Multimon and 1x PDW.

Check this public link, this are latest x messages that i have received with PDW but not with Multimon.

https://staging.api.112pers.nl/v2/missed_messages

joper112 commented 4 years ago

Im not sure if im happy with this Feature

im doing this: if line.startswith('FLEX'): flex =line[0:4] date = line[6:17] tiime = line[17:25] capcode = line[45:52] message= line[57:]

After that i copy it in to mysql database

This is now not usefull anymore because i dont know how many capcodes are in there.

How do you manage this @bierviltje ?

bertinholland commented 4 years ago

@joper112 Thats right that your code with fixed positions is not usefull anymore. An implementation with fixed positions is a bad idea I think. You better can use regular expression and use the "|" sign as seperator.

bierviltje commented 4 years ago

@joper112 Assuming you're using Python I made an example how to use list with line.split and how to extract it previously in this thread:

https://github.com/EliasOenal/multimon-ng/issues/123#issuecomment-460845949

bertinholland commented 4 years ago

@tomswinkel

https://staging.api.112pers.nl/v2/missed_messages

Sended: 1585950368000 Message: A1 AMBU 17121 Motorstraat 3083AP Rotterdam ROTTDM bon 42588 Capcodes: 2029568, 1420999, 1420021 Receivers: Someren PDW

Sended: 1585950319000 Message: A2 Zevenbergschen Hoek rit: 28015 (Directe inzet: ja) eh: 20107 Capcodes: 2029568, 1220607, 1220499 Receivers: Someren PDW

Sended: 1585950304000 Message: P 1 BNH-02 (Middel BR) BR woning (schoorsteen) De Clercqstraat Haarlem 121201 121205 123060 123061 122160 Capcodes: 2029568, 0127860, 0127185, 0127030, 0108999, 0107581, 0107521, 0107081, 0106910, 0106900, 0106585 Receivers: Someren PDW

Sended: 1585950230000 Message: Ambu 06183 Einde VWS Nunspeet Rit 30114 Capcodes: 0820183 Receivers: Someren PDW

Sended: 1585950165000 Message: A1 Tilburg rit: 28014 eh: 20143 Capcodes: 2029568, 1220643, 1220499 Receivers: Someren PDW

Sended: 1585950155000 Message: A2 VWS Spoorstraat 6663AE Lent 41612 Capcodes: 2029568, 0923122, 0923100 Receivers: Someren PDW

Sended: 1585950103000 Message: A1 Tilburg rit: 28013 eh: 20141 Capcodes: 2029568, 1220641, 1220499 Receivers: Someren PDW

All messages are captured by multimon-ng 1.1.8

Output multimon-ng 1.1.8: 2020-04-03 23:45:50: FLEX|2020-04-03 21:45:50|1600/2/K/A|11.068|002029568 001420999 001420021|ALN|A1 AMBU 17121 Motorstraat 3083AP Rotterdam ROTTDM bon 42588

2020-04-03 23:45:01: FLEX|2020-04-03 21:45:01|1600/2/K/A|11.042|002029568 001220607 001220499|ALN|A2 Zevenbergschen Hoek rit: 28015 (Directe inzet: ja) eh: 20107

2020-04-03 23:44:47: FLEX|2020-04-03 21:44:47|1600/2/K/A|11.034|002029568 000127860 000127185 000127030 000108999 000107581 000107521 000107081 000106910 000106900 000106585|ALN|P 1 BNH-02 (Middel BR) BR woning (schoorsteen) De Clercqstraat Haarlem 121201 121205 123060 123061 122160

2020-04-03 23:43:33: FLEX|2020-04-03 21:43:33|1600/2/K/A|10.123|000820183|ALN|Ambu 06183 Einde VWS Nunspeet Rit 30114

2020-04-03 23:42:27: FLEX|2020-04-03 21:42:27|1600/2/K/A|10.088|002029568 001220643 001220499|ALN|A1 Tilburg rit: 28014 eh: 20143

2020-04-03 23:42:18: FLEX|2020-04-03 21:42:18|1600/2/K/A|10.083|002029568 000923122 000923100|ALN|A2 VWS Spoorstraat 6663AE Lent 41612

2020-04-03 23:41:25: FLEX|2020-04-03 21:41:25|1600/2/K/A|10.055|002029568 001220641 001220499|ALN|A1 Tilburg rit: 28013 eh: 20141

I think you have an issue with your local configuration.

My configuration has:

So this is not an implementation multimon-ng error.

bertinholland commented 4 years ago

@Zanoroy Thank for implementation and to implement it in the base release. Well done!

Also I checked the reported the latest reported issue and this is not and implementation error only a local site configuration error.

This implementation is running succesfull for 2 months now so I think you can close this issue. Thanks for your cooperation!