![]() |
|
Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - Printable Version +- 6.5 Grendel Forum (https://65grendel.com) +-- Forum: 6.5 GRENDEL DISCUSSION FORUMS (https://65grendel.com/forumdisplay.php?fid=3) +--- Forum: 6.5 Grendel Ammunition & Reloading (https://65grendel.com/forumdisplay.php?fid=10) +--- Thread: Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility (/showthread.php?tid=26213) |
Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - Zeneffect - 01-20-2024 How to Import your Garmin Xero C1s shooting data to your Windows PC Introduction The following procedures show you how to import your Xero C1s shot-session data to your PC and convert it to a more useable format. Well show you how to: Set up your environment, then Copy your Xeros shot-session data to your PC and convert it from Garmins proprietary FIT format to the more usable Character Separated Values (CSV) format and user-friendly text format. Why do this? This will allow you to back up and use your Xeros captured shooting data on your PC. Setup 1. Download the zip (includes four sub-folders and an launcher.bat file) from the developers Google drive or GitHub. Pick either one: https://drive.google.com/file/d/1SMq9lcJLsMsSC06hnqZXBz2wTmKVcxlh/view?usp=drive_link https://github.com/dkpp123/Xero-C1-Pro-FIT-to-CSV-and-TXT/archive/refs/tags/garmin_xero.zip Note: When you select Download, itll create a zip folder for you and download it to your Downloads folder. 2. Open your Downloads folder and extract the zip folder to anywhere on your PC. Suggestion: Create a Garmin folderits easy to rememberon your desktop or within your Documents folder, and extract the zip folders contents there. The setup is now complete. See the Usage section below when youre ready to import some session data. Usage Importing and converting shot data Do the following whenever you want to copy over and convert new session data to CSV and text: 1. Run the "Launcher.bat" file (AKA the app), by either double-clicking it or by right-clicking it and selecting Run as administrator in the context menu. 2. Using your Xeros provided USB cord, connect your Xero to your Windows laptop (or desktop if those still exist). Your Xero will switch on automatically and pair with the laptop. You should see an Explorer window open showing the contents of a new Xero C1 drive. 3. Open the Xero C1 drives Garmin folder, then open the Shot_Sessions folder. 4. Select the .FIT files you wish to import & convert (you can select multiple files; it works), then select Open. 5. The app will then ask you successively to name each session youve selected. At each prompt, enter a session name for the currently displayed session. Note: Spaces within the names are allowed, but do not add a .txt or .csv extension to the end. The app does that automatically. Thats it! Youre done. You can close the app now if it does not close automatically. You will find the converted files within the "Results" folder. Feel free to move and reorganize them in any directories you wish. Thank you SDW for the documentation application is written and maintained by me and is free to use / distribute. Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - Zeneffect - 01-20-2024 main script Code: # .
# Notes: Requires Java... Using parts of the Garmin SDK for this part and thats how they do it
#
# Copy entire folder from google drive
# [url]https://drive.google.com/file/d/1SMq9lcJLsMsSC06hnqZXBz2wTmKVcxlh/view?usp=drive_link[/url]
# Connect Garmin Xero C1 Pro to Computer
# Run the script (right click + run with powershell) or use the launcher.bat
# Navigate to the .FIT files on the device in the pop up and select them, press "Open" button
# Name the sessions when prompted in terminal window. Spaces are OK, dont include .txt
#
#
#
# Created by ZenEffect
clear-host
Add-Type -AssemblyName System.Windows.Forms
# temp directory cleaning to be lazy. suppressed errors will be present if re-running the same fit files but wont break function
remove-item -path .\fit_temp\*.csv -ErrorAction SilentlyContinue
remove-item -path .\fit_temp\*.fit -ErrorAction SilentlyContinue
# file selection window
$Fit = New-Object System.Windows.Forms.OpenFileDialog -Property @{
InitialDirectory = [Environment]::GetFolderPath('Desktop')
Filter = 'Garmin fit (*.fit)|*.fit'
Multiselect = $true}
$null = $Fit.ShowDialog()
# copies to the "fit_temp" folder first for processing. Does not interact with device except to copy the files to computer first.
if (!$fit.filenames)
{
Write-Output "No Files Selectd `nExiting"
pause
break
}
Copy-Item $fit.filenames .\fit_Temp -ErrorAction SilentlyContinue
# sends the selected files to the bat file that came with the Garmin SDK. Only modification to the .BAT was to remove the "Pause" at the end. FIT files
# are processed into CSV by some Garmin SDK Java magic.
$fit_temp = get-childitem -Path .\fit_temp\*.fit
foreach ($fitfile in $fit_temp)
{
$fit2 = "`"$fitfile`""
start-process -filepath '.\java\fittocsv.bat' -argumentlist $fit2 -wait
}
# gets list of newly created .csv from fit_temp directory for processing
$items = get-childitem -Path .\fit_temp\*.csv
# Gets shot data and calculates standard deviation
foreach ($item in $items)
{
$csv1 = $item.fullname | import-csv
$csv_data = $csv1 | where-object 'type' -eq 'data' | where-object 'local number' -eq 4
$measured = $csv_data.'value 2' | measure-object -average
$mean = $null
ForEach ($number in $csv_data)
{$mean += [Math]::Pow(($number.'value 2' - $measured.Average), 2)}
$stdDev = [math]::Sqrt($($mean / ($measured.Count - 1)))
$stdDevp = [math]::Sqrt($($mean / ($measured.Count)))
$stddev_fps=$stddev / 304.79999025
$stddevp_fps=$stddevp / 304.79999025
# Begin CSV to TXT file processing
# csv location detection for general statistics and bullet weight
foreach ($csv in $csv1)
{
$type = $csv.type
$localnumber = $csv."local number"
# value correction to feet per second, local time, bullet weight
if ($type -eq "Data" -and $localnumber -eq "3")
{
$min = ($csv."Value 2" / 304.79999025)
$max = ($csv."Value 3" / 304.79999025)
$average = ($csv."Value 4" / 304.79999025)
$shots = $csv."Value 6"
$time_hack=([int]$csv."Value 1" + [int]631065600)
$time = (([System.DateTimeOffset]::FromUnixTimeSeconds($time_hack)).DateTime.ToLocalTime()).ToString("s")
$extreme_spread= ($max - $min)
$weight = ($csv."Value 5" / 10)
$tdelta = $null
$kenergya = (([Math]::Pow($average ,2) * $weight) / 450437)
# sessionn info, user prompt for session name. if empty will still process using file name as base
$Session_name = Read-Host -Prompt "Session Time/Date: $time `nNum of Shots $shots `nBullet Weight gr: $weight `n `nMin: $min `nMax: $max `nAverage: $average `n `nStandard Deviation: $stddev_fps `nPopulation Standard Deviation: $stddevp_fps `nExtreme Spread: $extreme_spread `nAverage Kinetic Energy: $kenergya `n `n `nEnter Session Name"
if (!$Session_name)
{$Session_name = $item.Name.Replace('.', '_') }
$filecheck = get-childitem -Path .\Results\$session_name.txt
if ($Session_name = $filecheck.name)
{$Session_name = -join($session_name,"_new")}
# Write TXT file and dummy CSV for later processing into a real CSV
write-output "Session Time/Date: $time `nSession Name: $session_name `nNum of Shots: $shots `nBullet Weight: $weight `n `nMin: $min `nMax: $Max 'nStandard Deviation: $stddev_fps `nPopulation Standard Deviation: $stddevp_fps 'nExtreme Spread: $extreme_spread `nAverage Kinetic Energy FPE: $kenergya `n" | out-file -filepath .\Results\$Session_name.txt -Append
Write-output '"Shot #","Speed (FPS)","Delta from AVG (FPS)","Delta from Last (FPS)","Kinetic Energy (Ft-LBS)","Power Factor (kgr-ft/s)", "Time"' | out-file -filepath .\Results\$Session_name.csx -Append
clear-host
}
# csv location detection for individual shot data and value processing
if ($type -eq "Data" -and $localnumber -eq "4")
{
$shot_num = $csv.'Value 3'
$speed = ($csv.'Value 2' / 304.79999025)
$time_hack1=([int]$csv."value 1" + [int]631065600)
$time1 = (([System.DateTimeOffset]::FromUnixTimeSeconds($time_hack1)).DateTime.ToLocalTime()).ToString("s")
$kenergy = (([Math]::Pow($speed ,2) * $weight) / 450437)
$adelta = $speed - $average
$ldelta = $speed - $tdelta
$pfactor = ($weight * $speed) / 1000
$tdelta = $speed
# Write TXT file and dummy CSV for later processing into a real CSV
Write-Output "`n `nShot #: $shot_num `nSpeed: $speed `nDelta from Average: $adelta `nDelta from Last: $ldelta `nKinetic Energy FPE: $kenergy `nTime of Shot: $time1 `n" | out-file -filepath .\Results\$Session_name.txt -Append
Write-Output "$shot_num,$speed,$adelta,$ldelta,$kenergy,$pfactor,$time1" | out-file -filepath .\Results\$Session_name.csx -Append
}
}
# Additional information written to CSV at end of file after shot data processing completes
write-output "-,,,,,, `nWeight(gr): , $weight ,,,,,,,,,, `nAverage: , $average ,,,,,,,,,, `nSample Standard Deviation (N-1): , $stddev_fps ,,,,,,,,, `nPopulation Standard Deviation: , $stddevp_fps ,,,,,,,,,, `nExtreme Spread: , $extreme_spread ,,,,,,,,,, `nAverage Kinetic Energy: , $kenergya ,,,,,,,,,, `n-,,,,,, `nSession Name: , $Session_name `nSession Time: , $time" | out-file -filepath .\Results\$Session_name.csx -Append
# turning into a real CSV. Imports the dummy csv then exports it as properly formatted with file headers so it becomes a real csv
$csvprocessing = import-csv .\results\$session_name.csx
$csvprocessing | export-csv .\results\$session_name.csv -NoTypeInformation
remove-item .\results\$session_name.csx
}
# cleanup actions
move-item -path .\fit_temp\*.csv -destination .\results -ErrorAction SilentlyContinue
move-item -path .\fit_temp\*.fit -destination .\fit_backup -ErrorAction SilentlyContinue
# open file explorer window to results
explorer '.\Results'Launcher.bat Code: powershell.exe -executionpolicy bypass -file ".\Garmin_CSV_Converter_v2.517.ps1"git main: https://github.com/dkpp123/Xero-C1-Pro-FIT-to-CSV-and-TXT/ Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - Zeneffect - 01-20-2024 Sample Output ![]()
Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - Zeneffect - 01-20-2024 also, dont use 24gr xbr.. that was actually varget. i was just typing crap in when prompted (this isnt real load data!!!) 24gr of xbr was popping out primers pushes 2750fps. dont do it. Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - jasper2408 - 01-20-2024 My antivirus did not even like the .exe file when I tried to extract it this time. :confused: Edit: I tried running the .exe file after getting it out of quarantine but it was causing weird things to happen so I deleted everything. My antivirus would not let me download the github version as it blocked the whole process there. I can download the google version but when I try to extract the files then it stops at the .exe file and quits. Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - SDW - 01-20-2024 Ach... Zen... instructions unformatted.... hurts eyes to look at it.... :p If you will allow me, here's the downloadable PDF version. It's is a little easier to read:
Xero_data_importation-and-conversion_exec_v1.pdf (Size: 142.78 KB / Downloads: 8)
I was going to ask if you wanted your name on the doc. I hadn't gotten around yet to putting in screen shots etc. Wasn't really sure they are needed anyway. I also wasn't sure if we want to include the SW version in the referenced file name, since that will probably change from time to time. Edit: already has. Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - SDW - 01-20-2024 jasper2408 Wrote:My antivirus did not even like the .exe file when I tried to extract it this time. :confused:Yeah, that's the problem with executables. I ran into the same thing a couple of times yesterday, and that was while just trying to download the .exe file itself in Github. It was blocked. Github said it "Contains a virus". Must do that with every executable? Strangely, when I tried downloading a third time, later in the day, Github allowed it without any protest. And I ended up with the .exe file sitting in my Downloads folder. Of course when I launch it, Windows throws up a warning, "unknown publisher" do I really want to run it, etc. I launched it and it ran. Opened up an explorer window for us to go find and select our .fit files. Didn't get beyond that. I haven't set up my test environment properly with the sample/test .fit files yet. Edit: Here's a trick we used to do back at one company I worked for. We created an app for testing SW. It was also a basic executable. The developers would make updates to it periodically and then have to pass it on to the testers. How we'd pass it around was through emails attachments: the sender would change the app's extension from .exe to .txt, so it looked perfectly innocent. Then the recipient would simply change the extension back to .exe and launch the app on their system. Never mind that handing off corporate SW tools through emails was pretty bush league LOL Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - jasper2408 - 01-20-2024 I finally got everything working correctly. Used the Google version. Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - SDW - 01-20-2024 jasper2408 Wrote:I finally got everything working correctly. Used the Google version. I've found Google drive easier to use and download from, and that was before Zeneffect made it even easier as of last night(?). Github's download method is a little less intuitive. Not a problem for its typical users though. Bitbucket is kinda the same. I got really used to downloading SW packages from BB in my last job though, once I was shown where to find the button. Hah. Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - Zeneffect - 01-20-2024 No virus in exe, you can compile it yourself as all code is included. Normally one would be using an actual programming language intended to be turned into a binary. This is not that, this is a script intended to be run as a script that got turned into a binary. Since this is mostly complete I'll turn my attention back to the raw csv file to see if there is any more useful info given. post 999 Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - SDW - 01-20-2024 Oh no, of course not. Didn't mean to imply it is. I was just saying that is how Chrome (as it turns out, not Github) saw that file yesterday and would not download it. Presumably because of the .exe extension alone? Can't say for certain. Here's my Chrome download history from yesterday. Three of my download attempts failed. "Virus detected". :confused: But as said, eventually it let me do it w/o a fuss. It was a different version of the file; Chrome didn't like 2.512 but it did accept 2.513 for some reason. Go figure. [ATTACH=CONFIG]20222[/ATTACH] BTW, thanks again for doing all this. Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - Zeneffect - 01-20-2024 I'll be making another update soon-ish. No new features, just some cleanup actions could be better in temp_fit and duplicate file detection. Oh and it's moving to a Gui based prompt rather than command/text window... and I'm adding an icon SDW Wrote:Oh no, of course not. Didn't mean to imply it is. I was just saying that is how Chrome (as it turns out, not Github) saw that file yesterday and would not download it. Presumably because of the .exe extension alone? Can't say for certain. You need the whole folder as there are working, backup, and results directories hard coded. Just download the zip package and extract, not individual files unless you care to get the Garmin sdk separately, place the exe in the appropriate folder (1 up from "java" in the sdk) then recreate the results, temp, and backup directories in the same location as the exe, inside the Garmin sdk... Maybe it's time to consider an installer/self extracting executable. Seems there is potential to reduce user error Also, there is only 1 field I don't quite understand and it only contains a "1" so it seems useless to me. It might be a sort of paused or complete flag. *edit* got defender to not freak out, turns out it likes a virtualized space first to sandbox the process and protect the rest of memory from potential bad behavior. added some safety pre-cleanup items for duplicate files or failed jobs, revised my math formulas and some other small things to make code more efficient Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - SDW - 01-21-2024 Zeneffect Wrote:You need the whole folder as there are working, backup, and results directories hard coded. Just download the zip package and extract, not individual files unless you care to get the Garmin sdk separately, place the exe in the appropriate folder (1 up from "java" in the sdk) then recreate the results, temp, and backup directories in the same location as the exe, inside the Garmin sdk...My reason for doing it that way---downloading just the executable---was that I already had those folders (backup, temp, java, and results) on my HD. It was an experiment to see if the .exe would work with the earlier .jar and batch files. Just curious. Anyway, it seemed to run. Least wise it didn't crash when I launched the .exe. The main headline though was the download failures I was (and still am) seeing do to a "Virus detected" sometimes. Didn't do that with the PowerShell version of course. I'll just wait until the dust settles. I figure you've been busy improving the features and working on a better way to import your tool. Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - Zeneffect - 01-21-2024 i need to do this is a proper coding language lol Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - SDW - 01-21-2024 Well there's always that PowerShell method to fall back on, right?
Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - Zeneffect - 01-21-2024 yep. Until then, im pulling the exe from distribution and just including a .bat file to launch. double click and it works like the exe. it will launch powershell and bypass execution policy temporarily so that wont have to be messed with. should be no virus warnings now because there are no binaries. everything is now a form of script though smart screen filter still complains about "unknown publisher" thats the lesser of the 2. ill brush up on my c# and re-make this sometime into a proper application Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - SDW - 01-21-2024 Thanks! Just in the spirit of providing feedback, I don't know if anyone saw the same things I did when trying to download the .exe, but here is how my Win10 machine evaluated it, the ones that did make it to my HD, in the screenshot below. [ATTACH=CONFIG]20225[/ATTACH] There were a bunch in there like that. It was saying the .exe contained a "Trojan:Win32/Wacatac.B!ml" virus. Microsoft describes it briefly here: https://www.microsoft.com/en-us/wdsi/threats/malware-encyclopedia-description?name=Trojan%3AWin32%2FWacatac.B!ml&threatid=2147735505 I never got to open the .exe in an editor to see what it looks like. I imagine it's exactly like you said, just a bunch of ascii text. Perhaps that trojan's classification/definition includes any executable file of unknown origin, unsigned, etc. Microsoft's description here is pretty vague. Deliberately so, I'll bet. Garmin Xero C1 Pro Chronograph - USB Export to CSV and TXT Utility - Zeneffect - 01-21-2024 I did some digging and its a known false positive when wrapping a powershell script into a exe. The way around it is to sign the exe with a cert that costs $400 a year. I only got it to trigger on my own machine after uploading and downloading it, stayed up until midnight trying to see what the hell, then made a decision to just pull the binary entirely as it's not really needed and goes back to my "everything is exposed" philosophy regarding this utility. Opening the exe in a text editor will look like an exe most likely, unreadable. No thanks. I'll just pull the exe, leave the bat which functionally is identical to the exe, and not pay money to avoid false detection. It's a script anyways and that's how it should live until ported to something appropriate. If anyone wants to make their own, the Garmin fit sdk has the .jar and .BAT files, the timestamp from device is 20 years and 4 days slow, weight in grains is represented in a whole number in raw csv so idivide by 10, min, max, avg are recorded in the raw csv, speed is MM per second, the rest is calculated and not recorded. Anything else the developer can figure out easily or just port from script. |