Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mpu6050_part2 #155

Open
wants to merge 48 commits into
base: Vitalii.Pudov
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
85186d2
02-Git: Add homework
an1kh Oct 11, 2018
3b5cedf
03-Bash: add homework
yekovalyov Oct 10, 2019
2aef62c
02-Bash: add the requirement for separate PRs
yekovalyov Oct 11, 2019
b127de0
03-Bash: fix typo error
yekovalyov Oct 13, 2019
47038e9
03-Make: add examples and homework
yekovalyov Oct 15, 2019
bb074fe
04-KernelModule: Add homework task
an1kh Oct 24, 2018
884c3f4
05-Interfaces: Add homework task
an1kh Nov 1, 2018
5c58ebe
mpu6050: Placeholder and documentation for mpu6050 driver
AleksandrBulyshchenko Oct 26, 2017
f062ed8
mpu6050: Create driver skeleton
an1kh Oct 19, 2017
314acff
mpu6050: Add I2C driver
an1kh Oct 19, 2017
c9e4089
mpu6050: Add check of WHO_AM_I register value
an1kh Oct 20, 2017
e93fe9e
mpu6050: Add driver functionality
an1kh Oct 24, 2017
068d343
mpu6050: practice 1 homework part 2 kernel module development
yekovalyov Dec 5, 2019
717edfd
02-Git: Add initial files
VitaliiPudov Oct 8, 2019
5779513
02-Git: Add user interface functionality
VitaliiPudov Oct 8, 2019
cf4c69d
02-Git: Implement of makefile
VitaliiPudov Oct 8, 2019
46df43f
02-Git: Add BL functionality
VitaliiPudov Oct 8, 2019
202263c
03-Bash: add empty file
VitaliiPudov Oct 14, 2019
99c1880
03-Bash: Add solution for print the quantity files
VitaliiPudov Oct 14, 2019
7901f44
03-Bash: Add quantity 'revert' commits implementation
VitaliiPudov Oct 14, 2019
6bb6017
03-Bash: Add empty script
Oct 15, 2019
f979b3c
03-Bash: Add check home solution
Oct 15, 2019
8ae9e65
03-Bash: Add solution for home folder owner checking
Oct 15, 2019
6c97f36
03-Bash: Add empty script
VitaliiPudov Oct 16, 2019
b3f4533
03-Bash: Add solution
VitaliiPudov Oct 16, 2019
7875258
03-Bash: Add statistic for authors
VitaliiPudov Oct 16, 2019
5e70f43
03-Make: Fix logical error
VitaliiPudov Oct 19, 2019
94ece4e
03-Make: Add Buy functionality
VitaliiPudov Oct 20, 2019
a9798d9
03-Make: Add receipt
VitaliiPudov Oct 20, 2019
dfd00b8
03-Make: Chanhge of makefile
Oct 22, 2019
578452c
04-Kernel: Add module
Oct 21, 2019
570821d
04-Kernel: Add parameter to module
VitaliiPudov Oct 22, 2019
15bb6c5
05-Interfaces: Add uppercase module
VitaliiPudov Nov 2, 2019
6e22c33
05-Interfaces: Add calls statistics
VitaliiPudov Nov 3, 2019
9669cd2
05-Interfaces: Add statistics
VitaliiPudov Nov 3, 2019
c4eed95
05-Interfaces: Add statistics
VitaliiPudov Nov 3, 2019
506955b
05-Interfaces: Add module (sysfs)
VitaliiPudov Nov 3, 2019
78c5028
05-Interfaces: Add Conversion
VitaliiPudov Nov 4, 2019
f1b4a59
05-Interfaces: Add calls statistics
VitaliiPudov Nov 4, 2019
0a4c7e0
05-Interfaces: Add statistics
VitaliiPudov Nov 4, 2019
8bb2345
06-Timing: Add absolute time returning
VitaliiPudov Nov 10, 2019
c7ada50
06-Timing: Add kernel module, timing
VitaliiPudov Nov 10, 2019
5174d17
06-Timing: Add module (timing)
VitaliiPudov Nov 10, 2019
9dfd727
06-Timing: Add CPU load
VitaliiPudov Nov 11, 2019
03a804f
07-Memory: Add userspace solution
VitaliiPudov Nov 17, 2019
95e7d52
07-Memory: Add memory managment kernel
VitaliiPudov Nov 17, 2019
2046e9c
mpu6050: Fix mpu6050 module
VitaliiPudov Dec 25, 2019
9ceeb06
mpu6050: Optimize source code
VitaliiPudov Dec 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions 02-Git/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Homework:

Create a rock-paper-scissors console game
(rules https://en.wikipedia.org/wiki/Rock%E2%80%93paper%E2%80%93scissors)

The game should be simple, the goal is to create a git project with proper commit order and structure. E.g.:

```
> Please choose: rock (r) - paper (p) - scissors (s)
> r
> You choose rock, I choose paper
> I win: paper beats rock
```
43 changes: 43 additions & 0 deletions 02-Git/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {

char human_val = 0, computer_val = 0;
time_t t;
const char str [3][10] = {"rock\n", "paper\n", "scissors\n"};
const char symbols[3] = {'r', 'p', 's'};

printf("rock-r, paper-p, scissors-s. Make your choose: \n");

// read value from keyboard
while ((human_val != 'r')
&& (human_val != 'p')
&& (human_val != 's')) {
human_val = getchar();
}

// generate random value for computer
srand((unsigned) time(&t));
int index = rand() % 3;
computer_val = symbols[index];

printf("Computer: %s", str[index]);

// comaring values and detection of winer
if (computer_val == human_val) {
printf("Nobody wins\n");
}
else if (((computer_val == 'r') && (human_val == 'p')) ||
((computer_val == 'p') && (human_val == 's')) ||
((computer_val == 's') && (human_val == 'r'))) {
printf("Human wins\n");
}
else {
printf("Computer wins\n");
}

return 0;

}
12 changes: 12 additions & 0 deletions 02-Git/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CC = gcc

CFLAGS = -g -Wall

TARGET = game_rsp

all: $(TARGET)

$(TARGET): main.c
$(CC) $(CFLAGS) -o $(TARGET) main.c
clean:
$(RM) $(TARGET) *.o
4 changes: 4 additions & 0 deletions 03-Bash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Homework Bash:

Create the scripts according to the tasks in subfolders.
Provide separate pull requests for each task.
14 changes: 14 additions & 0 deletions 03-Bash/find_dup_files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Homework Bash 2:

Create the script 'find_dup_files.sh'

First script parameter is the folder for searching.
In case of its absence the current folder should be used instead of it.
Print file names and file size for files with same md5 checksum.

Script should support command-line options:
-h, --help - print program description and these options.

Tips:
* use find utility for get list of files names
* use md5sum utility for checksum
40 changes: 40 additions & 0 deletions 03-Bash/find_dup_files/find_dup_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

display_help() {
echo "Usage: $0 [target directory]"
echo
echo " -h, --help - print these options"
echo
}

declare DYR_PATH

if [ "$#" -eq 0 ]; then
DYR_PATH="."
else
if [ "$1" = "--h" ] || [ "$1" = "--help" ]; then
display_help
exit 1
else
DYR_PATH="$1"
fi
fi

for pfile in $(find $DYR_PATH -type f -name "*");
do
echo $pfile -
MDSUM=($(md5sum $pfile))
if [ ! -z "$MDSUM" ]; then
for sfile in $(find $DYR_PATH -type f -exec md5sum {} + | grep "^$MDSUM");
do
if [ $sfile != $pfile ] && [ -f "$sfile" ]; then
echo $MDSUM :
echo size of $sfile \file is $(stat -c%s "$sfile")
fi
done
fi
done

echo
echo name of executed script:
echo $0
16 changes: 16 additions & 0 deletions 03-Bash/fix_owner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Homework Bash 1:

Create the script 'fix_owner.sh'

For every user in system with id >= 1000 check home folder.
In case of inequality of user's id and file/dir/link owner's id
ask for fixing it.
Do the same for default user's group file/dir/link group id.
Script should support command-line options:
-f, --force - fix without acknowledgement,
-h, --help - print these options.

Tips:
* use user's list from /etc/passwd
* for folder traversal use find utility
* for get users and group ids from line delimeted by : use cut -d\:
67 changes: 67 additions & 0 deletions 03-Bash/fix_owner/kernel_hm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

display_help() {
echo
echo "Usage: $0 [target directory]"
echo
echo " -f, --force - fix without asknowledgement"
echo " -h, --help - print these options"
echo
echo
}

ask_user_yes_no() {

read -p "Would you like to change owner? y/n " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
return 0
fi
return 1;
}

if [ "$1" = "--help" ] || [ "$1" = "--h" ]; then
display_help
exit 1
fi

# For every user in system with id >= 1000 check home folder.
# In case of inequality of user's id and file/dir/link owner's id
local_users=($( awk -F: '($3 >= 1000) {printf "%s\n",$1}' /etc/passwd))

for local_user in $(awk -F: '($3 >= 1000) {printf "%s\n",$1}' /etc/passwd);
do
echo $local_user
user_path=$(grep $local_user /etc/passwd|cut -f6 -d":")

if [ -d "$user_path" ]; then
echo "$user_path direcroty is present"

USERID=$(grep $local_user /etc/passwd|cut -f3 -d":")
echo Userid is $USERID

for cur_file in $(find "${user_path}" -name '*.*');
do
# get user and group id of owner
OWENER_USERID=$(stat -c '%u' $cur_file)
OWENER_GROUPID=$(stat -c '%g' $cur_file)

if [ -z "$OWENER_USERID" ] || [ -z "$OWENER_GROUPID" ] || [ $USERID != $OWENER_USERID ] || [ $USERID != $OWENER_GROUPID ]; then
echo Mismatch between User/Group ID and real Owner User ID
echo Real Owner Userid is $OWENER_USERID
echo Real Owner UserGroupid is $OWENER_GROUPID
if [ "$1" = "-f" ] || [ "$1" = "--force" ] || ask_user_yes_no; then
chown -R $USERID:$USERID $cur_file
echo permission \for $cur_file \file changed
fi
fi
done
else
echo "$user_path direcroty is not present"
fi
done

echo
echo name of executed script:
echo $0
15 changes: 15 additions & 0 deletions 03-Bash/kernel_git/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Homework Bash 3:

Create the script 'kernel_stats.sh'

Download mainline Linux repo from [email protected]:torvalds/linux.git

Print the quantity of files with extention .c, .cpp and *.py.

Find the quantity of commits with word 'revert' in commit name.

How many lines for each author are in *.py files.

Tips:
Use 'git blame' for getting info about source.
Use HEAD of master branch.
39 changes: 39 additions & 0 deletions 03-Bash/kernel_git/kernel_hm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

display_help() {
echo "Usage: $0 [target directory]"
echo
}

if [ "$#" -ne 1 ] || [ "$1" = "--h" ] || [ "$1" = "--help" ]; then
display_help
exit 1
fi

if [ ! -d "$1" ]; then
echo target directory does not exists
exit 1
fi

cd $1

# Print the quantity of files with extention .c, .cpp and *.py.
echo Quantity of files with extention .c in target diretory:
ls -lR | grep --count \.c$
echo Quantity of files with extention .cpp in target diretory:
ls -lR | grep --count \.cpp$
echo Quantity of files with extention .py in target diretory:
ls -lR | grep --count \.py$

# Find the quantity of commits with word 'revert' in commit name.
echo
echo Quantity of commits with word \'revert\'
git rev-list HEAD --count --grep='revert'

# How many lines for each author are in all *.py files in summury.
find -name "*.py" -exec \
git blame --line-porcelain {} \; | sed -n 's/^author //p' | sort | uniq -c | sort -rn

echo
echo name of executed script:
echo $0
72 changes: 72 additions & 0 deletions 03-Make/Cooking/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/make -f

PATHMARKET=food-market
PATHPOT=kitchen/table/pot/
PATHFPAN=kitchen/table/fpan/

SOURCE += salt.txt
SOURCE += chicken.txt
SOURCE += onion.txt
SOURCE += potato.txt
SOURCE += oil.txt
SOURCE += greenpeas.txt
SOURCE += carrot.txt

FOOD = $(addprefix $(PATHMARKET)/, $(SOURCE))

receipt_ready.txt: buy_food add_frying
./ready.sh

add_frying: add_greenpeas frying ${PATHPOT}
echo "Put the frying to the pot and boil 3 min" \
> ${PATHPOT}add_frying.txt

add_greenpeas: add_potato ${PATHPOT}
echo "Put 100 g of the $$(cat kitchen/table/greenpeas.txt)" \
" to the pot and boil 3 min" > ${PATHPOT}add_greenpeas.txt

add_potato: add_salt ${PATHPOT}
echo "Peel 50 g of the $$(cat kitchen/table/potato.txt),"\
" cut it, put to the pot"\
" and boil 20-30 min" > ${PATHPOT}add_potato.txt

frying: add_carrot add_onion add_oil ${PATHFPAN}
cat ${PATHFPAN}add_oil.txt > ${PATHFPAN}frying.txt
cat ${PATHFPAN}add_onion.txt >> ${PATHFPAN}frying.txt
cat ${PATHFPAN}add_carrot.txt >> ${PATHFPAN}frying.txt

add_carrot: add_onion ${PATHFPAN}
echo "Chop one $$(cat kitchen/table/carrot.txt),"\
" put it to the frying pan and fry it" > \
${PATHFPAN}add_carrot.txt

add_onion: add_oil ${PATHFPAN}
echo "Cut 1-2 st. of the $$(cat kitchen/table/onion.txt),"\
" put it to the frying pan and fry it" \
> ${PATHFPAN}add_onion.txt

add_oil: buy_food ${PATHFPAN}
echo "Put 50 g of the $$(cat kitchen/table/oil.txt)" \
" to the hot frying pan" > ${PATHFPAN}add_oil.txt

add_salt: add_chicken ${PATHPOT}
echo "Put the $$(cat kitchen/table/salt.txt) to the pot and mix it" > \
${PATHPOT}add_salt.txt

add_chicken: add_water ${PATHPOT}
echo "Put 500 g of the $$(cat kitchen/table/chicken.txt) to the pot" \
" and boil 60 min" > ${PATHPOT}add_chicken.txt

add_water: buy_food ${PATHPOT}
./get_water_from_faucet.sh 2000 kitchen/table/pot/add_water.txt

buy_food: create_res $(FOOD)
./buy_food_from_market.sh kitchen/table/receipt.txt

create_res:
./create_res.sh ${PATHMARKET} kitchen/faucet/

.PHONY: clean

clean:
find -type f -name "*.txt" -delete
25 changes: 25 additions & 0 deletions 03-Make/Cooking/buy_food_from_market.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# by foods in the market

CHIKEN=$(cat food-market/chicken.txt)
POTATO=$(cat food-market/potato.txt)
SALT=$(cat food-market/salt.txt)
ONION=$(cat food-market/onion.txt)
CARROT=$(cat food-market/carrot.txt)
OIL=$(cat food-market/oil.txt)
GREENPEAS=$(cat food-market/greenpeas.txt)

echo "Buy $CHIKEN, $POTATO, $CARROT, $SALT, $ONION, $OIL, $GREENPEAS" \
"in the food market" > $1

cp food-market/chicken.txt kitchen/table/
cp food-market/potato.txt kitchen/table/
cp food-market/carrot.txt kitchen/table/
cp food-market/onion.txt kitchen/table/
cp food-market/salt.txt kitchen/table/
cp food-market/oil.txt kitchen/table/
cp food-market/greenpeas.txt kitchen/table/



17 changes: 17 additions & 0 deletions 03-Make/Cooking/create_res.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash


mkdir -p food-market
mkdir -p kitchen
mkdir -p kitchen/table
mkdir -p kitchen/faucet
mkdir -p kitchen/table/fpan
mkdir -p kitchen/table/pot
echo "carrot" > ${1}/carrot.txt
echo "chicken" > ${1}/chicken.txt
echo "greenpeas" > ${1}/greenpeas.txt
echo "oil" > ${1}/oil.txt
echo "onion" > ${1}/onion.txt
echo "potato" > ${1}/potato.txt
echo "salt" > ${1}/salt.txt
echo "water" > ${2}/water.txt
5 changes: 5 additions & 0 deletions 03-Make/Cooking/get_water_from_faucet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

WATER=$(cat kitchen/faucet/water.txt)
echo "Put of $1 ml of $WATER to the pot" > $2

Loading