示例#1
0
    def get_scaled_gyro(self):
        """
        This is a vector quantifying the rate of rotation (angular rate) of the 
        3DM-GX3®. This quantity is derived from the Raw Angular Rate quantities, 
        but is fully temperature compensated and scaled into units of 
        radians/second. It is expressed in terms of the 3DM-GX3®’s local 
        coordinate system in units of radians/second.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_3DM_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_desc = 0x01
        field_data = 0x00, 0x01, 0x05, 0x00, 0x00
        field_len = len(field_data) + 2
        
        mpi_packet.payload = [field_len, field_desc]
        for value in field_data:
            mpi_packet.payload.append(value)

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(30)
        
        if reply[7] == "\x00":
            gyro_x = rad2deg(struct.unpack('>f', reply[16:20])[0])
            gyro_y = rad2deg(struct.unpack('>f', reply[20:24])[0])
            gyro_z = rad2deg(struct.unpack('>f', reply[24:28])[0])
            
            print "  Got Scaled Gyro values successfully!"
            print "  Scaled Gyro Vector (in degrees/sec) : "
            print "    X : %6.4f" %gyro_x
            print "    Y : %6.4f" %gyro_y
            print "    Z : %6.4f" %gyro_z
        else:
            print "  IMU Scaled Gyro unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return (gyro_x, gyro_y, gyro_z)
示例#2
0
    def get_scaled_magneto(self):
        """
        This is a vector which gives the instantaneous magnetometer direction 
        and magnitude. It is fully temperature compensated and is expressed in 
        terms of the 3DM-GX3®’s local coordinate system in units of Gauss.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_3DM_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_desc = 0x01
        field_data = 0x00, 0x01, 0x06, 0x00, 0x00
        field_len = len(field_data) + 2
        
        mpi_packet.payload = [field_len, field_desc]
        for value in field_data:
            mpi_packet.payload.append(value)

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(30)
        
        if reply[7] == "\x00":
            magneto_x = struct.unpack('>f', reply[16:20])[0]
            magneto_y = struct.unpack('>f', reply[20:24])[0]
            magneto_z = struct.unpack('>f', reply[24:28])[0]
            
            print "  Got Scaled Magnetometer values successfully!"
            print "  Scaled Magnetometer values (in Gauss) : "
            print "    X : %6.4f" %magneto_x
            print "    Y : %6.4f" %magneto_y
            print "    Z : %6.4f" %magneto_z
        else:
            print "  IMU Scaled Magnetometer unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return (magneto_x, magneto_y, magneto_z)
示例#3
0
    def get_scaled_accelerometer(self):
        """
        This is a vector quantifying the direction and magnitude of the 
        acceleration that the 3DMGX3 s exposed to. This quantity is derived 
        from Raw Accelerometer, but is fully temperature compensated and scaled 
        into physical units of g (1 g = 9.80665 m/sec^2). It is expressed in 
        terms of the 3DM-GX3®’s local coordinate system.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_3DM_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_desc = 0x01
        field_data = 0x00, 0x01, 0x04, 0x00, 0x00
        field_len = len(field_data) + 2
        
        mpi_packet.payload = [field_len, field_desc]
        for value in field_data:
            mpi_packet.payload.append(value)

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(30)
        
        if reply[7] == "\x00":
            print "  Got Scaled Accelerometer values successfully!"
            print "  Scaled Accelerometer (in m/sec^2) : "
            print "    X : %6.4f" %(struct.unpack('>f', reply[16:20])[0] * 9.080665)
            print "    Y : %6.4f" %(struct.unpack('>f', reply[20:24])[0] * 9.80665)
            print "    Z : %6.4f"  %(struct.unpack('>f', reply[24:28])[0] * 9.80665)
        else:
            print "  IMU Scaled Accelerometer unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return
示例#4
0
    def get_euler_angles(self):
        """
        Get Pitch, Roll and Yaw angles.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_3DM_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_desc = 0x01
        field_data = 0x00, 0x01, 0x0C, 0x00, 0x00
        field_len = len(field_data) + 2
        
        mpi_packet.payload = [field_len, field_desc]
        for value in field_data:
            mpi_packet.payload.append(value)

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(30)
        
        if reply[7] == "\x00":
            roll = rad2deg(struct.unpack('>f', reply[16:20])[0])
            pitch = rad2deg(struct.unpack('>f', reply[20:24])[0])
            yaw = rad2deg(struct.unpack('>f', reply[24:28])[0])
        
            print "  Got Euler angles successfully!"
            print "  Euler Angles (in degrees) : "
            print "    Roll : %6.4f" %roll
            print "    Pitch : %6.4f"  %pitch
            print "    Yaw : %6.4f"  %yaw
        else:
            print "  IMU Euler angles unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return (roll, pitch, yaw)
示例#5
0
    def get_quaternion(self):
        """
        This method returns a 4 component quaternion which describes the 
        orientation of the 3DM-GX3 with respect to the fixed earth coordinate 
        quaternion.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_3DM_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_desc = 0x01
        field_data = 0x00, 0x01, 0x0A, 0x00, 0x00
        field_len = len(field_data) + 2
        
        mpi_packet.payload = [field_len, field_desc]
        for value in field_data:
            mpi_packet.payload.append(value)

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(34)
        
        if reply[7] == "\x00":
            print "  Got Quaternion successfully!"
            print "  Quaternions : "
            print "    q0 : %6.6f" %struct.unpack('>f', reply[16:20])[0]
            print "    q1 : %6.6f"  %struct.unpack('>f', reply[20:24])[0]
            print "    q2 : %6.6f"  %struct.unpack('>f', reply[24:28])[0]
            print "    q3 : %6.6f"  %struct.unpack('>f', reply[28:32])[0]
        else:
            print "  IMU Quaternion unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return
示例#6
0
    def get_device_info(self):
        """
        Get the device ID strings and firmware version. Reply has two fields: 
        “ACK/NACK” and “Device Info Field”.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_BASE_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_len = 0x02
        field_desc = 0x03
        mpi_packet.payload = [field_len, field_desc]

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(94)
        
        if reply[7] == "\x00":
            print "  IMU information received!"
            print "    Firmware version : %d" %int(reply[10:12].encode('hex'), 16) 
            print "    Model Name       : %s" %reply[12:28].encode('ascii')
            print "    Model Number     : %s" %reply[28:44].encode('ascii')
            print "    Serial Number    : %s" %reply[44:60].encode('ascii')
            print "    Lot Number       : %s" %reply[60:76].encode('ascii')
            print "    Device Options   : %s" %reply[76:92].encode('ascii')
        else:
            print "  Command unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return
示例#7
0
    def set_to_idle(self):
        """
        Place device into idle mode. Device responds with ACK if successfully 
        placed in idle mode. This command will suspend streaming (if enabled) 
        or wake the device from sleep (if sleeping) to allow it to respond to 
        status and setup commands. You may restore the device mode by issuing 
        the Resume command.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_BASE_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_len = 0x02
        field_desc = 0x02
        mpi_packet.payload = [field_len, field_desc]

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(10)
        
        if reply[7] == "\x00":
            print " IMU placed in idle mode."
        else:
            print "  Command unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return
示例#8
0
    def reset(self):
        """
        Resets the 3DM-GX3-35. This command has a single 32 bit security value 
        parameter. Device responds with ACK if it recognizes the command and 
        then immediately resets.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_BASE_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_len = 0x02
        field_desc = 0x7E
        mpi_packet.payload = [field_len, field_desc]

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(10)
        
        if reply[7] == "\x00":
            print "  IMU reset successful!"
        else:
            print "  IMU reset unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return
示例#9
0
    def resume(self):
        """
        Place device back into the mode it was in before issuing the Set To 
        Idle command. If the Set To Idle command was not issued, then the 
        device is placed in default mode.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_BASE_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_len = 0x02
        field_desc = 0x06
        mpi_packet.payload = [field_len, field_desc]

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(10)
        
        if reply[7] == "\x00":
            print "  Resume successful!"
        else:
            print "  Command unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return
示例#10
0
    def ping(self):
        """
        Send a 'ping' command to the imu.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_BASE_CMD_DESCRIPTOR
        
        # Ping payload
        field_desc = 0x01
        field_len = 0x02
        mpi_packet.payload = [field_len, field_desc]

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(10)
        
        if reply[7] == "\x00":
            print "  Ping successful!"
        else:
            print "  Ping unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return
示例#11
0
def solver(iterations):
    mpi = MPI()

    world = mpi.MPI_COMM_WORLD
    rank = world.rank()
    delta = 1

    for i in range(iterations):
        # Calc takes times
        time.sleep(0.1)

        # Fake a delta.
        delta = min(delta, random.random())

        # Take the sum of the delta
        world_delta = world.allreduce(delta, sum)

        # Update the user register
        mpi.user_register = {
            'delta': delta,
            'world_delta': world_delta,
            'iterations': i,
        }
示例#12
0
#!/usr/bin/env python
# meta-description: Test establishment of MPI environment
# meta-expectedresult: 0
# meta-minprocesses: 2

from mpi import MPI

assert not MPI.initialized(
), "The mpi environment was initialized before starting mpi.. wrong"

mpi = MPI()
assert MPI.initialized(
), "The mpi environment was not initialized after starting mpi.. wrong"

# Close the sockets down nicely
mpi.finalize()
示例#13
0
    def get_uav(self):
        """
        Get Pitch, Roll and Yaw angles along with gyro and magnetometer values.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_3DM_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_desc = 0x01
        field_data = 0x00, 0x04, 0x0C, 0x00, 0x00, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x06, 0x00, 0x00
        field_len = len(field_data) + 2
        
        mpi_packet.payload = [field_len, field_desc]
        for value in field_data:
            mpi_packet.payload.append(value)

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.001)
        reply = self.ser.read(72)
        
        if reply[7] == "\x00":
            print "  IMU UAV Successful!"
            
            roll = rad2deg(struct.unpack('>f', reply[16:20])[0])
            pitch = rad2deg(struct.unpack('>f', reply[20:24])[0])
            yaw = rad2deg(struct.unpack('>f', reply[24:28])[0])
        
            accl_x = struct.unpack('>f', reply[30:34])[0] * g
            accl_y = struct.unpack('>f', reply[34:38])[0] * g
            accl_z = struct.unpack('>f', reply[38:42])[0] * g
        
            gyro_x = rad2deg(struct.unpack('>f', reply[44:48])[0])
            gyro_y = rad2deg(struct.unpack('>f', reply[48:52])[0])
            gyro_z = rad2deg(struct.unpack('>f', reply[52:56])[0])
            
            magneto_x = struct.unpack('>f', reply[58:62])[0]
            magneto_y = struct.unpack('>f', reply[62:66])[0]
            magneto_z = struct.unpack('>f', reply[66:70])[0]
        else:
            print "  IMU UAV unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return (roll, pitch, yaw, accl_x, accl_y, accl_z, gyro_x, gyro_y, gyro_z, magneto_x, magneto_y, magneto_z)
示例#14
0
#!/usr/bin/env python
# meta-description: Test abort, rank 0 will abort right away, other processes will sleep and should not exit with code 0
# meta-expectedresult: 1
# meta-minprocesses: 4

from mpi import MPI

mpi = MPI()

world = mpi.MPI_COMM_WORLD

if world.rank() == 0:
    mpi.abort()
else:
    import time, sys
    time.sleep(4)

    #print "We're about to sys exit with a positive return value"

    # If we get to this line the abort stuff has not worked
    # so we actually return nicely, which is not expected.
    sys.exit(0)
示例#15
0
def main(reps):
    mpi = MPI()
    world = mpi.MPI_COMM_WORLD
    rank = world.rank()
    size = world.size()
    handle_list = []
    obj = None  # Will be replaced when calling a NBC.

    if rank == 0:
        print "Benchmarking with %d reps" % reps

    datacount = 1000
    while datacount % size != 0:
        datacount += 1

    data = range(datacount)
    b = Benchmark(communicator=world, roots=range(size))

    # Testing allgather
    bw, _ = b.get_tester("allgather", datasize=rank)
    for _ in range(reps):
        with bw:
            obj = world.iallgather(data)
        handle_list.append(obj)
    world.waitall(handle_list)

    world.barrier()

    # Testing barrier
    bw, _ = b.get_tester("barrier", datasize=rank)
    for _ in range(reps):
        with bw:
            obj = world.ibarrier()
        handle_list.append(obj)
    world.waitall(handle_list)

    world.barrier()

    # Testing bcast
    bw, _ = b.get_tester("bcast", datasize=rank)
    for _ in range(reps):
        with bw:
            obj = world.ibcast(data, root=0)
        handle_list.append(obj)
    world.waitall(handle_list)

    world.barrier()

    # Allreduce
    bw, _ = b.get_tester("allreduce", datasize=rank)
    for _ in range(reps):
        with bw:
            obj = world.iallreduce(data, MPI_sum)
        handle_list.append(obj)
    world.waitall(handle_list)

    world.barrier()

    # Alltoall
    bw, _ = b.get_tester("alltoall", datasize=rank)
    for _ in range(reps):
        with bw:
            obj = world.ialltoall(data)
        handle_list.append(obj)
    world.waitall(handle_list)

    world.barrier()

    # Gather
    bw, _ = b.get_tester("gather", datasize=rank)
    for _ in range(reps):
        with bw:
            obj = world.igather(data)
        handle_list.append(obj)
    world.waitall(handle_list)

    world.barrier()
    # Reduce
    bw, _ = b.get_tester("reduce", datasize=rank)
    for _ in range(reps):
        with bw:
            obj = world.ireduce(data, MPI_sum, 0)
        handle_list.append(obj)
    world.waitall(handle_list)

    b.flush()
    mpi.finalize()
示例#16
0

def solver_it(mpi):
    world = mpi.MPI_COMM_WORLD
    rank = world.rank()
    delta = 1

    # Calc takes times
    time.sleep(0.1)

    # Fake a delta.
    delta = min(delta, random.random())

    # Take the sum of the delta
    world_delta = world.allreduce(delta, sum)

    # Update the user register
    mpi.user_register = {
        'delta': delta,
        'world_delta': world_delta,
        'iterations': i,
    }


if __name__ == "__main__":

    it = 100000
    m = MPI()
    for i in range(it):
        solver_it(m)
示例#17
0
import numpy, sys, time
from mpi import MPI
from mpi.collective.operations import MPI_sum

pupy = MPI()
world, rank, size = pupy.initinfo


def stencil_solver(local, epsilon):
    """
    The function receives a partial system-matrix including ghost rows in top and bottom
    """

    # We define the data size as the product of W and H times the byte size of the inner
    # data type.
    W, H = local.shape
    maxrank = size - 1

    work = numpy.zeros((W - 2, H - 2))  # temp workspace

    cells = local[1:-1, 1:-1]  # interior
    left = local[1:-1, 0:-2]
    up = local[0:-2, 1:-1]
    down = local[2:, 1:-1]
    right = local[1:-1, 2:]

    delta = epsilon + 1
    counter = 0
    while epsilon < delta:
        if rank != 0:
            local[0, :] = world.sendrecv(local[1, :], dest=rank - 1)
示例#18
0
    def device_test(self):
        """
        Run the device Built-In Test (BIT). The Built-In Test command always 
        returns a 32 bit value. A value of 0 means that all tests passed. A 
        non-zero value indicates that not all tests passed. The failure flags 
        are device dependent. The flags for the 3DM-GX3-35 are defined below.
        
        The BIT will take approximately 5 seconds to complete on the 3DM-GX3-35. 
        The GPS power will be cycled during the test resulting in the temporary 
        loss and subsequent recalculation of the position solution.
        
        Byte     Byte 1(LSB)     Byte 2     Byte 3     Byte 4(MSB)
        Device  AP-1 Processor    AHRS       GPS         Reserved
        =========================================================== 
        Bit 1 (LSB)I2C Hardware Error Communication Error Communication  Error Reserved
        Bit 2 I2C EEPROM Error Reserved 1PPS Signal Error Reserved
        Bit 3 Reserved Reserved 1 PPS Inhibit Error Reserved
        Bit 4 Reserved Reserved Power Control Error Reserved
        Bit 5 Reserved Reserved Reserved Reserved
        Bit 6 Reserved Reserved Reserved Reserved
        Bit 7 Reserved Reserved Reserved Reserved
        Bit 8 (MSB) Reserved Reserved Reserved Reserved
        
        Parameters
        ----------
        None
        
        Returns
        -------
        None
        """
        # Create a MPI packet object
        mpi_packet = MPI()
        mpi_packet.descriptor = MPI.MPI_BASE_CMD_DESCRIPTOR
        
        # Set to idle payload
        field_len = 0x02
        field_desc = 0x05
        mpi_packet.payload = [field_len, field_desc]

        # Payload length        
        mpi_packet.payload_len = len(mpi_packet.payload)
        
        # Build imu ping command in bytes
        command = mpi_packet.build()
                
        # Send byte packet to microstrain imu       
        self.ser.write(command)
        
        # Read output from the imu adter sleeping for 2 ms
        sleep(0.002)
        reply = self.ser.read(16)
        
        if reply[7] == "\x00":
            print "  Device Built-In Test (BIT) successful!"
            print "  BIT Error Flags : "
            print "    Byte 1 : ", '0x' + reply[10].encode('hex') 
            print "    Byte 2 : ", '0x' + reply[11].encode('hex')
            print "    Byte 3 : ", '0x' + reply[12].encode('hex')
            print "    Byte 4 : ", '0x' + reply[13].encode('hex')
        else:
            print "  Command unsuccessful"
            err = '0x' + reply[7].encode('hex')
            print "  Error Code : ", err
            print "  Error Message : ", MPI.MPI_ACK_NACK_ERROR[err]
            
        return
示例#19
0
#!/usr/bin/env python
# meta-description: Test alltoall, while refactoring collective ops
# meta-expectedresult: 0
# meta-minprocesses: 10
# meta-max_runtime: 60

from mpi import MPI

mpi = MPI()

world = mpi.MPI_COMM_WORLD

rank = world.rank()
size = world.size()
chunk_size = 4

iterations = 1000

data = [str(i) * chunk_size for i in range(size)]

#print "DATA:" + str(data)

recv_data = world.alltoall(data)

for i in xrange(iterations):
    if rank == 0:
        print "doing iteration %i of %i" % (i + 1, iterations)
    recv_data = world.alltoall(data)

#if rank == 0:
#    print "\tdata:%s \n\trecv_data:%s" % (data,recv_data)
示例#20
0
        migrate = False
        migrate_data = None
        all_commands = []

        rank = mpi.MPI_COMM_WORLD.comm_group.rank()

        # Try to find a migrate command.
        with mpi.pending_systems_commands_lock:
            for obj in mpi.pending_systems_commands:
                cmd, connection, user_data = obj
                if cmd == constants.CMD_MIGRATE_PACK:
                    migrate = True
                    migrate_data = user_data
                else:
                    all_commands.append(obj)

            mpi.pending_systems_commands = all_commands

        if migrate:
            from mpi.migrate import MigratePack
            migration = MigratePack(mpi, migrate_data)

        return f(mpi, *args, **kwargs)

    return inner


if __name__ == "__main__":
    # If this script is called directly it means that we are unpacking.
    mpi = MPI()