Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Support #2

Open
robbrad opened this issue Nov 19, 2023 · 0 comments
Open

Network Support #2

robbrad opened this issue Nov 19, 2023 · 0 comments

Comments

@robbrad
Copy link

robbrad commented Nov 19, 2023

This is amazing work - I found this by doing my own and though I wonder if someone else has done this before

Where im going is to do this via the network interface instead using the following

Reason is I have the mount in an observatory connected to a network

Could your lib support the same ?

    def _send_command(self, command, expected_length=None):
        try:
            ip = socket.gethostbyname(self.mount_address)
            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
                s.connect((ip, self.port))
                while True:
                    s.sendall(command.encode())
                    response = s.recv(1024).decode().strip()

                    # Check if expected_length is provided and response length matches
                    if expected_length is not None and len(response) != expected_length:
                        continue
                    else:
                        return response  # Return response if length matches or if expected_length is not provided

        except socket.error as e:
            return f"Cannot connect to {self.mount_address}:{self.port}: {e}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant