Beispiel #1
0
 def send_ping1d_request():
     data = pingmessage.PingMessage()
     data.request_id = pingmessage.PING1D_DISTANCE_SIMPLE
     data.src_device_id = 0
     data.pack_msg_data()
     ping1d_io.sendto(data.msg_data, pingserver)
     print("Sent Request")
Beispiel #2
0
 def control_auto_transmit(self, start_angle, stop_angle, num_steps, delay):
     m = pingmessage.PingMessage(definitions.PING360_AUTO_TRANSMIT)
     m.start_angle = start_angle
     m.stop_angle = stop_angle
     m.num_steps = num_steps
     m.delay = delay
     m.pack_msg_data()
     self.write(m.msg_data)
    def request(self, m_id, timeout=0.5):
        msg = pingmessage.PingMessage(definitions.COMMON_GENERAL_REQUEST)
        msg.requested_id = m_id
        msg.pack_msg_data()
        self.write(msg.msg_data)
        # uncomment to return nacks in addition to m_id
        # return self.wait_message([m_id, definitions.COMMON_NACK], timeout)

        return self.wait_message([m_id], timeout)
Beispiel #4
0
    def __request(self, id):
        '''
        Request new messages of a specific ID

        :param id: The ID to refrest messages with
        '''
        msg = pingmessage.PingMessage()
        msg.request_id = id
        msg.pack_msg_data()
        self.__sock.sendto(msg.msg_data, self.address)
        self.log.trace('Request sent for message of id: ' + str(id))
Beispiel #5
0
 def set_ping_interval(self, ping_interval, verify=True):
     m = pingmessage.PingMessage(definitions.PING1D_SET_PING_INTERVAL)
     m.ping_interval = ping_interval
     m.pack_msg_data()
     self.write(m.msg_data)
     if self.legacyRequest(definitions.PING1D_PING_INTERVAL) is None:
         return False
     # Read back the data and check that changes have been applied
     if (verify and (self._ping_interval != ping_interval)):
         return False
     return True  # success
Beispiel #6
0
 def set_speed_of_sound(self, speed_of_sound, verify=True):
     m = pingmessage.PingMessage(definitions.PING1D_SET_SPEED_OF_SOUND)
     m.speed_of_sound = speed_of_sound
     m.pack_msg_data()
     self.write(m.msg_data)
     if self.legacyRequest(definitions.PING1D_SPEED_OF_SOUND) is None:
         return False
     # Read back the data and check that changes have been applied
     if (verify and (self._speed_of_sound != speed_of_sound)):
         return False
     return True  # success
Beispiel #7
0
 def set_ping_enable(self, ping_enabled, verify=True):
     m = pingmessage.PingMessage(definitions.PING1D_SET_PING_ENABLE)
     m.ping_enabled = ping_enabled
     m.pack_msg_data()
     self.write(m.msg_data)
     if self.legacyRequest(definitions.PING1D_PING_ENABLE) is None:
         return False
     # Read back the data and check that changes have been applied
     if (verify and (self._ping_enabled != ping_enabled)):
         return False
     return True  # success
Beispiel #8
0
 def set_gain_setting(self, gain_setting, verify=True):
     m = pingmessage.PingMessage(definitions.PING1D_SET_GAIN_SETTING)
     m.gain_setting = gain_setting
     m.pack_msg_data()
     self.write(m.msg_data)
     if self.legacyRequest(definitions.PING1D_GAIN_SETTING) is None:
         return False
     # Read back the data and check that changes have been applied
     if (verify and (self._gain_setting != gain_setting)):
         return False
     return True  # success
Beispiel #9
0
 def set_mode_auto(self, mode_auto, verify=True):
     m = pingmessage.PingMessage(definitions.PING1D_SET_MODE_AUTO)
     m.mode_auto = mode_auto
     m.pack_msg_data()
     self.write(m.msg_data)
     if self.legacyRequest(definitions.PING1D_MODE_AUTO) is None:
         return False
     # Read back the data and check that changes have been applied
     if (verify and (self._mode_auto != mode_auto)):
         return False
     return True  # success
Beispiel #10
0
 def set_gain_index(self, gain_index, verify=True):
     m = pingmessage.PingMessage(pingmessage.PING1D_SET_GAIN_INDEX)
     m.gain_index = gain_index
     m.pack_msg_data()
     self.write(m.msg_data)
     if self.request(pingmessage.PING1D_GAIN_INDEX) is None:
         return False
     # Read back the data and check that changes have been applied
     if (verify and (self._gain_index != gain_index)):
         return False
     return True  # success
Beispiel #11
0
 def set_device_id(self, device_id, verify=True):
     m = pingmessage.PingMessage(definitions.PING1D_SET_DEVICE_ID)
     m.device_id = device_id
     m.pack_msg_data()
     self.write(m.msg_data)
     if self.legacyRequest(definitions.PING1D_DEVICE_ID) is None:
         return False
     # Read back the data and check that changes have been applied
     if (verify and (self._device_id != device_id)):
         return False
     return True  # success
Beispiel #12
0
    def legacyRequest(self, m_id, timeout=0.5):
        msg = pingmessage.PingMessage()
        # legacy hack logic is in PingMessage
        # TODO: remove that logic and construct/assemble an arbitrary PingMessage
        msg.request_id = m_id
        msg.pack_msg_data()
        self.write(msg.msg_data)

        # uncomment to return nacks in addition to m_id
        # return self.wait_message([m_id, definitions.COMMON_NACK], timeout)

        return self.wait_message([m_id], timeout)
Beispiel #13
0
 def set_range(self, scan_start, scan_length, verify=True):
     m = pingmessage.PingMessage(definitions.PING1D_SET_RANGE)
     m.scan_start = scan_start
     m.scan_length = scan_length
     m.pack_msg_data()
     self.write(m.msg_data)
     if self.legacyRequest(definitions.PING1D_RANGE) is None:
         return False
     # Read back the data and check that changes have been applied
     if (verify and (self._scan_start != scan_start
                     or self._scan_length != scan_length)):
         return False
     return True  # success
Beispiel #14
0
 def control_transducer(self, mode, gain_setting, angle, transmit_duration, sample_period, transmit_frequency,
                        number_of_samples, transmit, reserved):
     m = pingmessage.PingMessage(definitions.PING360_TRANSDUCER)
     m.mode = mode
     m.gain_setting = gain_setting
     m.angle = angle
     m.transmit_duration = transmit_duration
     m.sample_period = sample_period
     m.transmit_frequency = transmit_frequency
     m.number_of_samples = number_of_samples
     m.transmit = transmit
     m.reserved = reserved
     m.pack_msg_data()
     self.write(m.msg_data)
Beispiel #15
0
 def device_id(self, id, reserved, verify=True):
     m = pingmessage.PingMessage(definitions.PING360_DEVICE_ID)
     m.id = id
     m.reserved = reserved
     m.pack_msg_data()
     self.write(m.msg_data)
     if self.request(definitions.PING360_DEVICE_ID) is None:
         return False
     # Read back the data and check that changes have been applied
     if (verify and (self._id != id or self._reserved != reserved)):
         return False
     return True  # success        m.id = id
     m.reserved = reserved
     m.pack_msg_data()
     self.write(m.msg_data)
Beispiel #16
0
 def control_reset(self, bootloader, reserved):
     m = pingmessage.PingMessage(definitions.PING360_RESET)
     m.bootloader = bootloader
     m.reserved = reserved
     m.pack_msg_data()
     self.write(m.msg_data)
Beispiel #17
0
 def control_motor_off(self):
     m = pingmessage.PingMessage(definitions.PING360_MOTOR_OFF)
     m.pack_msg_data()
     self.write(m.msg_data)
Beispiel #18
0
 def request(self, m_id, timeout=0.5):
     msg = pingmessage.PingMessage()
     msg.request_id = m_id
     msg.pack_msg_data()
     self.write(msg.msg_data)
     return self.wait_message(m_id, timeout)
Beispiel #19
0
def request(id: int):
    msg = pingmessage.PingMessage()
    msg.request_id = id
    msg.pack_msg_data()
    SOCK.sendto(msg.msg_data, ADDRESS)