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

Hwdetect task #109

Open
wants to merge 5 commits into
base: Maryna.Malakhova
Choose a base branch
from

Conversation

marynamalakhova
Copy link

Hardware detector bash script implemented

Copy link

@AleksandrBulyshchenko AleksandrBulyshchenko left a 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.

#!/bin/sh
#!/bin/bash

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).

exit 0
;;
*) echo "Invalid option $REPLY";;
esac

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indentation

Comment on lines 3 to 29
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"
}

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.

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}'

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)

Comment on lines +5 to +14
mapfile -t i2c_array < <(ls /dev | grep i2c)
for i in ${i2c_array[@]}; do
echo $i
done

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?

Copy link
Author

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.

@@ -15,7 +18,6 @@ function find_sd_card()
echo "sd card"
}


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.

Comment on lines 24 to 28
(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

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)

Copy link
Author

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'

@AleksandrBulyshchenko AleksandrBulyshchenko added Change requested Change requested and removed Ready for review Ready for review labels Apr 2, 2021
@marynamalakhova marynamalakhova force-pushed the hwdetector branch 4 times, most recently from 14d07b9 to 0b2d3d2 Compare April 2, 2021 10:26
@marynamalakhova
Copy link
Author

Thank you for review. I`ve fixed

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]>
@marynamalakhova marynamalakhova force-pushed the hwdetector branch 2 times, most recently from 1e0b49e to 09e2349 Compare April 6, 2021 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready for review Ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants