def __init__(self, serial_connection, radio_class=ZigBee, packet_filter=lambda a: True, **kwargs): SerialReader.__init__(self, None, 0, serial_connection) self.radio_class = radio_class self.radio_args = kwargs self.packet_filter = packet_filter
def __init__(self, port, baud, timeout=60, parity=serial.PARITY_NONE, stop_bits=serial.STOPBITS_ONE, radio_class=ZigBee, packet_filter=lambda a: True, **kwargs): SerialReader.__init__(self, None, 0, port, baud, timeout, parity, stop_bits) self.radio_class = radio_class self.radio_args = kwargs self.packet_filter = packet_filter
def setup(self): SerialReader.setup(self) if 'callback' in self.radio_args: cb = self.radio_args['callback'] del self.radio_args['callback'] else: cb = lambda frame: self.handle_frame(frame) self.radio = self.radio_class(self.stream, **self.radio_args) def filtered_callback(frame): if self.packet_filter(frame): cb(frame) self.radio._callback = filtered_callback self.radio._thread_continue = True self.radio.setDaemon(True) self.radio.start() self.radio.send("at", command="AI")
def setup(self): SerialReader.setup(self) if 'callback' in self.radio_args: cb = self.radio_args['callback'] del self.radio_args['callback'] else: cb = lambda frame: self.handle_frame(frame) self.radio = self.radio_class(self.stream, **self.radio_args) def filtered_callback(frame): if self.packet_filter(frame): cb(frame) def error_callback(e): self.logger.exception("Exception from radio: %s" % str(e)) self.radio._error_callback = error_callback self.radio._callback = filtered_callback self.radio._thread_continue = True self.radio.setDaemon(True) self.radio.start() self.radio.send("at", command="AI")
def close(self): SerialReader.close(self) self.radio._thread_continue = False self.radio = None
# # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from serial_grabber.reader import TransactionExtractor from serial_grabber.reader.SerialReader import SerialReader from serial_grabber.connections import TcpServer from serial_grabber.processor import LoggingProcessor # Serial Settings hostname = "127.0.0.1" port = 8099 # Settings cache_collision_avoidance_delay = 1 processor_sleep = 1 watchdog_sleep = 1 reader_error_sleep = 1 drop_carriage_return = True transaction = TransactionExtractor("default", "BEGIN DATA", "END DATA") tcp = TcpServer(hostname, port) reader = SerialReader(transaction, 1000, tcp) processor = LoggingProcessor()
from serial_grabber.reader.FileReader import FileReader from serial_grabber.reader.SerialReader import SerialReader from serial_grabber.processor.UploadProcessor import UploadProcessor #Serial Settings timeout = 1 port = "/dev/ttyUSB0" baud = 57600 parity = serial.PARITY_NONE stop_bits = 1 #Settings cache_collision_avoidance_delay = 1 processor_sleep = 1 watchdog_sleep = 1 reader_error_sleep = 1 drop_carriage_return = True transaction = TransactionExtractor("default", "BEGIN DATA", "END DATA") reader = SerialReader(transaction, 1000, port, baud, timeout=timeout, parity=parity, stop_bits=stop_bits) processor = UploadProcessor("https://example.org/cgi-bin/upload.py")