Skip to content

Commit

Permalink
add tools which could help with the data collection sketch
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasguocn committed Oct 23, 2022
1 parent 7f66a2e commit ac41393
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Arduino_BHY2/examples/SyncAndCollectIMUData/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# process_nicla_bhy2_log_base64.py
This script is used to convert the log encoded in base64 to ascii
## Usage
```
./process_nicla_bhy2_log_base64.py [log_file_name]
```
## Example
./process_nicla_bhy2_log_base64.py log_nicla_bhy2.txt


# check_for_data_loss.sh
This script is used to check for any potential data loss during the transfer,
and it reports some errors if it does find any data loss

## Usage
```
./check_for_data_loss.sh [OPTION] [log_file_name]
```

## Example
- Example 1
```
./check_for_data_loss.sh -b ./minicom.log
```
The above command check for the data loss using the log "./minicom.log" which is base on base64 encoding
- Example 2
```
./check_for_data_loss.sh -a ./minicom.log
```
The above command check for the data loss using the log "./minicom.log" which is base on ascii encoding
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh


log_encoding_is_base64=false

if [ ":""$1" = ":-b" ] ; then
log_encoding_is_base64=true
echo "log is using base64 encoding"
elif [ ":""$1" = ":-a" ] ; then
log_encoding_is_base64=false
echo "log is using ascii encoding"
else
echo "usage: ./check_for_data_loss.sh [OPTION] [log_filename]"
echo "\t[OPTION]:"
echo "\t\t" "-a"
echo "\t\t" "\t:log use ascii encoding"
echo "\t\t" "-b"
echo "\t\t" "\t:log use base64 encoding"

echo "\texample: ./check_for_data_loss.sh -b minicom.cap"
return
fi

if [ ":""$2" = ":" ] ; then
log_file="./minicom.cap"
else
log_file="$2"
fi


tmp_file="./tmp.csv"
log_file_cp="${log_file}.cp"
log_file_in="${log_file_cp}.tmp"

echo "log_file:$log_file"


if [ $log_encoding_is_base64 = true ] ; then
cp $log_file $log_file_cp
./process_nicla_bhy2_log_base64.py $log_file_cp > $log_file_in
else
cp $log_file $log_file_in
fi

echo "log_id,seq,ax,ay,az,gx,gy,gz" > $tmp_file

sed 's/.*\([a-zA-Z]\)\([0-9]\)/\1,\2/g' $log_file_in >> $tmp_file
./check_for_data_loss.py $tmp_file

0 comments on commit ac41393

Please sign in to comment.