def build_packet(self, message): """ Creates a ready to send modbus packet :param message: The populated request/response to send """ data = message.encode() packet = struct.pack('>BB', message.unit_id, message.function_code) + data packet += struct.pack('>H', compute_crc(packet)) return packet
def build_packet(self, message): """ Creates a ready to send modbus packet :param message: The request/response to send :returns: The encoded packet """ data = self._preflight(message.encode()) packet = struct.pack('>BB', message.unit_id, message.function_code) + data packet += struct.pack(">H", compute_crc(packet)) packet = self.__start + packet + self.__end return packet
def build_packet(self, message): """ Creates a ready to send modbus packet :param message: The populated request/response to send """ data = message.encode() packet = struct.pack( '>BB', message.unit_id, message.function_code ) + data packet += struct.pack('>H', compute_crc(packet)) return packet
def build_packet(self, message): """ Creates a ready to send modbus packet :param message: The request/response to send :returns: The encoded packet """ data = self._preflight(message.encode()) packet = struct.pack( '>BB', message.unit_id, message.function_code ) + data packet += struct.pack(">H", compute_crc(packet)) packet = self.__start + packet + self.__end return packet