jlennox / HeartRate

Bluetooth heart rate monitor
MIT License
109 stars 35 forks source link

Current Heart Rate Every XXX seconds #25

Closed mrdeadlocked closed 3 years ago

mrdeadlocked commented 3 years ago

Is it possible to just write a txt file with current heart rate at a set interval. I would like to just import the .txt into OBS.

jlennox commented 3 years ago

Sure thing. So the only thing inside the text file would be the last reading? It can do CVS logging now but that doesn't sound like what you want.

mrdeadlocked commented 3 years ago

Yep. Just a setting to have it write the current heart rate every XXX milliseconds/seconds. I could then set up OBS however I want and import that txt data. I didn't find an easy way for OBS to read a column in the CSV file.

jlennox commented 3 years ago

@mrdeadlocked Let me know if this works for you.

Right click any where and select "Set heart rate file..." heartratefile-test1.zip

mrdeadlocked commented 3 years ago

I will try this tonight when I get home! Thanks.

mrdeadlocked commented 3 years ago

It seems to do exactly what I wanted. Thanks!

jlennox commented 3 years ago

Great! I'll close out this issue. If something comes up, either ping me here or open another issue.

mrdeadlocked commented 3 years ago

@jlennox It seems like the app is closing after running for so long. Even if I leave the window up on another screen.

jlennox commented 3 years ago

Oh interesting. Sounds like it might be crashing. How long does it happen after?

mrdeadlocked commented 3 years ago

It seems to be maybe 3-5 minutes of running. I think I did have it run once for about 20 mins but during the middle of the match I was playing I noticed it stopped updating the heartrate. Can I get your logs for the app anywhere?

jlennox commented 3 years ago

heartrate-crash-test.zip

I don't have my heart rate monitor on hand, and my simulated one just ran for a few hours without issue.

I've added in a crash logger. When it crashes the file %appdata%\heartrate\crash.txt should appear. If you could grab me the contents of that I should be able to fix it up for you.

mrdeadlocked commented 3 years ago

Here you go.

System.Exception: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) at HeartRate.Extensions.AsyncResult[T](IAsyncOperation`1 async) in C:\Users\joe\Dropbox_code\HeartRate\HeartRate\Extensions.cs:line 24 at HeartRate.HeartRateService.InitiateDefault() in C:\Users\joe\Dropbox_code\HeartRate\HeartRate\HeartRateService.cs:line 114 at HeartRate.HeartRateServiceWatchdog.WatchdogThread() in C:\Users\joe\Dropbox_code\HeartRate\HeartRate\HeartRateServiceWatchdog.cs:line 62 at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

jlennox commented 3 years ago

Ha, strange. There's a "watchdog" service that ensures the program didn't stop updating. It appears that it's triggering, then it's hitting an abort when attempting to reinitialize.

I wonder if the watchdog is too aggressive. In this build it's set to 60 seconds instead of 10. Let me know if this helped at all. heartrate-crash-test2.zip

jlennox commented 3 years ago

I've made a version with debug logs being written to %appdata%\heartrate\logs.txt if you don't mind reproducing and grabbing those for me, as well. heartrate-crash-test3.zip

mrdeadlocked commented 3 years ago

I grabbed test3 and am currently testing. I have some stuff to do around the house so I'll get the log/new crash as soon as/if it happens.

mrdeadlocked commented 3 years ago

Here is what the logs show. crash.txt logs.txt

mrdeadlocked commented 3 years ago

Good Morning. I just wanted to check and make sure what I attached would work?

jlennox commented 3 years ago

Yes. You've given me what I need to investigated further. I need to find my monitor and see if I can reproduce what's happening for you.

It's very strange. Your monitor stops responding so the watchdog restarts the monitoring. It does so successfully, then it happens again but the monitor returns Unreachable

Which monitor are you using?

mrdeadlocked commented 3 years ago

Its a CooSpoo BT Monitor

https://www.amazon.com/dp/B086PK4Q4K?psc=1&ref=ppx_yo2_dt_b_product_details

mrdeadlocked commented 3 years ago

Just checking in. @jlennox Any other testing you need from me? I'll be traveling for a week starting Sunday so I won't have access to my monitor/pc.

jlennox commented 3 years ago

I've got today off so I'll have the capability to try and reproduce your issue. I'm wearing my Polar H7 monitor around to see if I can reproduce it.

~Do you happen to have a means to check your battery (a multimeter)? If not, no worries.~ (I see now it's rechargable)

I have a rough idea of how we might work around what you're seeing and I'll have a build up to test that later, presuming it doesn't reproduce.

jlennox commented 3 years ago

I was not able to reproduce your issues, per say, but doing stuff like unplugging my bluetooth dongle while in use did cause it to crash. I've made it much more crash resistant. It will now keep retrying and does much better at checking and reporting status issues, etc.

heartrate-crash-test5.zip

Let me know how this goes.

Your device seems to drop out sporadically, so there might be blank periods where it's trying to reconnect. I tried to make it behave as as-expected as possible during those times.

mrdeadlocked commented 3 years ago

Alright. I'm testing it out now. The monitor itself is always flashing blue for me. I don't have anything else connected bluetooth to see if it could be the BT dongle.

I got this after only a few minutes of running it. It did seem to recover and begin updating my heartrate again.

image logs.txt

mrdeadlocked commented 3 years ago

I set up your app and my sensor on my son's laptop (built-in Bluetooth). I was running both for 10-15 mins without issue. I am going to order a different brand BT dongle and see how it works. I will get back with you likely in a week or so (due to work trip).

jlennox commented 3 years ago

Ah interesting. Let me know how that goes.

mrdeadlocked commented 3 years ago

New BT dongle seemed to fix the issue. I ran it last night for like 2 hours w/o that error message using the test5 version.