-
Notifications
You must be signed in to change notification settings - Fork 28
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
Hwdetect task #109
base: Maryna.Malakhova
Are you sure you want to change the base?
Hwdetect task #109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marynamalakhova,
In general - OK,
but see my comments inline.
hwdetect/hwdetect.sh
Outdated
#!/bin/sh | ||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing interpreter deserves at least to be mentioned in the commit message (with reasoning).
hwdetect/hwdetect.sh
Outdated
exit 0 | ||
;; | ||
*) echo "Invalid option $REPLY";; | ||
esac |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong indentation
hwdetect/hwdetect.sh
Outdated
function find_sdcard() | ||
{ | ||
echo "SDcards" | ||
} | ||
|
||
function find_i2c() | ||
{ | ||
echo "i2c" | ||
echo $(ls /dev | grep i2c) | ||
} | ||
|
||
function find_usb_ttl() | ||
{ | ||
echo "usb_ttl" | ||
echo $(ls /dev | grep tty) | ||
} | ||
|
||
function find_flash() | ||
function find_sd_card() | ||
{ | ||
echo "flash" | ||
echo "sd card" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit f80508a states that it only implements find_flash()
, but actually it contains implementation of find_i2c()
, find_usb_ttl()
and renaming find_sdcard()
.
Commit message should reflect actual changes.
But better to really separate not connected changes into different patches.
hwdetect/hwdetect.sh
Outdated
echo "Please install it before" | ||
return -1 | ||
fi | ||
lsblk -rno SIZE,NAME,HOTPLUG,MOUNTPOINT | grep -w 1| grep -vE "sr|loop" | awk '{if ($4!="") print $1," ",$4}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither commit message nor code explains why such not obvious processing (like grep -w 1
and others) is applied.
(also please don't forget to separate pipes with spaces)
mapfile -t i2c_array < <(ls /dev | grep i2c) | ||
for i in ${i2c_array[@]}; do | ||
echo $i | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- inconsistent indentation;
Not mistake, but I'm just curious why arrays are used here if the results are actually not processed in any way which requires it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided that it could be processed later, but I had no opportunity to check the workflow of this part of the script on my laptop. Probably I`ll check it later on the board.
hwdetect/hwdetect.sh
Outdated
@@ -15,7 +18,6 @@ function find_sd_card() | |||
echo "sd card" | |||
} | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply such changes inplace to not pollute functional changes.
hwdetect/hwdetect.sh
Outdated
(ls /dev | grep mmcblk) > newsdcard | ||
lsusb | grep -i storage >> newsdcard | ||
diff sdcard newsdcard | awk -F'>' '{if ($2!="") print "Added ", $2}' | ||
diff sdcard newsdcard | awk -F'<' '{if ($2!="") print "Removed ", $2}' | ||
cat newsdcard > sdcard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creation files in working directory when user doesn't expect this is definitely bad idea.
You should use /tmp/
, etc. for such purpose.
Or if you don't need to preserve state between launches - files aren't needed at all - variables should be enough.
BTW, have you seen lsusb
showing device with "storage" in description?
Is it block device?
(Because in my case only cardreader itself is seen and it doesn't have "storage" in description)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no SDcard reader in GL laptop, but I have separate SDCard reader via usb and it is detected as usb staorage device. It is observed as 'sda' but not 'mmcblk'
14d07b9
to
0b2d3d2
Compare
Thank you for review. I`ve fixed |
0b2d3d2
to
ec33c71
Compare
Add util main menu. There are for options. There is proposition to find the list of: -USB to TTL convertors, -flash drives, -SD cards, -i2c devices Signed-off-by: Maryna Malakhova <[email protected]>
Add function to detect Flash disks via lsblk tool Filter lsblk result by grep command and awk script in order to get userfriendly output Signed-off-by: Maryna Malakhova <[email protected]>
Add i2c slot lister Signed-off-by: Maryna Malakhova <[email protected]>
Add usb-serial converter but without /dev/ttyUSBn Signed-off-by: Maryna Malakhova <[email protected]>
Add SD card finder via mmcblk checking in /dev and looking for usb Signed-off-by: Maryna Malakhova <[email protected]>
1e0b49e
to
09e2349
Compare
Hardware detector bash script implemented