diff options
author | Mykola Salomatin <mykola.salomatin@globallogic.com> | 2022-05-05 12:28:37 +0300 |
---|---|---|
committer | Mykola Salomatin <mykola.salomatin@globallogic.com> | 2022-05-05 12:28:37 +0300 |
commit | 76bdabe5709107f664a3d851ac2d3eb7a7073dd3 (patch) | |
tree | 43cff2ae4c3c8f104f5dd0623dbf064c6d4c1838 /recipes-connectivity/bluez/bluez5/rfcomm | |
parent | eeb29ee4deaa89e4f10bc193fb9e6714e420aece (diff) | |
parent | ca1aadba53b3683386bc034451212b8317492a83 (diff) | |
download | meta-mlinux-76bdabe5709107f664a3d851ac2d3eb7a7073dd3.tar.gz meta-mlinux-76bdabe5709107f664a3d851ac2d3eb7a7073dd3.tar.bz2 meta-mlinux-76bdabe5709107f664a3d851ac2d3eb7a7073dd3.zip |
Merge remote-tracking branch 'origin/6' into mpower-dev-nxp
Diffstat (limited to 'recipes-connectivity/bluez/bluez5/rfcomm')
-rwxr-xr-x | recipes-connectivity/bluez/bluez5/rfcomm/init | 8 | ||||
-rw-r--r-- | recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py | 29 |
2 files changed, 17 insertions, 20 deletions
diff --git a/recipes-connectivity/bluez/bluez5/rfcomm/init b/recipes-connectivity/bluez/bluez5/rfcomm/init index 69455d8..08366ea 100755 --- a/recipes-connectivity/bluez/bluez5/rfcomm/init +++ b/recipes-connectivity/bluez/bluez5/rfcomm/init @@ -2,7 +2,7 @@ NAME=rfcomm SERVER=/usr/libexec/bluetooth/${NAME} -PYTHON=$(readlink -f /usr/bin/python2) +PYTHON=$(readlink -f /usr/bin/python) PIDFILE="/run/${NAME}.pid" ENABLED=yes @@ -16,12 +16,12 @@ fi case $1 in start) echo "Starting ${NAME}" - echo /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -x ${PYTHON} -b -- ${SERVER} ${RFCOMMOPTS} - /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -x ${PYTHON} -b -- ${SERVER} ${RFCOMMOPTS} + echo /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -a ${SERVER} -n ${NAME} -b -- ${RFCOMMOPTS} + /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -a ${SERVER} -n ${NAME} -b -- ${RFCOMMOPTS} ;; stop) - /usr/sbin/start-stop-daemon -K -p ${PIDFILE} -x ${PYTHON} + /usr/bin/pkill --ns $(cat "$PIDFILE") -f " ${SERVER} " echo "Stopping ${DNAME}" ;; diff --git a/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py b/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py index e8f2554..cf8fec4 100644 --- a/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py +++ b/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python2 -import thread +#!/usr/bin/env python import os import dbus import dbus.service @@ -16,9 +15,7 @@ import grp import stat import atexit import re -import mmap import subprocess -import threading import struct import fcntl import termios @@ -298,9 +295,9 @@ class Profile(dbus.service.Object): # Bluetooth address portion of the path address = os.path.basename(self.path) - numaddr = address[address.find("_")+1:] + numaddr = address[address.find("_")+1:] # Replace _ with : - Name = bluetooth.lookup_name(numaddr.replace("_",":")) + Name = bluetooth.lookup_name(numaddr.replace("_",":")) print('NewConnection(%s, %s, %s:%d)' % (path,Name,type(fd).__name__,self.fd)) lg.info('NewConnection(%s, %s, %s:%d)' % (path,Name,type(fd).__name__,self.fd)) @@ -316,18 +313,18 @@ class Profile(dbus.service.Object): lg.debug('pseudoterminal major and minor: (%d,%d)' % (os.major(slavestat.st_rdev),self.minor)) if not os.path.isdir(RFCOMMDIR): lg.debug('Before mkdir: RFCOMMDIR %s' % (RFCOMMDIR)) - os.mkdir(RFCOMMDIR,0755) + os.mkdir(RFCOMMDIR,0o755) lg.debug('Address %s' % (address)) self.linkPath = RFCOMMDIR + '/' + address + '_' + Name + '_pts' + str(self.minor) - self.slavePath = SLAVEDIR + '/' + str(self.minor) + self.slavePath = SLAVEDIR + '/' + str(self.minor) lg.debug('termPath %s' % (self.linkPath)) self.removeLink(self.notexiting) # linkPath was removed lg.debug('os.symlink(%s,%s)' % (self.slavePath,self.linkPath)) - old = os.umask(002) + old = os.umask(0o002) lg.debug('past umask') try: os.symlink(self.slavePath,self.linkPath) @@ -471,7 +468,7 @@ class Profile(dbus.service.Object): try: os.write(self.fd,data) except Exception as e: - print '%s' % (e) + print('%s' % e) lg.error('%s' % (e)) self.RequestDisconnection(self.path) return True @@ -563,12 +560,12 @@ if __name__ == '__main__': if opts.pseudoterminal and opts.loopback: msg = 'Cannot have both pseudoterminal and loopback option' - print msg + print(msg) lg.error(msg) exit(1) if not opts.pseudoterminal and not opts.loopback and not opts.login: doterm = True - print "main: doterm is %s" % (str(doterm)) + print("main: doterm is %s" % (str(doterm))) if opts.pseudoterminal or opts.login: needpseudot = True @@ -594,7 +591,7 @@ if __name__ == '__main__': rpipe,wpipe = os.pipe() loginProcess = logins() Profile.w = wpipe - lg.debug('Call threading next') + lg.debug('Call StartLogin threading next') try: StartLoginThread = threading.Thread(target=loginProcess.StartLogin,args=[rpipe,mainloop]) except Exception as e: @@ -621,10 +618,10 @@ if __name__ == '__main__': try: manager.RegisterProfile(profile_path, opts.uuid, SPP_opts) except dbus.exceptions.DBusException as inst: - print 'dbus exception:',inst._dbus_error_name + print('dbus exception:',inst._dbus_error_name) lg.error('dbus exception: %s',inst._dbus_error_name) if inst._dbus_error_name == 'org.freedesktop.DBus.Error.AccessDenied': - print 'Try running as root' + print('Try running as root') exit(1) lg.debug('Completed Register Profile...') @@ -636,7 +633,7 @@ if __name__ == '__main__': pass except Exception as e: lg.error('mainloop exception: %s' % (e)) - print '\nSerial Port Profile: ERROR Goodbye' + print('\nSerial Port Profile: ERROR Goodbye') lg.error('Serial Port Profile: ERROR Goodbye') data = struct.pack('i',-1) os.write(wpipe,data) |