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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/metrics/hardware_class
diff --git a/src/platform/metrics/hardware_class b/src/platform/metrics/hardware_class
new file mode 100755
index 0000000000000000000000000000000000000000..c99db9b9e57edaa729f6fd0f962590a3bbd9b1c7
--- /dev/null
+++ b/src/platform/metrics/hardware_class
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This script prints the hardware class (e.g., the hardware
+# qualification ID) of this device, or "unknown" if it can't determine
+# the hardware class.
+
+# TODO(petkov): The hardware qualification ID is not available on
+# systems yet, so the script uses alternative ways to identify
+# different system classes (e.g., the WiFi adapter PCI vendor and
+# device IDs). Switch the script to use real hardware qualification ID
+# when that becomes available.
+
+# Appends a new component ID to the hardware class. Separates IDs with
+# dashes.
+append_class() {
+ [ -n "$HARDWARE_CLASS" ] && HARDWARE_CLASS="${HARDWARE_CLASS}-"
+ HARDWARE_CLASS="${HARDWARE_CLASS}$1"
+}
+
+# Adds the CPU family, model and stepping info, if available, to the
+# class.
+cpu() {
+ [ -r /proc/cpuinfo ] || return
+ FAMILY=`grep -m1 '^cpu family' /proc/cpuinfo \
+ | sed 's/cpu family\s\+:\s\+\([0-9]\+\)$/\1/'`
+ MODEL=`grep -m1 '^model' /proc/cpuinfo \
+ | sed 's/model\s\+:\s\+\([0-9]\+\)$/\1/'`
+ STEPPING=`grep -m1 '^stepping' /proc/cpuinfo \
+ | sed 's/stepping\s\+:\s\+\([0-9]\+\)$/\1/'`
+ if [ -n "$FAMILY" ] && [ -n "$MODEL" ] && [ -n "$STEPPING" ]; then
+ append_class "cpu/$FAMILY:$MODEL:$STEPPING"
+ fi
+}
+
+# Adds the wlan0 PCI vendor and device ID, if available, to the class.
+wlan() {
+ WLAN_DEV=/sys/class/net/wlan0/device
+ if [ -r $WLAN_DEV/vendor ] && [ -r $WLAN_DEV/device ]; then
+ WLAN_ID=`paste -d ':' $WLAN_DEV/vendor $WLAN_DEV/device | sed s/0x//g`
+ append_class "wlan0/$WLAN_ID"
+ fi
+}
+
+
+HARDWARE_CLASS=
+
+cpu
+wlan
+
+[ -z "$HARDWARE_CLASS" ] && HARDWARE_CLASS=unknown
+
+echo $HARDWARE_CLASS
« 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