Example #1
0
 def __init__(self, local_callsign, local_callsign_id, destination_callsign, destination_id):
     """
     The message application object contains all the functions, definitions, and state machines needed to implement a bare-bones text message application using the Faraday command application "experimental RF Packet Forward" functionality."
     """
     #Identification Variables
     self.local_device_callsign = str(local_callsign).upper()
     self.local_device_node_id = int(local_callsign_id)
     self.remote_callsign = str(destination_callsign).upper()
     self.remote_id = int(destination_id)
     #Initialize objects
     self.faraday_1 = faradaybasicproxyio.proxyio(self.transmit_proxy_flask_port)
     self.faraday_cmd = faradaycommands.faraday_commands()
     #Initialize variables
     self.destination_callsign = ''
     self.destination_id = 0
Example #2
0
 def __init__(self):
     """
     The message application object contains all the functions, definitions, and state machines needed to implement
     a bare-bones text message application using the Faraday command application "experimental RF Packet Forward"
     functionality."
     """
     # Identification Variables
     self.local_device_callsign = 'kb1lqc'
     self.local_device_node_id = 1
     # Initialize objects
     self.faraday_Rx = faradaybasicproxyio.proxyio()
     self.faraday_Rx_SM = MsgStateMachineRx()
     # Initialize variables
     # Frame Definitions (Should be combined later with TX?)
     self.pkt_datagram_frame = struct.Struct('1B 41s')  # Fixed
     self.pkt_start = struct.Struct('9s 3B')  # Fixed
     self.pkt_data = struct.Struct('2B 39s')  # Variable  Data Length
     self.pkt_end = struct.Struct('1B')  # Fixed
Example #3
0
#Imports - Faraday Specific
from FaradayIO import faradaybasicproxyio
from FaradayIO import faradaycommands
from FaradayIO import telemetryparser
from FaradayIO import cc430radioconfig

import time

#Variables
local_device_callsign = 'REPLACEME'  # Should match the connected Faraday unit as assigned in Proxy configuration
local_device_node_id = REPLACEME  # Should match the connected Faraday unit as assigned in Proxy configuration

#Start the proxy server after configuring the configuration file correctly
#Setup a Faraday IO object
faraday_1 = faradaybasicproxyio.proxyio()
faraday_cmd = faradaycommands.faraday_commands()
faraday_parser = telemetryparser.TelemetryParse()

############
## Telemetry
############


def get_telemetry():
    #Flush old data from UART service port
    faraday_1.FlushRxPort(local_device_callsign, local_device_node_id,
                          faraday_1.TELEMETRY_PORT)

    #Command UART Telemetry Update NOW
    faraday_1.POST(local_device_callsign, local_device_node_id,
from FaradayIO import deviceconfig

# Global Constants
UART_PORT_APP_COMMAND = 2

# Start logging after importing modules
logging.config.fileConfig('loggingConfig.ini')
logger = logging.getLogger('deviceconfiguration')

# Load Telemetry Configuration from telemetry.ini file
# Should have common file for apps...
deviceConfig = ConfigParser.RawConfigParser()
deviceConfig.read('deviceconfiguration.ini')

# Initialize proxy object
proxy = faradaybasicproxyio.proxyio()

# Initialize faraday command module
faradayCmd = faradaycommands.faraday_commands()

# Initialize Flask microframework
app = Flask(__name__)


@app.route('/', methods=['GET', 'POST'])
def unitconfig():
    """
    This function is called when the RESTful API GET or POST call is made to the '/' of the operating port. Querying a
    GET will command the local and queried unit's device configuration in Flash memory and return the information as a
    JSON dictionary. Issuing a POST will cause the local .INI file configuration to be loaded into the respective units
    Flash memory device configuration.
Example #5
0
import os
import sys
import time

sys.path.append(
    os.path.join(os.path.dirname(__file__), "../../Faraday_Proxy_Tools")
)  #Append path to common tutorial FaradayIO module

from FaradayIO import faradaybasicproxyio
from FaradayIO import faradaycommands

#Setup a Faraday IO object
faraday_1 = faradaybasicproxyio.proxyio()  #default proxy port
faraday_cmd = faradaycommands.faraday_commands()

while (1):
    #Turn LED 1 ON (GREEN)
    print "Turning LED 1 ON"
    command = faraday_cmd.CommandLocalGPIOLED1On()
    faraday_1.POST('REPLACEME', REPLACEME, faraday_1.CMD_UART_PORT, command)
    time.sleep(0.5)

    #Turn LED 1 OFF
    print "Turning LED 1 OFF"
    command = faraday_cmd.CommandLocalGPIOLED1Off()
    faraday_1.POST('REPLACEME', REPLACEME, faraday_1.CMD_UART_PORT, command)
    time.sleep(0.5)
Example #6
0
def telemetry_worker(config):
    """
    Interface Faraday Proxy to obtain telemtry

    This function interfaces the Proxy application via its RESTful interface.
    It is a one-way operation as it makes no sense to POST data to proxy for
    telemetry to a specific unit with this application.
    """
    logger.info('Starting telemetry_worker thread')

    # initialize variables
    stations = {}

    # Initialize proxy object
    proxy = faradaybasicproxyio.proxyio()

    # Initialize Faraday parser
    faradayParser = telemetryparser.TelemetryParse()  # Add logger?

    # Open configuration file
    dbFilename = config.get("DATABASE", "FILENAME")

    # Pragmatically create descriptors for each Faraday connected to Proxy
    count = config.getint("TELEMETRY", "UNITS")

    for num in range(count):
        callsign = config.get("TELEMETRY", "UNIT" + str(num) + "CALL").upper()
        nodeid = config.get("TELEMETRY", "UNIT" + str(num) + "ID")
        stations["UNIT" + str(num) + "CALL"] = callsign
        stations["UNIT" + str(num) + "ID"] = nodeid
        telemetryDicts[str(callsign) + str(nodeid)] = deque([], maxlen=1000)

    # check for data on telemetry port, if True place into deque
    while (1):
        for radio in range(count):
            callsign = stations["UNIT" + str(num) + "CALL"]
            nodeid = stations["UNIT" + str(num) + "ID"]
            data = proxy.GET(str(callsign), str(nodeid),
                             int(proxy.TELEMETRY_PORT))

            # Iterate through each packet and unpack into dictionary
            if data != None:
                for item in data:
                    try:
                        # Decode BASE64 JSON data packet into
                        unPackedItem = proxy.DecodeRawPacket(item["data"])
                        # Unpack packet into datagram elements
                        datagram = faradayParser.UnpackDatagram(
                            unPackedItem, False)
                        # Extract the payload length from payload since padding could be used
                        telemetryData = faradayParser.ExtractPaddedPacket(
                            datagram["PayloadData"],
                            faradayParser.packet_3_len)
                        # Unpack payload and return a dictionary of telemetry, return tuple and dictionary
                        parsedTelemetry = faradayParser.UnpackPacket_3(
                            telemetryData, False)

                    except ValueError as e:
                        logger.error("ValueError: " + str(e))
                    except IndexError as e:
                        logger.error("IndexError: " + str(e))
                    except KeyError as e:
                        logger.error("KeyError: " + str(e))

                    else:
                        sqlInsert(parsedTelemetry)
                        telemetryDicts[str(callsign) +
                                       str(nodeid)].append(parsedTelemetry)

        time.sleep(1)  # should slow down