pypogs icon indicating copy to clipboard operation
pypogs copied to clipboard

Mount error if identity is 0

Open donce71 opened this issue 3 years ago • 4 comments

hardware_mount.py 256 serial_port_name = self._serial_find_port(identity) if identity.isnumeric() else identity

if identity is 0, then isnumeric() gives an error.

solution": 149 self.identity = identity change ->>> self.identity = (str)identity

donce71 avatar May 25 '22 15:05 donce71

Hello! Thanks for the suggestion.

I typically specify a com port explicitly (e.g. "COM2", like the provided example) rather than a numeric index, and I am not sure I understand the design intent for the serial_find_port function. I assumed that a numeric value specified as identity maps to corresponding com port number, i.e. identity "2" maps to "COM2". If that was the case then identity 0 should be disallowed in Windows since COM0 does not exist. However, looking closer now, it looks like pypogs builds its own list of com ports, and a numeric index specified as identity maps to local list indices, rather than com port indices, in which case value 0 should resolve to the first detected com port regardless of the com port index. @gustavmpettersson, can you please confirm that is your intention? I certainly see value in that approach since index 0 should usually correspond to the intended mount when the mount is the only serial device present.

If a numeric identity is intended to map to com port index then we should prohibit value 0. If it's intended to map to list index then we may need to figure out a better way to handle zero index, possibly using @donce71's suggestion.

However, I'm not sure why @donce71 gets an error with identity 0. That works fine on my system:

C:\>py -3
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
>>> str('0').isnumeric()
True

@donce71 can you please show the error you're getting? Thanks

rkinnett avatar May 25 '22 20:05 rkinnett

Hi, well it is obvious, if you provide string it works. But if you provide number 0 (self._serial_find_port(identity)) it will give an error.

donce71 avatar Jun 03 '22 13:06 donce71

“well it is obvious”

That is not helpful. As I said, I was (initially) unable to reproduce the error on my system.

I deduced that you’re using the hw_ascom branch. That kind of info is helpful to provide up front. I also deduced that you’re trying to initialize a mount by script or python prompt, rather than the GUI, which is fine, but again that would have been helpful to mention up front. I was previously unable to reproduce the error when I specified index 0 through the GUI (which casts as str), but now I get the same error when I specify identity=0 (without quoting 0) in a pypogs start script.

~~An easier way to fix this is to cast the identity argument to a string in the identity setter method.~~ Edit: recommendation: replace "identity.isnumeric()" with "isinstance(identity, str)"

Thanks again for noting this issue.

rkinnett avatar Jun 03 '22 19:06 rkinnett

Hi Ryan, I'm happy that there are more people who are interest in Gustav's project and do contribute. I see that you put a lot of effort to make this project even better. On the other hand your attitude is not encouraging for collaboration. You must understand that not everyone is so capable in programing and used to GitHub platform as yourself. I'm willing to add my contribution to this project and learn standart issues reporting and fixing ways, but please keep conversation less toxic, more professional.

donce71 avatar Jun 03 '22 20:06 donce71