Commit 9486c1c6 authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Data Checksum in binary mode

parent 19c38b28
...@@ -19,7 +19,7 @@ CCFLAGS=-g -lrt -std=c++11 -pthread ...@@ -19,7 +19,7 @@ CCFLAGS=-g -lrt -std=c++11 -pthread
EXCL=driver_serial_emulate.o EXCL=driver_serial_emulate.o
# Uncomment to use virtual serial port. Run 'make clean all' afterwards # Uncomment to use virtual serial port. Run 'make clean all' afterwards
EXCL=driver_serial.o #EXCL=driver_serial.o
.SECONDARY: .SECONDARY:
......
...@@ -806,15 +806,16 @@ int driver_obs_obsdaq::parse_data_bin(data_obs_vector* data, char* buf) { ...@@ -806,15 +806,16 @@ int driver_obs_obsdaq::parse_data_bin(data_obs_vector* data, char* buf) {
} }
} }
// Check control bit // Check checksum byte
tmp_d=0; tmp_d=0;
// Sum over N-1 data bytes
for (int i=0; i<reclen-1; i++){ for (int i=0; i<reclen-1; i++){
tmp_d += buf[i]; tmp_d += buf[i];
} }
// Last byte must contain sum of last (N-1) bytes in bits 0-6
if ( (tmp_d&127) != (buf[reclen-1]&127) ){ if ( (tmp_d&127) != (buf[reclen-1]&127) ){
fprintf(stderr,"Faulty data: Control sum check failed for "); fprintf(stderr,"Faulty data: Control sum check failed for ");
for (int i=0; i<strlen(buf);i++){ for (int i=0; i<reclen-1;i++){
fprintf(stderr,"%d ",buf[i]); fprintf(stderr,"%d ",buf[i]);
} }
fprintf(stderr,"and values %d %d %d.\n", fprintf(stderr,"and values %d %d %d.\n",
......
# Baudrate for ObsDAQ # Baudrate for ObsDAQ
BAUD=19200 #19200 BAUD=19200 #19200
# PORT for ObsDAQ # PORT for ObsDAQ
PORT=/dev/ttyUSB1 PORT=/dev/ttyUSB0
# Resistance of variometer # Resistance of variometer
R=1.0 R=1.0
# Scale values of variometer # Scale values of variometer
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment