#!/usr/bin/python import serial import os ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1) ser.reset_input_buffer() outFile = "/home/pi02/data.txt" cmd='curl -s -XPOST "http://fsunuc.physics.fsu.edu:8086/write?db=interlock" --data-binary @/home/pi02/data.txt' while True: if ser.in_waiting > 0: line = ser.readline().decode('utf-8').rstrip() components = line.split(';') format_value = {} for component in components: #print(component) parts = component.strip().split(': ') if len(parts) == 2: key, valueUnit = parts part2 = valueUnit.split(' ') if len(part2) == 2: value, unit = part2 format_value[key] = value else: format_value[key] = valueUnit #print(line) #for key, value in format_value.items(): # print(f"{key} value={value}") with open(outFile, "w") as file: for key, value in format_value.items(): file.write(f"{key} value={value}\n") os.system(cmd)