mirror of
https://github.com/google/pebble.git
synced 2025-05-17 17:04:53 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
74
tools/pebble_tty.py
Normal file
74
tools/pebble_tty.py
Normal file
|
@ -0,0 +1,74 @@
|
|||
# Copyright 2024 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# PyFTDI doesn't work if these KEXTs are loaded
|
||||
KEXT_BLACKLIST = [
|
||||
'AppleUSBFTDI',
|
||||
'FTDIUSBSerialDriver'
|
||||
]
|
||||
|
||||
def _is_driver_loaded():
|
||||
loaded = False
|
||||
if sys.platform == 'darwin':
|
||||
output = subprocess.check_output(['kextstat'])
|
||||
for kext in KEXT_BLACKLIST:
|
||||
if kext in output:
|
||||
loaded = True
|
||||
break
|
||||
|
||||
if loaded:
|
||||
print 'WARNING: FTDI DRIVERS ARE DEPRECATED, UNINSTALL THEM!'
|
||||
|
||||
return loaded
|
||||
|
||||
if _is_driver_loaded():
|
||||
from pebble_tty_native import _get_tty
|
||||
else:
|
||||
from pebble_tty_pyftdi import _get_tty
|
||||
|
||||
|
||||
def find_accessory_tty():
|
||||
return _get_tty(tty_type="accessory")
|
||||
|
||||
|
||||
def find_dbgserial_tty():
|
||||
return _get_tty(tty_type="primary")
|
||||
|
||||
|
||||
def find_ble_tty():
|
||||
return _get_tty(tty_type="ble")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
tty_acc = find_accessory_tty()
|
||||
tty_dbg = find_dbgserial_tty()
|
||||
tty_ble = find_ble_tty()
|
||||
|
||||
if tty_dbg:
|
||||
print 'dbgserial: ' + str(tty_dbg)
|
||||
else:
|
||||
print 'no dbgserial tty found'
|
||||
|
||||
if tty_acc:
|
||||
print 'accessory: ' + str(tty_acc)
|
||||
else:
|
||||
print 'no accessory tty found'
|
||||
|
||||
if tty_ble:
|
||||
print 'ble: ' + str(tty_ble)
|
||||
else:
|
||||
print 'no ble tty found'
|
Loading…
Add table
Add a link
Reference in a new issue