whaleygeek / anyio

A GPIO Package that works on any platform
Other
18 stars 19 forks source link

Findport raises exception on new win7 laptop if no com port ever seen #11

Closed whaleygeek closed 10 years ago

whaleygeek commented 10 years ago

From: @martinohanlon I have found an error with findport.

Its probably a very odd set of conditions.

I have a windows 8 laptop, but I got fed up of using windows 8 so I put 7 on it. In the main all the hardware worked and I could find drivers, but I couldn't get the bluetooth stuff to work (not a big worry as I dont use it).

So as a result my laptop as no COM ports and as a result doesnt have a registry entry in "HARDWARE\DEVICEMAP\SERIALCOMM"

Without a registry entry Im pretty sure this is causing an error in ports_win32.py (see below):

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information.

================================ RESTART ================================

SERIAL PORT SCANNER PROGRAM

could not open cache file No name remembered Scanning for serial ports remove device, then press ENTER scanning...

Traceback (most recent call last): File "C:\Users\Mart\Desktop\AdventuresInMinecraft\MyAdventures\findPort.py", line 12, in portscan.main() File "C:\Users\Mart\Desktop\AdventuresInMinecraft\MyAdventures\anyio\arduino\portscan.py", line 192, in main d = find() File "C:\Users\Mart\Desktop\AdventuresInMinecraft\MyAdventures\anyio\arduino\portscan.py", line 155, in find dev = scan() File "C:\Users\Mart\Desktop\AdventuresInMinecraft\MyAdventures\anyio\arduino\portscan.py", line 93, in scan before = ports.scan() File "C:\Users\Mart\Desktop\AdventuresInMinecraft\MyAdventures\anyio\arduino\ports_win32.py", line 14, in scan key = registry.OpenKey(reg, KEY) WindowsError: [Error 2] The system cannot find the file specified

But presumably if there is some windows hardware out there which doesnt have any com ports this could be a problem?

whaleygeek commented 10 years ago

The temporary fix is to plug the device in until it appears in the device manager view, this will create the registry node. Then run findport and follow the instructions.

whaleygeek commented 10 years ago

Ok thanks I'll put an exception trap around that. It's because ally laptops have in past had a com port at some time so the parent registry node was created at last com port insertion. If the laptop has never seen a com port, the parent node won't have been created. A 2 line fix is needed, I'll do it and push to github, and let you know when its done.

whaleygeek commented 10 years ago

I have now fixed this by catching the exception if the SERIALCOMM registry branch cannot be opened, and returning an empty port list. Tested and it works fine now.