Skip to content
Snippets Groups Projects
Commit 4e1c167e authored by Lennard's avatar Lennard
Browse files

Various updates

- Adding debug data to find cause for weird didn't receive error
- Fix data log files having wrong date because of rollover time
parent 7925a6e7
No related branches found
No related tags found
No related merge requests found
......@@ -2,5 +2,5 @@
out/*
CHANGELOG.md
profiling.log
logs/log
data/data
data.zip
\ No newline at end of file
......@@ -3,7 +3,7 @@ DataLogger:
filename: data # filename for datalogs
levels: # log level for outputting to file and to stdout respectivly
- INFO
- INFO
- WARNING
InfoLogger:
backupCount: 10 # number of logs to keep
......@@ -16,4 +16,3 @@ InfoLogger:
Data:
factors: [1.855, 0, 0.923, -1] # factors for the 4 dms
delta_time: 10 # time between logging data
smoothing: false # whether to smoothe the logged data
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
......@@ -33,8 +33,6 @@ class TimedRotatingFileHandlerWithHeader(logging.handlers.TimedRotatingFileHandl
def emit(self, record):
try:
if self.shouldRollover(record) or self.first:
if self.shouldRollover(record):
self.doRollover()
stream = self.stream
if self._header:
stream.write(self._header + self.terminator)
......@@ -96,7 +94,7 @@ def setup_loggers(config: Any) -> None:
header=f"Timestamp,{','.join([f'dms{i+1}' for i in range(4)])},{','.join([f'temp{i+1}' for i in range(4)])},n",
filename=f"{Path(__file__).parent}/data/{config['DataLogger']['filename']}",
when="h",
interval=25,
interval=23,
backupCount=config["DataLogger"]["backupCount"],
)
)
......@@ -155,9 +153,9 @@ def main(config: Any) -> None:
try:
new_data = data.copy()
# offsets for writing data of each arduino in correct column
con1.write(1)
# offsets for writing data in correct column
off1 = 0 if int(convert(con1.readline())) == 1.0 else 4
# read data
......@@ -165,20 +163,23 @@ def main(config: Any) -> None:
recv1 = con1.readline()
new_data[i + off1] += float(convert(recv1))
recv1 = None
off1 = None
con2.write(2)
# offsets for writing data in correct column
off2 = 4 if int(convert(con2.readline())) == 2.0 else 0
for i in range(4):
recv2 = con2.readline()
new_data[i + off2] += float(convert(recv2))
recv2 = None
off2 = None
n += 1
data = new_data
except (TypeError, ValueError):
# may occur if no data was read over serial
logger.info(f"Didn't receive data from arduino, off1: {off1}, off2: {off2}, recv1: {recv1}, recv2: {recv2}")
# may occur if no data was read over serial, but why???
logger.exception(f"Didn't receive data from arduino, off1: {off1}, off2: {off2}, recv1: {recv1}, recv2: {recv2}")
if time.time() - last_write > delta_time:
# write data
......
......@@ -121,7 +121,7 @@ def get_data(con1: serial.Serial, con2: serial.Serial):
except (TypeError, ValueError):
# may occur if no data was read over serial
log_event(ph="I", ts=time_usec(), name="NoData", cat="NoData", **base_info)
print("Didn't receive data from arduino")
print(f"Didn't receive data from arduino, {traceback.format_exc().replace(os.linesep, '')}")
@log_profile("loop")
......@@ -140,7 +140,7 @@ def main() -> None:
print("Starting")
try:
with serial.Serial("/dev/ttyACM0", 9600, timeout=3) as con1, serial.Serial("/dev/ttyACM1", 9600, timeout=3) as con2:
for _ in range(50):
for _ in range(100):
loop(con1, con2)
except serial.serialutil.SerialException:
print(traceback.format_exc())
......
......@@ -77,21 +77,20 @@ void writeInData() {
if (Serial.available()) {
Serial.read();
delay(10);
delay(20);
Serial.println(1);
delay(10);
regelbetrieb(LoadCell, LoadCell2, LoadCell3, LoadCell4);
Serial.println(messwert);
delay(10);
delay(20);
Serial.println(messwert2);
delay(10);
delay(20);
Serial.println(messwert3);
delay(10);
delay(20);
Serial.println(messwert4);
}
......
......@@ -21,7 +21,7 @@ void loop() {
if (Serial.available()) {
Serial.read();
delay(10);
delay(20);
Serial.println(2); // for identification
......@@ -29,7 +29,7 @@ void loop() {
dhts[i].readHumidity();
float temp = dhts[i].readTemperature();
delay(10);
delay(20);
Serial.println(temp);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment