Beispiel #1
0
def chart_data(average):
    """Returns a data stream of readings from the sensor

    Args:
        average (string): Determines if we're returning all five observations or just an average of selected

    Returns:
        Array: Array of values (either all five readings or set point from INI and avg of selected)
    """
    if average == None:
        ser = SerialReader.SerialReader(csvLog=sessionLog)
        return Response(ser.read_sensor_data(currentConfig,
                                             averageObservation=False),
                        mimetype='text/event-stream')
    else:
        ser = SerialReader.SerialReader(csvLog=sessionLog)
        return Response(ser.read_sensor_data(currentConfig,
                                             averageObservation=True),
                        mimetype='text/event-stream')
Beispiel #2
0
    def __init__(self):
        super(canSnifferGUI, self).__init__()
        self.setupUi(self)
        self.portScanButton.clicked.connect(self.scanPorts)
        self.portConnectButton.clicked.connect(self.serialPortConnect)
        self.portDisconnectButton.clicked.connect(self.serialPortDisconnect)
        self.startSniffingButton.clicked.connect(self.startSniffing)
        self.stopSniffingButton.clicked.connect(self.stopSniffing)
        self.saveSelectedIdInDictButton.clicked.connect(
            self.saveIdLabelToDictCallback)
        self.saveSessionToFileButton.clicked.connect(self.saveSessionToFile)
        self.loadSessionFromFileButton.clicked.connect(
            self.loadSessionFromFile)
        self.showOnlyIdsLineEdit.textChanged.connect(
            self.showOnlyIdsTextChanged)
        self.hideIdsLineEdit.textChanged.connect(self.hideIdsTextChanged)
        self.clearLabelDictButton.clicked.connect(self.clearLabelDict)
        self.serialController = serial.Serial()
        self.mainMessageTableWidget.cellClicked.connect(self.cellWasClicked)
        self.newTxTableRow.clicked.connect(self.newTxTableRowCallback)
        self.removeTxTableRow.clicked.connect(self.removeTxTableRowCallback)
        self.sendTxTableButton.clicked.connect(self.sendTxTableCallback)
        self.abortSessionLoadingButton.clicked.connect(
            self.abortSessionLoadingCallback)
        self.showSendingTableCheckBox.clicked.connect(
            self.showSendingTableButtonCallback)
        self.addToDecodedPushButton.clicked.connect(self.addToDecodedCallback)
        self.deleteDecodedPacketLinePushButton.clicked.connect(
            self.deleteDecodedLineCallback)
        self.decodedMessagesTableWidget.itemChanged.connect(
            self.decodedTableItemChangedCallback)
        self.clearTableButton.clicked.connect(self.clearTableCallback)
        self.sendSelectedDecodedPacketButton.clicked.connect(
            self.sendDecodedPacketCallback)
        self.playbackMainTableButton.clicked.connect(
            self.playbackMainTableCallback)
        self.stopPlayBackButton.clicked.connect(self.stopPlayBackCallback)
        self.hideAllPacketsButton.clicked.connect(self.hideAllPackets)
        self.showControlsButton.hide()

        self.serialWriterThread = SerialWriter.SerialWriterThread(
            self.serialController)
        self.serialReaderThread = SerialReader.SerialReaderThread(
            self.serialController)
        self.serialReaderThread.receivedPacketSignal.connect(
            self.serialPacketReceiverCallback)
        self.fileLoaderThread = FileLoader.FileLoaderThread()
        self.fileLoaderThread.newRowSignal.connect(
            self.mainTablePopulatorCallback)
        self.fileLoaderThread.loadingFinishedSignal.connect(
            self.fileLoadingFinishedCallback)
        self.hideOldPacketsThread = HideOldPackets.HideOldPacketsThread()
        self.hideOldPacketsThread.hideOldPacketsSignal.connect(
            self.hideOldPacketsCallback)

        self.stopPlayBackButton.setVisible(False)
        self.playBackProgressBar.setVisible(False)
        self.sendingGroupBox.hide()
        self.hideOldPacketsThread.enable(5)
        self.hideOldPacketsThread.start()

        self.scanPorts()
        self.startTime = 0
        self.receivedPackets = 0
        self.playbackMainTableIndex = 0
        self.labelDictFile = None
        self.idDict = dict([])
        self.showOnlyIdsSet = set([])
        self.hideIdsSet = set([])
        self.idLabelDict = dict()
        self.isInited = False
        self.init()

        if not os.path.exists("save"):
            os.makedirs("save")

        for i in range(5, self.mainMessageTableWidget.columnCount()):
            self.mainMessageTableWidget.setColumnWidth(i, 32)
        for i in range(5, self.mainMessageTableWidget.columnCount()):
            self.decodedMessagesTableWidget.setColumnWidth(i, 32)
        self.decodedMessagesTableWidget.setColumnWidth(1, 150)
        self.decodedMessagesTableWidget.horizontalHeader(
        ).setSectionResizeMode(0, QHeaderView.Stretch)
        self.txTable.horizontalHeader().setSectionResizeMode(
            3, QHeaderView.Stretch)
        self.showFullScreen()
Beispiel #3
0
__author__ = 'alan'
import logging
import BtComm
import SerialReader


class Main:
    def bluetoothHandler(self, data):
        print(data)

    def serialHandler(self, data):
        btComm.send(data)


if __name__ == '__main__':
    logging.basicConfig(handlers=[logging.StreamHandler()], level=logging.INFO)

    btComm = BtComm.BtComm()
    #btComm.start(Main.bluetoothHandler)

    serialReader = SerialReader.SerialReader("mmaptest")
    serialReader.start(Main.serialHandler)

    while True:
        # do facial
        print("doing facial")