def control(buffer0): logger.debug("setRate called") if samplerstatus.status() == 8000: status = 2 value = None else: try: config.read("StarinetBeagleLogger.conf") config.set('capture', 'rate', buffer0) # update with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() except IOError as e: logger.debug("%s %s", "setRate IOError ", e) status = 4 value = e else: status = 0 value = None logger.debug("%s %s", "setRate returned ", status) status = status + samplerstatus.status() return status, value
def control(buffer0): value = None config.read("StarinetBeagleLogger.conf") logger.debug("%s %s", "controllerControl buffer0 ", buffer0) if samplerstatus.status() == 0: logger.debug("%s %s", "samplerstatus reports sampler not active", str(samplerstatus.status())) status = 0 if buffer0 == 'Reboot': os.system('reboot') return 0, value elif buffer0 == 'Shutdown': os.system('shutdown -h now') return 0, value else: logger.critical("%s %s", "controllerControl INVALID_PARAMETER buffer0", buffer0) return 4, value elif samplerstatus.status() == 8000: logger.debug("%s %s", "samplerstatus reports sampler active", str(samplerstatus.status())) status = 8002 return status, value
def control(buffer0, buffer1, buffer2, buffer3, buffer4, buffer5): logger.debug("setPublisher called") logger.debug("%s %s %s %s %s %s", buffer0, buffer1, buffer2, buffer3, buffer4, buffer5) if publisherstatus.status() == 0: status = 2 # ABORT value = 'capturePublisher_ACTIVE' else: try: config.read("StarinetBeagleLogger.conf") config.set('publisher', 'interval', buffer0) # update config.set('publisher', 'server', buffer1) # update config.set('publisher', 'username', buffer2) # update config.set('publisher', 'password', buffer3) # update config.set('publisher', 'remotefolder', buffer4) # update with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() except IOError as e: logger.debug("%s %s", "setPublisher IOError ", e) status = 4 # PREMATURE_TERMINATION value = e else: status = 0 # SUCCESS value = None logger.debug("%s %s", "setPublisher returned ", status) status = status + samplerstatus.status() return status, value
def control(): logger.debug("getPublisherArtist called") try: config.read("StarinetBeagleLogger.conf") chart = config.get("publisherartist", "chart") channel0 = config.get("publisherartist", "channelArt0") channel1 = config.get("publisherartist", "channelArt1") channel2 = config.get("publisherartist", "channelArt2") temperature = config.get("publisherartist", "TemperatureArt") autoscale = config.get("publisherartist", "autoscale") except ConfigParser.Error as e: status = 4 value = e logger.critical( "%s %s", "Unable to get publisher artist parameters from config", e) else: status = 0 value = chart + ',' + channel0 + ',' + channel1 + ',' + channel2 + ',' + temperature + ',' + autoscale logger.debug("%s %s", "returning value ", value) status = status + samplerstatus.status() return status, value
def control(buffer0, buffer1, buffer2): logger.debug("setPublisherLabels called") logger.debug("%s %s %s", buffer0, buffer1, buffer2) if publisherstatus.status() == 0: status = 2 # ABORT value = 'capturePublisher_ACTIVE' else: try: config.read("StarinetBeagleLogger.conf") config.set('publisherlabels', 'channel0', buffer0) # update config.set('publisherlabels', 'channel1', buffer1) # update config.set('publisherlabels', 'channel2', buffer2) # update with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() except IOError as e: logger.debug("%s %s", "setPublisherLabels IOError ", e) status = 4 # PREMATURE_TERMINATION value = e else: status = 0 # SUCCESS value = None logger.debug("%s %s", "setPublisherLabels returned ", status) status = status + samplerstatus.status() return status, value
def control(buffer0, buffer1, buffer2, buffer3, buffer4, buffer5): logger.debug("setPublisherArtist called") logger.debug("%s %s %s %s %s %s", buffer0, buffer1, buffer2, buffer3, buffer4, buffer5) if publisherstatus.status() == 0: status = 2 # ABORT value = 'capturePublisher_ACTIVE' else: try: config.read("StarinetBeagleLogger.conf") config.set('publisherartist', 'chart', buffer0) # update config.set('publisherartist', 'channelArt0', buffer1) # update config.set('publisherartist', 'channelArt1', buffer2) # update config.set('publisherartist', 'channelArt2', buffer3) # update config.set('publisherartist', 'temperatureArt', buffer4) # update config.set('publisherartist', 'autoscale', buffer5) with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() except IOError as e: logger.debug("%s %s", "setPublisherArtist IOError ", e) status = 4 # PREMATURE_TERMINATION value = e else: status = 0 # SUCCESS value = None logger.debug("%s %s", "setPublisherArtist returned ", status) status = status + samplerstatus.status() return status, value
def control(): logger.debug("getDataPublisher called") try: config.read("StarinetBeagleLogger.conf") interval = config.get("datapublisher", "interval") server = config.get("datapublisher", "server") username = config.get("datapublisher", "username") password = config.get("datapublisher", "password") remotefolder = config.get("datapublisher", "remotefolder") except ConfigParser.Error as e: status = 4 value = e logger.critical("%s %s", "Unable to get dataPublisher parameters from config", e) else: status = 0 value = str( interval ) + ',' + server + ',' + username + ',' + password + ',' + str( remotefolder) logger.debug("%s %s", "returning value ", value) status = status + samplerstatus.status() return status, value
def ping(): value = None logger.debug("ping called") if samplerstatus.status() == 8000: status = 8000 else: status = 0 logger.debug("%s %s", "ping status ", status) return status, value
def control(): logger.debug("getHostname called") try: value = socket.gethostname() except StandardError as e: status = 4 value = e logger.critical("%s %s", "failure to get gethostname() ", e) else: status = 0 logger.debug("%s %s", "getHostname returned ", value) status = status + samplerstatus.status() return status, value
def control(): logger.debug("getMACAddress called") try: value = ':'.join(re.findall('..', '%012x' % uuid.getnode())) except StandardError as e: status = 4 value = e logger.critical("%s %s", "failure to get uuid.getnode() ", e) else: status = 0 logger.debug("%s %s", "getMACAddress returned ", value) status = status + samplerstatus.status() return status, value
def control(): logger.debug("getVersion called") try: config.read("StarinetBeagleLogger.conf") value = config.get("version", "version") except ConfigParser.Error as e: status = 4 value = e logger.critical("%s %s", "Unable to get version from config", e) else: status = 0 logger.debug("%s %s", "getVersion returned ", value) status = status + samplerstatus.status() return status, value
def control(): logger.debug("getClockTime called") try: value = datetime.datetime.now().strftime("%H:%M:%S") except StandardError as e: logger.critical("%s %s", "premature termination", e) value = e status = 4 else: status = 0 logger.debug("%s %s", "getClockTime returned ", value) status = status + samplerstatus.status() return status, value
def control(): logger.debug("getRate called") try: config.read("StarinetBeagleLogger.conf") rate = config.get("capture", "rate") except ConfigParser.Error as e: status = 4 value = e logger.critical("%s %s", "Unable to get capture rate from config", e) else: status = 0 value = rate.zfill(4) logger.debug("%s %s", "returning value ", value) status = status + samplerstatus.status() return status, value
def control(): logger.debug("getDataBlockCount called") value = None try: lastblock = int(max(os.listdir(config.get("paths", "datafolder")), key=lambda p: os.path.getctime(os.path.join( config.get("paths", "datafolder"), p))), 16) + 1 value = hex(lastblock).split('x')[1].upper().zfill(4) except StandardError: status = 800 else: status = 0 status = status + samplerstatus.status() return status, value
def control(buffer0): logger.debug("%s %s", "getA2D called", buffer0) try: value = readadc.read()[int(buffer0)] logger.debug("%s %s", "getA2D returned value ", value) except IOError as e: logger.critical("%s %s", "premature termination", e) status = 4 value = None except IndexError as e: logger.critical("invalid parameter") status = 8 value = None else: status = 0 status = status + samplerstatus.status() return status, value
def control(): logger.debug("getRealtimeData called") try: samplerresponse = readadc.read() #print "getRealTimeData sampleresponse = ", samplerresponse temp = getTemperature.control() except IOError as e: status = 4 value = e logger.critical("%s %s", "Unable to get temperature", e) else: status = 0 value = temp[1] + '\x1E' + samplerresponse[ 0] + '\x1E' + samplerresponse[1] + '\x1E' + samplerresponse[2] logger.debug("%s %s", "getRealtimeData returned value ", value) status = status + samplerstatus.status() return status, value
def control(): logger.debug("getPublisher called") try: config.read("StarinetBeagleLogger.conf") channel0 = config.get("publisherlabels", "channel0") channel1 = config.get("publisherlabels", "channel1") channel2 = config.get("publisherlabels", "channel2") except ConfigParser.Error as e: status = 4 value = e logger.critical("%s %s", "Unable to get publisher parameters from config", e) else: status = 0 value = channel0 + ',' + channel1 + ',' + channel2 logger.debug("%s %s", "returning value ", value) status = status + samplerstatus.status() return status, value
def control(buffer0): logger.debug("getDataBlock called") value = None try: f = open(config.get("paths", "datafolder") + str(buffer0), 'r') datablock = f.read().strip('\x02\x1F\x04\r\n\x00') f.close() logger.debug("%s %s", "getting data block ", buffer0) except IOError as e: status = 8 logger.critical("%s %s", "unable to open data block", e) else: status = 0 value = datablock.ljust(512, '0').strip('\r\n\x00') logger.debug("%s %s", "returning data block", buffer0) status = status + samplerstatus.status() return status, value
def control( buffer0, buffer1, buffer2 ): # buffer0 = reponse_command, buffer1 = response_status, buffer2 = response_crc logger.debug("%s %s %s %s", "getStatus called", buffer0, buffer1, buffer2) #status_code = {'0000': 'SUCCESS', # '0001': 'TIMEOUT', # '0002': 'ABORT', # '0004': 'PREMATURE_TERMINATION', # '0008': 'INVALID_PARAMETER', # '0010': 'INVALID_MESSAGE', # '0020': 'INVALID_COMMAND', # '0040': 'INVALID_MODULE', # '0080': 'INVALID_INSTRUMENT', # '0200': 'CRC_ERROR', # '0400': 'INVALID_XML', # '8000': 'CAPTURE_ACTIVE'} if buffer0 is not None: basecommand = buffer0[2:] command = basecommand[:4] commandvariant = basecommand[4:] #print "getStatus buffer 0 stripped of address ", basecommand #print "getStatus basecommand stripped of command variant ", command #print "getStatus basecommand stripped of code base and command ", commandVariant #print "getStatus response status of last command ", buffer1 #print "getStatus response crc of last command ", buffer2 value = command + ' ' + commandvariant + ' ' + buffer1 + ' ' + buffer2 else: value = '0000 0000 0000 0000' status = 0 logger.debug("%s %s", "getStatus returned ", value) status = status + samplerstatus.status() return status, value
def control(): logger.debug("getSpace called") try: blockcount = int(max(os.listdir(config.get("paths", "datafolder")), key=lambda p: os.path.getctime(os.path.join( config.get("paths", "datafolder"), p))), 16) + 1 value = str(int(100 - int(100 * float(blockcount) / 65534))).zfill(3) except ConfigParser.Error as e: status = 4 value = e logger.critical("%s %s", "Unable to open datafolder", e) except ValueError: value = '000' status = 0 else: status = 0 logger.debug("%s %s", "getSpace returned value ", value) status = status + samplerstatus.status() return status, value
def control(buffer0): status = None value = None config.read("StarinetBeagleLogger.conf") config.set('systemstate', 'publisher', buffer0) with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() logger.debug("%s %s", "capturePublisher buffer0 ", buffer0) nx = publisherstatus.status() if buffer0 == 'true': logger.debug("Entered true routine") if nx == 0: logger.debug("%s %s", "publisherstatus reports combined active", str(publisherstatus.status())) status = 2 # needs status 9000 value = 'capturePublisher_ACTIVE' elif nx == 1: logger.debug("%s %s", "publisherstatus reports combined not active", str(publisherstatus.status())) if samplerstatus.status() == 8000: try: pro = subprocess.Popen(["/usr/bin/python", "publisher/combined.py"]) except IOError as e: logger.critical("%s %s", "premature termination", e) logger.critical("Unable to start capturePublisher") status = 4 value = e else: try: pidfile = open(config.get('publisher', 'pidfile'), 'w') pidfile.write(str(pro.pid)) pidfile.close() except IOError as e: logger.critical("%s %s", "premature termination", e) logger.critical("Unable to create pid file") status = 4 value = e else: logger.debug("Started publisher.combined ....") status = 0 else: logger.debug("capture not active command capturePublisher aborted") status = 2 value = 'capture not active' else: logger.debug("premature termination") status = 4 value = 'unable to ascertain publisher status' elif buffer0 == 'false': logger.debug("Entered false routine") if nx == 1: logger.debug("%s %s", "publisherstatus reports combined not active", str(publisherstatus.status())) status = 0 elif nx == 0: logger.debug("%s %s", "publisherstatus reports combined active", str(publisherstatus.status())) try: pidfile = open(config.get('publisher', 'pidfile'), 'r') pid = int(pidfile.read()) pidfile.close() logger.debug("%s %s %s", "publisher.combined pidfile and pid - ", str(pidfile), str(pid)) except IOError as e: logger.critical("%s %s", "Unable to assign pid to pro.pid capturePublisher.py", e) status = 4 value = e else: try: os.kill(pid, signal.SIGTERM) except OSError as e: logger.debug("%s %s", "Unable to kill process publisher.combined", e) status = 4 value = e else: try: os.remove(str(config.get('publisher', 'pidfile'))) except OSError as e: logger.critical("%s %s", "Unable to remove pid file fatal error", e) status = 4 value = e else: status = 0 else: logger.critical("invalid parameter") status = 8 status = status + samplerstatus.status() return status, value
def myDataPublisher(): if config.get('systemstate', 'datapublisher') == 'true': # Check to see if capturePublisher is running if it is stop it. if publisherstatus.status() == 0: # if capturePublisher active true config.set('systemstate', 'datapublisherpub', 'true') with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() capPub = 1 capturePublisher.control('false') else: config.set('systemstate', 'datapublisherpub', 'false') with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() capPub = 0 # Check to see if capture is running which is should be and stop it. if samplerstatus.status() == 8000: # if capture active true capture.control('false') def myftp(filename): try: session = ftplib.FTP(config.get('datapublisher', 'server'), config.get('datapublisher', 'username'), config.get('datapublisher', 'password')) session.cwd(config.get('datapublisher', 'remotefolder')) # Change directory fd = open(filename, 'rb') # file to send session.storbinary("STOR %s" % filename, fd) # send the file file.close() # close file and FTP session.quit() except ftplib.all_errors as e: print "We had an FTP Error - ", e # Format date and time for RawData filename # Change this to get date and time from block 0000 daystamp = datetime.datetime.now().strftime("%Y%m%d") timestamp = datetime.datetime.now().strftime("%H%M%S") # Create filename for RawData filename = 'RawData_' + str(daystamp) + '_' + str(timestamp) + '.csv' # filename format RawData_20140726_230300.csv # Copy metadata into new filename with open("instrument.metadata") as f: with open(filename, "w") as f1: for line in f: if "ROW" in line: f1.write(line) f1.close() f.close() with open("observer.metadata") as f: with open(filename, "a") as f1: for line in f: if "ROW" in line: f1.write(line) f1.close() f.close() with open("observatory.metadata") as f: with open(filename, "a") as f1: for line in f: if "ROW" in line: f1.write(line) f1.close() f.close() len(list) # will print number of items in list
def control(buffer0): status = None value = None config.read("StarinetBeagleLogger.conf") logger.debug("%s %s", "Capture buffer0 ", buffer0) if buffer0 == 'true': logger.debug("Entered true routine") if samplerstatus.status() == 8000: logger.debug("%s %s", "samplerstatus reports sampler active", str(samplerstatus.status())) status = 8002 elif samplerstatus.status() == 0: logger.debug("%s %s", "samplerstatus reports sampler not active", str(samplerstatus.status())) folder = config.get('paths', 'datafolder') logger.debug("%s %s", "systemstate capture", config.get('systemstate', 'capture')) if config.get('systemstate', 'capture') == 'false': logger.debug('%s', 'Removing previous data files - capture started') for the_file in os.listdir(folder): file_path = os.path.join(folder, the_file) try: if os.path.isfile(file_path): os.unlink(file_path) logger.debug("%s %s", "Removing data file ", file_path) except OSError as e: logger.critical("%s %s", "premature termination", e) status = 4 f = open(config.get("paths", "datafolder") + '0000', 'wb') f.close() try: pro = subprocess.Popen( ["/usr/bin/python", "logger/sampler.py"]) except IOError as e: logger.critical("%s %s", "premature termination", e) logger.critical("Unable to start capture") status = 4 config.set('systemstate', 'capture', 'false') with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() else: try: pidfile = open(config.get('paths', 'pidfile'), 'w') pidfile.write(str(pro.pid)) pidfile.close() except IOError as e: logger.critical("%s %s", "premature termination", e) logger.critical("Unable to create pid file") status = 4 else: logger.debug("Started logger/sampler ....") config.set('systemstate', 'capture', buffer0) with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() status = 0 else: logger.debug("premature termination") status = 4 elif buffer0 == 'false': logger.debug("Entered false routine") if samplerstatus.status() == 0: logger.debug("%s %s", "samplerstatus reports sampler not active", str(samplerstatus.status())) status = 0 elif samplerstatus.status() == 8000: logger.debug("%s %s", "samplerstatus reports sampler active", str(samplerstatus.status())) if publisherstatus.status() == 0: logger.debug("%s %s", "publisher running terminating first", str(publisherstatus.status())) config.read("StarinetBeagleLogger.conf") config.set('systemstate', 'publisher', buffer0) with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() try: pidfile = open(config.get('publisher', 'pidfile'), 'r') pid = int(pidfile.read()) pidfile.close() logger.debug("%s %s %s", "publisher.combined pidfile and pid - ", str(pidfile), str(pid)) except IOError as e: logger.critical( "%s %s", "Unable to assign pid to pro.pid capturePublisher.py", e) else: try: os.kill(pid, signal.SIGTERM) except OSError as e: logger.debug( "%s %s", "Unable to kill process publisher.combined", e) else: try: os.remove(str(config.get('publisher', 'pidfile'))) except OSError as e: logger.critical( "%s %s", "Unable to remove pid file fatal error", e) else: pass try: pidfile = open(config.get('paths', 'pidfile'), 'r') pid = int(pidfile.read()) pidfile.close() logger.debug("%s %s %s", "logger/sampler pidfile and pid - ", str(pidfile), str(pid)) except IOError as e: logger.critical("%s %s", "Unable to assign pid to pro.pid capture.py", e) status = 4 else: try: os.kill(pid, signal.SIGTERM) except OSError as e: logger.debug("%s %s", "Unable to kill process logger/sampler", e) status = 4 else: try: os.remove(str(config.get('paths', 'pidfile'))) except OSError as e: logger.critical( "%s %s", "Unable to remove pid file fatal error", e) status = 4 else: config.read("StarinetBeagleLogger.conf") config.set('systemstate', 'capture', buffer0) with open('StarinetBeagleLogger.conf', 'wb') as configfile: config.write(configfile) configfile.close() status = 0 else: logger.critical("invalid parameter") status = 8 return status, value
def processor(buffer0): global response_status global response_command global response_crc response_value = None logger.debug("Interpreter was called.") if re.match("^\x02*[0-9a-zA-Z]{14}\x04*", buffer0): # Matched Command with no parameters logger.debug("Matched command with no parameters") logger.debug("%s %s", "Current current response_command - ", response_command) logger.debug("%s %s", "Current current response_status - ", response_status) logger.debug("%s %s", "Current current response_value - ", response_value) logger.debug("%s %s", "Current current response_crc - ", response_crc) try: data = buffer0.strip('\x02\x1F\x04\r\n') logger.debug("%s %s", "Stripped control chars from packet ", repr(data)) except Exception as e: logger.debug("%s %s", "Unable to strip ctl chars from packet ", e) else: try: address, command, crc = struct.unpack('<2s8s4s', data) logger.debug("%s %s %s %s", "Unpacked Staribus command", address, command, crc) except struct.error as e: logger.debug("%s %s", "Can not unpack command ", e) else: if int(staribuscrc.checkcrc(buffer0)) == 0200: logger.debug("Packet failed crc check") x = 200, None else: if int(address) != int(config.get("instaddr", "iaddr")): # Check Instrument Address Is Correct logger.debug("Instrument address does not match our address") x = 80, None else: ########## Core Module ################# if re.match('00010000', command): # ping logger.debug("Matched command ping") x = ping.ping() elif re.match('000A0000', command): # getVersion logger.debug("Matched command getVersion") x = getVersion.control() elif re.match('000D0000', command): # getMACAddress logger.debug("Matched command getMACAddress") x = getMACAddress.control() elif re.match('000E0000', command): # getStatus logger.debug("Matched command getStatus") x = getStatus.control(response_command, response_status, response_crc) ############ Utilities Module ############ elif re.match('01010000', command): # getTemperature logger.debug("Matched command getTemperature") x = getTemperature.control() elif re.match('010D0000', command): # getClockDate logger.debug("Matched command getClockDate") x = getClockDate.control() elif re.match('01070000', command): # getHostname logger.debug("Matched command getHostname") x = getHostname.control() elif re.match('010E0000', command): # getClockTime logger.debug("Matched command getClockTime") x = getClockTime.control() ############# Data Capture Module ############ elif re.match('03000000', command): # getSpace logger.debug("Matched command getSpace") x = getSpace.control() elif re.match('03040000', command): # getRate return capture interval logger.debug("Matched command getRate") x = getRate.control() elif re.match('03020000', command): # getDataBlockCount logger.debug("Matched command getDataBlockCount") x = getDataBlockCount.control() ############# Publisher Module ############### elif re.match('05040000', command): # getPublisherLabels logger.debug("Matched command getPublisherLabels") x = getPublisherLabels.control() elif re.match('05030000', command): # getPublisher logger.debug("Matched command getPublisher") x = getPublisher.control() elif re.match('05060000', command): # getPublisherArtist logger.debug("Matched command getPublisherArtist") x = getPublisherArtist.control() elif re.match('06030000', command): # getDataPublisher logger.debug("Matched command getDataPublisher") x = getDataPublisher.control() ############ Logger Plugin ############ elif re.match('04000000', command): # getRealTimeData logger.debug("Matched command getRealTimeData") x = getRealtimeData.control() else: logger.debug("Matched command - NO MATCH") x = 20, None elif re.match("^\x02*[0-9a-zA-Z]{10}\x1F*(([0-9a-zA-Z]*)(\x1F)*)*\x04*", buffer0): # Matched Cmd with parameters logger.debug("Matched command with parameters") logger.debug("%s %s", "Current current response_command - ", response_command) logger.debug("%s %s", "Current current response_status - ", response_status) logger.debug("%s %s", "Current current response_value - ", response_value) logger.debug("%s %s", "Current current response_crc - ", response_crc) try: data = buffer0.strip('\x02\x1F\x03\x04\r\n').split('\x1F') # Strip off ctrl characters and split on <us> logger.debug("%s %s", "Stripped control chars from packet", repr(data)) except Exception as e: logger.debug("%s %s", "Unable to strip ctl chars from packet ", e) else: try: address, command = struct.unpack('<2s8s', data[0]) # Unpack command logger.debug("%s %s %s", "Unpacked Staribus command", address, command) except struct.error as e: logger.debug("%s %s", "Can not unpack command ", e) else: if int(staribuscrc.checkcrc(buffer0)) == 0200: # check crc logger.debug("Packet failed crc check") x = 200, None else: if int(address) != int(config.get("instaddr", "iaddr")): # Check Staribus Inst Address Is Correct logger.debug("Packet instrument address does not match our address") x = 80, None else: ############ Publisher Module ############ if re.match('05050000', command): # setPublisherLabels logger.debug("Matched command setPublisherLabels") x = setPublisherLabels.control(data[1], data[2], data[3]) elif re.match('05070000', command): # setPublisherArtist logger.debug("Matched command setPublisherArtist") x = setPublisherArtist.control(data[1], data[2], data[3], data[4], data[5], data[6]) elif re.match('05010000', command): # publisher logger.debug("Matched command publisher") x = capturePublisher.control(data[1]) elif re.match('05020000', command): # setPublisher logger.debug("Matched command setPublisher") x = setPublisher.control(data[1], data[2], data[3], data[4], data[5], data[6]) ############ Analogue Module ############# elif re.match('02000000', command): # getA2D logger.debug("Matched command getA2D") x = getA2D.control(data[1]) ############### DataCapture Module ############ elif re.match('03030000', command): # getDataBlock logger.debug("Matched command getDataBlock") x = getDataBlock.control(data[1]) elif re.match('03050000', command): # setRate set capture interval logger.debug("Matched command setRate") x = setRate.control(data[1]) elif re.match('03060000', command): # capture logger.debug("Matched command capture") x = capture.control(data[1]) elif re.match('06020000', command): # setDataPublisher logger.debug("Matched command setDataPublisher") x = setDataPublisher.control(data[1], data[2], data[3], data[4], data[5], data[6]) elif re.match('06010000', command): # dataPublisher logger.debug("Matched command dataPublisher") x = dataPublisher.control(data[1]) elif re.match('000F0000', command): # controllerControl logger.debug("Matched command controllerControl") x = controllerControl.control(data[1]) else: logger.debug("Matched command - NO MATCH") x = 20, None if (x[0] is not None) and (x[1] is not None): response_status = str(x[0]).zfill(4) response_value = str(x[1]) response_command = str(address) + str(command) joinvalue = response_command + str(response_status) + '\x1F' + str(response_value) + '\x1F' response_crc = str(staribuscrc.newcrc(joinvalue)) value = '\x02' + joinvalue + response_crc + '\x04\r\n' logger.debug("%s %s", "Created Return Message -", repr(value)) elif (x[0] is not None) and (x[1] is None): response_status = str(x[0]).zfill(4) response_command = str(address) + str(command) response_value = None joinvalue = response_command + str(response_status) response_crc = str(staribuscrc.newcrc(joinvalue)) value = '\x02' + joinvalue + response_crc + '\x04\r\n' logger.debug("%s %s", "Created Return Message -", repr(value)) else: status = 4 + samplerstatus.status() response_status = str(status).zfill(4) response_command = str(address) + str(command) response_value = None joinvalue = response_command + str(response_status) response_crc = str(staribuscrc.newcrc(joinvalue)) value = '\x02' + joinvalue + response_crc + '\x04\r\n' logger.debug("%s %s", "Created Return Message -", repr(value)) return value