diff options
author | Ferenc Wágner <wferi@niif.hu> | 2014-07-04 11:31:51 +0200 |
---|---|---|
committer | Ferenc Wágner <wferi@niif.hu> | 2014-10-11 21:59:16 +0200 |
commit | fa923837f1cfb18b85ff864139dc55562e7d5cf2 (patch) | |
tree | 72f544922239b872468d74e424ac58208eb9215d | |
parent | 43dd02b9d267cba29b997bacf3cf2e6067007c84 (diff) | |
download | syslinux-fa923837f1cfb18b85ff864139dc55562e7d5cf2.tar.gz syslinux-fa923837f1cfb18b85ff864139dc55562e7d5cf2.tar.xz syslinux-fa923837f1cfb18b85ff864139dc55562e7d5cf2.zip |
lua: docs: condense the PCI example
Signed-off-by: Ferenc Wágner <wferi@niif.hu>
-rw-r--r-- | com32/lua/doc/syslinux.asc | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/com32/lua/doc/syslinux.asc b/com32/lua/doc/syslinux.asc index dac8cee3..87dbb662 100644 --- a/com32/lua/doc/syslinux.asc +++ b/com32/lua/doc/syslinux.asc @@ -199,38 +199,15 @@ _Example_: ...................................................... local pci = require "pci" --- get nice output -printf = function(s,...) - return io.write(s:format(...)) - end - --- get device info -pciinfo = pci.getinfo() - --- get plain text device description pciids = pci.getidlist("/pci.ids") --- list all pci busses -for dind,device in pairs(pciinfo) do - - -- search for device description - search = string.format("%04x%04x", device.vendor, device.product) - - printf(" %04x:%04x:%04x:%04x = ", device.vendor, device.product, - device.sub_vendor, device.sub_product) - - if ( pciids[search] ) then - printf("%s\n", pciids[search]) - else - printf("Unknown\n") - end +for dind, device in pairs (pci.getinfo()) do + local vendor = string.format ("%04x", device.vendor) + local main_id = vendor .. string.format ("%04x", device.product) + local sub_id = string.format ("%04x%04x", device.sub_vendor, device.sub_product) + io.write (string.format ("%s:%s = %s %s (%s)\n", main_id, sub_id, pciids[vendor], + pciids[main_id], pciids[main_id .. sub_id] or "unknown subdevice")) end - --- print(pciids["8086"]) --- print(pciids["10543009"]) --- print(pciids["00700003"]) --- print(pciids["0070e817"]) --- print(pciids["1002437a1002437a"]) ...................................................... |