You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The original assumption that everything would be talked to via serial is clearly wrong. Here's a patch from Mike that adds rotcld support:
--- autotracker/controller.orig.py 2012-09-07 21:55:05.388298558 +0100+++ autotracker/controller.py 2012-09-07 22:48:10.438299558 +0100@@ -1,10 +1,13 @@
# Copyright 2012 (C) Daniel Richman; GNU GPL 3
+# Additions by Mike Hollowell, tiouk.com. rotcld (hamlib) addition. ver 1.02
import time
import earthmaths
import couchdbkit
import logging
import serial
+import socket+import sys
logger = logging.getLogger("habitat_extensions.autotracker")
@@ -33,7 +36,23 @@ class AutoTracker(object):
ser = cfg["serial"]
self.serial_format = ser["format"]
- self.open_serial(ser)++ if self.serial_format == "simple":+ self.open_serial(ser)+ elif self.serial_format == "rotcld":+ rotator = cfg["rotcld"]+ self.rotcld_host = rotator["host"]+ self.rotcld_port = rotator["port"]+ self.rotcld_model = rotator["model"]+ self.rotcld_desc = rotator["desc"]+ if self.rotcld_model == 202:+ logger.debug("Rotctld: Model 202")+ else:+ logger.debug("Rotctld: rotator model not supported")+ sys.exit(1)+ else:+ logger.debug("No supported output device")+ sys.exit(1)
def open_serial(self, settings):
self.serial = serial.Serial(settings["file"], settings["baud"])
@@ -88,15 +107,48 @@ class AutoTracker(object):
def aim_at(self, tgt):
logger.info("Aiming at " + repr(tgt))
- f = self.serial_format- if f == "simple":+ if self.serial_format == "simple":
l = "{0} {1}\n".format(int(tgt[0]), int(tgt[1]))
+ self.serial.write(l)+ elif self.serial_format == "rotcld":+ for res in socket.getaddrinfo(self.rotcld_host, self.rotcld_port, socket.AF_UNSPEC, socket.SOCK_STREAM):+ af, socktype, proto, canonname, sa = res+ try:+ rotcld = socket.socket(af, socktype, proto)+ except socket.error, msg:+ rotcld = None+ continue+ try:+ rotcld.connect(sa)+ except socket.error, msg:+ rotcld.close()+ rotcld = None+ continue+ break+ if rotcld is None:+ logger.debug("could not open socket")+ sys.exit(1)+ if self.rotcld_model == 202:+ l = "{0} {1}\n".format(int(tgt[0]), int(tgt[1]))+ else:+ logger.debug("Rotctld: rotator model not supported")+ sys.exit(1)++ rotcld.sendall(l)+ data = rotcld.recv(1024)+ rotcld.close()+ #logger.debug("Received: " + repr(data))+ #logger.debug(data.find("RPRT 0"))+ if data.find("RPRT 0") == 0:+ logger.debug("OK")+ else:+ logger.debug("ERR: " + data)+
else:
raise NotImplementedError("Unimplemented format " + f)
- logger.debug("Serial write: " + repr(l))- self.serial.write(l)+ logger.debug("Sending: " + repr(l))
def run(self):
while True:
--- habitat.orig.yml 2012-09-07 22:01:09.978298672 +0100+++ habitat.yml 2012-09-07 22:41:37.178299434 +0100@@ -5,9 +5,9 @@ log_file_level: NONE
autotracker:
period: 60
location:
- longitude: -0.7890- latitude: 51.1234- altitude: 80+ longitude: -2.1920+ latitude: 52.9971+ altitude: -1000
limits:
bearing:
min: 0
@@ -17,8 +17,14 @@ autotracker:
max: 60
track_payload_id: 8285c24fabf8a73df8f7ec10c00c703e
serial:
- file: /dev/ttyUSB0- format: simple+ file: /dev/ttyUSB1+ format: rotcld
baud: 4800
+ rotcld:+ host: 127.0.0.1+ port: 4533+ model: 202+ desc: EasycommII
max_age: 300
Though I think at this point it would be far better to break it out into several classes which handle a different type of rotator. So this is the TODO item.
N.B.: Need to contact Mike for more recent changes when doing this.
The text was updated successfully, but these errors were encountered:
The original assumption that everything would be talked to via serial is clearly wrong. Here's a patch from Mike that adds rotcld support:
Though I think at this point it would be far better to break it out into several classes which handle a different type of rotator. So this is the TODO item.
N.B.: Need to contact Mike for more recent changes when doing this.
The text was updated successfully, but these errors were encountered: