first implementation of protobuf
restructure in client server model loads of work still missing
This commit is contained in:
33
ledd.py
33
ledd.py
@@ -32,41 +32,13 @@ Options:
|
||||
"""
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
from pkgutil import iter_modules
|
||||
import sys
|
||||
|
||||
import coloredlogs
|
||||
from docopt import docopt
|
||||
|
||||
import ledd.daemon
|
||||
import ledd
|
||||
|
||||
if "smbus" not in (name for loader, name, ispkg in iter_modules()):
|
||||
print("smbus not found, installing replacement")
|
||||
|
||||
|
||||
class SMBus:
|
||||
def __init__(self, i2c_address):
|
||||
self.i2c_address = i2c_address
|
||||
self.channels = {}
|
||||
|
||||
def write_word_data(self, addr, cmd, val):
|
||||
if (cmd - 6) % 4 == 0:
|
||||
self.channels[(cmd - 6) // 4] = val
|
||||
|
||||
def read_word_data(self, addr, cmd):
|
||||
if (cmd - 8) // 4 not in self.channels:
|
||||
self.channels[(cmd - 8) // 4] = 0
|
||||
return self.channels[(cmd - 8) // 4]
|
||||
|
||||
|
||||
class SMBusModule:
|
||||
SMBus = SMBus
|
||||
|
||||
|
||||
sys.modules['smbus'] = SMBusModule
|
||||
sys.modules['smbus'].SMBus = SMBus
|
||||
import ledd.daemon
|
||||
|
||||
|
||||
def pid_exists(processid):
|
||||
@@ -93,7 +65,6 @@ if __name__ == "__main__":
|
||||
lvl = logging.DEBUG
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
coloredlogs.install(level=lvl)
|
||||
|
||||
try:
|
||||
with open('ledd.pid', 'r') as f:
|
||||
|
Reference in New Issue
Block a user