Skip to content

Hwdetect task#109

Open
marynamalakhova wants to merge 5 commits intoKernel-GL-HRK:Maryna.Malakhovafrom
marynamalakhova:hwdetector
Open

Hwdetect task#109
marynamalakhova wants to merge 5 commits intoKernel-GL-HRK:Maryna.Malakhovafrom
marynamalakhova:hwdetector

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.

@@ -1,4 +1,54 @@
#!/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.

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

@marynamalakhova marynamalakhova added Ready for review Ready for review and removed Change requested Change requested labels Apr 2, 2021
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 <maryna.malakhova@globallogic.com>
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 <maryna.malakhova@globallogic.com>
Add i2c slot lister

Signed-off-by: Maryna Malakhova <maryna.malakhova@globallogic.com>
Add usb-serial converter but without /dev/ttyUSBn

Signed-off-by: Maryna Malakhova <maryna.malakhova@globallogic.com>
Add SD card finder via mmcblk checking in /dev and looking for usb

Signed-off-by: Maryna Malakhova <maryna.malakhova@globallogic.com>
@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