.

     

MPI Application Template
template.c
 

coffee.c -- Read XMP firmware signature
/* coffee.c */

/* Copyright(c) 1991-2006 by Motion Engineering, Inc.  All rights reserved.
 *
 * This software  contains proprietary and  confidential information  of
 * Motion Engineering Inc., and its suppliers.  Except as may be set forth
 * in the license agreement under which  this software is supplied, use,
 * disclosure, or  reproduction is prohibited without the prior express
 * written consent of Motion Engineering, Inc.
 */

/*

:Read firmware signature

This sample application reads the firmware signature and other controller
ID registers including:  Signature, Disable, SoftwareID, and Option.

Warning!  This is a sample program to assist in the integration of an
 MEI motion controller with your application.  It may not contain all
 of the logic and safety features that your application requires.
*/

#include <stdlib.h>
#include <stdio.h>

#include "stdmpi.h"
#include "stdmei.h"

#include "apputil.h"

#if defined(ARG_MAIN_RENAME)
#define main    coffeeMain

argMainRENAME(main, coffee)
#endif

unsigned long MEIMemory[64];

int
    main(int    argc,
         char   *argv[])
{
    MPIControl  control;    /* Motion controller handle */

    MPIControlType      controlType;
    MPIControlAddress   controlAddress;

    void    *memory;        /* Control memory */

    long    returnValue;    /* Return value from library */
    long    argIndex;

    /* Parse command line for Control type and address */
    argIndex =
        argControl(argc,
                   argv,
                   &controlType,
                   &controlAddress);

    if (argIndex < argc) {
        meiPlatformConsole("usage: %s %s\n",
                           argv[0],
                           ArgUSAGE);
        exit(MPIMessagePARAM_INVALID);
    }

    /* Create motion controller object */
    control =
        mpiControlCreate(controlType,
                         &controlAddress);
    msgCHECK(mpiControlValidate(control));

    /* Initialize motion controller */
    returnValue = mpiControlInit(control);
    msgCHECK(returnValue);

    returnValue =
        mpiControlMemory(control,
                         &memory,
                         NULL);
    msgCHECK(returnValue);

    /* Read and Print the Controller firmware signature */
    returnValue =
        mpiControlMemoryGet(control,
                            MEIMemory,
                            memory,
                            sizeof(MEIMemory));
    msgCHECK(returnValue);

    fprintf(stderr, "Sharc memory: 0x0%08x 0x%08x 0x%08x 0x%08x\n",
                    MEIMemory[0],
                    MEIMemory[1],
                    MEIMemory[2],
                    MEIMemory[3]);

    /* Delete objects */
    returnValue = mpiControlDelete(control);
    msgCHECK(returnValue);

    return ((int)returnValue);
}


 
      
       Legal Notice  |  Tech Email  |  Feedback
      
Copyright ©
2001-2009 Motion Engineering