Ejemplo n.º 1
0
    def run(self):
        port_nb = serial_port()[0]
        self.device = Serial(port_nb, baudrate=self.BAUDRATE, timeout=0.2)
        while not self.exit_flag:
            c = self.device.read(1)
            if c == self.START_CHARACTER:
                while self.device.inWaiting() < self.PACKET_SIZE:
                    pass
                data = self.device.read(self.PACKET_SIZE)

                rocket_data = RocketData(data)
                # checksum_validated = rocket_data.validateCheckSum()
                checksum_validated = True
                if checksum_validated:
                    self.acquisition_queue.put(rocket_data)
        self.device.close()
Ejemplo n.º 2
0
import serial
import csv
from datetime import datetime

from rocket_data.rocket_packet import RocketData
from communication.DetectSerial import serial_port


BAUDRATE = 57600
START_CHARACTER = b's'
PACKET_SIZE = 69


if __name__ == "__main__":
    # Connecting to serial port
    port_number = serial_port()[0]
    device = serial.Serial(port_number, baudrate=BAUDRATE, timeout=0.2)
    # device = serial.Serial("COM7", baudrate=BAUDRATE, timeout=0.2)

    # initializing csv file
    file_name = "output_files/{}_acquisition_data_basic.csv".format(datetime.now().strftime("%Y%m%d_%H%M%S"))
    print("File Name = {}".format(file_name))
    csv_file = open(file_name, 'a', newline='')
    writer = csv.writer(csv_file)
    writer.writerow(["TIME STAMP", "ANG SPEED X", "ANG SPEED Y", "ANG SPEED Z", "ACCEL X", "ACCEL Y", "ACCEL Z", "MAGNET X", "MAGNET Y", "MAGNET Z", "ALTITUDE", "LATITUDE 1", "LONGITUDE 1", "LATITUDE 2", "LONGITUDE 2", "TEMPERATURE 1", "TEMPERATURE 2"])

    while True:
        c = device.read(1)
        if c != b'':
            print(c)
        if c == START_CHARACTER: