--[[ example connect in /var/log/syslog: Apr 1 20:06:44 stefan-Aspire-3810T kernel: [ 281.020329] usb 2-2: new high-speed USB device number 6 using ehci-pci" [...] Apr 1 20:06:44 stefan-Aspire-3810T kernel: [ 281.153752] usb 2-2: Product: Cynus E1 example disconnect in same log: Apr 1 20:07:23 stefan-Aspire-3810T kernel: [ 319.671170] usb 2-2: USB disconnect, device number 6 phone in output of "usb-devices": [blank line] T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 8 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=e0(wlcon) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=0bb4 ProdID=0003 Rev=02.55 S: Manufacturer=MediaTek S: Product=Cynus E1 S: SerialNumber=0123456789ABCDEF C: #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 1 Cls=e0(wlcon) Sub=01 Prot=03 Driver=rndis_host I: If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=rndis_host [blank line] ]] get("#515") -- splitLines bla = os_backtick('usb-devices') lines = splitLines(bla) for _, line in ipairs(lines) do if line:match("S:%s+Product=Cynus E1") then print("Phone connected!") return end end 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
ID | Author/Program | Comment | Date |
---|---|---|---|
51 | stefan | Works!!
run -power -offline 554 | 2015-04-01 20:20:57 |
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: | 1117 / 204 |
Referenced in: | [show references] |