Re: [Gpsbabel-misc] Setting temp path without Windows environmental variable
Brought to you by:
robertl
From: philshem <phi...@zo...> - 2017-09-11 18:53:32
|
Hi All Thanks for your reply Robert, and the nice welcome to the list. I’m also not a Windows dev, and actually use my own Python wrapper scripts to scan COM ports and generate and run the GPSBabel command line executable. To run GPSBabel as multiple processes, I need to hijack the environmental variable TMP for each process. It works from two cmd.exe sessions, but not yet with Python. I found this question on StackOverflow useful, and used it to open a new question. None of this really solves the issue of GPSBabel code writing data.bin files for MTK loggers. I've looked into the GPSBabel source code and see where GPSBabel creates the temp path and file name - function GetTempName() at line 300 of mtk_logger.cc. Would the fix be as easy as this? current: static const char* GetTempName(bool backup) { const char kData[]= "data.bin"; const char kDataBackup[]= "data_old.bin"; QString t = QDir::tempPath(); t += QDir::separator(); t += backup ? kDataBackup : kData; return t.toLatin1(); } suggested: static const char* GetTempName(bool backup) { QTemporaryFile kFile; // create a unique temp file QString t = QDir::tempPath(); t += QDir::separator(); t += kFile; return t.toLatin1(); } Or is the hardcoded data.bin needed somewhere else? Regards Philip p.s. also not a C++ developer :) On 7 Sep 2017, at 23:56, Robert Lipe <rob...@gp...> wrote: Hi, Phillip and welcome. You're right. The code gets the temporary directory from the OS, but then doesn't use QTemporaryFile to ensure that the file within it is unique. I can't dive into the code right now, but it's just so hokey that that format alone (I think) writes a file while you're reading. If you're automating this, I'd think that scripting this in a batch file would look something like mkdir temp/1 temp/2 temp/3 set TMP=C:\temp\1\ && gpsbabel.exe -w -t -i mtk -f COM6 -o gpx1 -F test.gpx set TMP=C:\temp\2\ && gpsbabel.exe -w -t -i mtk -f COM7 -o gpx2 -F test.gpx set TMP=C:\temp\3\ && gpsbabel.exe -w -t -i mtk -f COM8 -o gpx3 -F test.gpx ...but that does them one at a time and I'm guessing the real goal is to do them at the same time. Again, making this up because I'm not a windows dev, bug I can read stack overflow... start cmd /c call set TMP=C:\temp\1\ && gpsbabel.exe -w -t -i mtk -f COM6 -o gpx1 -F test.gpx start cmd /c set TMP=C:\temp\2\ && gpsbabel.exe -w -t -i mtk -f COM7 -o gpx2 -F test.gpx start cmd /c set TMP=C:\temp\3\ && gpsbabel.exe -w -t -i mtk -f COM8 -o gpx3 -F test.gpx but there may be some quoting rules that I'm breaking. Start with something like https://stackoverflow.com/questions/649634/how-do-i-run-a-bat-file-in-the-background-from-another-bat-file Really, this code just needs to be fixed to Not Do This. Any takers? RJL On Thu, Sep 7, 2017 at 2:49 PM, Philip Shemella <phi...@zo...> wrote: Hi All When I run the code to extract from MTK and convert to GPX, the code reads my Windows environmental variable TMP and write a temp file "data.bin" in that folder (at least this is what I've learned from a bit of reverse engineering). I can set a temporary new path for TMP before running gpsbabel.exe from the command line: set TMP=C:\temp\ && gpsbabel.exe -w -t -i mtk -f COM6 -o gpx -F test.gpx Is there a built-in way to define the temp folder, without using Windows environmental variables? Perhaps with gpsbabel.ini? The reason for this question is that I'd like to reliably extract data from devices in parallel, and I'm expecting that setting the windows environmental variable TMP on several concurrent threads will have conflicts. Many thanks Philip ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Gpsbabel-misc mailing list http://www.gpsbabel.org Gps...@li... To unsubscribe, change list options, or see archives, visit: https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc |