Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #554 // Stefan's phone detect

Lua code

1  
--[[
2  
example connect in /var/log/syslog:
3  
4  
Apr  1 20:06:44 stefan-Aspire-3810T kernel: [  281.020329] usb 2-2: new high-speed USB device number 6 using ehci-pci"
5  
[...]
6  
Apr  1 20:06:44 stefan-Aspire-3810T kernel: [  281.153752] usb 2-2: Product: Cynus E1
7  
8  
example disconnect in same log:
9  
10  
Apr  1 20:07:23 stefan-Aspire-3810T kernel: [  319.671170] usb 2-2: USB disconnect, device number 6
11  
12  
phone in output of "usb-devices":
13  
14  
[blank line]
15  
T:  Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  8 Spd=480 MxCh= 0
16  
D:  Ver= 2.00 Cls=e0(wlcon) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
17  
P:  Vendor=0bb4 ProdID=0003 Rev=02.55
18  
S:  Manufacturer=MediaTek
19  
S:  Product=Cynus E1
20  
S:  SerialNumber=0123456789ABCDEF
21  
C:  #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=500mA
22  
I:  If#= 0 Alt= 0 #EPs= 1 Cls=e0(wlcon) Sub=01 Prot=03 Driver=rndis_host
23  
I:  If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=rndis_host
24  
[blank line]
25  
26  
]]
27  
28  
get("#515") -- splitLines
29  
30  
bla = os_backtick('usb-devices')
31  
lines = splitLines(bla)
32  
33  
for _, line in ipairs(lines) do
34  
  if line:match("S:%s+Product=Cynus E1") then
35  
    print("Phone connected!")
36  
    return
37  
  end
38  
end
39  
40  
print("Phone not connected!")

test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
51 stefan Works!!

run -power -offline 554
2015-04-01 20:20:57

add comment

Snippet ID: #554
Snippet name: Stefan's phone detect
Eternal ID of this version: #554/1
Text MD5: 473b373bade3e213e08676173c4a0e06
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-04-01 20:18:51
Source code size: 1168 bytes / 40 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1015 / 183
Referenced in: [show references]