From 11c061c8edc3677bf4a11671ee8ccb76f83f1080 Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Mon, 18 Nov 2013 14:13:17 +0100 Subject: [PATCH] api usb info --- src/rest/api/api_info.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/rest/api/api_info.lua b/src/rest/api/api_info.lua index 6645064..b824215 100644 --- a/src/rest/api/api_info.lua +++ b/src/rest/api/api_info.lua @@ -111,6 +111,24 @@ function M.access(request, response) return true end +function M.usb(request, response) + + response:setSuccess() + + local file, error = io.open("/sys/devices/platform/ehci-platform/usb1/1-1/speed",'r') + if file ~= nil then + local speed = file:read('*a') + file:close() + speed = tonumber(speed) + response:addData('speed', speed) + + -- check usb device speed + -- http://stackoverflow.com/questions/1957589/usb-port-speed-linux + local highSpeed = (speed == 480) + response:addData('highSpeed', highSpeed) + end +end + function M.status(request, response) local ds = wifi.getDeviceState()