Tjoppen Posted April 10, 2011 Share Posted April 10, 2011 I've been considering investing in a Harmony to be able to test my creations on a real VCS. It seems the Harmony can be in-system programmed judging by [1] and the programming tool. My question is: is there's a command line interface for downloading ROMs to the device? I use Visual Studio as my programming environment, so having this ability would enable me to have a target that when run will assemble, download and reset the system. That way I can develop with my laptop on the couch in front of the TV, which would be the killer app for me so to speak. I searched around the forums and couldn't come up with an answer, hence this post. [1] http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#harmony (I'm not using bB though) Quote Link to comment Share on other sites More sharing options...
+batari Posted April 11, 2011 Share Posted April 11, 2011 Yes. You may use lpc21isp to upload binaries after combining them with the appropriate bankswitch file (the .arm files included with the programming software.) lpc21isp is freely available but you need to subscribe to a Yahoo! group to download it (or alternatively, I posted a Win32 build of it in this forum in the "Harmony as CopyCart" thread.) To combine a file, use copy to create a combined file to upload: copy /b 2k4k.arm+game.bin combined.bin The proper command line for lpc21isp is something like this: lpc21isp -bin -control -controlswap combined.bin com# 38400 10000 If you are using a com port greater than 9, you need to use \\.\com# instead. This method will work for most bankswitching types but not all. For those, I also have a CLI program that automatically detects bankswitch type and creates the combined binary. I don't believe I've ever posted it but I can upon request. Quote Link to comment Share on other sites More sharing options...
alex_79 Posted April 11, 2011 Share Posted April 11, 2011 I don't know if this is documented, but the harmony cart software can be used from the command line to download a single rom to the harmony. The command harmonycart game.bin will download the rom called "game.bin" into the harmony in single-load mode. I use the linux version, but I think this is true for windows and mac as well. 1 Quote Link to comment Share on other sites More sharing options...
Tjoppen Posted April 11, 2011 Author Share Posted April 11, 2011 @batari: Thanks, that looks like it could work. Hopefully the lpc2isp binary you uploaded will suffice - I'd rather not deal with Yahoo. For future reference, lpc2isp seems to be accessible in source form via http://www.cmucam.org/browser/trunk/tools/lpc21isp, which I'm sure one could work out an SVN URI from. @alex_79: That sounds exactly like what I want, and might be the CLI batari mentioned. I checked the source code out and it seems to indicate that the programming tool should indeed work that way. Since I don't have the hardware yet, I can't test this properly. However, "HarmonyCart.exe -help" should display usage information according to main.cxx:105. It doesn't, which has me a little worried. Similarly, running "HarmonyCart.exe foo.bin" results in zero console output: C:\Program Files (x86)\HarmonyCart>HarmonyCart.exe -help C:\Program Files (x86)\HarmonyCart>HarmonyCart.exe whatever C:\Program Files (x86)\HarmonyCart> If Windows requires a separate CLI tool it'd be great if it were bundled with the HarmonyCart installer. Thanks for the help so far. Assuming there's no problem shipping to Sweden I'll probably place an order in the near future Quote Link to comment Share on other sites More sharing options...
+batari Posted April 11, 2011 Share Posted April 11, 2011 I don't know if this is documented, but the harmony cart software can be used from the command line to download a single rom to the harmony. The command harmonycart game.bin will download the rom called "game.bin" into the harmony in single-load mode. I use the linux version, but I think this is true for windows and mac as well. Yes, I remember this feature now that you mention it This is probably the preferred method since it will do everything for you. I admit I haven't played around with this very much. That link to lpc21isp is an old version which may have issues. It's best to use the actual Harmonycart software or the latest lpc21isp I posted to this forum. Quote Link to comment Share on other sites More sharing options...
Tjoppen Posted April 12, 2011 Author Share Posted April 12, 2011 (edited) I don't know if this is documented, but the harmony cart software can be used from the command line to download a single rom to the harmony. The command harmonycart game.bin will download the rom called "game.bin" into the harmony in single-load mode. I use the linux version, but I think this is true for windows and mac as well. Yes, I remember this feature now that you mention it This is probably the preferred method since it will do everything for you. I admit I haven't played around with this very much. There's still the question of why it doesn't seem to do anything with extra arguments on Windows. I tested it in cmd on both Vista and 7. Suspecting that it might have accidentally been compiled with older source code or something I ran strings on HarmonyCart.exe to see if it contained the usage text or not. It did, which has me confused. Maybe main() gets called from WinMain() without passing along the arguments or something? Here's part of the strings btw: Harmony Cart not detected Downloading BIOS file... Couldn't find BIOS file ' Couldn't open Harmony Cart Downloading single-load ROM file... Couldn't find ROM file ' -help Harmony Programming Tool version Usage: harmonycart [options ...] datafile Run without any options or datafile to use the graphical frontend Consult the manual for more in-depth information Valid options are: -bios Treat the specified datafile as an EEPROM loader BIOS image Otherwise, the datafile is treated as a ROM image instead -bs=[type] Specify the bankswitching scheme for a ROM image (default is 'auto ') -help Displays the message you're now reading This software is Copyright (c) 2009 Stephen Anthony, and is released under the GNU GPL version 3. edit: It seems one might need to call QApplication::arguments() to get the arguments on Windows. See http://stackoverflow.com/questions/2918353/obtaining-command-line-arguments-in-a-qt-application I also found this: http://web.mit.edu/qt-dynamic/www/qcoreapplication.html#arguments [...] On Windows, the arguments() are not built from the contents of argv/argc, as the content does not support Unicode. Instead, the arguments() are constructed from the return value of GetCommandLine(). Edited April 12, 2011 by Tjoppen Quote Link to comment Share on other sites More sharing options...
+batari Posted April 12, 2011 Share Posted April 12, 2011 I tried the CLI in Windows and I can't get it to do anything either, not even the -help. If you're set up to do so, the source is included so you might be able to fix it. Otherwise, we may release another version sometime, or there's always lpc21isp which is known to work. Quote Link to comment Share on other sites More sharing options...
Tjoppen Posted April 13, 2011 Author Share Posted April 13, 2011 (edited) Here's a patch that makes the program use QApplication::arguments(). Feel free to incorporate it into the next version. So far I've only tested it in Ubuntu since I don't have Qt set up on any Windows machine atm. I might try it later though. edit: hrm, the forums won't let my upload .patch files. I pasted it below instead: From eed32d0c6cd862f79f444528cf116fc7255fd6ba Mon Sep 17 00:00:00 2001 From: Tjoppen <tjoppen@gamedev.se> Date: Wed, 13 Apr 2011 09:52:18 +0200 Subject: [PATCH] Use QApplication::arguments() instead of argc/argv since the latter doesn't work on Windows --- main.cxx | 30 +++++++++++++++++------------- 1 files changed, 17 insertions(+), 13 deletions(-) diff --git a/main.cxx b/main.cxx index 3312227..9e027b0 100644 --- a/main.cxx +++ b/main.cxx @@ -27,22 +27,22 @@ #include "HarmonyCartWindow.hxx" #include "Version.hxx" -void runCommandlineApp(HarmonyCartWindow& win, int ac, char* av[]) +void runCommandlineApp(HarmonyCartWindow& win, const QStringList& args) { string datafile = ""; BSType bstype = BS_AUTO; bool biosupdate = false; // Parse commandline args - for(int i = 1; i < ac; ++i) + for(int i = 1; i < args.size(); ++i) { - if(strstr(av[i], "-bs=") == av[i]) - bstype = Bankswitch::nameToType(av[i]+4); - else if(strcmp(av[i], "-bios") == 0) + if(args.at(i).indexOf("-bs=") == 0) + bstype = Bankswitch::nameToType(args.at(i).mid(4).toStdString()); + else if(args.at(i) == "-bios") biosupdate = true; // else if(...) // add more options here else - datafile = av[i]; + datafile = args.at(i).toStdString(); } Cart cart; @@ -102,7 +102,15 @@ void runCommandlineApp(HarmonyCartWindow& win, int ac, char* av[]) int main(int ac, char* av[]) { - if(ac == 2 && !strcmp(av[1], "-help")) + // The application and window needs to be created even if we're using + // commandline mode, since the settings are controlled by a QSettings + // object which needs a Qt context. + QApplication app(ac, av); + + // Get the arguments via Qt since av contains empty strings on Windows + QStringList args = QApplication::arguments(); + + if(args.size() == 2 && args.at(1) == "-help") { cout << "Harmony Programming Tool version " << HARMONY_VERSION << endl << endl @@ -123,13 +131,9 @@ int main(int ac, char* av[]) return 0; } - // The application and window needs to be created even if we're using - // commandline mode, since the settings are controlled by a QSettings - // object which needs a Qt context. - QApplication app(ac, av); HarmonyCartWindow win; - if(ac == 1) // Launch GUI + if(args.size() == 1) // Launch GUI { // Only start a 'connect' thread if we're in UI mode win.connectHarmonyCart(); @@ -138,7 +142,7 @@ int main(int ac, char* av[]) } else // Assume we're working from the commandline { - runCommandlineApp(win, ac, av); + runCommandlineApp(win, args); } return 0; -- 1.7.1 Edited April 13, 2011 by Tjoppen Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted April 13, 2011 Share Posted April 13, 2011 Posting like that often messes something up. Would be better to post a ZIP of the patch file. Quote Link to comment Share on other sites More sharing options...
Tjoppen Posted April 15, 2011 Author Share Posted April 15, 2011 I tested the patch on Windows (yay for Qt being 1.5 GB) and I was wronng about the problem. HarmonyCart.exe works just fine - it just doesn't produce any console output because it doesn't use the console subsystem. To get the console output, redirect the program's output to a file (or pipe to cat in MinGW), like: c:\Program Files (x86)\HarmonyCart>HarmonyCart.exe -help > c:\work\test.txt c:\Program Files (x86)\HarmonyCart>type c:\work\test.txt Harmony Programming Tool version 1.1 Usage: harmonycart [options ...] datafile Run without any options or datafile to use the graphical frontend Consult the manual for more in-depth information Valid options are: -bios Treat the specified datafile as an EEPROM loader BIOS image Otherwise, the datafile is treated as a ROM image instead -bs=[type] Specify the bankswitching scheme for a ROM image (default is 'auto ') -help Displays the message you're now reading This software is Copyright (c) 2009 Stephen Anthony, and is released under the GNU GPL version 3. c:\Program Files (x86)\HarmonyCart> However, this is tedious. I managed to figure out that adding "CONFIG += console" to the project file fixed this problem. One problem is that this causes a useless console to pop up when the GUI is launched. The attached file adds a new project called harmonycart-cli just for Windows. I also modified main.cxx slightly to be more console friendly (show help rather then the GUI when run without options). Ah, and having a .txt file extension makes the file attachable - yay! 0001-Add-harmonycart-cli-project-for-Windows-to-work-arou.patch.txt Quote Link to comment Share on other sites More sharing options...
dwane413 Posted April 15, 2011 Share Posted April 15, 2011 I tested the patch on Windows (yay for Qt being 1.5 GB) and I was wronng about the problem. HarmonyCart.exe works just fine - it just doesn't produce any console output because it doesn't use the console subsystem. To get the console output, redirect the program's output to a file (or pipe to cat in MinGW), like: c:\Program Files (x86)\HarmonyCart>HarmonyCart.exe -help > c:\work\test.txt c:\Program Files (x86)\HarmonyCart>type c:\work\test.txt I didn't test it, but I think the above two lines could be replaced with the following: c:\Program Files (x86)\HarmonyCart>HarmonyCart.exe -help > con Quote Link to comment Share on other sites More sharing options...
+stephena Posted April 16, 2011 Share Posted April 16, 2011 As was mentioned above, the exact problem is that Windows doesn't support redirection of stdout/stderr output to a console window. And while you're correct that adding the 'console' command to the Makefile will have it create a console, it will do so on every run, which is annoying. And it seems to be all or nothing; you always get a console, or you don't get one at all. The much better approach is how Linux and OSX work. If a program starts in a console, its output is sent there. If it starts from an icon, the output goes nowhere, but at least it doesn't open up a console window. If anyone can suggest how to duplicate this behaviour in Windows, I'd really appreciate it. This is also an issue for Stella in Windows, for exactly the same reasons. Quote Link to comment Share on other sites More sharing options...
+batari Posted April 16, 2011 Share Posted April 16, 2011 The redirect to "con" sounds like a good workaround for now. I've noticed that Stella creates a couple of text files as a workaround. This makes me wonder, though, if you couldn't just open the file "con" in the Harmony programming tool and write to it when the command line is detected. Would that open a command window only when wanted? Quote Link to comment Share on other sites More sharing options...
+stephena Posted April 16, 2011 Share Posted April 16, 2011 The redirect to "con" sounds like a good workaround for now. I've noticed that Stella creates a couple of text files as a workaround. This makes me wonder, though, if you couldn't just open the file "con" in the Harmony programming tool and write to it when the command line is detected. Would that open a command window only when wanted? I'd have to research it, but my first guess is that it wouldn't work. Adding the 'console' directive to the Makefile is basically instructing Windows to build the app as a console one vs. a GUI. That is, different libraries are linked to the project, and it's using a different WinMain at startup. That's why you always get the console when that option is enabled; you're basically saying this will be a console application. Having this work like Linux and OSX would be nice, but I suspect it involves delving into the guts of the Windows console handler (that's if it's even possible at all). You're right about stdout.txt and stderr.txt from Stella. They're generated by SDL (the graphics library that Stella uses), to get around this exact problem. But IMO doing that still isn't as nice as having real-time console output. In any event, I will try to find some time to research it further. Quote Link to comment Share on other sites More sharing options...
Tjoppen Posted April 17, 2011 Author Share Posted April 17, 2011 The con workaround doesn't seem to work for me. I found an alternative solution in the following thread on stackoverflow: http://stackoverflow.com/questions/54536/win32-gui-app-that-writes-usage-text-to-stdout-when-invoked-as-app-exe-help Implementing Hugh Allen's suggestion seems to work quite well. The only downside I can see is that there is a temporary console visible for a split second when starting the GUI app from a shortcut. A slightly better solution would be to use the .com/.exe trick, but I don't know how to set up the Qt project for that. There's a project called dualsubsystem on Google Code for this, which may be easier to work into Stella at least: http://code.google.com/p/dualsubsystem/ Anyway, proof-of-concept patch attached. 0001-Switch-to-the-console-subsystem-on-Windows-and-ditch.patch.txt Quote Link to comment Share on other sites More sharing options...
+stephena Posted April 17, 2011 Share Posted April 17, 2011 The con workaround doesn't seem to work for me. I found an alternative solution in the following thread on stackoverflow: http://stackoverflow.com/questions/54536/win32-gui-app-that-writes-usage-text-to-stdout-when-invoked-as-app-exe-help Implementing Hugh Allen's suggestion seems to work quite well. The only downside I can see is that there is a temporary console visible for a split second when starting the GUI app from a shortcut. A slightly better solution would be to use the .com/.exe trick, but I don't know how to set up the Qt project for that. There's a project called dualsubsystem on Google Code for this, which may be easier to work into Stella at least: http://code.google.com/p/dualsubsystem/ Anyway, proof-of-concept patch attached. I will research the links you provided, to see if this can be implemented cleanly (ie, so you don't see the console even temporarily). Barring that, I will add your patch to the codebase. However, I need your permission to include this under the GPLv3 license. Do you agree to this? Quote Link to comment Share on other sites More sharing options...
Tjoppen Posted April 17, 2011 Author Share Posted April 17, 2011 I will research the links you provided, to see if this can be implemented cleanly (ie, so you don't see the console even temporarily). Barring that, I will add your patch to the codebase. However, I need your permission to include this under the GPLv3 license. Do you agree to this? Yes, I agree. Anyway, since this seems to fix the only issue I have with the program I'll probably place an order today or tomorrow. Quote Link to comment Share on other sites More sharing options...
+stephena Posted December 9, 2012 Share Posted December 9, 2012 Sorry for resurrecting the dead, but never let it be said that I don't follow up on a bug! I completely forgot about this issue, but in preparing a new release for this week, I went through my old emails. I've tried dualsubsystem, and while it works perfectly well in Windows XP, it doesn't in Windows 7. For some reason, in Win7 not all the text is being output; it always stops before the last few lines are complete (no matter how many lines there are). I've sent off a message to the maintainer, but since the last (and only) release was from 2009, I don't know if it's even being maintained. I'd rather get this working, though, since when it works, it works wonderfully. Just like in Linux, and exactly how it should be EDIT: The same problem is happening in Stella, so if it can be fixed, it's definitely a candidate to add there too. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.