I was trying to scan ble devices using hcitool lescan in a python code. The hcitool lescan works well on the command line but fails to return any output using subprocess.Popen.The code works fine when lescan is replaced with 'scan' ie scan of conventional bluetooth. My code is:
import os
import time
import subprocess
proc = subprocess.Popen(['sudo','timeout', '20s','hcitool', 'lescan'],stdout=subprocess.PIPE)
proc.wait()
lines = proc.stdout.readlines()
print lines