epos.h
Go to the documentation of this file.
00001 
00009 #ifndef _EPOS_H
00010 #define _EPOS_H
00011 
00012 #include <stdio.h>   /* Standard input/output definitions */
00013 #include <string.h>  /* String function definitions */
00014 #include <unistd.h>  /* UNIX standard function definitions */
00015 #include <fcntl.h>   /* File control definitions */
00016 #include <errno.h>   /* Error number definitions */
00017 #include <termios.h> /* POSIX terminal control definitions */
00018 #include <stdlib.h>
00019 #include <stdint.h>  /* int types with given size */
00020 #include <math.h>
00021 
00022 /* added oct06 for openTCPEPOS() */
00023 #include <sys/types.h>
00024 #include <sys/socket.h>
00025 #include <netinet/in.h>
00026 #include <arpa/inet.h>
00027 
00028 #define E_NOERR         0x00000000   ///< Error code: no error
00029 #define E_ONOTEX        0x06020000   ///< Error code: object does not exist
00030 #define E_SUBINEX       0x06090011   ///< Error code: subindex does not exist
00031 #define E_OUTMEM        0x05040005   ///< Error code: out of memory
00032 #define E_NOACCES       0x06010000   ///< Error code: Unsupported access to an object
00033 #define E_WRITEONLY     0x06010001   ///< Error code: Attempt to read a write-only object
00034 #define E_READONLY      0x06010002   ///< Error code: Attempt to write a read-only object
00035 #define E_PARAMINCOMP   0x06040043   ///< Error code: general parameter incompatibility 
00036 #define E_INTINCOMP     0x06040047   ///< Error code: general internal incompatibility in the device 
00037 #define E_HWERR         0x06060000   ///< Error code: access failed due to an hardware error
00038 #define E_PRAGNEX       0x06090030   ///< Error code: value range of parameter exeeded
00039 #define E_PARHIGH       0x06090031   ///< Error code: value of parameter written is too high
00040 #define E_PARLOW        0x06090032   ///< Error code: value of parameter written is too low
00041 #define E_PARREL        0x06090036   ///< Error code: maximum value is less than minimum value
00042 #define E_NMTSTATE      0x0f00ffc0   ///< Error code: wrong NMT state
00043 #define E_RS232         0x0f00ffbf   ///< Error code: rs232 command illegeal
00044 #define E_PASSWD        0x0f00ffbe   ///< Error code: password incorrect
00045 #define E_NSERV         0x0f00ffbc   ///< Error code: device not in service mode
00046 #define E_NODEID        0x0f00fb9    ///< Error code: error in Node-ID
00047 
00048 //#include "eposlib.h" -> moved to epos.c
00049 
00050 /* all EPOS data exchange is based on 16bit words, but other types are
00051    also used...*/
00052 typedef unsigned long DWORD ; 
00053 typedef unsigned short WORD ; 
00054 #ifndef CPP
00055 typedef char BYTE ; 
00056 #endif
00057 
00058 /* EPOS will reset communication after 500ms of inactivity */
00059 
00061 #define NTRY      5
00062 
00063 //#define TRYSLEEP  (unsigned int)1e5
00064 #define TRYSLEEP  (unsigned int)4000
00065 
00066 
00067 
00068 
00069 
00070 /* globals, defined in epos.c */
00071 
00073 extern int sp; 
00075 extern DWORD E_error; 
00076 
00077 /* all high-level functions return <0 in case of error */
00078 
00080 int openEPOS(char *device);
00082 int openTCPEPOS(char *ip, short unsigned port);
00084 int closeEPOS();
00086 int checkEPOS();
00087 
00088 
00090 int checkEPOSerror();
00091 
00093 int checkEPOSstate();
00095 int printEPOSstate();
00097 int changeEPOSstate(int state);
00098 
00099 
00100 
00107 int readSWversion();
00108 
00109 
00113 int readDeviceName(char *name);
00114 
00115 
00117 int readRS232timeout();
00118 
00120 int readDInputPolarity(WORD* w);
00121 
00123 int setHomePolarity(int pol);
00124 
00125 
00126 
00128 int readStatusword(WORD *eposStatus);
00130 int printEPOSstatusword(WORD statusword);
00131 
00132 
00133 
00135 int readControlword(WORD *w);
00137 int printEPOScontrolword(WORD controlword);
00138 
00139 
00141 int setOpMode(int OpMode);
00142 
00147 int readOpMode();
00148 
00149 
00151 int readDemandPosition(long *val);
00153 int readActualPosition(long *val);
00154 
00156 int readPositionWindow(unsigned long int *value);
00158 int writePositionWindow(unsigned long int value);
00159 
00161 int readDemandVelocity(long *val);
00163 int readActualVelocity(long *val);
00164 
00166 int readActualCurrent(short *val);
00167 
00169 int readTargetPosition(long *val);
00170 
00171 
00172 int set_speed_profile( unsigned int max_velocity,        // rpm
00173                        unsigned int acceleration = 1000, // rpm/s
00174                        unsigned int deceleration = 1000, // rpm/s
00175                        bool trapezoidal = true );
00176   
00179 int doHoming(int method, long int start);
00180 
00181 
00183 int moveRelative(long int steps);
00185 int moveAbsolute(long int steps);
00187 int moveVelocity(int32_t steps);
00188 
00191 int monitorStatus();
00193 int monitorHomingStatus();
00194 
00197 int waitForTarget(unsigned int t);
00198 
00199 
00200 #endif


epos_driver
Author(s): Tomasz Kucner , Martin Magnusson , Hakan Almqvist , Marcus Hauser
autogenerated on Fri Aug 28 2015 10:38:28