This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tcs:legacy_tcs_socket_communction [2014/02/12 12:40] 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:// | + | ===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:// | ||
+ | |||
+ | === === | ||
+ | You can find a list of legacy TCS commands [[tcs: | ||
===== Request syntax ===== | ===== Request syntax ===== | ||
==== ==== | ==== ==== | ||
Line 39: | Line 43: | ||
==== " | ==== " | ||
- | 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 structure of the string is given in the table below. | + | 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 |
^Return Values | MOT | RA | DEC | HA | ST | EL | AZ | SECZ | EQ | JD | WOBBLE | DOME | UT | IIS | | ^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 | | ^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 | ||
It should be noted that all strings returned on the Telcom socket will end with a carriage return (\r). | It should be noted that all strings returned on the Telcom socket will end with a carriage return (\r). | ||
Line 67: | Line 74: | ||
^BOK TCS 123 OK^ | ^BOK TCS 123 OK^ | ||
- | The < | + | The < |
^BOK TCS 123 TRACKON^ (command for turning tracking on) | ^BOK TCS 123 TRACKON^ (command for turning tracking on) | ||
Line 77: | Line 84: | ||
But the telescope will not start tracking because it can't when the drives are off. | But the telescope will not start tracking because it can't when the drives are off. | ||
- | ***For brevity sake the complete list of TCS command | + | ***For brevity sake the complete list of TCS commands |
===== Example Scripts ===== | ===== Example Scripts ===== | ||
- | Below are some sample scripts to communicate with telcom | + | 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. | ||
< | < | ||
# | # | ||
- | """ | + | |
+ | """ | ||
+ | Author: Scott Swindell, Steward Observatory | ||
+ | |||
+ | A short example | ||
+ | the Telcom server and store that information in a python | ||
+ | dictionary object""" | ||
+ | |||
+ | IPADDR = "" | ||
+ | PORT = "" | ||
+ | |||
+ | TELID = " | ||
+ | REF_NUM = 123 | ||
+ | REQUEST = " | ||
+ | |||
+ | keyList = [ | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | "UT" | ||
+ | | ||
+ | |||
+ | |||
+ | ] | ||
import socket | import socket | ||
+ | |||
+ | # | ||
+ | telSock = socket.socket( socket.AF_INET, | ||
+ | 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 | ||
+ | # | ||
+ | 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 != '' | ||
+ | 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 | ||
+ | |||
+ | #print them all out in | ||
+ | #a nice clean way | ||
+ | for (key, value) in telemDict.iteritems(): | ||
+ | print " | ||
+ | |||
</ | </ |