Beispiel #1
0
def data_to_csv(data_obj: RadioData, filename: str = "buggydata.csv"):

    # Creating a new CSV if there doesn't exist one
    if not csv_funcs.exists_csv(filename):
        csv_funcs.create_csv_file(filename, data_obj.get_fieldnames())

    # Writing to the CSV
    csv_funcs.write_to_csv(filename, data_obj.get_data_dict())
def data_to_csv(data_obj: RadioData, filename: str):

    # Creating a new CSV if there doesn't exist one
    if not exists_csv(filename):
        create_csv_file(filename, data_obj.get_fieldnames())

    # Writing to the CSV
    # (For loop is there for testing purposes; script will only add one data row per call)
    # for i in range(5):
    write_to_csv(filename, randomize_data(data_obj.get_data_dict()))
Beispiel #3
0
def send_json(obj: RadioData):
    ser = Serial(SEND_JSON_PORT, baudrate=BAUDRATE, timeout=1)

    timestamp = datetime.now().strftime("%Y-%b-%d;%I:%M:%S:%p").split(';')
    obj.OBC_date = timestamp.pop(0)
    obj.OBC_time = timestamp.pop(0)

    data_to_send = {"data": obj.get_data_dict(), "buggy_id": obj.BUGGY_ID}

    data = json.dumps(data_to_send, cls=MyEncoder)
    ser.write(data.encode('utf-8'))
    # ser.flush()
    ser.close()