[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:
parent
f5cc04caa7
commit
9df2921743
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import serial
|
import serial
|
||||||
|
import subprocess
|
||||||
|
from os.path import isfile
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
|
|
||||||
|
@ -148,15 +150,20 @@ class Blackbox(Thread):
|
||||||
ser.close()
|
ser.close()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
blackbox_thread = Blackbox()
|
if isfile("/home/pi/registered_blackbox_be"):
|
||||||
hw_proxy.drivers['fiscal_data_module'] = blackbox_thread
|
blackbox_thread = Blackbox()
|
||||||
|
hw_proxy.drivers['fiscal_data_module'] = blackbox_thread
|
||||||
|
|
||||||
class BlackboxDriver(hw_proxy.Proxy):
|
class BlackboxDriver(hw_proxy.Proxy):
|
||||||
@http.route('/hw_proxy/request_blackbox/', type='json', auth='none', cors='*')
|
@http.route('/hw_proxy/request_blackbox/', type='json', auth='none', cors='*')
|
||||||
def request_blackbox(self, high_level_message, response_size):
|
def request_blackbox(self, high_level_message, response_size):
|
||||||
to_send = blackbox_thread._wrap_low_level_message_around(high_level_message)
|
to_send = blackbox_thread._wrap_low_level_message_around(high_level_message)
|
||||||
|
|
||||||
with blackbox_thread.blackbox_lock:
|
with blackbox_thread.blackbox_lock:
|
||||||
response = blackbox_thread._send_to_blackbox(to_send, response_size, blackbox_thread.device_path)
|
response = blackbox_thread._send_to_blackbox(to_send, response_size, blackbox_thread.device_path)
|
||||||
|
|
||||||
return response
|
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:]
|
||||||
|
|
Loading…
Reference in New Issue