def _handshake(self): self._write_reg("main_control", "stop", expect_response=False) exp_addr = protocol.get_addr_for_reg("main_control") exp_enc_val = protocol.encode_reg_val("main_control", "stop") exp_reg_val = protocol.UnpackedRegVal(exp_addr, exp_enc_val) exp_packet = protocol.UnpackedRegWriteResponse(exp_reg_val) exp_frame = protocol.insert_packet_into_frame(exp_packet) self._link.recv_until(exp_frame) idn_reg = self._read_reg("product_id") if idn_reg != protocol.EXPECTED_ID: raise ClientError("unexpected product id")
def _handshake(self): self._write_reg("main_control", "stop", expect_response=False) exp_addr = protocol.get_addr_for_reg("main_control") exp_enc_val = protocol.encode_reg_val("main_control", "stop") exp_reg_val = protocol.RegVal(exp_addr, exp_enc_val) exp_packet = protocol.RegWriteResponse(exp_reg_val) exp_frame = protocol.insert_packet_into_frame(exp_packet) self._link.recv_until(exp_frame) idn_reg = self._read_reg("product_id") possible_ids = [product.id for product in protocol.PRODUCTS] if idn_reg not in possible_ids: raise ClientError("unexpected product id")
def _send_packet(self, packet): frame = protocol.insert_packet_into_frame(packet) self._link.send(frame)
def test_insert_packet_into_frame(): frame = ptcl.insert_packet_into_frame(unp_reg_write_req) assert frame == pkd_reg_write_req_frame