Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help using Pyserial
#11
HEY!!! your code works !!!!

To be safe, I am inserting #:GR# as the command and I get back what is expected.

However on further executions I use the code exactly as you have it.

I am curious, if you do not have a motorized scope, then why do you know so much about the commands??
You must use Python often for other things, yes??
Reply
#12
Got it, thanks. I guess I did not surf to the correct place in the documentation.
Reply
#13
I know nothing about serial commands to a Meade telescope, but I have use serial communication protocols before. The Meade protocol is terrible! It would be difficult coming up with something worse. I have only used Pyserial once before and feel stupid that I forgot about read_until() since the protocol I was working with used linefeed (\r) instead of newline (\n) and I had to use read_until() when reading responses.

If I didn't use Python for other things it would be odd for me to be reading the Python forum, don't you think? I just troll around looking for interesting questions to expand my Python horizons.
Reply
#14
I am a math and science tutor. I tell my students that problems seem hard until they learn how to do them, then they are easy. I think the Meade protocol is one of these things.

Now that Pyserial is sort of mastered, on to cv2-python, Pygame, tkinter, etc.

thanks again for the help and quick response.
Reply
#15
Dean, I discovered a hickup.
When I send a command :Gt# I should receive +30*12# but the * is decoded incorrectly.
I removed the
.decode" from the return response.decode() and get the following b'+30\xdf12#'

If I do not remove the .decode() I get an error and the program exits.

So, the decode does not work on what should be an *.

I can manipulate the received string to get rid of the \xfd but is there an easier way to do so?

Like you said, the Meade protocol is strange. Why do they send a funny *?
Reply
#16
\xdf is decimal 223, part of the extended ASCII character set (codes > 127), but it is not *. ASCII has * as \x2A or decimal 42. I thook this from https://www.ascii-code.com/
Quote:223 DF ß ß ß Latin small letter sharp s - ess-zed
I looked for symbols for 223/df in other encodings and none of them I found use 223 for *. Odd

It would be interesting to see what happens with other commands that return strings containing *; GA, GD, Gd, GE, Ge, Gg, Gh, Gm, Go, GZ.

You can tell the .decode() to ignore errors or try to replace unknown codes with something else.
x = b'+30\xdf12#'
print(x.decode(errors='ignore'))
print(x.decode(errors='replace'))
print(x.decode(errors='backslashreplace'))
Output:
+3012# +30�12# +30\xdf12#
As indicated, 'ignore' ignores characters not in the character set, 'replace' replaces them with a marker, and 'backslashreplace' replaces them with the backslash hex code.

But it would be better to find out why there is this odd character is appearing. Are you sure you have all the serial port settings correct? I would change the decoding error to 'replace' or 'backslashreplace' and try sending a bunch of commands that return *. Are they always translated?
Reply
#17
Of these commands GA, GD, Gd, GE, Ge, Gg, Gh, Gm, Go, GZ My documentation doesn't show a Ge or Gm option.
Maybe I should try to find later documentation. Mine is dated Rev L, 9 October 2002.
I checked and find my docs were old. I have now downloaded an Oct 2010 version.
All commands that look for an * behave the same.

I just updated the software in my Autostar 497 to Apr 26, 2019 and the error is still there.

About the errors, I guess the deault is to replace the code with the backslashhex code. Since I will have to parse the strings anyway, replacing with a marker might be OK. I could also deal with ignoring the error.





This seems like a major error in the Mead code.
Reply
#18
When you type the command in a PUTTY window how does the telescope respond? Is there an *?
Reply
#19
It seems like when I send a * it is accepted. I will continue to test.
Reply
#20
This is in the docs

Quote:There are four special non-terminal characters in the grammar. The <command-prefix> non-terminal (see the BNF or RR Syntax pages) is a hash-mark (or number sign) character (ASCII 0x23 '#') followed by a colon character (ASCII 0x3a ':'). The <command-suffix> non-terminal is a hash-mark (or number sign) character (ASCII 0x23 '#'). An ACK non-terminal (ASCII 0x06) is also used as a Command in the grammar (returning the current Alignment mode). And finally the degree symbol (ASCII 223 '°' [0xdf]) non-terminal is used as the separator character in degrees and minutes. This character is shown as an asterisk (ASCII 0x2a '*') in the manual for both the 16-inch and smaller telescopes and is followed by a note in the manual describing the ASCII value of the character. On the hand controller, however, the value appears as a degree symbol.

and here is where I found the docs

https://www.astro.louisville.edu/softwar...GETcommand

hope this helps you progress.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020