コード例 #1
0
ファイル: fsx.py プロジェクト: RobertSchuster/mcdu
 def connect(self):
     try:
         pyuipc.open(pyuipc.SIM_FSX)
     except pyuipc.FSUIPCException:
         return False
     else:
         return True
コード例 #2
0
ファイル: main.py プロジェクト: shotwn/FS-Time-Sync
    def connect_pyuipc(self):
        if self.pyuipc_open:
            return self.pyuipc_open

        try:
            pyuipc.open(0)
        except pyuipc.FSUIPCException as exc:  # noqa: F841
            print(exc)
            return None

        sim_offset = self.create_offset_set({
            'SIM_VERSION': [0x3308, 'b'],
            'IS_XPLANE': [0x6FFF, 'b']
        })
        result = sim_offset.read()

        if result['IS_XPLANE']:
            self.pyuipc_open = SIMULATOR_XPLANE_ID
            self.opened_sim = SIMULATOR_XPLANE
        else:
            self.pyuipc_open = result['SIM_VERSION']
            try:
                self.opened_sim = SIMULATORS[self.pyuipc_open]
            except IndexError:
                self.opened_sim = f'Unknown Sim: {self.pyuipc_open}'

        return True
コード例 #3
0
ファイル: fsx.py プロジェクト: 7h0ma5/mcdu
 def connect(self):
     try:
         pyuipc.open(pyuipc.SIM_FSX)
     except pyuipc.FSUIPCException:
         return False
     else:
         return True
コード例 #4
0
ファイル: track.py プロジェクト: dcheva/xACARS
def beginTrack():
    try:
        pyuipc.open(0)
        return True
    except pyuipc.FSUIPCException as e:
        return "UIPC Connection Error: " + str(e.errorCode)
    except Exception as e:
        return "ERROR: " + str(e)
コード例 #5
0
def connectToSim(ui):
    try:
        fs.open(0)
        ui.statusLabel.setText("Connected to simulator!")
        global isConnectedToSim  # sorry not sorry
        isConnectedToSim = True
    except Exception:
        msg = QMessageBox()
        msg.setText("Cannot connect to simulator.")
        msg.exec_()
コード例 #6
0
def setup():
    global pyuipcOffsets, oldActMode, alivetime, client, event, oldAPStatus, OFFSETS

    # Connect to flight simulator via FSUIPC (pyuipc)
    try:
        pyuipcConnection = pyuipc.open(0)
    except pyuipc.FSUIPCException:
        logging.critical(
            "Unable to connect FSUIPC: check Flight Sim is running first. Exit"
        )
        sys.exit(1)
    logging.info("Connected to FSUIPC")

    # MQTT borcker connection on localhost
    client = mqtt.Client()
    client.on_connect = on_connect
    client.on_message = on_message

    logging.debug("Trying to connect to MQTT server " +
                  config.get('MQTT', 'server') + " on port " +
                  config.get('MQTT', 'port'))
    client.connect(config.get('MQTT', 'server'), config.getint('MQTT', 'port'),
                   60)
    client.loop_start()
    logging.info("Connectes to MQTT server " + config.get('MQTT', 'server'))

    oldActMode = ""
    alivetime = time.time()  # the keepalive ticker
    event = Event()
    oldAPStatus = -1
    #        AP STATUS    HAS AP
    OFFSETS = [(0x07BC, 'u'), (0x0764, 'u')]
    pyuipcOffsets = pyuipc.prepare_data(OFFSETS)
コード例 #7
0
ファイル: refuelUipc.py プロジェクト: Sowintuu/smartRefuel
 def connect_pyuipc(self):
     try:
         self.pyuipc_connection = pyuipc.open(0)
         self.pyuipc_offsets = pyuipc.prepare_data(self.OFFSETS)
         print('FSUIPC connection established.')
         return True
     except NameError:
         self.pyuipc_connection = None
         print('Error using PYUIPC.')
         return False
     except pyuipc.FSUIPCException:
         print('FSUIPC: No simulator detected. Start you simulator first!')
         return False
コード例 #8
0
 def connectPyuipc(self):
     try:
         self.pyuipcConnection = pyuipc.open(0)
         self.pyuipcOffsets = pyuipc.prepare_data(self.OFFSETS)
         self.logger.info('FSUIPC connection established.')
         return True
     except NameError:
         self.pyuipcConnection = None
         self.logger.warning(
             'Error using PYUIPC, running voiceAtis without it.')
         return True
     except:
         self.logger.warning(
             'FSUIPC: No simulator detected. Start you simulator first!')
         return False
コード例 #9
0
ファイル: fstest2.py プロジェクト: szebenyib/afs
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import pyuipc
>>> open(7)

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    open(7)
TypeError: coercing to Unicode: need string or buffer, int found
>>> pyuipc.open(7)
>>> toread = pyuipc.prepare_data((0x034E, "integer"), True)

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    toread = pyuipc.prepare_data((0x034E, "integer"), True)
TypeError: list is expected
>>> toread = pyuipc.prepare_data([0x034E, "integer"]), True)
SyntaxError: invalid syntax
>>> toread = pyuipc.prepare_data([0x034E, "integer"], True)

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    toread = pyuipc.prepare_data([0x034E, "integer"], True)
TypeError: list element 0: should be a tuple of a length of at least 2
>>> toread = pyuipc.prepare_data([(0x034E, "integer"),], True)

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    toread = pyuipc.prepare_data([(0x034E, "integer"),], True)
TypeError: list element 0: type string be of length 1
>>> toread = pyuipc.prepare_data([(0x034E, "i"),], True)
コード例 #10
0
ファイル: yaatcp.py プロジェクト: DarthVeder/yaatcp
    

def hotkey(data):
    """
    Read any hotkey trapped
    """
    byte=[data[0][i:(i+DWORD)] for i in range(0,len(data[0]),DWORD)]


flight_in_progress = True
counter = 1
stop_counter = 10
starttime = time.time()
ICAO = ['EGGD','LIRF']
try:
    fsuipc.open(fsuipc.SIM_FSX)

    while flight_in_progress:
        # MENU ON - wip
        #text = '1 - Request Clearance\n'
        #data = [(int('3380',16),len(text)), (int('32FA',16),'h')]
        #fdata = fsuipc.prepare_data(data, False)
        #fsuipc.write(fdata, [text, 100])

        #data = [(int('0x3210',16),224)]
        #rdata = fsuipc.prepare_data(data)
        #call = fsuipc.read(rdata)
        #hotkey(call)
        # MENU OFF

        # WEATHER START
コード例 #11
0
def startup():
    pyuipc.open(pyuipc.SIM_FSX)
コード例 #12
0
ファイル: froggersFSmidi.py プロジェクト: frosch03/MIDI2FSX
def startup():
    pyuipc.open(pyuipc.SIM_FSX)
コード例 #13
0
ファイル: yaatcp.py プロジェクト: DarthVeder/yaatcp

def hotkey(data):
    """
    Read any hotkey trapped
    """
    byte = [data[0][i:(i + DWORD)] for i in range(0, len(data[0]), DWORD)]


flight_in_progress = True
counter = 1
stop_counter = 10
starttime = time.time()
ICAO = ['EGGD', 'LIRF']
try:
    fsuipc.open(fsuipc.SIM_FSX)

    while flight_in_progress:
        # MENU ON - wip
        #text = '1 - Request Clearance\n'
        #data = [(int('3380',16),len(text)), (int('32FA',16),'h')]
        #fdata = fsuipc.prepare_data(data, False)
        #fsuipc.write(fdata, [text, 100])

        #data = [(int('0x3210',16),224)]
        #rdata = fsuipc.prepare_data(data)
        #call = fsuipc.read(rdata)
        #hotkey(call)
        # MENU OFF

        # WEATHER START
コード例 #14
0
import pyuipc
import time
import struct
from datetime import datetime


pyuipc.open(12)

def convert_bcd(data, length):
    """BCD to string"""
    bcd = ""
    for i in range(0, length):
        digit = chr(ord('0') + (data&0x0f))
        data >>= 4
        bcd = digit + bcd
    return bcd

def prepare_offsets(offsets):
    offsets_rough_dict = []
    for key, offset in offsets.items():
        offsets_rough_dict.append((offset[0], offset[1]))

    return pyuipc.prepare_data(offsets_rough_dict, True)

def format_radio_freq_to_string(freq):
    return """1{}.{}0""".format(hex(freq)[2:4], hex(freq)[4:6])

def format_string_to_radio_freq(string):
    return int("0x"+string[1:3] + string[4:6], 16)

def read_offsets(offsets_to_read):
コード例 #15
0
ファイル: fstester.py プロジェクト: szebenyib/afs
import pyuipc
import serial
from time import sleep

#Init arduino
arduinoSerial = serial.Serial("COM1", 9600)
sleep(1.5)

#Open Fs2004
pyuipc.open(7)

def convertBCD(data, length):
    """BCD to string"""
    bcd = ""
    for i in range(0, length):
        digit = chr(ord('0') + (data&0x0f))
        data >>= 4
        bcd = digit + bcd
    return bcd

batteryToRead = pyuipc.prepare_data([(0x028c, "d")])

batteryState = pyuipc.read(batteryToRead)
#batteryStateConverted = convertBCD(batteryState[0], len(batteryState))
#print batteryStateConverted
print batteryState[0]
print chr(batteryState[0]+48)
print str(chr(batteryState[0]+48))

#arduinoSerial.write(str(0))
arduinoSerial.write(str(batteryState[0]))
コード例 #16
0
ファイル: fsdme.py プロジェクト: szebenyib/afs
def create_fs_connection(fs_version=7):
    """Creates the connection with the flight simulator.

    Returns: the connection to the Flight Sim"""
    return pyuipc.open(fs_version)
コード例 #17
0
ファイル: fstest.py プロジェクト: szebenyib/afs
import pyuipc

pyuipc.open(7) #fs2004

def convertBCD(data, length):
	"""BCD to string"""
	bcd = ""
	for i in range (0, length):
		digit = chr(ord('0') + (data&0x0f))
		data >>= 4
		bcd = digit + bcd
	return bcd

nav1 = pyuipc.read([(0x0350, "H"),]) #Nav1

print nav1
print convertBCD(nav1, 4)