Android Question USBSerial - where is the DataAvailable event raised?

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

B4X:
repshare.mUSBInit

in repshare.mUSBinit i setup the callback event

B4X:
…

usbserial.Initialize("evtUSBSerial", device, 1)

I expected that the event Sub should be declared in the code module as:

B4X:
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
 

DonManfred

Expert
Licensed User
Longtime User
Static Code Modules can not handle Events.
So the code should run
- In an Activity
- In an Service
- In a Class
 
Upvote 0

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??
 
Upvote 0

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.
 
Upvote 0
Top