Serial Port Does Not Work In Rewritten Python Code
I have a Python program that reads some parameters from an Arduino and stores it in a database. The serial port is set up and used like this: ser = serial.Serial(port=port, baudrat
Solution 1:
During the daemonization of your app, all file handlers are closed except stdin, stderr and stdout. This includes the connection to /dev/log
, which then fails with the fd error (so it looks like this has nothing to do with the serial fd, but instead with the handler's socket).
You need either to add this FD to the exclusion list:
classApp():def__init__(self):
...
self.files_preserve = [handler.socket]
...
Or alternatively, set up the handler after the daemon process forked:
class App():
def run(self):
handler = logging.handlers.SysLogHandler(address = '/dev/log')
my_logger.addHandler(handler)
my_logger.debug(appname+': Starting up storedata')
...
Both version ran fine during my tests.
Post a Comment for "Serial Port Does Not Work In Rewritten Python Code"