Skip to content

Commit f46ccc9

Browse files
committed
smarter exception handling, also some code cleanup
1 parent aed1296 commit f46ccc9

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,14 @@ rules:
104104
destinations:
105105
- name: default
106106
path: "/SuperMetroid/Rando"
107-
```
107+
```
108+
109+
## Troubleshooting
110+
111+
Problem: RomLoader hangs without any input
112+
Solutions:
113+
1. try restaring usb2snes.exe
114+
2. power off and back on your sd2snes
115+
3. load a non-special chip/MSU1 ROM through the sd2snes menu
116+
117+
Basically RomLoader is having trouble interacting with the usb2snes.

src/py2snes/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def Boot(self, romname):
9292
else:
9393
raise usb2snesException("Boot: not attached to usb2snes. Try executing Attach first.")
9494

95-
def Menu(self, romname):
95+
def Menu(self):
9696
if self.attached:
9797
cmd = {
9898
'Opcode': 'Menu',

src/romloader.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
import yaml
77

88
from py2snes import usb2snes
9+
from py2snes import usb2snesException
10+
11+
12+
def show_exception_and_exit(exc_type, exc_value, tb):
13+
import traceback
14+
traceback.print_exception(exc_type, exc_value, tb)
15+
input("Press key to exit.")
16+
sys.exit(-1)
17+
18+
sys.excepthook = show_exception_and_exit
19+
920

1021
# load the configuration file (if it exists, otherwise use default config)
1122
scriptpath = os.path.dirname(sys.argv[0])
@@ -72,10 +83,7 @@ def main():
7283
else:
7384
path = config['default_destination']
7485
romname = filename
75-
print("making {path} directory if it doesn't exist".format(
76-
path=path
77-
))
78-
conn.MakeDir('/romloader')
86+
conn.MakeDir('/romloader')
7987
conn.List(path)
8088
print("copying rom to {fullpath}".format(
8189
fullpath=path + '/' + romname
@@ -87,7 +95,7 @@ def main():
8795
conn.Boot(path + '/' + romname)
8896
conn.close()
8997

90-
sleep(15)
98+
sleep(5)
9199

92100

93101
def matchrule(name):

src/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import py2snes
2+
3+
conn = py2snes.usb2snes()
4+
conn.Attach()
5+
print(conn.Info())

0 commit comments

Comments
 (0)