Android Question USBSerial - where is the DataAvailable event raised?

Discussion in 'Android Questions' started by Thorsen, May 8, 2018.

  1. Thorsen

    Thorsen Member Licensed User

    Hi, I found an unexpected behaviour of the DataAvailable event:

    My main module calls a codemodule (repshare) to initialize and use the felUSBSerial

    in repshare.mUSBinit i setup the callback event


    usbserial.Initialize("evtUSBSerial", device, 1)
    I expected that the event Sub should be declared in the code module as:

    Sub evtUSBSerial_DataAvailable (Buffer() As Byte)
    However it never fires here. Instead if I move it to the Main module it works.

    What I don’t understand is why it belongs in the main and not in the repshare code module?

    Furthermore it is frustrating that there are no warnings about missing event declaration!

    Can anybody please clarify, thanks
  2. DonManfred

    DonManfred Expert Licensed User

    Static Code Modules can not handle Events.
    So the code should run
    - In an Activity
    - In an Service
    - In a Class
    Thorsen and Erel like this.
  3. Thorsen

    Thorsen Member Licensed User

    Thanks. Good to know. So the event handler should be in the current activity!?
    How would one Know if an event is not handled because it's in the wrong place or maybe misspelled. In other words, how can you test if all events are implemented correctly??
  4. Erel

    Erel Administrator Staff Member Licensed User

    1. Code modules cannot handle events. I recommend you to watch the code modules and classes video tutorial:

    2. Unless otherwise stated the events are raised in the module where the object was initialized.
  5. Thorsen

    Thorsen Member Licensed User

    Thanks I do understand, remains the problem of debugging-detecting events not declared or misspellings and maybe underlining that point to newbees like me in the documentation.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice