BACnet icon indicating copy to clipboard operation
BACnet copied to clipboard

Receiving events (OnEventNotify) is not working

Open Doctorslo opened this issue 5 years ago • 2 comments

With BacnetClient I have used OnEventNotify event, but it seems that it is never called. However, OnUnconfirmedServiceRequest does work. I have used "AnotherStorageImplementation" example which is sending those events.

I think the problem lies in Serialize\Services.cs DecodeEventNotifyData method.

How to reproduce

Create new C# console, install BACnet.Core via NuGet. Write code, such as:

class Program
{
    static void Main(string[] args)
    {
        BacnetClient client = new BacnetClient();
        client.OnIam += Client_OnIam;
        client.OnEventNotify += Client_OnEventNotify;
        client.OnUnconfirmedServiceRequest += Client_OnUnconfirmedServiceRequest;
        client.Start();

        Console.ReadLine();
    }

    private static void Client_OnUnconfirmedServiceRequest(BacnetClient sender, BacnetAddress adr, BacnetPduTypes type, BacnetUnconfirmedServices service, byte[] buffer, int offset, int length)
    {
        Console.WriteLine("Client_OnUnconfirmedServiceRequest");
    }

    private static void Client_OnEventNotify(BacnetClient sender, BacnetAddress adr, byte invokeId, BacnetEventNotificationData eventData, bool needConfirm)
    {
        Console.WriteLine("Client_OnEventNotify");
    }

    private static void Client_OnIam(BacnetClient sender, BacnetAddress adr, uint deviceId, uint maxAPDU, BacnetSegmentations segmentation, ushort vendorId)
    {
        Console.WriteLine("Got I am.");
    }
}

And now test it with "AnotherStorageImplementation" example. Client_OnEventNotify is never called.

Edit: It seems like there is a problem in the part where it is "tag 12 - event values". ASN1.decode_is_closing_tag_number is false, and then it returns -1.

Doctorslo avatar Mar 01 '19 10:03 Doctorslo

hi @DoctorSloww, which version of the nuget are you using? Please try with latest beta. If that still exists, can you checkout the v2 branch and try again?

gralin avatar Mar 01 '19 16:03 gralin

@gralin, the nuget I am using is: NuGet Package Manager 4.6.0. And I installed BACnet.Core, version 1.0.30. I think I have no option for beta.

I tried with v2 branch and it is the same. Is it possible that AnotherStorageImplementation example is not working properly? How would you test this?

Doctorslo avatar Mar 04 '19 09:03 Doctorslo