jvde-github / AIS-catcher-for-Android

Android AIS receiver for RTL SDR dongles, Airspy R2, Airspy Mini, Airspy HF+ and TCP (RTL-TCP and SpyServer). Output is send via UDP and visualized on the built-in map
GNU General Public License v3.0
96 stars 7 forks source link

driver crashes after a minute or 2 #4

Closed j2l closed 2 years ago

j2l commented 2 years ago

I'm getting boat positions in OpenCPN now. I think a full tutorial is needed though :smile:

For now, the problem is with duration. The RTL-SDR driver is started manually and it throws:

onStart
RtlSdr: found 1 device opening options
HackRF: found 0 device opening options
Only 1 option available, no need to ask user. Opening rtl-sdr /dev/bus/usb/001/003
Queueing
Arguments SdrTcpArguments{gain=24, samplerateHz=1024000, frequencyHz=91800000, address='0.0.0.0', port=14423, ppm=0}
Starting service with device rtl-sdr /dev/bus/usb/001/003
Opening fd 48
Set sampling rate to 1024000
Tuner gain set to 2.400000 dB
SdrTcp: Listening on [0.0.0.0:14423](http://0.0.0.0:14423/)
SdrTcp: Waiting for client...
Device was open. Closing the prompt activity.
The rtl-tcp implementation is running and is ready to accept clients
Acquired wake lock. Will keep the screen on.
Starting was successful!

SdrTcp: TCP server succesfully started and listening for clients!
SdrTcp: Client has connected.
set freq correction 0
set gain mode 0
set sample rate 240000
SdrTcp: commandListener failed to receive command
SdrTcp: Command listener thread exiting
SdrTcp: Waiting for command thread to die
SdrTcp: TCP server shutting down.
SdrTcp: Closing sdrtcp due to main thread finishing
SdrTcp: Closing from state 0
SdrTcp: Server thread shut down
rtlsdr_read_async finished successfully
SdrTcp: Requested sdrtcp stop but already stopped
Successfully closed service
Wake lock released
Closing service

Starting was successful! is the last message before launching AIS-catcher. I don't know what commandListener is, but it seems that it's missing at some point and it closes.

jvde-github commented 2 years ago

Hi Philippe, I am still working on the tutorial but was distracted with sorting some other things. Have the impression that you managed to get the messages send through.

AIS-catcher currently limits the running time to two minutes to avoid that users will see it as a replacement for commercial hardware. But not sure whether that makes sense. I can remove that. Simply have to press play again. Could that be it?

What is this log that you pasted? What program is that from? I do not recognize it. AIS-catcher should be able to run standalone or are you running via a rtl-sdr server remotely?

I suspect that you are running via rtl_tcp_andro or some other local RTL-TCP server. Have you tried to run it directly with the RTL-SDR dongle? If the dongle is available, you should be able to select it in the bottom right corner (Where it says that Source is RTL-TCP) and then there is no need for other programs to run. It will still have a time limit of two minutes (which I shall remove in the next update) but maybe bit more friendly for your battery.

Thanks and regards, Jasper

jvde-github commented 2 years ago

Hi, I added a tutorial and a new APK with the 2 minute time limit removed. So, hopefully in the right direction :-)

j2l commented 2 years ago

In my case (RTL-SDR.com device with driver from https://github.com/martinmarinov/rtl_tcp_andro-), AIS-Catcher doesn't start the dongle driver by itself (other apps do start it though), I have to manually start the driver as a server, hence its log, then I start AIS-Catcher. Thank you very much for removing the 2min limitation!

Maybe, AIS-Catcher misses something to start this driver? What driver do you use?

jvde-github commented 2 years ago

I installed that app and the route that you have taken seems to work. Great solution.

You are right, the program does not start the driver as it was not intended to work only with this particular RTL-TCP server but any server, also running remotely.

AIS-catcher does not need a driver as it is build into the program by default. So no other apps needed. The only thing you need to do is to use the button on the lower right (which says RTL-TCP) and use that to select RTL-SDR (like in the short tutorial). Step 6 in the tutorial (and step 4 is required as well to give AIS-catcher access to your dongle).

Your route works as well but using the internal driver is maybe easier as it does not require another app. Do you see that option?

j2l commented 2 years ago

I'm back. I only have RTL-TCP and SpyServer, no RTL-SDR. when I plugin my USB device, it doesn't popup to allow AIS-Catcher to use it. I'm using Android 7

jvde-github commented 2 years ago

Interestingly RTL-TCP Andro is able to find the device and seems to work fine so that is possibly a bug then.

If you have time, it could be interesting to remove AIS-catcher from the phone and install the new version v0.15 from here.

Then start the app without the dongle connected, go on top to "LOG" and press the source button on the lower right. I have added some messages on USB devices that are connected but to which AIS-catcher has no access (which then should be yours). Will look something like in this picture.

Maybe your specific dongle is not connected in the list. Would be interesting to hear what the message says, if anything.

Thanks, Jasper

j2l commented 2 years ago

Here there are Screenshot_20220717-190031

Screenshot_20220717-190045

jvde-github commented 2 years ago

Thanks! This is useful and this is the standard dongle so nothing exotic. It can see the device but does not list it for usage as it does not have permission from Android to use it. The permission should be automatically asked for by Android when you connect the dongle.

I need to research a bit and possibly implement a different approach where the App asks for permission and does not depend on Android arranging this.

Just to be clear, your Android phone is not rooted and the dongle is not running by rtl-tcp andro or another application that somehow stops this process?

Hope you can use the rt-tcp root for now until we have a fix in the next few days.

j2l commented 2 years ago

Just to be clear, your Android phone is not rooted and the dongle is not running by rtl-tcp andro or another application that somehow stops this process?

No, stock basic phone used for AIS and ADS-B.

I really don't know if the driver starts in the background, I don't get any notification.

AIS-Catcher seems to not asking any special permission, Permissions is grayed in the app settings.

---- On Sun, 17 Jul 2022 19:49:18 +0200 Jasper @.***> wrote ---

Thanks! This is useful and this is the standard dongle so nothing exotic. It can see the device but does not list it for usage as it does not have permission from Android to use it. The permission should be automatically asked for by Android when you connect the dongle.

I need to research a bit and possibly implement a different approach where the App asks for permission and does not depend on Android arranging this.

Just to be clear, your Android phone is not rooted and the dongle is not running by rtl-tcp andro or another application that somehow stops this process?

Hope you can use the rt-tcp root for now until we have a fix in the next few days.

— Reply to this email directly, https://github.com/jvde-github/AIS-catcher-for-Android/issues/4#issuecomment-1186579651, or https://github.com/notifications/unsubscribe-auth/AAAP6LNEMHHBWUPY5OD6YELVURBR5ANCNFSM53FECV7A. You are receiving this because you authored the thread.

jvde-github commented 2 years ago

Tricky one this as I cannot replicate the issue. I went through the Android documentation and no leads. Perhaps because it is installed as APK file or because you run a particular version of Android. I also had a look at some other projects and it seems like most Apps are following the same pattern as I did but are additionally requesting permission by code. I will implement the same approach in the next two weeks.

Hope you are willing to test again at that point to see if it fixes your issue. For now, it seems we have to follow the TCP route.

j2l commented 2 years ago

Weird indeed. Of course, I'll test again and help you as much as I can. My other apps: RF Analyser, Avare ADSB, RTL_AIS_Driver, Dump1090, Ships (from Videgro, it can't be shut down!, uninstalled) are seeing the RTL-SDR device. I'd love to know if ADS-B (1090Mhz) could be added? Since AIS-catcher scans 2 channels, could we add a third one? Not sure but I think it's NMEA. I know this megahertz frequency would need a shorter antenna, but the signal is pretty strong.

jvde-github commented 2 years ago

I was going through these other apps you mention and the Android documentation and noticed that there is this section:

"Because not all Android-powered devices are guaranteed to support the USB host APIs, include a element that declares that your application uses the android.hardware.usb.host feature."

I forgot to add that in the Manifest file and might cause the app not to find the dongle on some devices. I also discovered that if there is already an app autostarting with a particular device, Android will not ask for AIS-catcher. That might be another issue that needs to be fixed. I added some fixes in v0.17.

Could you kindly give that a try (perhaps removing the old version first) and see whether it resolved the issue?

On your ADSB comment. AIS and ADSB are different protocols and require completely different decoding algorithms so that is unfortunately not that easy. But I noticed you already have Dump1090 installed, so this should be fine?

j2l commented 2 years ago

Thank you! I'll test the new version ASAP

I'd need to track boats and planes on one phone in OpenCPN (or LK8000), if possible :smile: Dump1090 is a demo version. I have limited choices on Android 7. Sorry, I though AIS and ADS-B were both NMEA.

j2l commented 2 years ago

With 0.17, it works! You're the man!

Thank you very much for this app. If you feel like learning ADS-B, let me know :smile_cat:

Closing this one since you fixed it and went beyond expectations.

jvde-github commented 2 years ago

Great, thanks for the test and confirmation!