[IMP] hw_blackbox_be: implement support for registered POSBoxes

POSBoxes will be registered with the government. If a POSBox is not
registered it won't load the blackbox driver, preventing communication
with the Fiscal Data Module.
This commit is contained in:
Joren Van Onder 2016-02-22 14:10:59 +01:00
parent f5cc04caa7
commit 9df2921743
1 changed files with 16 additions and 9 deletions

View File

@ -3,6 +3,8 @@
import logging
import serial
import subprocess
from os.path import isfile
from os import listdir
from threading import Thread, Lock
@ -148,6 +150,7 @@ class Blackbox(Thread):
ser.close()
return ""
if isfile("/home/pi/registered_blackbox_be"):
blackbox_thread = Blackbox()
hw_proxy.drivers['fiscal_data_module'] = blackbox_thread
@ -160,3 +163,7 @@ class BlackboxDriver(hw_proxy.Proxy):
response = blackbox_thread._send_to_blackbox(to_send, response_size, blackbox_thread.device_path)
return response
@http.route('/hw_proxy/request_serial/', type='json', auth='none', cors='*')
def request_serial(self):
return subprocess.check_output("ifconfig eth0 | grep -o 'HWaddr.*' | sed 's/HWaddr \\(.*\\)/\\1/' | sed 's/://g'", shell=True).rstrip()[-7:]