User Tools

Site Tools


tcs:legacy_tcs_socket_communction

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tcs:legacy_tcs_socket_communction [2014/02/09 14:05]
scott [Request syntax]
tcs:legacy_tcs_socket_communction [2017/02/10 17:14] (current)
scott
Line 1: Line 1:
-=====Overview=====+=====Legacy TCS Network Communication=====
  
-Legacy TCS only allows remote telescope communication and control through a serial port on the main TCS computer. In order to allow network communication and control of the telescope we have built software called Telcom to convert tcp/ip sockets to serial communication. To make sure this software is up and running on the BOK telescope you can check the website http://bokpop.as.arizona.edu and look for the table marked telemetry. This webpage queries the telcom server about once a second. +===Overview===
  
 +Legacy TCS only allows remote telescope communication and control through a serial port on the main TCS computer. In order to allow network communication and control of the telescope we have built software called Telcom to convert tcp/ip sockets to serial communication. To make sure this software is up and running on the BOK telescope you can check the website http://bok.as.arizona.edu:42080 and look for the table marked telemetry. This webpage queries the telcom server about once a second. 
 +
 +=== ===
 +You can find a list of legacy TCS commands [[tcs:list_of_network_commands| here]] .
 ===== Request syntax ===== ===== Request syntax =====
-Legacy TCS makes 14 pieces of information available. The syntax for for getting these values from telcom is+==== ====
  
-<TELESCOPE ID> TCS <REF NUM> REQUEST <KEYWORD> +The Telcom server makes 14 pieces of information available
-For Example: +
-//BOK TCS 123 REQUEST RA// +
- +
-The telcom server will return: +
-<BOK> TCS <REF NUM> <RETURN VALUE> +
-For Example: +
-//BOK TCS 123 214412.79//+
  
 ^ Description ^ Key Word ^ return synax ^ ^ Description ^ Key Word ^ return synax ^
Line 20: Line 17:
 | Declination | DEC | [+/-ddmmss.ss] | | Declination | DEC | [+/-ddmmss.ss] |
 | Hour Angle | HA | [+/-hh:mm:ss.ss] | | Hour Angle | HA | [+/-hh:mm:ss.ss] |
-| Secant z (Air Mass) | SECZ | | +| Secant z (Air Mass) | SECZ | [s.ss] |
-| Error state |ERROR| [E( a number or letter representing serial error state ) |+
 | Epoch | EQ | D[YYYY.YYY] | | Epoch | EQ | D[YYYY.YYY] |
 | Julian Date | JD | [DDDDDDD.D] | | Julian Date | JD | [DDDDDDD.D] |
Line 32: Line 28:
 | WOBBLE | WOBBLE | ??? | | WOBBLE | WOBBLE | ??? |
  
-=== //ALL// keyword === +To retrieve these values simply open a TCP socket to the Telcom server and send a request. The syntax is as follows. 
-If you want to get multiple pieces of data from the telcom server you can use the ALL keyword. This will give a string containing all the telemetry data described above which will have to be parsed.  + 
-string is shown below+^<TELESCOPE ID> TCS <REF NUM> REQUEST <KEYWORD>
 +For Example: 
 +^BOK TCS 123 REQUEST RA^ 
 + 
 +The telcom server will return: 
 +^<TELESCOPE ID> TCS <REF NUM> <RETURN VALUE>
 +For Example: 
 + 
 +^BOK TCS 123 214412.79^ 
 + 
 +As you can see the RA units are not seperated by colons. 
 + 
 +==== "ALLkeyword ==== 
 +If you want to get multiple pieces of data from the telcom server rapidly you can use the ALL keyword. This will return a string containing all the telemetry data described above which will have to be parsed. The string gives values seperated by 1 or more white spaces. The table below shows the order the values are placed in the string.    
 + 
 +^Return Values | MOT | RA | DEC | HA | ST | EL | AZ | SECZ |  EQ | JD | WOBBLE | DOME | UT | IIS |  
 +^Example Value |0 | 221941.92 | +314308.8 | -00:00:00 | 22:20:19 |  90.0 |   +7.6 |  1.00 |  D2000.000 | 2456698.3 | 1 |-78.6 | 20:27:19.1 | 0.0 | 
 + 
 +An example string
 +^ BOK TCS 123 0  2231:27.64 +314312.0  +00:00:01 22:32:22  90.0  -29.2  1.00              2000.000 2456702.3 1        -115.4 20:23:36.5        0.0 ^ 
 + 
 +It should be noted that all strings returned on the Telcom socket will end with a carriage return (\r).  
 + 
 + 
 +===== Command Syntax ===== 
 + 
 +==== ==== 
 +The syntax for sending commands to the Telcom server is very similar to sending requestsThe syntax looks like: 
 + 
 + 
 +^<TELESCOPE ID> TCS <REF NUM> <COMMAND> <ARG_1> ... <ARG_n>
 + 
 +For Example 
 +^BOK TCS 123 BIASRA 12.5^ 
 + 
 +This example sets the Right Ascension bias rate at 12.5 seconds per second.  
 + 
 +Each command will return: 
 + 
 +^ <TELESCOPE ID> TCS <REF NUM> <ERROR_STATE>
 + 
 +For Example 
 +^BOK TCS 123 OK^ 
 + 
 +The <ERROR_STATE> value will be either "OK" or "BAD". "OK" means the command was understood and "BAD" means the command was NOT understood (not found in the list of commands). "OK" does NOT mean the command was executed. For example, if the Right Ascension drive is turned off or disable and you send the command: 
 + 
 +^BOK TCS 123 TRACKON^ (command for turning tracking on) 
 + 
 +Telcom server will return : 
 + 
 +^BOK TCS 123 OK^ 
 + 
 +But the telescope will not start tracking because it can't when the drives are off.  
 + 
 +***For brevity sake the complete list of TCS commands will not be written here. Instead they can be found [[tcs:list of network commands]] 
 + 
 + 
 +===== Example Scripts ===== 
 +Below  are some sample scripts to communicate with Telcom server 
 + 
 +==== telem_example.py ==== 
 +This program gets the telemetry from The Telcom server and stores it in a python dictionary object and prints it 
 +out in a clean format.  
 + 
 +<code> 
 +#!/usr/bin/python 
 + 
 +"""  
 +Author: Scott Swindell, Steward Observatory 
 + 
 +A short example script to grab telemetry from the BOK Telcom server 
 +the Telcom server and store that information in a python 
 +dictionary object""" 
 + 
 +IPADDR = ""     #Available upon request 
 +PORT  = ""      #Available upon request 
 + 
 +TELID = "BOK" 
 +REF_NUM = 123 
 +REQUEST = "ALL" 
 + 
 +keyList = [ 
 +        "ID"            , 
 +        "SYS"           , 
 +        "REF_NUM"       , 
 +        "MOT"           , 
 +        "RA"            , 
 +        "DEC"           , 
 +        "HA"            , 
 +        "ST"            , 
 +        "EL"            , 
 +        "AZ"            , 
 +        "SECZ"          , 
 +        "EQ"            , 
 +        "JD"            , 
 +        "WOBBLE"        , 
 +        "DOME"          , 
 +        "UT"            , 
 +        "IIS" 
 + 
 + 
 +                ] 
 + 
 +import socket 
 + 
 +#instantiate the socket class 
 +telSock = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) 
 +telSock.settimeout( 0.5 ) 
 + 
 +#IPADDR = telSock.gethostbyname(HOST) 
 +telSock.connect( ( IPADDR, PORT ) )#open the socket 
 + 
 +reqString = "%s TCS %i REQUEST %s" %( TELID, REF_NUM, REQUEST ) 
 + 
 + 
 +telSock.send( reqString ) #send the request 
 + 
 +resp = "" 
 +test = True 
 + 
 +#Grab 100 bytes at a time 
 +#from the socket and check for 
 +#timeouts.  
 +while test: 
 +        try: 
 +                inStuff = telSock.recv( 100 ) 
 + 
 +        except socket.timeout: 
 +                if resp: 
 +                        print "No Telem Recieved" 
 +                test = False 
 +                break 
 + 
 +        if inStuff: 
 +                resp+=inStuff 
 + 
 +        else: 
 +                test=False 
 + 
 +#turn string into list, seperate by whitespace 
 +resp = resp.split(' ') 
 + 
 +cleanResp = [] 
 + 
 +#remove all empty elements and new line 
 +#and put everything else in cleanResp 
 +for char in resp: 
 +        if char != '' and not char.endswith("\n"): 
 +                cleanResp.append( char ) 
 + 
 + 
 +#gather the telemetry into a dictionary 
 +#for easy referencing            
 +telemDict = {} 
 +II = 0 
 +for key in keyList: 
 +        telemDict[key] = cleanResp[II] 
 +        II+=1
  
-^Return Values^ MOT | RA | DEC | HA | ST | EL | AZ | SECZ | ERROR | Blank | EQ | JD | WOBBLE | DOME | UT | IIS | Carriage Return |  +#print them all out in  
-^ Positon in String after REF NUM^ 0 4 to 12 14 to 22 25 to 33 | 35 to 42 | 44 to 48 | 50 to 55 | 57 to | 63 to 70 | 72  to 75 | 76 to 83 | 85 to 93 | 94 to 98 | 99 to 100 | +#a nice clean way 
-BOK TCS 123 0  221941.92 +314308.8  -00:00:00 22:20:19  90.0   +7.6  1.00             D2000.000 2456698.3 1         -78.6 20:27:19.1        0.0//+for (key, value) in telemDict.iteritems(): 
 +        print "|%s\t|\t%s|" %( key.ljust( 10 ), value.ljust( 12 ) )
  
  
 +</code>
tcs/legacy_tcs_socket_communction.1391979913.txt.gz · Last modified: 2014/02/09 14:05 by scott