Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: src/platform/metrics/hardware_class

Issue 2289001: A script to print the hardware class (e.g., hwqual ID) of the device. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Add cpu info. Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/sh
2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # This script prints the hardware class (e.g., the hardware
8 # qualification ID) of this device, or "unknown" if it can't determine
9 # the hardware class.
10
11 # TODO(petkov): The hardware qualification ID is not available on
12 # systems yet, so the script uses alternative ways to identify
13 # different system classes (e.g., the WiFi adapter PCI vendor and
14 # device IDs). Switch the script to use real hardware qualification ID
15 # when that becomes available.
16
17 # Appends a new component ID to the hardware class. Separates IDs with
18 # dashes.
19 append_class() {
20 [ -n "$HARDWARE_CLASS" ] && HARDWARE_CLASS="${HARDWARE_CLASS}-"
21 HARDWARE_CLASS="${HARDWARE_CLASS}$1"
22 }
23
24 # Adds the CPU family, model and stepping info, if available, to the
25 # class.
26 cpu() {
27 [ -r /proc/cpuinfo ] || return
28 FAMILY=`grep -m1 '^cpu family' /proc/cpuinfo \
29 | sed 's/cpu family\s\+:\s\+\([0-9]\+\)$/\1/'`
30 MODEL=`grep -m1 '^model' /proc/cpuinfo \
31 | sed 's/model\s\+:\s\+\([0-9]\+\)$/\1/'`
32 STEPPING=`grep -m1 '^stepping' /proc/cpuinfo \
33 | sed 's/stepping\s\+:\s\+\([0-9]\+\)$/\1/'`
34 if [ -n "$FAMILY" ] && [ -n "$MODEL" ] && [ -n "$STEPPING" ]; then
35 append_class "cpu/$FAMILY:$MODEL:$STEPPING"
36 fi
37 }
38
39 # Adds the wlan0 PCI vendor and device ID, if available, to the class.
40 wlan() {
41 WLAN_DEV=/sys/class/net/wlan0/device
42 if [ -r $WLAN_DEV/vendor ] && [ -r $WLAN_DEV/device ]; then
43 WLAN_ID=`paste -d ':' $WLAN_DEV/vendor $WLAN_DEV/device | sed s/0x//g`
44 append_class "wlan0/$WLAN_ID"
45 fi
46 }
47
48
49 HARDWARE_CLASS=
50
51 cpu
52 wlan
53
54 [ -z "$HARDWARE_CLASS" ] && HARDWARE_CLASS=unknown
55
56 echo $HARDWARE_CLASS
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698