Add package in imports.
This commit is contained in:
parent
93a226ff79
commit
fe232de1b7
|
@ -27,7 +27,7 @@
|
|||
'''
|
||||
|
||||
|
||||
from _exceptions import MalformedDataError
|
||||
from librfid._exceptions import MalformedDataError
|
||||
|
||||
|
||||
def inventory(response):
|
||||
|
|
32
models.py
32
models.py
|
@ -23,20 +23,22 @@
|
|||
'''
|
||||
|
||||
|
||||
import utils
|
||||
from datetime import datetime
|
||||
|
||||
import core_standard
|
||||
|
||||
from serial import (Serial, EIGHTBITS, PARITY_NONE, STOPBITS_ONE)
|
||||
from _exceptions import (UnknownReaderTypeException, UnknownReaderException,
|
||||
|
||||
|
||||
import librfid.core_standard
|
||||
|
||||
|
||||
from librfid.utils import get_length_on_2_bytes, get_crc_16_CCITT
|
||||
from librfid._exceptions import (UnknownReaderTypeException, UnknownReaderException,
|
||||
BadLengthMessageException, BadCRCException,
|
||||
CommandResponseCodeMismatchException, UnknownReaderException,
|
||||
StandardResponseError, UnknownResponseErrorType,
|
||||
ReaderResponseError)
|
||||
from commands_standard import COMMANDS as STANDARD_COMMANDS
|
||||
from errors_standard import ERRORS as STANDARD_ERRORS
|
||||
from reader_configs import READERS
|
||||
from librfid.commands_standard import COMMANDS as STANDARD_COMMANDS
|
||||
from librfid.errors_standard import ERRORS as STANDARD_ERRORS
|
||||
from librfid.reader_configs import READERS
|
||||
|
||||
|
||||
class RFIDReader():
|
||||
|
@ -155,7 +157,7 @@ class Command():
|
|||
self.data = kwargs.pop('data', '')
|
||||
if self.data:
|
||||
self.process_data()
|
||||
self.lout = utils.get_length_on_2_bytes(self.raw_data)
|
||||
self.lout = get_length_on_2_bytes(self.raw_data)
|
||||
self.command = self.rfu + self.type_cmd + self.code_cmd + \
|
||||
self.reserved + self.lout + self.raw_data
|
||||
|
||||
|
@ -164,17 +166,17 @@ class Command():
|
|||
|
||||
def process_data(self):
|
||||
try:
|
||||
getattr(core_standard, self.command_name.lower())(self)
|
||||
getattr(librfid.core_standard, self.command_name.lower())(self)
|
||||
except:
|
||||
pass
|
||||
|
||||
def build_message(self):
|
||||
self.sof = '\x02'
|
||||
self.length = utils.get_length_on_2_bytes(self.command)
|
||||
self.length = get_length_on_2_bytes(self.command)
|
||||
self.ctrl_addr = '\x00' # RS232 only
|
||||
self.ctrl_mode = '\x00' # Unsecure mode
|
||||
message = self.length + self.ctrl_addr + self.ctrl_mode + self.command
|
||||
self.crc = utils.get_crc_16_CCITT(message)
|
||||
self.crc = get_crc_16_CCITT(message)
|
||||
self.message = self.sof + message + self.crc
|
||||
|
||||
def get_message(self):
|
||||
|
@ -227,7 +229,7 @@ class ReaderCommand(Command):
|
|||
self.data = kwargs.pop('data', '')
|
||||
if self.data:
|
||||
self.process_data()
|
||||
self.lout = utils.get_length_on_2_bytes(self.raw_data)
|
||||
self.lout = get_length_on_2_bytes(self.raw_data)
|
||||
self.command = self.rfu + self.type_cmd + self.code_cmd + \
|
||||
self.reserved + self.lout + self.raw_data
|
||||
|
||||
|
@ -259,7 +261,7 @@ class Response():
|
|||
self.response = message[5:-2]
|
||||
self.crc = message[-2:]
|
||||
str_to_check = self.message[1:-2] # [Len ... Commande]
|
||||
crc = utils.get_crc_16_CCITT(str_to_check)
|
||||
crc = get_crc_16_CCITT(str_to_check)
|
||||
if self.crc != crc:
|
||||
raise BadCRCException('CRC checking failed')
|
||||
self.code = self.response[0:2]
|
||||
|
@ -313,7 +315,7 @@ class Response():
|
|||
if isinstance(self.command, ReaderCommand):
|
||||
module = self.command.reader.core
|
||||
else:
|
||||
module = core_standard
|
||||
module = librfid.core_standard
|
||||
getattr(module, core_method_name)(self)
|
||||
except Exception, e:
|
||||
pass
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
'''
|
||||
|
||||
|
||||
from stid_readers.commands_basic import COMMANDS as BASIC_STID_COMMANDS
|
||||
from stid_readers.params_basic import PARAMS as BASIC_STID_PARAMS
|
||||
from stid_readers.errors_basic import ERRORS as BASIC_STID_ERRORS
|
||||
from stid_readers import core as BASIC_STID_CORE
|
||||
from librfid.stid_readers.commands_basic import COMMANDS as BASIC_STID_COMMANDS
|
||||
from librfid.stid_readers.params_basic import PARAMS as BASIC_STID_PARAMS
|
||||
from librfid.stid_readers.errors_basic import ERRORS as BASIC_STID_ERRORS
|
||||
from librfid.stid_readers import core as BASIC_STID_CORE
|
||||
|
||||
|
||||
READERS = {
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
'''
|
||||
|
||||
|
||||
from _exceptions import MalformedDataError, BadParameterException
|
||||
from utils import get_integer_on_two_bytes, hex_to_int
|
||||
from librfid._exceptions import MalformedDataError, BadParameterException
|
||||
from librfid.utils import get_integer_on_two_bytes, hex_to_int
|
||||
|
||||
|
||||
def get_rfsettings(response):
|
||||
|
|
Reference in New Issue