Commit dda1b05b by Czémán Arnold

freebsd: made SerialLineReceiverBase's delimiter platform specific

parent a108236a
from twisted.protocols.basic import LineReceiver from twisted.protocols.basic import LineReceiver
import json import json
import logging import logging
import platform
logger = logging.getLogger() logger = logging.getLogger()
system = platform.system()
class SerialLineReceiverBase(LineReceiver, object): class SerialLineReceiverBase(LineReceiver, object):
delimiter = '\n'
MAX_LENGTH = 1024*1024*128 MAX_LENGTH = 1024*1024*128
def __init__(self, *args, **kwargs):
if system == "FreeBSD":
self.delimiter = '\n'
self.delimiter = '\r'
super(SerialLineReceiverBase, self).__init__(*args, **kwargs)
def send_response(self, response, args): def send_response(self, response, args):
self.transport.write(json.dumps({'response': response, self.transport.write(json.dumps({'response': response,
'args': args}) + '\r\n') 'args': args}) + '\r\n')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment