Home

AnaGate API - anagate.de

image

Contents

1. i 147 LS CANopenSendSDOWrite rca nn nnannnrnnnnnnns 148 LS CANopenSendSDOReadBlock Li 149 LS_CANopenSendSDOWriteBlock i 150 Programmer example 0 151 14 LUA programming examples nm meme 153 14 1 Examples for devices with CAN interface 153 14 2 Examples for devices with SPI interface 154 14 3 Examples for devices with I2C interface 155 API return Codes a id 158 I2C slave address formats anar nan n a nr rre rrrn na V i Tiata 160 Programming 12C EEPROM vasale ei N 162 FAQ Frequent asked questions sisi 164 FAQ Programming API uti a 168 Technical Support used nannten gar 169 IblIography na een engl 170 V 2007 2010 Analytica GmbH List of Figures w N N H N HR Input form of SPI example VB6 ss 66 Edit LUA script in a text editor nennen nnn 76 HTTP interface LUA settings ss 78 Definition of a I2C slave address in 7 bit format 160 Definition of a I2C slave address in 10 bit format 160 vi 2007 2010 Analytica GmbH List of Tables COLE RER PR MNE H Hi Ha U1 QG N HA Hi Hi N Hi Library files for Windows ss 3 Library files for LINUX scores A eet 3 AnaGate devices and related port numbers een nn
2. getch wait for keyboard input deactivate callback nRC CANSetCallbackEx hHandle 0 CANCloseDevice hHandle return 0 Remarks The two different callback functions have to be used depending on the active setting of the global timestamp option CANSetGlobals Only one of the callbacks can be activated at the same time See also CANWrite CANWriteEx 24 2007 2010 Analytica GmbH CAN API reference CANReadDigital CANReadDigital Reads the current values of digital input and output registers of the AnaGate device Syntax include lt AnaGateDllCan h gt int CANReadDigital int hHandle unsigned long pnInputBits unsigned long pnOutputBits Parameter hHandle Valid access handle pnInputBits Pointer to the current value of the digital input register Currently only bits O to 3 are used other bits are reserved for future use and are set to O pnOutputBits Pointer to the current value of the digital output register Currently only bits O to 3 are used other bits are reserved for future use and are set to O Return value Returns Null if successful or an error value otherwise Appendix A APT return codes Description All models of the AnaGate series except the model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The current values of the digital inputs and outputs can be retrieved with the CANR
3. Parameter hHandle Valid connection handle of a successful call to CANOpenDevice Return value Returns the current network connection state Following values are possible e 1 DISCONNECTED The connection to the AnaGate is disconnected e 2 CONNECTING The connection is connecting e 3 CONNECTED The connection is established e 4 DISCONNECTING The connection is disonnecting e 5 NOT_INITIALIZED The network protocol is not successfully initialized Description This function can be used to check if an already connected device is disconnected The detection period of a state change depends on the use of internal AnaGate ALIVE mechanism This ALIVE mechanism has to be switched on explicitly via CANStartAlive function Once activated the connection state is periodically checked by the ALIVE mechanism Remarks The CANDeviceConnect State function is supported by library version 1 4 1 10 or higher See also CANStartAlive 29 2007 2010 Analytica GmbH CAN API reference CANStartAlive CANStartAlive Starts the ALIVE mechanism which checks periodically the state of the network connection to the AnaGate hardware Syntax include lt AnaGateDllCan h gt int CANStartAlive int hHandle int nAliveTime Parameter hHandle Valid access handle nAliveTime Default time out in seconds for the ALIVE mechanism Return value Returns null if successful
4. Parameter pHandle Pointer to a variable in which the access handle is saved in the event of a successful connection to the AnaGate device pcIPAddress Network address of the AnaGate partner nTimeout Default timeout for accessing the AnaGate in milliseconds A timeout is reported if the AnaGate partner does not respond within the defined timeout period This global timeout value is valid on the current network connection for all commands and functions which do not offer a specific timeout value Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description Opens a TCP IP connection to an AnaGate SPI resp AnaGate Universal Programmer After the connection is established access to the SPI bus is possible C Note The AnaGate SPI resp the SPI interface of an AnaGate Universal Programmer does not allow more than one concurrent network connection During an established network connection all new connections are refused See the following example for the initial programming steps include lt AnaGateD11SPI h gt int main int hHandle int nRC SPIOpenDevice amp hHandle 192 168 0 254 5000 if nRC now do something SPICloseDevice hHandle 33 2007 2010 Analytica GmbH SPI API reference return 0 See also SPICloseDevice 34 2007 2010 Analytica GmbH SPI API reference SPICloseDevice
5. The source code of the example can be found in directory Samples SPI VB NET on the CD 69 2007 2010 Analytica GmbH Programming examples Sub Main Dim hHandle As Int32 nIndex As Integer BufferWrite 100 As Byte BufferRead 100 nBaudrate As Int32 5000000 500kBit nSigLevel As Byte 2 DAS HO Lie T qn ad tse nAuxVoltage As Byte 0 support voltage is 3 3V nClockMode As Byte 3 CRHA 1 and CPOL 1 Dim As Byte Dim Dim Dim Dim Dim nRC SPIOpenDevice hHandle T are lt gt 0 Ther Console WriteLine Error SPIOpenDevice Else nRC nRC 92166125940 5000 1 amp GetErrorMsg nRC amp vbCrLf SPISetGlobals hHandle nBaudrate nSigLevel nAuxVoltage nClockMode SPIGetGlobals hHandle nBaudrate nSigLevel nAuxVoltage nClockMode nIndex 0 To 100 BufferWrite nIndex BufferRead nIndex Next nIndex For init buffers with some data 69 96 BufferWrite 0 BufferWrite 1 Ew ads Kr n 0x50 05350 READ STATUS READ STATUS M25P80 M25P80 nRC SPIDataReq hHandle If nRC lt gt 0 Then Console WriteLine Error SPIDatReg Else Conso BufferWrite 2 BufferRead 2 H amp GetErrorMsg nRC amp vbCrLf le Write Result DATAREQ For nIndex 0 To 1 init buffers with some data Console Write BufferRead nIndex amp Next Console WriteLine End If SPICloseDevice hHandle E End If End Sub A call to SPIOpenD
6. See the following example for setting some filters include lt AnaGateCAND11 h gt 17 2007 2010 Analytica GmbH CAN API reference int main int anFilter 16 OxPFF O OX0F mask filter 1 mask OxFF value 0x0F route only 0x 0F values 0 10 mask filter 2 unused O Oy mask filter 3 unused De 0 mask filter 4 unused 0 0x00000FFF range filter 1 all ids greater than OxFFF are discarded 0 Ox1FFFFFFF range filter 2 unused 0 Ox1FFFFFFF range filter 3 unused 0 Ox1FFFFFFF range filter 4 unused int hHandle int nRC CANOpenDevice amp hHandle TRUE TRUE 0 192 168 0 254 5000 if nRC nRC CANSetFilter hHandle amp anFilter 16 now do something CANCloseDevice hHandle return 0 See also CANGetFilter 18 2007 2010 Analytica GmbH CAN API reference CANGetFilter CANGetFilter Returns the current filter settings for the connection Syntax include lt AnaGateDIICAN h gt int CANGetFilter int hHandle int pnFilter Parameter hHandle Valid access handle pnFilter Pointer to an array of 8 filter entries 4 mask and 4 range filter entries A filter entry contains of two 32 bit values Unused mask filter entries are initialized with O values Unused range filter entries are initialized with 0 0x1FFFFFFF value pairs Return value Returns null if successful or an error value otherwise Appendi
7. sen eripiet be io ai 116 LS SPI Read Digital siii ia 117 LS SPIWrite Digitales nn anna nenn 118 12 12C Reference nass eau ceva digne vire divin ends devas ney 119 LS 12COpenDEVICe an Zia anna vers evens P AA UR IER e YD nie 120 LS 42CGloseDeVvice ssec nn 122 LS AIZCRESet u N tv p rut e rf Lv et EE 123 LS T2CRead ns an een 124 LS I26WEIUG anruft 125 LS I2CReadDigital ssa siste setas ue an 126 LS I2CWriteDigital i nn ra nenn 127 LS I2GErrorMessage nr ie Renee ER ada GRE 128 ES I2CReadEEPROM 7244446052 otr en sani aan en A FER CO tune 129 LS 12CWriteEEPROM ce a c t el E X REG IO ED CC 131 13 CANOpen functions u ae En ERE ANDERS 133 LS CANopenSetConfig 2224066605600242 Y A R E A nennen nnne nnn 134 LS CANopenGetConfig i 135 LS CANopenSetSYNCMode nenne enean aenean 136 LS CANopenSetCallbacks eme eme menn 137 LS CANopenGetPDO nena nasa aaa nena aane anna 138 LS CANopenGetSYNC cies urere rennen 1000 60006 nenne RI ILC ERA 139 LS CANopenGetEMOY enema nani aas rena rena nnn 140 LS CANopenGetGUARD rina ann 141 LS CANopenGetUndefined eee nennen nennen nnn 142 LS CANopensend NMT inicia rE E RAES 143 LS CANopenSendSYNC serrana errada 144 iv 2007 2010 Analytica GmbH AnaGate API gmmgogmrm ES CANopenSendTIME oe oriana 145 LS CANopenSendPDO eee aerea 146 LS CANopenSendSDORead
8. For I 1 To nBufferReadLen sByteText sByteText Ox amp ToHex arrRead I amp Next I Me txtBufferRead sByteText sText sText amp SPIDataReq OK amp vbCrLf Else sText sText amp Fehler bei SPIDataReq amp GetErrorMsg nRC amp vbCrLf ENGSTE nRC SPICloseDevice hHandle End If End Sub Ei A call to SPISetGlobals sets the global settings on the device the parameter values of the input fields in the dialog form are used E The cetcommand function converts the texual SPI command entered in the input field on the form to a byte array structure EJ To process the data in the read and receive buffers a byte array is used as VB6 data type for both buffers For this to work the real memory address of the array data has to be parsed to the DLL function This will be done by using the VarPtr function on the first byte array element 68 2007 2010 Analytica GmbH Programming examples 7 3 Programming language VB NET Of course it is also possible to use the functions of the AnaGate API with the NET programming languages For these languages the functions have only to be declared correctly in one of the NET languages Loading and unloading of the declared API functions is done automatically by the NET framework 7 3 1 CAN Console application VB NET This programming example for VB NET demonstrates how to connect to an AnaGate CAN and how to process received CAN data via a callba
9. char pcReadBuffer int nNumberOfBytesToRead int pnNumberOfBytesRead int pnByteNumberLastError Parameter hHandle Valid access handle pcWriteBuffer byte buffer containing the commands which are to be sent to the AnaGate I2C The single commands are stored sequential in this byte buffer A read command is defined as follows Structure of read command for I2CSequence Read command Description 2 bytes LSB MSB slave address in 7 or 10 bit format the R W bit must be set to explicitely to 1 2 bytes LSB MSB Bit 0 14 number of data bytes to be read from the 12C device The successfully read data bytes are stored in the pcReadBuffer buffer Bit 15 If this bit is set then the stop bit at the end of the read command is omitted A write command is defined as follows Structure write command for 12CSequence Write command Description 2 bytes LSB MSB slave address in 7 or 10 bit format the R W bit must be set to explicitely to 1 2 bytes LSB MSB Bit 0 14 number of data bytes to be written to the 12C device Bit 15 If this bit is set then the stop bit at the end of the write command is omitted 53 2007 2010 Analytica GmbH I2C API reference Write command Description N bytes data bytes nNumberOfBytesToWrite byte size of the data to write pcReadBuffer byte buffer in which the received data is to be stored The received dat
10. include lt AnaGateDllCan h gt int CANWrite int hHandle int nIdentifier const char pcBuffer int nBufferLen int nFlags int CANWriteEx int hHandle int nIdentifier const char pcBuffer int nBufferLen int nFlags long pnSeconds long pnMicroSeconds Parameter hHandle Valid access handle nIdentifier CAN identifier of the sender Parameter nFlags defines if the address is in extended format 29 bit or standard format 11 bit pcBuffer Pointer to the data buffer nBufferLen Length of data buffer max 8 bytes nFlags The format flags are defined as follows e Bit O If set the CAN identifier is in extended format 29 bit otherwise not 11 bit e Bit 1 If set the telegram is marked as remote frame e Bit 2 If set the telegram has a valid timestamp This bit is only set for incoming data telegrams and must not be set for the CANWrite and CANWriteEx functions pnSeconds Timestamp of the confirmation of the CAN controller seconds from 01 01 1970 pnMicroSeconds Micro seconds portion of the timestamp Return value Returns null if successful or an error value otherwise Appendix A API return codes Description Both functions sends a CAN telegram to the CAN bus via the AnaGate device The CANWriteEx additionallly returns a timestamp of the time at which the telegram is sent 21 2007 2010 Analytica GmbH CAN API reference Note With remote frames RTR remote transmission requ
11. 0 support voltage is 3 3V e 1 support voltage is 2 5V nClockMode The phase and polarity of the colck signal currently used by the AnaGate SPI Following values are possible e O CPHA 0 and CPOL 0 e 1 CPHA 0 and CPOL 1 e 2 CPHA 1 and CPOL 0 e 3 CPHA 1 and CPOL 1 Description Returns the currently used global settings of SPI interface of the AnaGate SPI or the AnaGate Universal Programmer 112 2007 2010 Analytica GmbH SPI Reference See also LS_SPISetGlobals 113 2007 2010 Analytica GmbH SPI Reference LS SPIDataReq LS SPIDataReq Writes and reads data to from SPI bus Syntax int RC table nReadLen tabRead LS_SPIDataReq int hHandle int nWriteLen int nReadLen table nWriteLen tabWrite Parameter hHandle Valid access handle nWriteLen Length of the data buffer pcBufWrite byte count nReadLen Number of bytes to read tabWrite Buffer with the data that is to be sent to the SPI partner Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes tabRead Table with data received from the SPI partner Description Sends data to the SPI bus and receives data from the SPI bus On the SPI bus Data is transferred on two seperates data lines full duplex SDO and SDI The SPIDatReq has to split a single data transfer in two steps because of the spacial separation to the SPI bus First the write data buffer is put into a TCP data
12. 10kBit e 20 000 f r 20kBit e 50 000 f r 50kBit e 62 500 f r 62 5kBit e 100 000 f r 100kBit 125 000 f r 125kBit e 250 000 f r 250kBit 500 000 f r 500kBit e 800 000 f r 800kBit not AnaGate CAN e 1 000 000 f r 1MBit The operating mode to be used Following values are allowed e O default mode e 1 loop back mode All telegrams sent by a connected partner is routed back to all active connected partners e 2 listen mode Device operates as passive bus partner this means no telegrams are sent to the CAN bus no ACKs for incoming telegrams too Use integrated CAN bus termination true yes false no This setting is not supported by all AnaGate CAN models Use high speed mode true yes false no This setting is not supported by all AnaGate CAN models The high speed mode was created for large baud rates with continuously high bus load In this mode telegrams are not 89 2007 2010 Analytica GmbH CAN Reference confirmed on procol layer and the software filters defined via LS_CANSetFilter are ignored bTimeStampOn Use time stamp mode true yes false no This setting is not supported by all AnaGate CAN models In activated time stamp mode an additional timestamp is sent with the CAN telegram This timestamp indicates when the incomming message is received by the CAN controller or when the outgoing message is confirmed by the CAN controller Return value RC Returns 0 if success
13. CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The digital outputs can be written with the 12cWriteDigital function A simple example for reading writing of the IOs can be found at the description of I2CReadDigital See also I2CReadDigital 57 2007 2010 Analytica GmbH I2C API reference I2CErrorMessage I2CErrorMessage Returns a description of the given error code as a text string Syntax include lt AnaGateDIICAN h gt int I2CErrorMessage int nRetCode char pcMessage int nMessageLen Parameter nRetCode Error code for which the error description is to be determined pcMessage Data buffer that is to accept the error description nMessageLen Size in bytes of the transferred data buffer Return value Actual size of the returned description Description Returns a textual description of the parsed error code see Appendix A API return codes If the destination buffer is not big enough to store the text the text is shortened to the specified buffer size See the following example in C C language IAE IRC char cBuffer 200 Limia TRGA L sss Call a API finerion h re I2CErrorMessage nRC cBuffer 200 Sto cont lt lt Fehlers cButrers lt lt stds vendi 58 2007 2010 Analytica GmbH I2C API reference I2CReadEEPROM I2CReadEEPROM Reads data from an EEPROM on the I2C bus Syntax
14. ERR_RANGE Value out of valid range 3 ERR_NOT_A_NUMBER Parameter is not of type number 4 ERR NOT A STRING Parameter is not of type string 5 ERR_NOT_A_BOOL Parameter is not of type boolean 6 ERR_NOT_A_TABLE Parameter is not of type table 10 ERR_NO_DATA No data available 159 2007 2010 Analytica GmbH Appendix B I2C slave address formats A standard I2C address is the first byte sent be the I2C master whereas only the first seven bit form the adress the last bit R W bit defines the direction in which the data is sent I2C has a 7 bit address space and can address 112 slaves on a single bus 16 of the 128 addresses are reserved fo special purposes Figure B 1 Definition of a I2C slave address in 7 bit format Slave Address Device Type Identifier Chip Enable Address R W 7 6 5 4 3 2 1 0 Each I2C able IC has a determined bus address The 4 upper bits of the bus address are called Device Type Identifier and define the chip type The lowest three bits called sub address or Chip Enable Address are usually defined by the corresponding wired control pins So in total up to 8 similar IC s can be used on a single I2C bus Because of a lack of address space a 10 bit addressing mode was introduced later This new mode is downwards compatible to the 7 bit standard mode through usage of 4 of the 16 reserved addresses Both addressing modes can be used simultaneously which implies that 1136 slaves can be
15. Function can t be executed on this device handle as she is assigned to another device type of AnaGate series Table A 2 Return values for AnaGate I2C Value Name Description 0x000120 ERR I2C NACK I2C NACK 0x000121 ERR I2C TIMEOUT I2C Timeout A textual description of the return value can be retrieved with the function I2CErrorMessage 158 2007 2010 Analytica GmbH API return codes Table A 3 Return values for AnaGate CAN Value Name Description 0x000220 ERR_CAN_NACK CAN NACK 0x000221 ERR_CAN_TX_ERROR CAN Transmit Error 0x000222 ERR_CAN_TX_BUF_OVERLOW CAN buffer overflow 0x000223 ERR_CAN_TX_MLOA CAN Lost Arbitration 0x000224 ERR_CAN_NO_VALID_BAUDRATE CAN Setting no valid Baudrate A textual description of the return value can be retrieved with the function CANErrorMessage Table A 4 Return values for AnaGate Renesas Value Name Description 0x000920 ERR_RENESAS_TIMEOUT Renesas timeout 0x000921 ERR_RENESAS_INVALID_ID Renesas Invalid ID 0x000922 ERR_RENESAS_FLASH_ERASE_FAILED Renesas failed erase the flash 0x000923 ERR_RENESAS_PAGE_PROG_FAILED Renesas failed prog the page A textual description of the return value can be retrieved with the function RenesasErrorMessage Table A 5 Return values for LUA scripting Value Name Description 1 ERR_SYNTAX Syntax error 2
16. GmbH Appendix C Programming I2C EEPROM The AnaGate I2C and the AnaGate Universal Programmer is very well suited for programming serial I2C EEPROM To support this special requirement two different API functions are made available 12CReadEEPROM and I2CWriteEEPROM Like all other I2C capable devices EEPROM s are addressable on the I2C bus via a unique slave address see also Appendix B I2C slave address formats The so called Device Type Identifier for these types of devcies is 0xA In principle 8 similar devices can be connected and addressed via the Chip Enable Bits EO E1 und EO Device Type Identifier Chip Enable Address R W 7 6 5 4 3 2 1 0 A data transmission is started with a Start signal by the master followed by the slave address The slave address is confirmed by the slave with a ACK Depending on the R W bit data is written data to slave or read data from slave The last byte of a read access has to be confirmed with a NAK by the master to signal the slave end of read transmission The data transmission is terminated always by a Stop signal from the master When using EEPROM s the memory address is transmitted after transmission of the slave address to advice the slave which memory address is to be written or read Depending on the used EEPROM type the memory address is sent as single byte 8 bit or as two bytes 16 bit MSB First To expand the address space from 8 bit or 16 bit some EE
17. GmbH CAN Reference LS CANSetCallback LS_CANSetCallback Defines an asynchronous callback function which is called for each incoming CAN telegram Syntax int RC LS_CANSetCallback int hHandle string sCallbackFunction function MY_LS_CALLBACK int nCANId int nDataLen table nDataLen tabData int nFlags int hHandle int nSeconds int nMicroseconds Parameter hHandle Valid access handle sCallbackFunction Name of the private callback function Set this parameter to to deactivate the callback function The parameters of the callback function are described in section Callback Parameter Callback Parameter nCANId CAN identifier of the sender Parameter nFlags defines if the address is in extended format 29 bit or standard format 11 bit nDataLen Length of data buffer max 8 bytes tabData Data buffer with telegram data nFlags The format flags are defined as follows e Bit O If set the CAN identifier is in extended format 29 bit otherwise not 11 bit e Bit 1 If set the telegram is marked as remote frame e Bit 2 If set the telegram has a valid timestamp hHandle Valid access handle nSeconds Timestamp of the confirmation of the CAN controller seconds from 01 01 1970 nMicroseconds Micro seconds portion of the timestamp Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description Incoming CAN telegrams can be receiv
18. LS I2CRead nHandle 0xa2 1024 for i 1 table getn Value 1 do printf 02X Value i end perni LS_I2CWriteDigital nHandle 0 LS_I2CCloseDevice nHandle end 5000 156 2007 2010 Analytica GmbH LUA programming examples Example 14 5 ck ck ck ck ck ck ck ck ck ck ck KKK KKK KKK DRES NC AC HK D HK TH Ck SE DAVE Doc AH KH VE Ve AH ko ko ko ko ko ko ko ko KKK inviare LOMO Rae eo 9 io write string format ioro E USNO end ck KKK KKK KKK KKK KKK KKK Ck Ck Ck KK KH KK RAS function getn t if type t n number then return t n end local max 0 fOr ip ala CO if type i number and i gt max then max i end end return max end ck ck ck ck ck ck ck ck KKK KKK KKK KKK KKK HH Fe Se M KH Ve KH TI SJ FH AH AH TI D AH ko AH TI ko FH ko AH I KKK function main aSendData foie al 1280 I clo table insert aSendData i 1 end nRC nHandle LS I2COpenDevice 1000000 10 1 2 162 5000 if nRC 0 then print LS I2CErrorMessage nRC exi end Sequence aData 0xa2 0x00 SLA 0x02 0x00 Laenge Schreibkommando 0x00 0x00 Daten Schreibkommando 0xa3 0x00 SLA 2 Lesekommando ESO CO Laenge 1 Lesekommando 0xa3 0x00 SLA 2 Lesekommando 0520 2005157 Laenge 2 Lesekommando nRC CountRead LastError Value LS_I2CSequence nHandle OxOE 0x0050 aData printf CountRead 02X astError 02X
19. Parameter hHandle Valid access handle nTimeout Maximum period of time in milliseconds to wait for the a new data telegram Return values nAvail Number of message which are left in the internal message puffer If there is currently no message available 10 ERR_NO_DATA is returned nCANId CAN identifier of the sender Parameter nFlags defines if the address is in extended format 29 bit or standard format 11 bit nDataLen Length of data buffer tabData Data buffer with telegram data nFlags The format flags are defined as follows e Bit O If set the CAN identifier is in extended format 29 bit otherwise not 11 bit e Bit 1 If set the telegram is marked as remote frame e Bit 2 If set the telegram has a valid timestamp nSeconds Timestamp of the confirmation of the CAN controller seconds from 01 01 1970 nMicroseconds Micro seconds portion of the timestamp Description This function reads a single CAN data telegram out of an internal message buffer The message buffer is automatically filled with all incoming CAN data telegrams in a seperate thread The parameter nTimeout defines a maximum period of time which the function should wait for a new data telegram if there is currently no telgram in the internal buffer If no new message is received within the time out the function returns in nAvail the recturn code 10 ERR NO DATA 99 2007 2010 Analytica GmbH CAN Reference 9 Warning If us
20. RC int nInputBits int nOutputBits LS_I2CReadDigital int hHandle Parameter hHandle Valid access handle Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes nInputBits Pointer to the current value of the digital input register Currently only bits O to 3 are used other bits are reserved for future use and are set to 0 nOutputBits Pointer to the current value of the digital output register Currently only bits O to 3 are used other bits are reserved for future use and are set to 0 Description All models of the AnaGate series except the model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The current values of the digital inputs and outputs can be retrieved with the LS_I2CReadDigital function See the following example for setting an reading the digital IO nOutputs 0x03 nRC hHandle LS_I2COpenDevice 400000 192 168 0 254 5000 if nRC then set the digital output register PIN 0 and PIN 1 to HIGH value nRC LS_I2CWriteDigital hHandle nOutputs read all input and output registers nRC nInputs nOutputs LS_I2CReadDigital hHandle LS_I2CCloseDevice hHandle end See also LS I2CWriteDigital 126 2007 2010 Analytica GmbH I2C Reference LS I2CWriteDigital LS I2CWriteDigital Writes a new value to the digital output register of the A
21. and the corresponding import library is linked 7 1 1 CAN Console application C C MSVC This programming example for C demonstrates how to connect to an AnaGate CAN and how to process received CAN data via a callback function Note The source code of the example can be found in directory Samples CAN VC6 resp Samples CAN VC7 on the CD include AnaGateDLLCAN h WINAPI void MyCallback int nIdentifier const char pcBuffer int nBuflen int nFlags int nHandle std cout lt lt CAN ID lt lt nIdentifier lt lt Data for Apt dl E JR a lt ABUELSp 32447 std cout T 0x lt lt std hex lt lt pebuffer i std cout lt lt std endl int main int hHandle NULL opens AnaGate CAN duo device on port A timeout after 1000 millseconds int nRC CANOpenDevice amp hHandle FALSE TRUE 0 192 168 2 1 1000 if nRC 0 nRC CANSetCallback hHandle MyCallback getch wait for keyborad input 64 2007 2010 Analytica GmbH Programming examples if nRC 0 i nRC CANCloseDevice hHandle close device 7 2 Programming language Visual Basic 6 As already described in the previous chapters the libraries of the AnaGate API use the cdecl calling convention to parse function parameters to the program stack Unfortunately this is generally not supported by the programming language Visual Basic 6 To work around this
22. data buffer pcBufwrite byte count pcBufRead Byte buffer which holds the data received from the SPI partner nBufReadLen Number of bytes to read Description Sends data to the SPI bus and receives data from the SPI bus On the SPI bus Data is transferred on two seperates data lines full duplex SDO and SDI The SPIDatReq has to split a single data transfer in two steps because of the spacial separation to the SPI bus First the write data buffer is put into a TCP data telegram and sent to the AnaGate SPI The AnaGate SPI makes the real data transfer on the SPI bus and send back a confirmation including the data received from the bus Important It is impossible to detect that no device is present at the SPI bus So if no device is attached the requested number of bytes are returned anyway in this case the read buffer is filled with 0 See the following example for sending a command to the connected SPI bus include lt AnaGateD11SPI h gt int main Char Chuimritel LA 2 Sy Ue S 7 Bo 9 10 Jp char cBufReceive 100 int hHandle 0 aime MINO 0 int nRC SPIOpenDevice amp hHandle 192 168 1 254 5000 if nRC 0 N send dL byte end receive db byt 40 2007 2010 Analytica GmbH SPI API reference nRC SPIDataReq hHandle cBufWrite 1 cBufReceive 1 send 1 byte and receive 5 byt nRC SPIDataReq hHandle cBufWrite 1 cBufReceive 5 send 2 byte and re
23. device 103 2007 2010 Analytica GmbH CAN Reference LS CANErrorMessage LS CANErrorMessage Returns a description of the given error code as a text string Syntax string sErrorMsg LS CANErrorMessage int nRetCode Parameter nRetCode Error code for which the error description is to be determined Return value sErrorMsg Textual description of the error code Description Returns a textual description of the parsed error code see Appendix A API return codes See the following example in LUA scripting language nRC 0 sErrorText No Error Moss Call a API ittingicidoa hara sErrorText LS CANErrorMessage nRC print sErrorText 104 2007 2010 Analytica GmbH CAN Reference LS CANReadDigital LS CANReadDigital Reads the current values of digital input and output registers of the AnaGate device Syntax int RC int nInputBits int nOutputBits LS CANReadDigital int hHandle Parameter hHandle Valid access handle Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes nInputBits Pointer to the current value of the digital input register Currently only bits O to 3 are used other bits are reserved for future use and are set to O nOutputBits Pointer to the current value of the digital output register Currently only bits O to 3 are used other bits are reserved for future use and are set t
24. files can be downloaded to the device and executed locally In the following you can see a screenshot of the LUA configuration page of a AnaGate CAN uno 77 2007 2010 Analytica GmbH The LUA scripting interface of the AnaGate product line Figure 8 2 HTTP interface LUA settings Lua Mozilla Firefox Datei Bearbeiten Ansicht Chronik Lesezeichen Extras Hilfe c Ps Lua ts AnaGate CAN uno IP Settings CAN Settings Status Firmware A Ps http 10 1 2 225 index cgi site lua amp name Get_Serial amp action start X 3 AnaGate AnaGate CAN uno Lua settings To add a lua script select the scriptfile and press the upload button Remarks Use only scripts which are compatible with this equipment Durchsuchen Upload Clear Running script Get Serial lua Available scripts CAN Basic lua Get Serial lua Script output Version 1 0 5 Script lua Get_Serial lua Connected to localhost I have successfully retrieved the current serial and MAC SN 01 02 02 1D MAC 00 50 C2 3C B2 1D Error output Copyright 2008 2010 Analytica GmbH www anagate de Stand Aug 4 2010 Browse Opens a file upload dialog to select a LUA script file Upload Uploads the selected script file to the device Clear Clears the current script file selection Boot script Script file executed on system startup Via the button Delete the boot script can be deactivated Only one boot script is allowed Running sc
25. gesendet Die CANOpen Funktionalit t ist eingeschaltet und es k nnen die nachfolgend beschriebenen Funktionen verwendet werden If no error occurs the return will be null O Otherwise the returncode will be different null 0 134 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenGetConfig LS CANopenGetConfig Synopsis int RC LS CANopenGetConfig int Handle Description Parameter int Handle Return values int RC int CANOpenConfig If no error occurs the return will be null 0 Otherwise the returncode will be different null 0 0 Die CANOpen Funktionalit t wird nicht unterst tzt Standard Ein Aufruf einer CANOpen Funktion wird negativ FFh quittiert Empfangene CAN Daten werden immer als Standard Datalndication OP_ANAGATE_CAN_DATA_IND gesendet Die CANOpen Funktionalit t ist eingeschaltet und es k nnen die nachfolgend beschriebenen Funktionen verwendet werden 135 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSetSYNCMode LS CANopenSetSYNCMode Synopsis int RC LS CANopenSetSYNCMode int Handle int PeriodTime Description Parameter int Handle int PeriodTime Return values int RC If no error occurs the return will be null 0 Otherwise the returncode will be different null 0 136 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSetCallbacks LS CANopenSetCallbacks Synops
26. include lt AnaGateDIII2C h gt int I2CReadEEPROM int hHandle unsigned short nSubAddress unsigned int nOffset const char pcBuffer int nBufferLen unsigned int nOffsetFormat Parameter hHandle Valid access handle nSubAddress Subaddress of the EEPROM to communicate with The valid values for nsubAddress are governed by the setting used in the parameter nOffsetFormat bits 8 10 If the EEPROM type needs to use bits of the Chip Enable Address to address the internal memory only the remaining bits can be used to select the device itself e No bit is used for addressing 0 to 7 e 1 bit is used for addressing O to 3 e 2 bits are used for addressing O to 1 e 3 bits are used for addressing O nOffset Data offset on the EEPROM from which the transferred data is to be read pcBuffer Character string buffer in which the received data is to be stored nBufferLen Length of the data buffer nOffsetFormat Defines how a memory address of EEPROM has to be specified when accessing the device Bits 0 7 indicate the number of bits which are used in the address byte word of the I2C command for addressing the device memory Bits 8 10 indicate how much and which bits of the Chip Enable Bits are used for addressing the device memory see Table C 1 Usage of the CHIP Enable Bits of I2C EEPROMs for allowed values Note C The maximum addressable size of an EEPROM is derived from the sum of all the bits For example a M24C08 uses
27. limitiation the libraries for the AnaGate devices are available in a specfic version for programming VB6 applications In this versions the stdcall calling convention is used which is the only supported by VB6 Except for the way the parameters are pushed on the stack these specific VB6 versions of the API libraries are exactly identical to the standard versions Note 1 Use library AnaGateCAN d11 instead of library AnaGateCANVB6 dll Use library AnaGateSPI d11 instead of library AnaGateSPIVB6 dll 7 2 1 SPI Example with user interface for VB6 This programming example for Visual Basisc 6 demonstrates how to connect to an AnaGate SPI and how to execute a command on the SPI bus e Getting the global device settings like baud rate for example e Sending a single command to the SPI bus Note 1 The source code of the example can be found in directory Samples SPI vB6 on the CD 65 2007 2010 Analytica GmbH Programming examples 7 2 1 1 User interface Figure 7 1 Input form of SPI example VB6 is Test Anagate SPI Library P ES DLL Version Anagate SPI DLL V1 1 1 10 NS 192 166 1 254 esse Retum code Z Information about MAC 00 50 C2 3C BO 3E SERIAL 00000000 Hw Version 10104 S W Version 10104 device Baudrate 5000000 Siglevel High impedance uxVoltage 3 3 ClockMode CPHA 0 und CPOL 0 10 Input 00 10 Qutput 00 Baud rate 6000000 Aux Voltage 3 3V S Signal Level EE y Cloc
28. make it available through simple function calls The software API Application Programming Interface is available free of charge for Windows and Linux operarting systems Table 1 1 Library files for Windows Device Windows library AnaGate CAN AnaGateCAN dll AnaGate CAN uno duo quattro AnaGateCAN dil AnaGate CAN USB AnaGateCAN dll AnaGate SPI AnaGateSPI dll AnaGate I2C I2C X7 AnaGateI2C dll AnaGate Universal Programmer AnaGateSPI dll AnaGateI2C dll C Note To provide a widespread support of differrent programming languages like C Visual Basic Delphi and the programming languages of the NET family the cdecl calling convention is used in all function calls Using this calling convention means that all function parameters are pushed on the stack in reverse order from right to left and that the caller is responsible for the stack handling Most programming languages support this calling convention Table 1 2 Library files for Linux Device Linux library X86 ARM9 AnaGate CAN libCANdll a libAnaCommon a AnaGate CAN uno duo quattro libCANdll a libAnaCommon a available AnaGate CAN USB libCANdll a libAnaCommon a available AnaGate SPI libSPIdll a libAnaCommon a AnaGate I2C I2C X7 libI2Cdll a libAnaCommon a AnaGate Universal Programmer libSPIdil a libI2Cdll a available libAnaCommon a 3 2007 2010 Analytica GmbH The Programming interface of AnaGate product l
29. model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The current values of the digital inputs and outputs can be retrieved with the I2CReadDigital function See the following example for setting an reading the digital IO include lt AnaGateD1112C h gt int main int hHandle 0 int nRC 0 unsigned long nInputs unsigned long nOutputs 0x03 int nRC I2COpenDevice amp hHandle 400000 192 168 0 254 5000 if nRC 0 set the digital output register PIN 0 and PIN 1 to HIGH value nRC I2CWriteDigital hHandle nOutputs read all input and output registers 55 2007 2010 Analytica GmbH I2C API reference nRC I2CReadDigital hHandle amp nInputs amp nOutputs CANCloseDevice hHandle return 0 See also I2CWriteDigital 56 2007 2010 Analytica GmbH I2C API reference I2CWriteDigital I2CWriteDigital Writes a new value to the digital output register of the AnaGate device Syntax int I2CWriteDigital int hHandle unsigned long nOutputBits Parameter hHandle Valid access handle nOutputBits New register value Currently only bits 0 to 3 are used other bits are reserved for future use Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description All models of the AnaGate series except the model AnaGate
30. nc e wis ec e Y x Ei wee Ir uc KE PR Era A Ed rad 129 LS AZEWriteEEPROM sur ais 26 002 28 o OR CE NR E e RR C Do PRU 131 13 CANOPEN functions re AERA NEU ARR nen Yr RR seas coves 133 ES CANopenSetGConfig 55 2 A ves EO RR perius M ENS 134 LS CANopenGetConfig zersennnnnnnnnnnnnnnnnn nennen mean nemen ana rna nnn nnn 135 LS CANopenSetSYNCMode nennen mes nsns nna ann nnn 136 LS CANopenSetCallbacks i 137 ES CANopenGetPDO u a A REA 138 ES CANopenGetSYNO enero spo eren cd RUM e Ma EE ste RM ZR 139 73 2007 2010 Analytica GmbH Scripting language LUA LS CANopenGetEMGCY 2 near ind 140 LS CANopenGetGUARD nenne 141 LS CANopenGetUndefined eee nenn nennen nnn nn 142 LS CANopenSendNMT an a ada 143 ESSEANOpenSend SYNG ans A A eee nel 144 LS CANopenSendTIME sico la ner 145 LS CAN penSendPDO viii laca 146 LS CANopenSendSDORead Li 147 ES CANopernSendSDONWTLIte iii deis 148 LS_CANopenSendSDOReadBlock ii 149 LS_CANopenSendSDOWriteBlock cesses nemen nnne 150 Programmer example reet ii nee 151 14 LUA programming examples issus 153 14 1 Examples for devices with CAN interface en een nennen 153 14 2 Examples for devices with SPI interface ii 154 14 3 Examples for devices with I2C interface csse 155 74 2007 2010 Analytica GmbH Chapter 8 The LUA scripting inte
31. partner The user must ensure that the setup of the data buffer and the address of the I2C partner are correct The R W bit of the slave address does not have to be explicitly set by the user See also I2CWrite 51 2007 2010 Analytica GmbH I2C API reference I2CWrite I2CWrite Writes data to an I2C partner Syntax include lt AnaGateDIII2C h gt int I2CWrite int hHandle unsigned short nSlaveAddress const char pcBuffer int nBufferLen Parameter hHandle Valid access handle nSlaveAddress Slave address of the I2C partner The slave address can represent a so called 7 bit or 10 bit address siehe Appendix B I2C slave address formats pcBuffer Byte buffer with the data that is to be sent to the I2C partner nBufferLen Size of bytes to be read Return value Returns Null if successful or an error value otherwise Appendix A APT return codes Description Writes data to an I2C partner The user must ensure that the setup of the data buffer and the address of the I2C partner are correct The R W bit of the slave address does not have to be explicitly set by the user See also I2CRead 52 2007 2010 Analytica GmbH I2C API reference I2CSequence I2CSequence This command is used to write a sequence of write and read commands to an I2C device Syntax include lt AnaGateDIII2C h gt int I2CSequence int hHandle const char X pcWriteBuffer int nNumberOfBytesToWrite
32. r 500kBit e 800 000 f r 800kBit not AnaGate CAN e 1 000 000 f r 1MBit nOperatingMode The operating mode to be used Following values are allowed e O default mode e 1 loop back mode All telegrams sent by a connected partner is routed back to all active connected partners e 2 listen mode Device operates as passive bus partner this means no telegrams are sent to the CAN bus no ACKs for incoming telegrams too bTermination Use integrated CAN bus termination TRUE yes FALSE no This setting is not supported by all AnaGate CAN models bHighSpeedMode Use high speed mode TRUE yes FALSE no This setting is not supported by all AnaGate CAN models 13 2007 2010 Analytica GmbH CAN API reference The high speed mode was created for large baud rates with continuously high bus load In this mode telegrams are not confirmed on procol layer and the software filters defined via CANSetFilter are ignored bTimeStampOn Use time stamp mode TRUE yes FALSE no This setting is not supported by all AnaGate CAN models In activated time stamp mode an additional timestamp is sent with the CAN telegram This timestamp indicates when the incomming message is received by the CAN controller or when the outgoing message is confirmed by the CAN controller Return value Returns null if successful or an error value otherwise Appendix A APT return codes Description Sets the global settings of the u
33. table 5 LS CANopenGet EMCY Description Parameter int Handle int Timeout Return values int NodeID int ErrorCode int ErrorRegister int table 5 ErrorDescritpion int Seconds int Microseconds O v NodeID ErrorDescription int Handle int int Timeout ErrorRegister Microseconds int int ErrorCode Seconds int 140 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenGetGUARD LS CANopenGetGUARD Synopsis int Avai lMessages int NodeID int Status int Seconds int Microseconds LS CANopenGetGUARD int Handle int Timeout Description Parameter int Handle int Timeout Return values 2 1 gt 0 int NodeID int Status int Seconds int Microseconds 141 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenGetUndefined LS CANopenGetUndefined Synopsis int AvailMessages int CANID int NodeID int FunctionCode table 1 8 Data int Seconds int Microseconds LS CANopenGetUndefined int Handle int Timeout Description Parameter int Handle int Timeout Return values Il 1 N Il 1 O v int CANID int NodeID int FunctionCode table 1 8 Data int Seconds int Microseconds Als undefinierte Nachrichten werden die eingehenden Nachrichten bezeichnet die anhand des Funktionscodes keiner CANOpen Funktion zugeordnet werden k nnen Sollte nur in Netzen vo
34. the baud rate exactly to the parsed value the nearest smaller possible value is used instead nSigLevel The voltage level for SPI signals to be used Following values are allowed e O Outputs in High Impedance Modus Standard mode el 5 0V for the signals e 2 3 3V for the signals e 3 2 5V for the signals nAuxVoltage The voltage level of the support voltage to be used Following values are allowed 0 support voltage is 3 3V e 1 support voltage is 2 5V nClockMode The phase and polarity of the clock signal Following values are allowed e O CPHA 0 and CPOL 0 e 1 CPHA 0 and CPOL 1 36 2007 2010 Analytica GmbH SPI API reference e 2 CPHA 1 and CPOL 0 e 3 CPHA 1 and CPOL 1 Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description Sets the global settings of SPI interface of the AnaGate SPI or the AnaGate Universal Programmer These settings are not saved permantently on the device and are reset every device restart See also SPIGetGlobals 37 2007 2010 Analytica GmbH SPI API reference SPIGetGlobals SPIGetGlobals Returns the currently used global settings of the AnaGate SPI Syntax include AnaGateDIISPI h int SPIGetGlobals int hHandle int pnBaudrate unsigned char pnSigLevel unsigned char pnAuxVoltage unsigned char pnClockMode Parameter hHandle Valid access handle pn
35. the digital output register PIN 0 and PIN 1 to HIGH value nRC LS_SPIWriteDigital hHandle nOutputs read all input and output registers nRC nInputs nOutputs LS SPIReadDigital hHandle LS SPICloseDevice hHandle end See also LS SPIWriteDigital 117 2007 2010 Analytica GmbH SPI Reference LS SPIWriteDigital LS SPIWriteDigital Writes a new value to the digital output register of the AnaGate device Syntax int RC LS SPIWriteDigital int hHandle int nOutputBits Parameter hHandle Valid access handle nOutputBits New register value Currently only bits 0 to 3 are used other bits are reserved for future use Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description All models of the AnaGate series except the model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The digital outputs can be written with the LS sPIWriteDigital function A simple example for reading writing of the IOs can be found at the description of LS SPIReadDigital See also LS SPIReadDigital 118 2007 2010 Analytica GmbH Chapter 12 12C Reference Philips Semiconductors now NXP Semiconductors has developed a simple bidirectional 2 wire bus for efficient inter IC control This bus is called the Inter IC or I2C bus Only two bus lines are required a serial data li
36. the packet is sent again Double packets are recognized at the recipient and are deleted During connection the data transmission may be impaired 5 2007 2010 Analytica GmbH Notes concerning the communication protocol TCP delayed or completely interrupted A successful connection do not guarantee a permanently stable data transmission Detection and evaluation of network and line malfunctions can be difficult if there is only sporadic communication on the line How is possible to distinguish between a malfunction on the line or simply no data from the connected endpoint To amend this problematic nature TCP provides an internal keep alive mechanism Keep alives are special data packets which are sent in regular intervalls between the two endpoints of an opened communication channel The recipient of a keep alive packet has to confirm the receipt to the sender within a certain period of time Are there no keep alives or confirmations of keep alives receivedm the communication partner assumes that the channel is interrupted or the corresponding socket is malfunctioning The keep alive mechanism of TCP is not active per default and has to be activated by the setsockopt function for each connection The API functions which establish a connection to an AnaGate like the CANOpenDevice function strictly activate the keep alive mechisam of TCP Note On Windows operating systems some settings concerning keep alives can be set i
37. true yes false no This setting is not supported by all AnaGate CAn modells bHighSpeedMode Is the high speed mode switched on true yes false no This setting is not supported by all AnaGate CAN modells The high speed mode was created for large baud rates with continuously high bus load In this mode telegrams are not confirmed on procol layer and the software filters defined via LS CANSetFilter are ignored Description Returns the global settings of the used CAN interface These settings are effective for all concurrent connections to the CAN interface Remarks The settings of the integrated CAN bus termination the high speed mode and the time stamp are not supported by the AnaGate CAN hardware version 1 1 A These settings are ignored by the device 91 2007 2010 Analytica GmbH CAN Reference See also LS CANSetGlobals 92 2007 2010 Analytica GmbH CAN Reference LS CANWrite CANWriteEx Send a CAN telegram to the CAN bus via the AnaGate device Syntax RC CANWrite int hHandle int nCANId int nDataLen table nDataLen tabData Parameter hHandle nCANId nDataLen tabData nFlags int nFlags Valid access handle CAN identifier of the sender Parameter nFlags defines if the address is in extended format 29 bit or standard format 11 bit Length of data buffer max 8 bytes Data buffer with telegram data The format flags are defined as follows e Bit
38. used on a single bus Figure B 2 Definition of a I2C slave address in 10 bit format 10 bit Address Indicator Slave Address 14 12 4 3 Note Devices of type AnaGate SPI and AnaGate Universal Programmer do support both addressing modes in general The API functions I2CRead and I2CWrite address the slaves via a two byte parameter Addressing of serial EEPROM The device type identifier of a serial EEPROM is defined as 0xA This results to the following schematic structure of an address the chip enable bits are often named EO El and E2 in literature Device Type Identifier Chip Enable Address R W 7 6 5 3 2 1 0 Table B 1 I2C EEPROM addressing examples Device Type Identifier Chip Enable s R W EEPROM bz b6 b5 b4 b3 b2 b bo Memory M24C01 1 0 1 0 E2 El EO R W 128 byte 160 2007 2010 Analytica GmbH I2C slave address formats Device Type Identifier Chip Enable FR R W EEPROM b7 b6 b5 b b3 b2 bi bo Memory M24C02 1 0 1 0 E2 El EO R W 256 byte M24C04 1 0 1 0 E2 El A8 R W 512 byte M24C08 1 0 1 0 E2 A9 A8 R W 1024 byte M24C16 1 0 1 0 A10 A9 A8 R W 2048 byte M24C64 1 0 1 0 E2 El EO R W 8192 byte TEo E1 and E2 are compared against the respective external pins on the memory device 2A10 A9 and A8 represent most significant bits of the address 161 2007 2010 Analytica
39. 8 bits of the address byte and an extra bit in the slave address The total 9 bits can address up to 512 bytes 59 2007 2010 Analytica GmbH I2C API reference Return value Returns null if successful or an error value otherwise Appendix A APT return codes Description The I2CReadEEPROM function reads data from an I2C EEPROM Of course all access to the memory of an EEPROM is done by standard I2C read or write commands So when reading from the memory only the matching slave address the memory offset address and the data has to be sent to the I2C bus I2CReadEEPROM translates the given memory address on the chip by means of the sub address and the addressing mode of the present EEPROM type The slave address of the EEPROM is automatically determined and not mandatory for the fucntion call A programming example which clears a ST24C1024 can be found at the description of I2WriteEEPROM See also I2CWriteEEPROM Appendix C Programming I2C EEPROM 60 2007 2010 Analytica GmbH I2C API reference I2CWriteEEPROM I2CWriteEEPROM Writes data to an I2C EEPROM Syntax include lt AnaGateDIII2C h gt int I2CWriteEEPROM int hHandle unsigned short nSubAddress unsigned int nOffset const char pcBuffer int nBufferLen unsigned int nOffsetFormat Parameter hHandle Valid access handle nSubAddress Subaddress of the EEPROM to communicate with The valid values for nsu
40. ANCloseDevice nHandle LS_CANCloseDevice nHandle2 end 10 152 2007 2010 Analytica GmbH Chapter 14 LUA programming exa Filter alle CAN Identifier akzeptieren aFilter 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Da00 Dx FERRER 0x00 OXLEFFEEEF Wx00 OxIPERERFR 0x00 XIFFRFEER Sencilla I 0 41 002 Orr ai Nr Osa MR Weds je ck ck KKK KKK ck ck ck ck ck Ck KKK ck Ck KR KH ck AN KH A A KK V ck A Ve Ve A KH kk Dde A Sk Ve A de A AH ko A ko FACE uou Dee 5 5 2 io write string format aL ade Jus p end Ka KKK KKK KKK ck kk ck Ck ck kk ck Ck ACS Ck ck Ck ck Ck KH KH A ck RV ck kk FE H kk XX A XX ko KH H K function main EE m nRC nHandle LS CANOpenDevice false true 5001 10 1 2 160 5000 if nRC 0 then print LS CANErrorMessage nRC CNN end nRC nHandle2 LS CANOpenDevice false true 5001 10 1 2 161 5000 if nRC 0 then print LS CANErrorMessage nRC exit end Filter setzen nRC LS CANSetFilter nHandle aFilter nRC LS CANSetFilter nHandle2 aFilter aktuelle Zeit auf den AnaGate Device setzen nRC oTime LS GetTime nRC LS CANSetTime nHandle oTime 1 oTime 2 nRC LS CANSetTime nHandle2 oTime 1 oTime 2 Globals setzen nRC LS CANSetGlobals nHandle 500000 0 true false false nRC LS CANSetGlobals nHandle2 500000 0 t
41. AnaGate API E Programmer s Manual Analytica GmbH A Schmidt Analytica GmbH S Welisch Analytica GmbH AnaGate API Programmer s Manual Analytica GmbH by A Schmidt and S Welisch This document was generated with DocBook at 2012 03 13 10 04 16 Hilfe Datei dtsch AnaGate API chm Hilfe Datei engl AnaGate API EN chm PDF Datei dtsch AnaGate API 1 10 pdf PDF Datei engl AnaGate API 1 10 EN pdf Publication date 09 September 2010 Copyright 2007 2010 Analytica GmbH Abstract The AnaGate Programmer s Manual includes the exact description of the programming interfaces to all models of AnaGate hardware series This manual bases on the actual AnaGate Application Programming Interface API in Version 1 10 and the AnaGate communication protocol V1 3 see TCP 2010 All rights reserved All the information in this manual was compiled with the greatest of care However no warranty can be given for it No parts of this manual or the program are to be reproduced in any way printing photocopying microfilm or any other process without written authorisation Any processing duplication or distribution by means of any electronic system is also strictly prohibited You are also advised that all the names and brand names of the respective companies mentioned in this documentation are generally protected by brand trademark or patent laws Analytica GmbH VorholzstraBe 36 76137 Karlsruhe Germany F
42. Baudrate The baud rate currently used on the SPI bus in kBit pnSigLevel The voltage level currently used by the AnaGate SPI Following values are possible e O Outputs in High Impedance Modus Standard mode e 1 5 0V for the signals e 2 3 3V for the signals e 3 2 5V for the signals pnAuxVoltage The voltage level of the support voltage currently used by the AnaGate SPI Following values are possible e O support voltage is 3 3V e 1 support voltage is 2 5V pnClockMode The phase and polarity of the colck signal currently used by the AnaGate SPI Following values are possible e O CPHA 0 and CPOL 0 e 1 CPHA 0 and CPOL 1 e 2 CPHA 1 and CPOL 0 e 3 CPHA 1 and CPOL 1 Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description Returns the currently used global settings of SPI interface of the AnaGate SPI or the AnaGate Universal Programmer 38 2007 2010 Analytica GmbH SPI API reference See also SPISetGlobals 39 2007 2010 Analytica GmbH SPI API reference SPIDataReq SPIDataReq Writes and reads data to from SPI bus Syntax include lt AnaGateDIISPI h gt int SPIDataReq int hHandle const char pcBufWrite int nBufWriteLen char pcBufRead int nBufReadLen Parameter hHandle Valid access handle pcBufWrite Buffer with the data that is to be sent to the SPI partner nBufWriteLen Length of the
43. C 0 unsigned long nInputs unsigned long nOutputs 0x03 int nRC SPIOpenDevice amp hHandle 192 168 0 254 5000 if nRC 0 set the digital output register PIN 0 and PIN 1 to HIGH value nRC SPIWriteDigital hHandle nOutputs read all input and output registers 42 2007 2010 Analytica GmbH SPI API reference nRC SPIReadDigital hHandle amp nInputs amp nOutputs SPICloseDevice hHandle return 0 See also SPIWriteDigital 43 2007 2010 Analytica GmbH SPI API reference SPIWriteDigital SPIWriteDigital Write a new value to the digital output register of the AnaGate device Syntax include lt AnaGateDIISPI h gt int SPIWriteDigital int hHandle unsigned long nOutputBits Parameter hHandle Valid access handle nOutputBits New register value Currently only bits 0 to 3 are used other bits are reserved for future use Return value Returns null if successful or an error value otherwise Appendix A API return codes Description All models of the AnaGate series except the model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The digital outputs can be written with the sPIWriteDigital function A simple example for reading writing of the IOs can be found at the description of SPIReadDigital See also SPIReadDigital 44 2007 2010 Analytica Gm
44. CAN Reference LS CANRestartDevice LS_CANRestartDevice Restarts a AnaGate CAN device Syntax int RC LS_CANRestartDevice string sIPAddress int nTimeout Parameter sIPAddress Network address of the AnaGate partner nTimeout Default timeout for accessing the AnaGate in milliseconds A timeout is reported if the AnaGate partner does not respond within the defined timeout period Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description Restarts the AnaGate CAN device at the specified network address It disconnects implicitly all open network connections to all existing CAN interfaces The Restart command is even possible if the maximum number of allowed connections is reached Important It is recommended to use this command only in emergency cases if there is a need to connect even if the maximum number of concurrent connections is reached See also LS_CANOpenDevice 88 2007 2010 Analytica GmbH CAN Reference LS CANSetGlobals LS_CANSetGlobals Sets the global settings which are to be used on the CAN bus Syntax int RC nOperatingMode bTimeStampOn Parameter hHandle nBaudrate nOperatingMode bTermination bHighSpeedMode LS CANSetGlobals int hHandle int nBaudrate int bool bTermination bool bHighSpeedMode bool Valid access handle The baud rate to be used Following values are allowed e 10 000 f r
45. EILCEX lina i 95 LS CANSetCallback eese memes nennen a 97 LS CANGetMessage xe RR etr T RE DR M rare da IDE 99 ES CANSSEEIItGT mas ia N RAS t RAS Res ca anca ate Eas ase 101 LS CANGeGEFilter sii 2 ee Rein e ea rb D A Le RASO 102 LSCCANSSETIIIG assa 0220228287 and RENE ARTE wou ie XEM NERO NM 103 ES CANErrorMessage severe D ERI ra RR len 104 LS CANReadDigital ara nenne 105 LS CANWriteDigital irre re enr ex xr ies nennen 106 1T SPI Re f rence a Eo Mes I MP cu aaa 107 ES SPIOPENDEVICE soe cete xta ea ER naa E ON DER ERA TANE RR 108 ES SPICIOSEDEVICE T Ra care bx e ne ER ee ELE UE REY an 109 ES SPISetGlobalS un a a o e cde c at E d e EC ea Mee 110 LS SPIGetGlobals 7242222249 rr 112 ES SPIDataReqg oie ri DIT 114 ES SPIErrorMessage sre Er ER mie rn EE E EE ER NE ees 116 LS SPIReadDigital 45 ses nr ee ex eer can 117 LS SPIWriteDigital at a a Rr ex NO ds Dire en dss ren anne Ti ds 118 12 I2C Ref rence i ise tree t Ue e t oco ae as dO 119 LS AZGOPENDeViCe Lui sent ee ia 120 LS 12CGloseDeVICe kn xv ede A e ed n GON e e Ss 122 ES I2GCR6Set soos ennemie eee E dete Rene eee AE EE RUE 123 LS I2CR6ad 4512 ere iret vaa pex Deed e E e o a ged ET i 124 ESI I2 WEIte essed wate dad ath asad pase rcx Vera us Eds Ere Eve Ed oa es 125 LS I2GReadDigital sas rere exei AR 126 E S I2GWriteDigital a RAR EXE E T E E M ERI NAT E eai 127 LS I2CErrorMessage eo Eee veta ee re EUR EO EPOR E NEMORE es 128 ES 12GReadEEPROM s
46. O If set the CAN identifier is in extended format 29 bit otherwise not 11 bit e Bit 1 If set the telegram is marked as remote frame Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description Both functions sends a CAN telegram to the CAN bus via the AnaGate device like the LS_CANWriteEx function The LS_CANWriteEx additionally returns a timestamp of the time at which the telegram is sent O Note With remote frames RTR remote transmission request a destination node can request data from a source node The data length is to be set to the number of requested bytes on the CAN bus no data is sent only the data size information When using the LS_CANWrite bzw LS_CANWriteEx functions to send remote frames the data buffer and the buffer size equal to the number of requested bytes have to be set correctly See the following example for sending a data telegram to the connected CAN bus tabData 93 2007 2010 Analytica GmbH CAN Reference for Al y 1 CO table insert tabData i end nFlags 0x0 llbit address standard not remote frame nCANId 0x25 send with CAN ID 0x25 nRC hHandle LS_CANOpenDevice true true 0 192 168 0 254 5000 if nRC 0 then send 8 bytes with CAN id 37 nRC LS_CANWrite hHandle nCANId 8 tabData nFlags send a remote frame to CAN id 37 request 4 da
47. PAddress int nTimeout int nSocketType Parameter pHandle Pointer to a variable in which the access handle is saved in the event of a successful connection to the AnaGate device bSendDataConfirm It set to TRUE all incoming and outgoing Data requests are confirmed by the internal message protocol Without confirmations a better transmittion performance is reached bSendDatalnd If set to FALSE all incoming telegrams are discarded nCANPort CAN port number Allowed values are 0 for port A Modells AnaGate CAN uno AnaGate CAN duo AnaGate CAN quattro AnaGate CAN USB and AnaGate CAN 1 for port B AnaGate CAN duo AnaGate CAN quattro 2 for port C AnaGate CAN quattro 3 for port D AnaGate CAN quattro pcIPAddress Network address of the AnaGate partner nTimeout Default timeout for accessing the AnaGate in milliseconds A timeout is reported if the AnaGate partner does not respond within the defined timeout period This global timeout value is valid on the current network connection for all commands and functions which do not offer a specific timeout value nSocketType Specifies the socket type ethernet layer 4 which is to be used for the new connection Only two different types are supported TCP and UDP The funttion CANOpenDevice alyways uses TCP sockets Use the following constants fpr the parameter 1 TCP Transmission Control Protocol SOCK_STREAM 10 2007 2010 Analytica GmbH CAN API reference 2 UDP U
48. PROM types use the Chip Enable Bits EO E1 E2 as additional address bits Which bits are used in individual cases is defined by the chip producer In the following all possible combinations of the bits usage are listed Table C 1 Usage of the CHIP Enable Bits of I2C EEPROMs lt r SS Mode Usage Description 0x0 E2 E1 E0 Bits are only used to select the chip 0x1 E2 E1 AO Bit EO is used to expand the addresse space It is used for address bit A8 resp A16 0x2 E2 A1 A0 EO and El are used to expand the addresse space EO is used for address bit A8 resp A16 and El is used for A9 resp A17 0x3 A2 A1 A0 EO E1 and E2 are used to expand the addresse space EO is used for address bit A8 resp A16 E1 for A9 resp A17 and E2 for A10 resp A18 0x5 AO E1 EO Bit E2 is used to expand the addresse space It is used for address bit A8 resp A16 Das E2 Bit wird f r die Addressierung verwendet Es entspricht dabei dem Adressbit A8 bzw A16 162 2007 2010 Analytica GmbH Programming 12C EEPROM Mode Usage Description 0x6 A1 A0 E0 E2 and El are used to expand the addresse space El is used for address bit A8 resp A16 and E2 is used for A9 resp A17 Set this mode flag in bit 8 10 of parameter noffsetFormat in the API funtions I2CReadEEPROM and I2CWriteEEPROM 163 2007 2010 Analytica GmbH Appendix D FAQ Frequent asked questions Here is a lis
49. RC int SDOReadType int ReadLen table ReadData LS_CANopenSendSDOReadBlock int Handle int NodeID int Index int Subindex int Timeout int Readlen Description Parameter int Handle int NodeID int Index int Subindex int Timeout int ReadLen Return values int RC If no error occurs the return will be null 0 Otherwise the returncode will be different null 0 int SDOReadType int ReadLen table ReadData 149 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSendSDOWriteBlock LS_CANopenSendSDOWriteBlock Synopsis int RC int SDOReadTyp int SDOReadData LS CANopenSendSDOWriteBlock int Handle int SDOReadTyp int SDOReadData Description Parameter int Handle int NodeID int Index int Subindex int Timeout int WriteLen Return values int RC If no error occurs the return will be null 0 Otherwise the returncode will be different null 0 int SDOReadType int SDOReadData 150 2007 2010 Analytica GmbH Draft CANOpen functions Draft Programmer example Programmer example 151 2007 2010 Analytica GmbH Draft CANOpen functions Draft Example 13 1 CANOpen LUA script example Filter alle CAN Identifier akzeptieren aval lec 1 05 00 9 00 0 00 05 00 000 O00 MN OO 0x00 Ox1FFFFFFF 0x00 Ox1FFFFFFF 0x00 Ox1FFFFFFF 0x00 OxlFFFFFFF Sencilla I Odi ha Orr ai Oda Osa MR Ver je ck S ck c
50. SPICloseDevice Closes an open network connection to an AnaGate SPI device Syntax include AnaGateDIISPI h int SPICloseDevice int hHandle Parameter hHandle Valid access handle Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description Closes an open network connection to an AnaGate SPI device The hHandle parameter is a return value of a succesfull call to the function SPIOpenDevice i Important It is recommended to close the connection because all internally allocated system resources are freed again and the connected AnaGate device is signalled that the active connection is not longer in use and can be used again for new connect requests See also SPIOpenDevice 35 2007 2010 Analytica GmbH SPI API reference SPISetGlobals SPISetGlobals Sets the global settings which are to be used on the AnaGate SPI Syntax include lt AnaGateDIISPI h gt int SPISetGlobals int hHandle int nBaudrate unsigned char nSigLevel unsigned char nAuxVoltage unsigned char nClockMode Parameter hHandle Valid access handle nBaudrate The baud rate to be used The values can be set individually like e 500 000 for 500kBit e 1 000 000 for 1MBit e 5 000 000 for 5MBit C Note The required baud rate can be different from the value actually used because of internal hardware restrictions frequency of the oscillator If it is not possible to adjust
51. _CANWriteEx additionally returns a timestamp of the time at which the telegram is sent Note With remote frames RTR remote transmission request a destination node can request data from a source node The data length is to be set to the number of requested bytes on the CAN bus no data is sent only the data size information When using the LS_CANWrite bzw LS_CANWriteEx functions to send remote frames the data buffer and the buffer size equal to the number of requested bytes have to be set correctly 95 2007 2010 Analytica GmbH CAN Reference See the following example for sending a data telegram to the connected CAN bus tabData foe 8 1 co table insert tabData i end nFlags 0x0 11bit address standard not remote frame nCANId 0x25 send with CAN ID 0x25 nRC hHandle LS_CANOpenDevice true true 0 192 168 0 254 5000 if nRC 0 then send 8 bytes with CAN id 37 nRC nSeconds nMicroSeconds LS_CANWriteEx hHandle nCANId 8 tabData nFlags send a remote frame to CAN id 37 request 4 data bytes nRC nSeconds nMicroSeconds LS_CANWriteEx hHandle nCANId 4 tabData 0x02 LS_CANCloseDevice hHandle end Remarks For devices of type AnaGate CAN hardware version 1 1 A the function CANWriteEx is equal to CANWrite the return values nSeconds and pnMicroseconds Will remain unchanged See also LS CANWrite 96 2007 2010 Analytica
52. a from an I2C partner The user must ensure that the setup of the address of the I2C partner are correct The R W bit of the slave address does not have to be explicitly set by the user See also LS_I2CWrite 124 2007 2010 Analytica GmbH I2C Reference LS I2CWrite LS I2CWrite Writes data to an I2C partner Syntax int RC int nSlaveAddress Parameter hHandle nSlaveAddress nBufferLen tabBuffer Return value ErrorByte LS I2CWrite int hHandle unsigned short table nBufferLen tabBuffer int nBufferLen Valid access handle Slave address of the I2C partner The slave address can represent a so called 7 bit or 10 bit address siehe Appendix B I2C slave address formats Size of bytes to be read Byte buffer with the data that is to be sent to the I2C partner RC Returns 0 if successful or an error value otherwise Appendix A API return codes ErrorByte Number of byte in data buffer which raises the error if the function failed Description Writes data to an I2C partner The user must ensure that the setup of the data buffer and the address of the I2C partner are correct The R W bit of the slave address does not have to be explicitly set by the user See also LS_I2CRead 125 2007 2010 Analytica GmbH I2C Reference LS 12CReadDigital LS I2CReadDigital Reads the current values of digital input and output registers of the AnaGate device Syntax int
53. a from different commands are stored in the buffer sequential first the data of command 1 then the data of command 2 nNumberOfBytesRead byte size of the read buffer must be big enough for all included read requests pnNumberOfBytesRead byte count which is read from I2C pnByteNumberLastError Number of byte in the pcwriteBuffer buffer which raises an error Return value Returns null if successful or an error value otherwise Appendix A API return codes Description The user must ensure that the setup of the data buffer and the address of the I2C partner are correct 54 2007 2010 Analytica GmbH I2C API reference I2CReadDigital I2CReadDigital Reads the current values of digital input and output registers of the AnaGate device Syntax include lt AnaGateDIII2C h gt int I2CReadDigital int hHandle unsigned long pnInputBits unsigned long pnOutputBits Parameter hHandle Valid access handle pnInputBits Pointer to the current value of the digital input register Currently only bits O to 3 are used other bits are reserved for future use and are set to O pnOutputBits Pointer to the current value of the digital output register Currently only bits O to 3 are used other bits are reserved for future use and are set to O Return value Returns Null if successful or an error value otherwise Appendix A APT return codes Description All models of the AnaGate series except the
54. age can be used as well as additional functional extensions for access of the AnaGate hardware The scripting language LUA is very well suited for use on embedded systems because of its good performance and small runtime size For this reason the LUA interpreter is integrated in the firmware of the AnaGate hardware E So it is possible to execute scripts not only on the personal computer but also on the AnaGate device itself Note Q Please refer to the printed paperbacks LUA Reference Manual LuaRef2006 EN and Programming in Lua LuaProg2006 EN for detailed information about LUA The reference manual is also available online at Lua org http www lua org tonly AnaGate CAN uno AnaGate CAN duo AnaGate CAN quattro AnaGate CAN USB and AnaGate Universal Programmer 75 2007 2010 Analytica GmbH The LUA scripting interface of the AnaGate product line 8 1 Creating scripts Creating and editing of script files for the scripting language LUA is exceptionally easy because a standard text editor is sufficient to do that On Windows operating systems Notepad or Wordpad can be used for example on linux systems vi or other text tools In the meantime some text editors partly free of charge support syntax high lighting for LUA which makes it really easier for a programmer to develop Figure 8 1 Edit LUA script in a text editor Y Tools AnaGate Tools LUA Get_Serial lua lt EIER x Datei Bearbeiten Suche
55. an be written with the LS_CANWriteDigital function A simple example for reading writing of the IOs can be found at the description of LS_SPIReadDigital See also LS_SPIReadDigital 106 2007 2010 Analytica GmbH Chapter 11 SPI Reference The Serial Peripheral Interface SPI is a synchroneous data link standard named by Motorola which operates in full duplex mode The SPI gateway models of the AnaGate series provides access to a SPI bus via a standard networking With the SPI API these SPI gateways can be easily controlled The programming interface is identical for all devices and used the network protocol TCP in general Following devices can be addresse via the SPI API interface e AnaGate SPI e AnaGate Universal Programmer Note All SPI specific functionality of the AnaGate C API is also available f r LUA users the LUA function extensions are documented in the following 107 2007 2010 Analytica GmbH SPI Reference LS SPlOpenDevice LS SPIOpenDevice Opens a network connection to an AnaGate SPI device Syntax int RC int Handle LS_SPIOpenDevice string sIPAddress int nTimeout Parameter sIPAddress Network address of the AnaGate partner nTimeout Default timeout for accessing the AnaGate in milliseconds A timeout is reported if the AnaGate partner does not respond within the defined timeout period This global timeout value is valid on the current network connection for all comma
56. arted by the CAN API and which is reading data from the socket Because of this behaviour the callback code is executed by the thread context of the API and therefore it uses it the heap memeory of the API DLL and not 23 2007 2010 Analytica GmbH CAN API reference the application program So programming code should not use functions like new delete alloc or free which allocate free or reallocate heap memory inside the callback See the following example for using a callback include lt AnaGateCAND11 h gt Defintion of a callback which writes incoming CAN data with timestamp to console void WINAPI MyCallbackEx int nIdentifier const char pcBuffer int nBufferLen int nFlags int hHandle long nSeconds long nMicroseconds std cout lt lt CAN ID lt lt nIdentifier lt lt Data tOr q int E NO Gk lt lt ebenen MCE std cout lt lt Ox lt lt std hex lt lt int unsigned char pcBuffer i time_t tTime nSeconds struct tm psLocalTime localtime amp tTime StdrIcout lt lt MS std sebw o lt lt asctimeit psLocaitimev xe mms desde lt lt std setw 3 lt lt nMicroseconds 1000 lt lt lt lt nMicroseconds 1000 lt lt lt lt std endl int main int hHandle 0 int nRC 0 int nRC CANOpenDevice amp hHandle TRUE TRUE 0 192 168 0 254 5000 if nRC 0 deactivate callback nRC CANSetCallbackEx hHandle MyCallbackEx
57. ate API 8 2 Running scripts on personal computer 76 8 3 Running scripts on AnaGate hardware nennen 77 9 Common function reference 0 80 LS DevicelrnfOo eedem a E EE CS Y RE e E Co 81 LS GetTilne o a te LP Ee Die Eddie Erde Od bases 82 EXE IDEM 83 10 CAN Reference essi ia ae et FAR CR NR ace vale st buceo ace te vts e FA TS 84 LS CANOpenDevice nnm CORS R A GORA RE CAR aan renean nnn 85 LS CANCIOSeDevic dc e na ang ee a bec OVER een esse TER EP PL 87 LS CANRestartDeviCe ri 88 LS CANSetGlobals cccccccecccceecccceeeueusuueuscuueueucuseueueuauenevauenesneuguens 89 LS CANGetGlobals stc een ee nn LR wa CE E ana ras 91 LS CANWrLEItG curia ret cas pe GTS P eui cadet da Bree Sen rude 93 LS CANWrLIteEX iii nn nr 95 LS CANS etCallbacGh ana a en 97 LS CANGetMesSage m nn einen 99 LSZEANSEREIITET coi LITRI a Aa Re RE dose 101 LS CANGetFilter u na en eurer 102 LS CANSetTIME ar Henn 103 LS CANErrorMessage xc ec a cee ERA 104 LS CANRead Digital areas 105 LS CANWriteDigital nan na nn nen nar a nr ia 106 UT SPE Reference Da 107 LS_SPIOpenDevice nean A DEAN nnn EN D DRA nna aan 108 LS SPIGIOSGDGVICG ran a einen CURAR AYER CY Sa Pa ebria 109 ES SPISetGlobals u rre ann 110 LS SPIGetGlobals aenant naaa aA Paaa haa CTA nena nun nun 112 LS SPIDataReq reu Ex Eee T Rye EXE OY REY ae 114 LS SPIErrorMesSaGe
58. bAddress are governed by the setting used in the parameter nOffsetFormat bits 8 10 If the EEPROM type needs to use bits of the Chip Enable Address to address the internal memory only the remaining bits can be used to select the device itself e No bit is used for addressing 0 to 7 e 1 bit is used for addressing O to 3 e 2 bits are used for addressing O to 1 e 3 bits are used for addressing O nOffset Data offset on the EEPROM to which the transferred data is to be written pcBuffer Character string buffer with the data that is to be written nBufferLen Length of the data buffer nOffsetFormat Defines how a memory address of EEPROM has to be specified when accessing the device Bits 0 7 indicate the number of bits which are used in the address byte word of the I2C command for addressing the device memory Bits 8 10 indicate how much and which bits of the Chip Enable Bits are used for addressing the device memory see Table C 1 Usage of the CHIP Enable Bits of I2C EEPROMs for allowed values Note C The maximum addressable size of an EEPROM is derived from the sum of all the bits For example a M24C08 uses 8 bits of the address byte and an extra bit in the slave address The total 9 bits can address up to 512 bytes 61 2007 2010 Analytica GmbH I2C API reference Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description The 12CWriteEEPROM f
59. bH SPI API reference SPIErrorMessage SPIErrorMessage Returns a description of the given error code as a text string Syntax include lt AnaGateDIICAN h gt int SPIErrorMessage int nRetCode char pcMessage int nMessageLen Parameter nRetCode Error code for which the error description is to be determined pcMessage Data buffer that is to accept the error description nMessageLen Size in bytes of the transferred data buffer Return value Actual size of the returned description Description Returns a textual description of the parsed error code see Appendix A APT return codes If the destination buffer is not big enough to store the text the text is shortened to the specified buffer size See the following example in C C language IAE RC char cBuffer 200 Limia TRGA Jf es Call a API stude h re SPIErrorMessage nRC cBuffer 200 stat scout lt lt Fenlers P lt Butter lt lt stds vendi 45 2007 2010 Analytica GmbH Chapter 6 I2C API reference Philips Semiconductors now NXP Semiconductors has developed a simple bidirectional 2 wire bus for efficient inter IC control This bus is called the Inter IC or I2C bus Only two bus lines are required a serial data line SDA and a serial clock line SCL Serial 8 bit oriented bidirectional data transfers can be made at up to 100 kbit s in the Standard mode up to 400 kbit s in the Fast mode up to 1 Mbit s in t
60. cOpenDevice i Important It is recommended to close the connection because all internally allocated system resources are freed again and the connected AnaGate device is signalled that the active connection is not longer in use and can be used again for new connect requests See also I2COpenDevice 49 2007 2010 Analytica GmbH I2C API reference I2CReset I2CReset Resets the I2C Controller in an AnaGate I2C device Syntax include lt AnaGateDIII2C h gt int I2CReset int hHandle Parameter hHandle Valid access handle Return value Returns null if successful or an error value otherwise Appendix A APT return codes Description Resets the I2C Controller in an AnaGate I2C device 50 2007 2010 Analytica GmbH I2C API reference I2CRead I2CRead Reads data from an I2C partner Syntax include lt AnaGateDIII2C h gt int I2CRead int hHandle unsigned short nSlaveAddress const char pcBuffer int nBufferLen Parameter hHandle Valid access handle nSlaveAddress Slave address of the I2C partner The slave address can represent a so called 7 bit or 10 bit address siehe Appendix B I2C slave address formats pcBuffer Byte buffer in which the data received from the I2C partner is to be stored nBufferLen Number of bytes to read Return value Returns null if successful or an error value otherwise Appendix A API return codes Description Reads data from an I2C
61. ca GmbH CAN API reference CANCloseDevice CANCloseDevice Closes an open network connection to an AnaGate CAN device Syntax include lt AnaGateDllCan h gt int CANCloseDevice int hHandle Parameter hHandle Valid access handle Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description Closes an open network connection to an AnaGate CAN device The hHandle parameter is a return value of a succesfull call to the function CANOpenDevice i Important It is recommended to close the connection because all internally allocated system resources are freed again and the connected AnaGate device is signalled that the active connection is not longer in use and can be used again for new connect requests See also CANOpenDevice CANOpenDeviceEx 12 2007 2010 Analytica GmbH CAN API reference CANSetGlobals CANSetGlobals Sets the global settings which are to be used on the CAN bus Syntax include lt AnaGateDIICAN h gt int CANSetGlobals int hHandle int nBaudrate unsigned char nOperatingMode BOOL bTermination BOOL bHighSpeedMode BOOL bTimeStampOn Parameter hHandle Valid access handle nBaudrate The baud rate to be used Following values are allowed e 10 000 f r 10kBit e 20 000 f r 20kBit e 50 000 f r 50kBit e 62 500 f r 62 5kBit e 100 000 f r 100kBit e 125 000 f r 125kBit e 250 000 f r 250kBit e 500 000 f
62. ce settings All SPI related functions of the AnaGate API are declared for Visual Basic users in AnaGateSPI bas and are read to use The following code snipplet includes some exemplary declarations of the API functions used below Public Declare Function SPIOpenDevice Lib AnaGateSPIVB6 _ Alias _SPIOpenDevice 12 ByRef Handle As Long _ ByVal TCPAddress As String _ ByVal Timeout As Long As Long Public Declare Function SPICloseDevice Lib AnaGateSPIVB6 _ Alias _SPICloseDevice 4 ByVal Handle As Long As Long Public Declare Function SPIGetGlobals Lib AnaGateSPIVB6 _ Alias _SPIGetGlobals 20 ByVal hHandle As Long _ ByRef nBaudrate As Long _ ByRef Sighevel As Byte _ ByRef nAuxVoltage As Byte _ ByRef nClockMode As Byte As Long The event procedure btnCheckAddress_Click is called on click of the Check Address button Private Sub btnCheckAddress_Click Dim nRC As Long Data As String sText As String I As Long nRC SPIOpenDevice hHandle Me IPAddresse Text 2000 H If nRC lt gt 0 Then Me lblErrorMsg Caption Fehler bei SPIOpenDevice amp GetErrorMsg nRC Else Me lblErrorMsg Caption GetAnagatelnfo hHandle End If nRC SPICloseDevice hHandle B End Sub Ei A call to SPIOpenDevice establishes a network connection to the device If the function fails a textual error description is returned via Funktion GetErrorMsg E The connection to the device is closed with the SPICloseDevice
63. ceive 1 byt nRC SPIDataReq hHandle cBufW2ite 2 cBufReceive 1 SPICloseDevice hHandle return 0 Return value Returns null if successful or an error value otherwise Appendix A API return codes 41 2007 2010 Analytica GmbH SPI API reference SPIReadDigital SPIReadDigital Reads the current values of digital input and output registers of the AnaGate device Syntax include lt AnaGateDIISPI h gt int SPIReadDigital int hHandle unsigned long pnInputBits unsigned long pnOutputBits Parameter hHandle Valid access handle pnInputBits Pointer to the current value of the digital input register Currently only bits 0 to 3 are used other bits are reserved for future use and are set to 0 pnOutputBits Pointer to the current value of the digital output register Currently only bits 0 to 3 are used other bits are reserved for future use and are set to 0 Return value Returns null if successful or an error value otherwise Appendix A API return codes Description All models of the AnaGate series except the model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The current values of the digital inputs and outputs can be retrieved with the SPIReadDigital function See the following example for setting an reading the digital IO include lt AnaGateD11SPI h gt int main int hHandle 0 int nR
64. ck function Declare Function CANOpenDevice Lib AnaGateCAN ByRef Handle As Int32 _ ByVal ConfirmData As Int32 _ ByVal MonitorOn As Int32 _ ByVal PortNumber As Int32 _ ByVal TCPAddress As String _ ByVal Timeout As Int32 As Int32 Declare Function CANCloseDevice Lib AnaGateCAN ByVal Handle As Int32 As Int32 Public Delegate Sub CAN_CALLBACK ByVal ID As Int32 ByVal Buffer As IntPtr _ ByVal Bufferlen As Int32 ByVal Flags as Int32 _ ByVal Handle as Int32 Declare Function CANSetCallback Lib AnaGateCAN ByVal Handle As Int32 _ ByVal MyCB As CAN_CALLBACK As Int32 Sub CANCallback ByVal ID As Int32 ByVal Buffer As IntPtr ByVal Bufferlen As Int32 _ ByVal Flags as Int32 ByVal Handle as Int32 Dim Bytes as Byte 8 System Runtime InteropServices Marshal Copy Buffer Bytes 0 Bufferlen Console Out Write CAN ID Console Out Write ID Console Out Write Data For I As Integer 0 To BufferLen 1 Console Out Write Bytes I Next End Sub Function Main ByVal CmdArgs As String As Integer Opens the single CAN port of a AnaGate CAN dim RC as Int32 CANOpenDevice Handle 0 1 400 0 192 168 2 1 1000 If RC 0 Then CANSetCallback Handle AddressOf CANCallback end If If RC 0 Then CANCloseDevice Handle end if end Function 7 3 2 SPI Console application VB NET This programming example for VB NET demonstrates how to connect to an AnaGate SPI and how to execute SPI commands Note
65. conds Description Returns the system time as the number of elapsed seconds and milliseconds since midnight of January 1 1970 82 2007 2010 Analytica GmbH Common function reference LS Sleep LS Sleep Suspends the execution until the time out interval elapses Syntax int RC LS Sleep unsigned int nMilliseconds Parameter nMilliseconds The time interval for which execution is to be suspended in milliseconds Return value RC Returns 0 if successful or an error value otherwise Table A 5 Return values for LUA scripting Description Suspends the execution until the time out interval in milliseconds elapses 83 2007 2010 Analytica GmbH Chapter 10 CAN Reference The CAN API can be used with all CAN gateway models of the AnaGate series The programming interface is identical for all devices and uses the network protocol TCP or UDP in general Following devices can be addresse via the CAN API interface e AnaGate CAN e AnaGate CAN uno e AnaGate CAN duo e AnaGate CAN quattro e AnaGate CAN USB Note All CAN specific functionality of the AnaGate C API is also available f r LUA users the LUA function extensions are documented in the following 84 2007 2010 Analytica GmbH CAN Reference LS CANOpenDevice LS CANOpenDevice Opens an network connection TCP to an AnaGate CAN device Syntax int RC int Handle LS CANOpenDevice boolbSendDataConfirm bo
66. do not offer a specific timeout value Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description Opens a TCP IP connection to an AnaGate I2C resp AnaGate Universal Programmer After the connection is established access to the I2C bus is possible Note The AnaGate I2C resp the I2C interface of an AnaGate Universal Programmer does not allow more than one concurrent network connection During an established network connection all new connections are refused 47 2007 2010 Analytica GmbH I2C API reference See the following example for the initial programming steps include lt AnaGateD1112C h gt int main int hHandle int nRC I2COpenDevice amp hHandle 100000 192 168 0 254 5000 if nRC now do something I2CCloseDevice hHandle return 0 See also I2CCloseDevice 48 2007 2010 Analytica GmbH I2C API reference I2CCloseDevice I2CCloseDevice Closes an open network connection to an AnaGate I2C device Syntax include lt AnaGateDIII2C h gt int I2CCloseDevice int hHandle Parameter hHandle Valid access handle Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description Closes an open network connection to an AnaGate I2C device The hHandle parameter is a return value of a succesfull call to the function I2
67. e control pins E2 and E1 have to be LOW E 17 address bits are used to address the 128KB of a ST24C1024 16 bits are set via the address bytes of the write command 16 0x0F The address bit A16 is set via the EO bit of the Chip Enable Address therefore addressing mode 1 E2 E1 A0 must be set 0x10 E The page size of a ST24C1024 is 256 byte every page is programmed full within the for loop See also I2CReadEEPROM 62 2007 2010 Analytica GmbH I2C API reference Appendix C Programming I2C EEPROM 63 2007 2010 Analytica GmbH Chapter 7 Programming examples 7 1 Programming language C C The AnaGate programming API can be used on Windows systems as well as on linux systems X86 All available API functions are coded operating system independant so that source code once created can be used on both operating systems Only the way the libraries are linked on the different operating systems or different compilers have to be customized Windows operating systems There are basically two ways to access the API functions for the C C programmer e When directly accessing the library all functions has to made known by preceding calls to the Win32 methods LoadLibrary and GetProcAddress e The functions can be alternatively accessed easily via an import library which automatically loads all DLL functions and make them available implicitely In the following examples it is assumed that the second option is used
68. eadDigital function See the following example for setting an reading the digital IO include lt AnaGateCAND11 h gt int main int hHandle 0 int nRC 0 unsigned long nInputs unsigned long nOutputs 0x03 int nRC CANOpenDevice amp hHandle TRUE TRUE 0 192 168 0 254 5000 ase mince MON set the digital output register PIN 0 and PIN 1 to HIGH value nRC CANWriteDigital hHandle nOutputs read all input and output registers 25 2007 2010 Analytica GmbH CAN API reference nRC CANReadDigital hHandle amp nInputs amp nOutputs CANCloseDevice hHandle return 0 See also CANWriteDigital 26 2007 2010 Analytica GmbH CAN API reference CANWriteDigital CANWriteDigital Writes a new value to the digital output register of the AnaGate device Syntax include lt AnaGateDIICAN h gt int CANWriteDigital int hHandle unsigned long nOutputBits Parameter hHandle Valid access handle nOutputBits New register value Currently only bits 0 to 3 are used other bits are reserved for future use Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description All models of the AnaGate series except the model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs ant the rear panel The digital outputs can be written wi
69. ed via a callback function which can be set by a simple API call If a callback function is used is will be called by the API 97 2007 2010 Analytica GmbH CAN Reference asynchronous In alternative to the callback function incoming data telegrams can be retrieved with the LS_CANGetMessage function See the following example for using a callback function MyCallback nID nLen tabData nFlags nHandle nSecond nMSecond jo write string format 3X 3X d nHandle nID nLen for iel L n 1 do jo write string format 2X tabData i end io write n io flush end function main nRC nHandle LS_CANOpenDevice false true 0 127 0 0 1 5000 if nRC 0 then errortext LS_CANErrorMessage nRC printer ss n errortext return end set globals 100kBit standard mode termination off no highspeed no timestamp nRC LS_CANSetGlobals nHandle 100000 0 true false false nRC LS_CANSetCallback nHandle MyCallback while true do forever Ls Sleep 500 end nRC LS_CANSetCallback hHandle LS CANCloseDevice nHandle end See also LS CANWrite LS CANWriteEx LS CANGetMessage 98 2007 2010 Analytica GmbH CAN Reference LS CANGetMessage LS_CANGetMessage Syntax int nAvail int nCANId int nDataLen table tabData int nFlags int nSeconds int nMicroseconds LS_CANGetMessage int hHandle int nTimeout
70. efines an asynchronous callback function which is called for each incoming CAN telegram Syntax include lt AnaGateDllCan h gt typedef void WINAPI CAN PF CALLBACK int nIdentifier const char pcBuffer int nBufferLen int nFlags int hHandle int CANSetCallback int hHandle CAN_PF_CALLBACK pCallbackFunction typedef void WINAPI CAN_PF_CALLBACK_EX int nIdentifier const char pcBuffer int nBufferLen int nFlags int hHandle long nSeconds long nMicroseconds int CANSetCallbackEx int hHandle CAN_PF_CALLBACK_Ex pCallbackFunctionEx Parameter hHandle Valid access handle pCallbackFunction Function pointer to the private callback function Set this parameter to NULL to deactivate the callback function The parameters of the callback function are described in the documentation of the CANWrite funciton pCallbackFunctionEx Function pointer to the private callback function Set this parameter to NULL to deactivate the callback function The parameters of the callback function are described in the documentation of the CANWriteEx funciton Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description Incoming CAN telegrams can bei received via a callback function which can be set by a simple API call If a callback function us set is will be called by the API asynchronous Caution The callback fucntion is called from a thread which is st
71. endix A API return codes See the following example in LUA scripting language nRC 0 sErrorText No Error Moss Call a API iuacrloa har sErrorText LS_SPIErrorMessage nRC print sErrorText 116 2007 2010 Analytica GmbH SPI Reference LS SPIReadDigital LS_SPIReadDigital Reads the current values of digital input and output registers of the AnaGate device Syntax int RC int nInputBits int nOutputBits LS_SPIReadDigital int hHandle Parameter hHandle Valid access handle Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes nInputBits Pointer to the current value of the digital input register Currently only bits O to 3 are used other bits are reserved for future use and are set to 0 nOutputBits Pointer to the current value of the digital output register Currently only bits O to 3 are used other bits are reserved for future use and are set to 0 Description All models of the AnaGate series except the model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The current values of the digital inputs and outputs can be retrieved with the LS_SPIReadDigital function See the following example for setting an reading the digital IO nOutputs 0x03 nRC hHandle LS_SPIOpenDevice 400000 192 168 0 254 5000 if nRC then set
72. error value otherwise Appendix A API return codes Description The LS_I2CWriteEEPROM function writes data to an I2C EEPROM Of course all access to the memory of an EEPROM is done by standard I2C read or write commands So when writing to the memory only the matching slave address the memory offset address and the data has to be sent to the I2C bus LS_I2CWriteEEPROM translates the given memory address on the chip by means of the sub address and the addressing mode of the present EEPROM type The slave address of the EEPROM is automatically determined and not mandatory for the fucntion call TP It is important to note that an EEPROM is divided into memory pages and that a single write command can only program data within a page Users of LS_I2CWriteEEPROM must ensure to do not write across page limits The page size depends on the EEEPOM type See the following example for writing data to a ST24C1024 tabData mor a 256 Jt ele table insert tabData 0x0 end nSubAddress 0 H nOffsetFormat 0x10 0x0F A RC hHandle LS_I2COpenDevice 400000 192 168 0 254 5000 if RC 0 then for page 0 512 1 1 do RC LS I2CWriteEEPROM hHandle nSubAddress i 256 nOffSetFormat 256 tabData H end LS I2CCloseDevice hHandle end E Itis possible to address 4 individual ST24C1024 on a single I2C bus By selection of subaddress 0 the control
73. est a destination node can request data from a source node The data length is to be set to the number of requested bytes on the CAN bus no data is sent only the data size information When using the CANWrite bzw CANWriteEx functions to send remote frames the data buffer and the buffer size equal to the number of requested bytes have to be set correctly See the following example for sending a data telegram to the connected CAN bus include lt AnaGateCAND11 h gt int main Chiers engel 4 dp 25 Bo dy Sn 5 752 By 9 O IP int hHandle OF int nRC 0 int nFlags 0x0 llbit address standard not remote frame int nIdentifier 0x25 send with CAN ID 0x25 int nRC CANOpenDevice amp hHandle TRUE TRUE 0 192 168 0 254 5000 if nRC send 8 bytes with CAN id 37 nRC CANWrite hHandle nIdentifier cMsg 8 nFlags send a remote frame to CAN id 37 request 4 data bytes nRC CANWrite hHandle nIdentifier cMsg 4 0x02 CANCloseDevice hHandle return 0 Remarks The CANWriteEx function is supported by library version 1 4 1 8 or higher For devices of type AnaGate CAN hardware version 1 1 A the function CANWriteEx is equal to CANWrite the return values pnSeconds and pnMicroSeconds Will remain unchanged 22 2007 2010 Analytica GmbH CAN API reference CANSetCallback CANSetCallbackEx CANSetCallback CANSetCallbackEx D
74. et 46 I2COpenD6eVICe s eleven rar BE Ree ae cre x e Ra rc ere Y e D 2 47 TAC CIOSE DEVICE er era ope eA ro XR de RE Deas weg UY REA DU TS DR 49 I2CReset oeste Ec RN UO UE 50 PAE T e EA EE A N A A E A E EA T 51 TAG WILE a A ER ORRORI i 52 I2CS quence 1220252850224227 rase il de ER stage RER ee 53 12CR adDigital a2 ia een 55 T2EWriteDigital ann a ace oix e 57 T2CErr rMess age A a NE 58 T2CREadEEPROM nn AGR ALOE ERE E Rc RUN ER rendra ele wees 59 I2CWrIteEEPROM oit mee Ra E DA I EXER ORE RENE aetna re 61 7 Programming examples menses enn 64 7 1 Programming language C C 64 7 2 Programming language Visual Basic 6 iss 65 7 3 Programming language VB NET en mme 69 2 2007 2010 Analytica GmbH Chapter 1 The Programming interface of AnaGate product line The AnaGate product line consist of several hardware devices which offers access to different bus systems I2C SPI CAN or processors Renesas via standard network protocol The communication to the individual devices always is done through a documented and disclosed proprietary network protocol Thus all products which incorporates a socket interface like personal computers PLC are allowed to access the devices of the AnaGate product line Analytica provides a programming interface for users of Windows and Linux operating systems X86 which implements the proprietary communication protocol and
75. evice establishes a network connection to the device If the function fails a textual error description is returned via Funktion GetErrorMsg SPISetGlobals sets the global parameters of the device baud rate signal level voltage level of the support voltage clock mode Via the SPIDataReg function data is written to the SPI bus If the command is successful the data read from the SPI partner is returned in the receive buffer The connection to the device is closed with the SPICloseDevice function The functions of the programming API are defined in a wrapper module In the following you can see a part of the wrapper module which includes the declarations of all API functions Imports System Runtime InteropServices Namespace Analytica AnaGate Public Module AnaGateAPI Declare Function SPIOpenDevice Lib AnaGateSPI ByRef Handle As Int32 ByVal TCPAddress As String _ ByVal Timeout As Int32 As Int32 Declare Function SPICloseDevice Lib AnaGateSPI ByVal Handle As Int32 As Int32 Declare Function SPISetGlobals Lib AnaGateSPI ByVal ByVal Handle As Int32 _ Baudrate As Int32 ByVal ByVal ByVal Declare Function SPIGetGlobals Lib AnaGateSPI ByVal ByRef ByRef Siglevel As Byte AuxVoltage As byte _ ClockMode As byte As Int32 Handle As Int32 _ Baudrate As Int32 _ SigLevel As Byte 70 2007 2010 Analytica GmbH Programming examples ByRef AuxVoltage As Byte ByRef ClockMode A
76. ffer that is to accept the error description nMessageLen Size in bytes of the transferred data buffer Return value Actual size of the returned description Description Returns a textual description of the parsed error code see Appendix A APT return codes If the destination buffer is not big enough to store the text the text is shortened to the specified buffer size See the following example in C C language IAE RC char cBuffer 200 alie TRGA lf sos Call a API suede h re CANErrorMessage nRC cBuffer 200 slats cout lt lt Fehlers cButrers lt lt stdicendis 31 2007 2010 Analytica GmbH Chapter 5 SPI API reference The Serial Peripheral Interface SPI is a synchroneous data link standard named by Motorola which operates in full duplex mode The SPI gateway models of the AnaGate series provides access to a SPI bus via a standard networking With the SPI API these SPI gateways can be easily controlled The programming interface is identical for all devices and used the network protocol TCP in general Following devices can be addresse via the SPI API interface e AnaGate SPI e AnaGate Universal Programmer 32 2007 2010 Analytica GmbH SPI API reference SPIOpenDevice SPIOpenDevice Opens a network connection to an AnaGate SPI device Syntax include lt AnaGateDIISPI h gt int SPIOpenDevice int pHandle const char pcIPAddress int nTimeout
77. ffsetFormat nDataLen tabData Valid access handle Subaddress of the EEPROM to communicate with The valid values for nSubAddress are governed by the setting used in the parameter nOffsetFormat bits 8 10 If the EEPROM type needs to use bits of the Chip Enable Address to address the internal memory only the remaining bits can be used to select the device itself e No bit is used for addressing O to 7 e 1 bit is used for addressing O to 3 e 2 bits are used for addressing O to 1 e 3 bits are used for addressing O Data offset on the EEPROM to which the transferred data is to be written Defines how a memory address of EEPROM has to be specified when accessing the device Bits 0 7 indicate the number of bits which are used in the address byte word of the I2C command for addressing the device memory Bits 8 10 indicate how much and which bits of the Chip Enable Bits are used for addressing the device memory see Table C 1 Usage of the CHIP Enable Bits of I2C EEPROMs for allowed values C Note The maximum addressable size of an EEPROM is derived from the sum of all the bits For example a M24C08 uses 8 bits of the address byte and an extra bit in the slave address The total 9 bits can address up to 512 bytes Length of the data buffer Character string buffer with the data that is to be written 131 2007 2010 Analytica GmbH I2C Reference Return value RC Returns 0 if successful or an
78. ful or an error value otherwise Appendix A API return codes Description Sets the global settings of the used CAN interface These settings are effective for all concurrent connections to the CAN interface The settings are not saved permantently on the device and are reset every device restart Remarks The settings of the integrated CAN bus termination the high speed mode and the time stamp are not supported by the AnaGate CAN hardware version 1 1 A These settings are ignored by the device See also LS CANGetGlobals 90 2007 2010 Analytica GmbH CAN Reference LS CANGetGlobals LS CANGetGlobals Returns the currently used global settings on the CAN bus Syntax int RC int nBaudrate int nOperatingMode bool bTermination bool bHighSpeedMode bool bTimeStampOn LS_CANGetGlobals int hHandle Parameter hHandle Valid access handle Return values RC Returns 0 if successful or an error value otherwise Appendix A API return codes nBaudrate The baud rate currently used on the CAN bus nOperatingMode The operating mode to be used Following values are returned e O default mode e 1 loop back mode All telegrams sent by a connected partner is routed back to all active connected partners e 2 listen mode Device operates as passive bus partner this means no telegrams are sent to the CAN bus no ACKs for incoming telegrams too bTermination Is the integrated CAN bus termination used
79. function Reading the device settings and creation of the textual presentation of the data is done by the GetAnagateInfo function Private Function GetAnagateInfo hHandle As Long As String Dim nRC As Long sText As String Dim nBaudrate As Long nSigLevel As Byte nAuxVoltage As Byte nClockMode As Byte Dim nDigitalOutput As Long nDigitalInput As Long nRC SPIGetGlobals hHandle nBaudrate nSigLevel nAuxVoltage nClockMode If nRC 0 Then sText sText amp Baudrate amp CStr nBaudrate amp Siglevel Select Case nSighevel Case 1 sText sText amp 5 0V Case 2 sText Sex amp 3 3V Case 3 sText sText amp 2 5V Case Else sText sText amp High impedance End Select sText sText amp vbCrLf amp AuxVoltage Select Case nAuxVoltage Case 1 sText sText amp 2 5V Case Else sText sText amp 3 3V End Select sText sText amp ClockMode Select Case nClockMode Case 1 sText sText amp CPHA 0 und CPOL 1 Case 2 sText sText amp CPHA 1 und CPOL 0 Case 3 sText sText amp CPHA 1 und CPOL 1 Case Else sText sText amp CPHA 0 und CPOL 0 End Select 67 2007 2010 Analytica GmbH Programming examples Else sText sText amp Fehler bei SPIGetGlobals amp GetErrorMsg nRC amp vbCrLf Price GetAnagateInfo sText End Function 7 2 1 3 Executing a command on the SPI bus The AnaGate SPI can send arbitrary commands to the connected SPI b
80. g interface of AnaGate product line Li 3 2 Notes concerning the communication protocol TCP en nn nenne 5 2 1 Important properties of the network protocol 5 3 Common function reference cnn rr rn ron narran rarnnr na rnnnnnnns 7 DLL a Da RE aba A Snap NT 8 4 CAN API reference acusa res ahaa TODO Da VES me Pe 9 CANOpenDevice CANOpenDeviceEX sistemas nennen nenn 10 EANEIOSEDEVIice ra tex om ar 12 CANSECGIODAIS nn E hued DE E RA E AA eh gene 13 CANGetGlobalS A eR ER E i 15 CANSetFilter ss ex Hee usen sei es rude tipo tester hw n 17 CANGEtrilter superada cc 19 CANSELTIME sir star amar ng ae ER RS RRR RO cage ones RENE 20 CANWrite CANWriteEX Rh 21 CANSetCallback CANSetCallbackEx mmm 23 CANReadDigital sisri iaia ERR gare C ea EPA 25 CANWriteDigital Ls iii a DGE as paisana 27 CANRestart A ea Da ER E E A E EE Da Te ea de 28 CANDeviceConnectState u a 29 CANStartAliVe i a AD 30 CANErFFOFMESSAgE sc nahe E ia re 31 5 SPIAPI reference annate TI 32 SPIOPEND EVICE A nee ne pM ERA sas 33 SPIGIOSE DEVICE e ru RR RO 35 SPISetGlob lS rs es Mane Na 36 SPIGEtGlobals 23 3 o o e E I 38 SPIDataReQq i cuo ER ee 40 SPIReadDigital rennen ee ne een ree n e RR E E cove 42 SPIWriteDigital meinir He a vat annee Fan CAR en 44 SPIErFOFMeSsage a u a V UM LU E PLE LLL UNE nette 45 6 I2C API r f renc iei eer er vesc ve dine eid nonce ne vanne me
81. he Fast mode Plus Fm or up to 3 4 Mbit s in the High speed mode NXP I2C The I2C gateway models of the AnaGate series provides access to a I2C bus via a standard networking With the I2C API these I2C gateways can be easily controlled The programming interface is identical for all devices and used the network protocol TCP in general Following devices can be addresse via the I2C API interface e AnaGate I2C e AnaGate Universal Programmer 46 2007 2010 Analytica GmbH I2C API reference I2COpenDevice I2COpenDevice Opens a network connection to an AnaGate I2C or an AnaGate Universal Programmer Syntax include lt AnaGateDIII2C h gt int I2COpenDevice int pHandle unsigned int nBaudrate const char pcIPAddress int nTimeout Parameter pHandle Pointer to a variable in which the access handle is saved in the event of a successful connection to the AnaGate device nBaudrate Baud rate to be used for the I2C bus Teh value can be set individually like e 100000 for 100kBit standard mode e 400000 for 400kBit fast mode C Note Values above 400kBit are ignored by the AnaGate SPI pcIPAddress Network address of the AnaGate partner nTimeout Default timeout for accessing the AnaGate in milliseconds A timeout is reported if the AnaGate partner does not respond within the defined timeout period This global timeout value is valid on the current network connection for all commands and functions which
82. ice Return values RC Returns 0 if successful or an error value otherwise Appendix A API return codes nSWVersion Firmware version The version number consists of 3 numbers major minor revision which are stored in a 4 byte integer value nHWVersion Hardware version The version number consists of 3 numbers major minor revision which are stored in a 4 byte integer value tabSerial Serial number of the AnaGate hardware 4 byte tabMACAddress MAC address of the AnaGate hardware 6 byte nDeviceID Device specific identifier Specifies the device type of the hardware e 1 AnaGate I2C e 2 AnaGate CAN e 3 AnaGate SPI e 8 AnaGate Universal Programmer e 9 AnaGate Renesas nSWDerivateID Indicates a customer specific firmware version if not 0x00 Description Returns specific information about a device of the AnaGate product line See also LS CANOpenDevice LS_SPIOpenDevice LS_I2COpenDevice 81 2007 2010 Analytica GmbH Common function reference LS GetTime LS_GetTime Returns the current system time Syntax int RC table 2 tabTime LS GetTime void Parameter This function does not have any parameters Return values RC Returns 0 if successful or an error value otherwise Table A 5 Return values for LUA scripting tabTime 1 tabTime 1 specifies the number of seconds elapsed since tabTime 2 01 01 1970 in tabTime 2 the fractions of a second is returned in millise
83. ine The different libraries include common and specific functions which are neccessary for accessing and controlling the devices of the AnaGate product line In the following all library functions of the software API are documented in detail Tip u It is possible to extend individually the newer device models with embedded Linux kernel 2 6 and ARM9 processor The complete software API is available in a cross compiled version and can be used on the devices itself to create individual device extensions To do so is very easy because the programming interface on the personal computer and the device is completely identical A preconfigured virtual machine Virtual Box Image with Ubuntu Linux READY to USE with installed development environment Kdevelop Eclipse and all neccessary program libraries GCC cross compiler libraries LUA is available optional 4 2007 2010 Analytica GmbH Chapter 2 Notes concerning the communication protocol TCP Access to the different models of the AnaGate product line is always done via the most frequently used network protocol TCP Transmission Control Protocol TCP is connection oriented packet switched transport protocol which is located in layer 4 of the of the OSI reference model In princible TCP is an end to end connection which allows exchange of data in both directions at the same time An end point is a pair formed of an IP address and a port number and Such a pair b
84. ing a individual callback function see LS CANSetCallback which is called if an incoming CAN data telegram is received the internal message puffer is not filled In this case is not possible to retrieve message via the LS CANGetMessage function See the following example which handles incoming CAN data telegrams nRC hHandle LS CANOpenDevice true true 0 192 168 0 254 5000 if nRC 0 then set globals 500Kbit standard mode termination on no high speed no timestamp nRC LS CANSetGlobals hHandle 500000 0 true false false nCurMsg 0 repeat nAvail ID Len Data Sec Microsec LS CANGetMessage hHandle 100 if nAvail gt 0 then nCurMsg nCurMsg 1 now do something with the incomming message data io write string format ID for example write out CAN id else LS_Sleep 25 wait 25 ms if no message available end until nCurMsg gt 100 read only 100 messages then stop LS_CANCloseDevice hHandle end Remarks For devices of type AnaGate CAN hardware version 1 1 A the return values nSeconds and pnMicroseconds are always set to zero See also LS CANSetCallback 100 2007 2010 Analytica GmbH CAN Reference LS CANSetFilter LS_CANSetFilter Sets the current filter settings for the connection Syntax int RC LS_CANSetFilter int hHandle table 16 tabFilter Parameter hHandle Valid access handle tabFilter Pointer to an array of 8 fil
85. is int RC LS CANopenSetCallbacks int Handle string CallbackFunctionPDO String CallbackFunctionSYNC string CallbackFunctionEMCY string CallbackFunctionGUARD string CallbackFunctionUndefined Description Parameter int Handle string CallbackFunctionPDO string CallbackFunctionSYNC string CallbackFunctionEMCY string CallbackFunctionGUARD string CallbackFunctionUndefined Return values int RC If no error occurs the return will be null 0 Otherwise the returncode will be different null O 137 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenGetPDO LS CANopenGetPDO Synopsis int Avai lMessages int NodeID int PDOTyp table 1 8 Data int Seconds int Microseconds Description Parameter int Handle int Timeout Return values int NodeID int PDOTyp table 1 8 Data int Seconds int Microseconds LS CANopenGet PDO int Handle int Timeout 138 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenGetSYNC LS_CANopenGetSYNC Synopsis int AvailMessages int ReturnCode int Seconds int Microseconds LS CANopenGet SYNC int Handle int Timeout Description Parameter int Handle int Timeout Return values int ReturnCode int Seconds int Microseconds 139 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenGetEMCY LS CANopenGetEMCY Synopsis int AvailMessages
86. k ck ck ck ck KKK KKK KKK KKK ck kk HH F KH FH D DEDE KH Te AK AH IK FH DS AC D ko ko ko M I KKK FACE LOM Dee 5 5 2 io write string format 3L ode Jima 7 end Q KEK KK KKK KKK KKK KKK KKK KKK KKK KK RAS function main om nRC nHandle LS_CANOpenDevice false true 5001 10 1 2 160 5000 if nRC 0 then print LS CANErrorMessage nRC CNN end nRC nHandle2 LS CANOpenDevice false true 5001 10 1 2 161 5000 if nRC 0 then print LS CANErrorMessage nRC exit end Filter setzen nRC LS CANSetFilter nHandle aFilter nRC LS CANSetFilter nHandle2 aFilter aktuelle Zeit auf den AnaGate Device setzen nRC oTime LS GetTime nRC LS CANSetTime nHandle oTime 1 oTime 2 nRC LS CANSetTime nHandle2 oTime 1 oTime 2 Globals setzen nRC LS CANSetGlobals nHandle 500000 0 true false false nRC LS CANSetGlobals nHandle2 500000 0 true false false Endlosschleife EVDE Et 1 Datenpackete auf dem 1 AnaGate CAN Device versenden nRC LS_CANWrite nHandle 1 8 aSendData LS_Sleep 20 20Millisekunden warten Datenpacket auf 2 AnaGate CAN Devic mpfangen nAvail ID Len Data Sec Microsec LS_CANGetMessage nHandle2 10 while nAvail gt 0 do nAvail ID Len Data Sec Microsec LS_CANGetMessage nHandle2 end until false Verbindungen beenden LS_C
87. k mode CPHA 0 und CPOL 0 y SPI command 0x05 Please enter only hex digits every two digits separated with a blank e g 05 1F FF Result Execute command Dialog fields Network address Check address Baud rate Signal Level Aux Voltage Clock mode SPI command Execute command Exit Network address of the AnaGate SPI Establishs a connection to the AnaGate SPI with the specified network address and reads back some device information and global device settings The baud rate to be used The value can be set individually The voltage level for SPI signals to be used The voltage level of the support voltage to be used The phase and polarity of the clock signal SPI command to be sent to the connected SPI device The command has to be entered as blank separated hexadecimal byte groups 05 1r 3A for example Executes a SPI command and displays the result in the Result dialog field Please keep in mind that the SPI bus is used as full duplex line this means that data is written and received parallel Make sure that you write the same number of bytes to the bus as you want to receive in this cace add padding bytes to the SPI command For example is the Read Status Register command of a M25P80 defined as 0x05 The result of the command is a single byte 8 bit representing the current value ofthe Status Register 66 2007 2010 Analytica GmbH Programming examples 7 2 1 2 Getting global devi
88. le Valid access handle pnFilter Pointer to an array of 8 filter entries 4 mask and 4 range filter entries A filter entry contains of two 32 bit values Unused mask filter entries must be initialized with O values Unused range filter entries must be initialized with a O for the start value and Ox1FFFFFFF for the end value Return value Returns null if successful or an error value otherwise Appendix A API return codes Description This function sets the current filter settings for the current connection Filter can be used to suppress messages with specific CAN message ids A mask filter contains of a mask value which defines the bits of the CAN identifier to examine and the appropriate filter value If the CAN identifier matches in the indicated filter mask with the filter value the incoming CAN telegram is sent to the PC otherwise not A range filter defines an address range with a appropriate start and end address If the CAN identifier do not lie in the indicated filter range the incoming CAN telegram is not sent to the PC Filter are only active if the parameter bsendDataInd is set via the CANOpenDevice function If the pararmeter bHighSpeedMode of the CANSetGlobals is set all filters are deactivated to increase the data pass through Table 4 1 mask filter examples for CAN identifier CAN id mask value filter value result OxOF OxOE 0x0C suppressed OxOC OxOE OxOC ok Ox5D OxOE OxOC ok
89. lowing C code function computes a valid CRC of an already created command telegram unsigned char CalcCRC char pBufrer int nBufferLength TIE alp unsigned char nCRC pBuffer 2 skip the length bytes XOR over all bytes in the message except the length information and the last byte for i 3 i lt nBufferLength 1 i nCRC pBuffer i return nCRC When using the function calccrc the parameter pBuffer must point to the data buffer which contains the already created complete data telegram The length parameter nBufferLength depends on the created command type and can be computed as shown below buffer length sizeof command length sizeof command code sizeor command aid sizeof CRC sizeof data 7 sizeof data 168 2007 2010 Analytica GmbH Appendix F Technical support The AnaGate hardware series software tools and all existing programming interfaces are developed and supported by Analytica GmbH Technical support can be requested as follows Internet EMail The AnaGate web site http www anagate de en index html of Analytica GmbH contains information and software downloads for AnaGate Library users e Product updates featuring bug fixes or new features are available here free of charge If you require technical assistance over the Internet please send an e mail to lt support anagate de gt To help us provide you with the best pos
90. n CountRead LastError Bone A Cowie Rac L clo oracle NEO I alme at y end ica al p LS_I2CWriteDigital nHandle 0 LS_I2CCloseDevice nHandle end 157 2007 2010 Analytica GmbH Appendix A API return codes Followed a list of the return values of the API functions This values are defined in the header file AnaGateErrors h Table A 1 Common return values for all devices of AnaGate series Value Name Description 0 ERR_NONE No errors 0x000001 ERR_OPEN_MAX_CONN Open failed maximal count of connections reached 0x0000FF ERR OP CMD FAILED Command failed with unknown failure 0x020000 ERR TCPIP SOCKET Socket error in TCP IP layer occured 0x030000 ERR_TCPIP_NOTCONNECTED Connection to TCP IP partner can t established or is disconnected 0x040000 ERR_TCPIP_TIMEOUT No answer received from TCP IP partner within the defined timeout 0x050000 ERR TCPIP CALLNOTALLOWED Command is not allowed at this time 0x060000 ERR TCPIP NOT INITIALIZED TCP IP Stack can t be initialized 0x0A0000 ERR INVALID CRC AnaGate TCP IP telegram has incorrect checksum CRC 0x0B0000 ERR INVALID CONF AnaGate TCP IP telegram wasn t receipted from partner 0x0C0000 ERR INVALID CONF DATA AnaGate TCP IP telegram wasn t receipted correct from partner 0x900000 ERR INVALID DEVICE HANDLE Invalid device handle 0x910000 ERR INVALID DEVICE TYPE
91. n Ansicht Kodierung Sprachen Einstefl ngen Makro Ausf hren TextFX Erweiterungen Fenster ARI bb 2e as aa GA S ER BETDBB xav E Get Serial lua Affunction printf io write string format io flush end function main nRC nHandle LS C NOpenDevice false true 0 192 165 1 254 if nRC 0 then errortext LS CANErrorMessage nRC printf ssin errortext return end printf Connected to 192 168 1 254n nRC SWVersion HWVersion Serial MACAddress DeviceID DerivateID LS DeviceInfo nHandle printf nI have successfully retrieved the current serial and MAC n printf S x Serial 4 printf Serial 3 printf s02X Serial 2 printf Serial printf in printf M c for i i table getn MiCiddress 1 do printf 02X MACAddress i end printf in LS Sleep 10000 LS CANCloseDevice nHandle end Lua source File 800 chars 832 bytes 33lines Ln 1 Col 1 Sel 0 Dbytes in O ranges When coding of a script is finished it can be executed and tested on a personal computer as decribed below 8 2 Running scripts on personal computer To execute LUA script files on a personal computer an actual program version of the LUA interpreter must be available On the CD ROM which is included in the scope of delivery a modified LUA interpreter can be found in the directory LUA This interpreter consists of a single e
92. n nennen nennen een 5 mask filter examples for CAN identifier iii 17 Common return values for all devices of AnaGate series 158 Return values for AnaGate I2C i 158 Return values for AnaGate CAN eee none nennen nennen nennen nennen 159 Return values for AnaGate Renesas unensenennnnenennnnnnennenn nennen nennen nennen 159 Return values for LUA scripting eee eect eee nn nenn nn nennen aerea 159 I2C EEPROM addressing examples eee e eee nenn namen nn nn nenn 160 Usage of the CHIP Enable Bits of I2C EEPROMS 162 Using AnaGate hardware with firewall sseseeeeen 165 vii 2007 2010 Analytica GmbH List of Examples 13 1 CANOpen LUA script example rss 152 CARE RG ANIA ER TE ERO SIA A A I TI 153 14 2 Gna RAR 154 TI Sla LI TI E n 155 LARE RAZR O TR ARE AE UR RR RT pd mens 156 RE ES aa MT PM 157 viii 2007 2010 Analytica GmbH Introduction The AnaGate Programmer s Manual includes the exact description of the programming interfaces to all models of AnaGate hardware series The existing interfaces will be decribed below e Application Programming Interface Part I AnaGate API e LUA Scripting Interface Part II Scripting language LUA ix 2007 2010 Analytica GmbH Part I AnaGate API Table of Contents 1 The Programmin
93. n reference DLLInfo DLLInfo Determines the current version information of the AnaGate DLL Syntax include lt AnaGateDLL h gt int DLLVersion char pcMessage int nMessageLen Parameter pcMessage Data buffer that is to accept the version reference number of the AnaGate DLL nMessageLen Size in bytes of the transferred data buffer Return value Actual size of the returned version reference number Remarks If the version reference number is too large for the transferred data buffer it is abbreviated to the given number of characters nMessageLen 8 2007 2010 Analytica GmbH Chapter 4 CAN API reference The CAN API can be used with all CAN gateway models of the AnaGate series The programming interface is identical for all devices and uses the network protocol TCP or UDP in general Following devices can be addresse via the CAN API interface AnaGate CAN AnaGate CAN uno AnaGate CAN duo AnaGate CAN quattro AnaGate CAN USB 2007 2010 Analytica GmbH CAN API reference CANOpenDevice CANOpenDeviceEx CANOpenDevice CANOpenDeviceEx Opens an network connection TCP or UDP to an AnaGate CAN device Syntax include lt AnaGateDllCan h gt int CANOpenDevice int pHandle BOOL bSendDataConfirm BOOL bSendDataInd int nCANPort const char pcIPAddress int nTimeout int CANOpenDeviceEx int pHandle BOOL bSendDataConfirm BOOL bSendDataInd int nCANPort const char pcl
94. naGate device Syntax int RC LS I2CWriteDigital int hHandle int nOutputBits Parameter hHandle Valid access handle nOutputBits New register value Currently only bits 0 to 3 are used other bits are reserved for future use Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description All models of the AnaGate series except the model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The digital outputs can be written with the LS I2CWriteDigital function A simple example for reading writing of the IOs can be found at the description of LS I2CReadDigital See also LS_I2CReadDigital 127 2007 2010 Analytica GmbH I2C Reference LS 12CErrorMessage LS_I2CErrorMessage Returns a description of the given error code as a text string Syntax string sErrorMsg LS_I2CErrorMessage int nRetCode Parameter nRetCode Error code for which the error description is to be determined Return value sErrorMsg Textual description of the error code Description Returns a textual description of the parsed error code see Appendix A API return codes See the following example in LUA scripting language nRC 0 sErrorText No Error Moss Call a API ittincgicidoa hara sErrorText LS_I2CErrorMessage nRC print sErrorText 128 2007 2010 Analy
95. nab Statusregister des SPI Partners abfragen nRC Value LS SPIDataReq nHandle 2 2 OPStatusReg for i l table getn Value 1 do printf Data Status 02X n Value il end Lesen von 20Bytes ab Adresse 0x00 nRC Value LS SPIDataReq nHandle 4 20 OPRead for i l table getn Value 1 do printf Data 02X n Valueli end Alle digitalen Ausgaenge zuruecksetzen LS_SPIWriteDigital nHandle 0 Verbindung zu AnaGate SPI Device beenden LS_SPICloseDevice nHandle end 154 2007 2010 Analytica GmbH LUA programming examples 14 3 Examples for devices with I2C interface Example 14 3 IIA KKK KKK KKK ck ck ck ck ck ck ck ckck ck ck ckckckckckckckckckck KH HH KH HH ck ck ck ck ck ck ck ck ck ck A i une tono io write string format io flush end KKK KKK KKK KKK KKK ck ck SEH ck ck KKK FES ck FH ck V KKK KH ck Ke KH oko ko AH AH ko Ve V kc ko ko K K K function getn t if type t n number then return t n end local max 0 iege aby ja e vole if type i number and i max then max i end end return max end __ kkk k k k k k k k k k k k k k k k X k k k k k k k k k k k k k k k k k k k k k k k k k k k k k k x function main aSendData Tor ly AS y db clo table insert aSendData i 1 end nRC nHandle LS I2COpenDevice 1000000 10 1 2 162 5000 if nRC 0 then print LS_I2CErrorMessage nRC exit end Read EEPROM Coun
96. nd the subnet mask to 255 255 255 0 Check if the AnaGate can be reached via ping 192 168 1 254 3 If the device can be reached via ping then the next step is to try if you can open a TCP connection to port 5001 Open a Windows command prompt and enter telnet a b c d 5001 where a b c dis the device IP address If this command fails check if a firewall runs on your PC or if there is a packet filter in the network between your PC and the AnaGate 164 2007 2010 Analytica GmbH FAQ Frequent asked questions No network connection after changing the network address After changing the network address of the AnaGate device via web interface the device is not longer reachable The used internet browsers displays only an emtpy web side additional error messages are not available Please check if your anti virus software has blocked the new network address After changing the network address you are redirected to the new network address in the browser Such activity is suspicious for some anti virus software so they block the new webside sometimes even without notification of the user Connection problems using multiple devices If multiple devices with identical IP addresses are used in a local area network at the same time the connections to the devices are not stable Because of this behaviour it is recommend to use different IP addresses This problem can also occur if devices with identical IP addresses are used not concur
97. ndividually These settings are valid for all network connection on this computer and can not be set individually for dedicated connections To do so the Window registry keys KeepAliveTime and KeepAliveInterval of node HKEY_ LOCAL MACHINE SYSTEM CurrentControlSet Tcpip Parameters has to be adjusted administrator rights Especially the CAN Ethernet gateways can be affected by the above described problems for example if customer specific needs ask for faster detection of connection aborts as possible via the standard mechanism So in the AnaGate models with CAN interface and linux OS an application specific keep alive algorithm is integrated in the device firmware to enhance connection control On base of a predefined time period additional data packets are exchanged between the AnaGate hardware and the controlling unit personal computer which have to be confirmed by the corresponding endpoint ALIVE REQ see TCP 2010 This integrated alive machanism can be activated individually on each connection with a different timeout interval C Note Users of the AnaGate API do not have to implement the application specific alive mechanism to use it With a simple call to the API function CANStartAlive a concurrent thread is started which automatically monitors the communication channel time controlled 6 2007 2010 Analytica GmbH Chapter 3 Common function reference 7 2007 2010 Analytica GmbH Common functio
98. nds and functions which do not offer a specific timeout value Return values RC Returns 0 if successful or an error value otherwise Appendix A API return codes Handle Access handle if successfully connected to the AnaGate device Description Opens a TCP IP connection to an AnaGate SPI resp AnaGate Universal Programmer After the connection is established access to the SPI bus is possible Note The AnaGate SPI resp the SPI interface of an AnaGate Universal Programmer does not allow more than one concurrent network connection During an established network connection all new connections are refused See the following example for the initial programming steps nRC nHandle LS_SPIOpenDevice 192 168 0 254 5000 if nRC 0 then print LS SPIErrorMessage nRC exit end now do something LS_SPICloseDevice nHandle See also LS_SPICloseDevice 108 2007 2010 Analytica GmbH SPI Reference LS SPiCloseDevice LS SPICloseDevice Closes an open network connection to an AnaGate SPI device Syntax int RC LS SPICloseDevice int hHandle Parameter hHandle Valid access handle Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description Closes an open network connection to an AnaGate SPI device The hHandle parameter is a return value of a succesfull call to the function LS SPIOpenDevice i Importa
99. ne SDA and a serial clock line SCL Serial 8 bit oriented bidirectional data transfers can be made at up to 100 kbit s in the Standard mode up to 400 kbit s in the Fast mode up to 1 Mbit s in the Fast mode Plus Fm or up to 3 4 Mbit s in the High speed mode NXP I2C The I2C gateway models of the AnaGate series provides access to a I2C bus via a standard networking With the I2C API these I2C gateways can be easily controlled The programming interface is identical for all devices and used the network protocol TCP in general Following devices can be addresse via the I2C API interface e AnaGate I2C e AnaGate Universal Programmer 119 2007 2010 Analytica GmbH I2C Reference LS 12COpenDevice LS_I2COpenDevice Opens a network connection to an AnaGate I2C or an AnaGate Universal Programmer Syntax int RC int Handle LS I2COpenDevice unsigned int nBaudrate string sIPAddress int nTimeout Parameter nBaudrate Baud rate to be used for the I2C bus Teh value can be set individually like e 100000 for 100kBit standard mode e 400000 for 400kBit fast mode u Note Values above 400kBit are ignored by the AnaGate SPI sIPAddress Network address of the AnaGate partner nTimeout Default timeout for accessing the AnaGate in milliseconds A timeout is reported if the AnaGate partner does not respond within the defined timeout period This global timeout value is valid on the current network connec
100. nt It is recommended to close the connection because all internally allocated system resources are freed again and the connected AnaGate device is signalled that the active connection is not longer in use and can be used again for new connect requests See also LS SPIOpenDevice 109 2007 2010 Analytica GmbH SPI Reference LS SPISetGlobals LS SPISetGlobals Sets the global settings which are to be used on the AnaGate SPI Syntax int LS SPISetGlobals int hHandle int nBaudrate unsigned char nSigLevel Parameter hHandle nBaudrate nSigLevel nAuxVoltage nClockMode unsigned char nAuxVoltage unsigned char nClockMode Valid access handle The baud rate to be used The values can be set individually like e 500 000 for 500kBit e 1 000 000 for 1MBit e 5 000 000 for 5MBit Note The required baud rate can be different from the value actually used because of internal hardware restrictions frequency of the oscillator If it is not possible to adjust the baud rate exactly to the parsed value the nearest smaller possible value is used instead The voltage level for SPI signals to be used Following values are allowed e O Outputs in High Impedance Modus Standard mode e 1 5 0V for the signals e 2 3 3V for the signals e 3 2 5V for the signals The voltage level of the support voltage to be used Following values are allowed e O support voltage is 3 3V e 1 su
101. o 0 Description All models of the AnaGate series except the model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The current values of the digital inputs and outputs can be retrieved with the LS CANReadDigital function See the following example for setting an reading the digital IO nOutputs 0x03 nRC hHandle LS CANOpenDevice 400000 192 168 0 254 5000 if nRC then set the digital output register PIN 0 and PIN 1 to HIGH value nRC LS CANWriteDigital hHandle nOutputs read all input and output registers nRC nInputs nOutputs LS CANReadDigital hHandle LS CANCloseDevice hHandle end See also LS CANWriteDigital 105 2007 2010 Analytica GmbH CAN Reference LS CANWriteDigital LS CANWriteDigital Writes a new value to the digital output register of the AnaGate device Syntax int RC LS_CANWriteDigital int hHandle int nOutputBits Parameter hHandle Valid access handle nOutputBits New register value Currently only bits 0 to 3 are used other bits are reserved for future use Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description All models of the AnaGate series except the model AnaGate CAN uno in DIN rail case have connectors for 4 digtial inputs and 4 digital outputs at the rear panel The digital outputs c
102. ol bSendDataInd int nCANPort string sIPAddress int nTimeout Parameter bSendDataConfirm It set to TRUE all incoming and outgoing Data requests are confirmed by the internal message protocol Without confirmations a better transmittion performance is reached bSendDatalnd If set to FALSE all incoming telegrams are discarded nCANPort CAN port number Allowed values are 0 for port A Modells AnaGate CAN uno AnaGate CAN duo AnaGate CAN quattro AnaGate CAN USB and AnaGate CAN 1 for port B AnaGate CAN duo AnaGate CAN quattro 2 for port C AnaGate CAN quattro 3 for port D AnaGate CAN quattro sIPAddress Network address of the AnaGate partner nTimeout Default timeout for accessing the AnaGate in milliseconds A timeout is reported if the AnaGate partner does not respond within the defined timeout period This global timeout value is valid on the current network connection for all commands and functions which do not offer a specific timeout value Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Handle Access handle if successfully connected to the AnaGate device Description Opens a TCP IP connection to an CAN interface of a AnaGate CAN device If the connection is established CAN telegrams can be sent and received The connection should be closed with the function CANCloseDevice if not longer needed 85 2007 2010 Analytica GmbH CAN Reference i Im
103. on 49 0 721 43035 0 Fax 49 0 721 43035 20 lt support analytica gmbh de gt www analytica gmbh de http www analytica gmbh de www anagate de http www anagate de Revision History won 01 10 2010 ASce Complete revision of all chapters u 12 07 2010 SWe CAN UPD fucntions added LUA only Revision 04 06 2010 SWe I2C RAW functions added temporarily Revision 01 04 2010 ASc english version Revision 08 06 2009 ASc Manual changed to DocBook format Table of Contents Introduction EE ix 1 AmnaGateAPI aa alia A m EUR RI 1 1 The Programming interface of AnaGate product line 3 2 Notes concerning the communication protocol TCP 5 2 1 Important properties of the network protocol 5 3 Common function reference i 7 DELI FO pM PPP 8 4 CAN API reference ot rennes uae nn EDER ne 9 CANOpenDevice CANOpenDeviceEX nme nennen mmn 10 CANEloseDevice io tee A A S Eee OP RT AS 12 CANSetGlobalsS re nl A dnd 13 CANGetGlobals 7 ex eoe ete tto a 15 CANS eTA E Pc EL 17 CANGeEtFilter 25 5 TS se A il 19 EANSELTIME E e isa ae ne nee daten 20 CANWrite CANWIItEER 5 2 He an 21 CANSetCallback CANSetCallbackEx i 23 CANReadDigital 23 52 A EI 25 CANWriteDigital isa sd 27 CANRESTAFE we ai 28 CANDeviceConnectState nennen nennen nenne nennen nennen ernennen 29 CANStar
104. or an error value otherwise Appendix A API return codes Description The AnaGate communication protocol see TCP 2010 supports an application specific connection control which allows faster detection of broken connection lines The CANStartAlive function starts a concurrent process in the DLL in order to send defined alive telegrams ALIVE_REQ peridically approx every half of the given time out to the Anagate device via the current network connection Is the alive telegram not confirmed within the alive time the connection is marked as disconnected and the socket is closed if not already closed Use the CANDeviceConnectState function to check the current network connection state Remarks The CANStartAlive function is supported by library version 1 4 1 10 or higher It requires firmware version 1 3 8 or higher installed on the hardware devices of type AnaGate CAN hardware version 1 1 A does not support the application specific alive mechanism See also CANDeviceConnectState Section 2 1 Important properties of the network protocol 30 2007 2010 Analytica GmbH CAN API reference CANErrorMessage CANErrorMessage Returns a description of the given error code as a text string Syntax include lt AnaGateDIICAN h gt int CANErrorMessage int nRetCode char pcMessage int nMessageLen Parameter nRetCode Error code for which the error description is to be determined pcMessage Data bu
105. or example a M24C08 uses 8 bits of the address byte and an extra bit in the slave address The total 9 bits can address up to 512 bytes Length of the data buffer RC Returns 0 if successful or an error value otherwise Appendix A API return codes 129 2007 2010 Analytica GmbH I2C Reference tabData Table with data read from EEPROM Description The LS_I2CReadEEPROM function reads data from an I2C EEPROM Of course all access to the memory of an EEPROM is done by standard I2C read or write commands So when reading from the memory only the matching slave address the memory offset address and the data has to be sent to the I2C bus LS_I2CReadEEPROM translates the given memory address on the chip by means of the sub address and the addressing mode of the present EEPROM type The slave address of the EEPROM is automatically determined and not mandatory for the fucntion call A programming example which clears a ST24C1024 can be found at the description of LS_I2WriteEEPROM See also LS_I2CWriteEEPROM Appendix C Programming I2C EEPROM 130 2007 2010 Analytica GmbH I2C Reference LS I2CWriteEEPROM LS_I2CWriteEEPROM Writes data to an I2C EEPROM Syntax unsigned int int RC LS I2CWriteEEPROM int hHandle unsigned short nSubAddress nOffset unsigned int nOffsetFormat int nDatalen tabData table nDataLen Parameter hHandle nSubAddress nOffset nO
106. ot supported by all AnaGate CAN modells The high speed mode was created for large baud rates with continuously high bus load In this mode telegrams are not confirmed on procol layer and the software filters defined via CANSetFilter are ignored pbTimeStampOn Is a timestamp mode activated on the current network connection TRUE yes FALSE no This setting is not supported by all AnaGate CAN modells In activated time stamp mode an additional timestamp is sent with the CAN telegram This timestamp indicates when the incomming message is received by the CAN controller or when the outgoing message is confirmed by the CAN controller Return value Returns Null if successful or an error value otherwise Appendix A API return codes 15 2007 2010 Analytica GmbH CAN API reference Description Returns the global settings of the used CAN interface These settings are effective for all concurrent connections to the CAN interface Remarks The settings of the integrated CAN bus termination the high speed mode and the time stamp are not supported by the AnaGate CAN hardware version 1 1 A These settings are ignored by the device See also CANGetGlobals 16 2007 2010 Analytica GmbH CAN API reference CANSetFilter CANSetFilter Sets the current filter settings for the connection Syntax include lt AnaGateDIICAN h gt int CANSetFilter int hHandle const int pnFilter Parameter hHand
107. pins E2 and E1 have to be LOW E 17 address bits are used to address the 128KB of a ST24C1024 16 bits are set via the address bytes of the write command 16 0x0F The address bit A16 is set via the EO bit of the Chip Enable Address therefore addressing mode 1 E2 E1 A0 must be set 0x10 E The page size of a ST24C1024 is 256 byte every page is programmed full within the for loop See also LS I2CReadEEPROM Appendix C Programming I2C EEPROM 132 2007 2010 Analytica GmbH Draft Draft Chapter 13 CANOpen functions CANopen is a communication protocol and device profile specification for embedded systems used in automation Standardised in Europe as EN 50325 4 see CiA DS301 it is mangaged by the user organisation CAN in Automation CiA Users of the AnaGate API are allowed to execute the in following decribed CANopen services as CANopen master 133 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSetConfig LS_CANopenSetConfig Configure the connection specific device settings for CANOpen operation Synopsis int RC LS_CANopenSetConfig int Handle int CANOpenConfig Description Parameter int Handle int CANOpenConfig O Return values Die CANOpen Funktionalit t wird nicht unterst tzt Standard Ein Aufruf einer CANOpen Funktion wird negativ FFh quittiert Empfangene CAN Daten werden immer als Standard Datalndication OP_ANAGATE_CAN_DATA_IND
108. portant It is recommended to close the connection because all internally allocated system resources are freed again and the connected AnaGate device is signalled that the active connection is not longer in use and can be used again for new connect requests See the following example for the initial programming steps open use no confirmations and receive incomping CAN data nRC hHandle LS CANOpenDevice false true 0 192 168 0 254 5000 if nRC then now do something LS CANCloseDevice hHandle end See also LS CANCloseDevice LS CANRestartDevice 86 2007 2010 Analytica GmbH CAN Reference LS CANCloseDevice LS CANCloseDevice Closes an open network connection to an AnaGate CAN device Syntax int RC LS CANCloseDevice int hHandle Parameter hHandle Valid access handle Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description Closes an open network connection to an AnaGate CAN device The hHandle parameter is a return value of a succesfull call to the function LS CANOpenDevice i Important It is recommended to close the connection because all internally allocated system resources are freed again and the connected AnaGate device is signalled that the active connection is not longer in use and can be used again for new connect requests See also LS CANOpenDevice 87 2007 2010 Analytica GmbH
109. pport voltage is 2 5V The phase and polarity of the clock signal Following values are allowed e O CPHA 0 and CPOL 0 e 1 CPHA 0 and CPOL 1 110 2007 2010 Analytica GmbH SPI Reference e 2 CPHA 1 and CPOL 0 e 3 CPHA 1 and CPOL 1 Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description Sets the global settings of SPI interface of the AnaGate SPI or the AnaGate Universal Programmer These settings are not saved permantently on the device and are reset every device restart See also LS SPIGetGlobals 111 2007 2010 Analytica GmbH SPI Reference LS SPIGetGlobals LS_SPIGetGlobals Returns the currently used global settings of the AnaGate SPI Syntax int RC int nBaudrate int nSigLevel int nAuxVoltage int nClockMode LS_SPIGetGlobals int hHandle Parameter hHandle Valid access handle Return values RC Returns 0 if successful or an error value otherwise Appendix A API return codes nBaudrate The baud rate currently used on the SPI bus in kBit nSigLevel The voltage level currently used by the AnaGate SPI Following values are possible e O Outputs in High Impedance Modus Standard mode e 1 5 0V for the signals e 2 3 3V for the signals e 3 2 5V for the signals nAuxVoltage The voltage level of the support voltage currently used by the AnaGate SPI Following values are possible
110. rently but within short intervals For example this can arise if some new devices which have the default IP address 192 168 1 254 are configured from a single PC The Address Resolution Protocol ARP is used by IP4 networks to determine the MAC address of a given IP address The neccessary information is cached in the ARP table If there is a wrong entry in the ARP table or even an entry which is not up to date it is not possible to communicate with the corresponding host An entry in the ARP table is deleted if it is not used any more after a short period time The time intervall used depends on the operating system On a current linux distribution an unused entry is discarded after about 5 minutes The ARP cache can be displayed and manipulated with the arp on windows and linux Cr Nes Sehmitiesteilles 105 152 950 0x2 Internetadresse Physikal Adresse Typ 192 LOS 254 0 01 500 692 36 190 cis dynamisch The command arp d can be used to delete the ARP Cache Qu Note Maybe the ARP cache of the PC has to be deleted if the IP address of a device is changed Using a firewall When working with a firewall the a TCP port has to be opened for communication with the AnaGate device Table D 1 Using AnaGate hardware with firewall Device Port number AnaGate I2C 5000 165 2007 2010 Analytica GmbH FAQ Frequent asked questions Device Port number AnaGa
111. rface of the AnaGate product line LUA http www lua org is a lightweight multi paradigm programming language designed as a scripting language with extensible semantics as a primary goal The name comes from the Portuguese word lua meaning moon LUA was created in 1993 by Roberto Ierusalimschy Luiz Henrique de Figueiredo and Waldemar Celes members of the Computer Graphics Technology Group Tecgraf at the Pontifical Catholic University of Rio de Janeiro in Brazil In general LUA strives to provide flexible meta features that can be extended as needed rather than supply a feature set specific to one programming paradigm As a result the base language is light in fact the full reference interpreter is only about 150 kB compiled and easily adaptable to a broad range of applications Wikipedia LUA In order to be able to solve simple programming problems concerning the AnaGate devices with the scripting language LUA the LUA interpreter is extended by several functions to operate the different AnaGate devices These additional functions are described in detail in the following chapters and are closely related to the functions of the AnaGate API libraries Source files for LUA called scripts are created and edited on a personal computer Windows or Linux in a standard text editor Then the script is simply executed in the command shell via a free LUA interpreter The full standard functionality of the LUA langu
112. ript Displays the currently executing script file Via the button Stop the execution can be cancelled Available scripts Displays all scripts which are currently available on the device To start the execution of a script click on the button Start Via button Delete a script can be deleted on the device and via Boot a script can be defined as boot script script output area In this text area the standard output stdout of the currently executing script is displayed Via the button Clear this text area can be cleared 78 2007 2010 Analytica GmbH The LUA scripting interface of the AnaGate product line error output area In this text area the standard error output stderr of the currently executing script is displayed Via the button Clear this text area can be cleared The text areas for script and error output are not refreshed automatically A manual page reload of the current page refreshes both text areas 79 2007 2010 Analytica GmbH Chapter 9 Common function reference 80 2007 2010 Analytica GmbH Common function reference LS Devicelnfo LS_Devicelnfo Retrieves some global information from the AnaGate hardware Syntax int RC int nSWVersion int nHWVersion table 4 tabSerial table 6 tabMACAddress int nDeviceID int nSWDerivateID LS_Devicelnfo int hHandle Parameter hHandle Valid access handle returned by call to LS CANOpenDevice LS_I2COpenDevice oder LS_SPIOpenDev
113. rkommen in denen gleichzeitig zu CANOpen noch Standard CAN oder andere Protokolle betrieben werden 142 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSendNMT LS_CANopenSendNMT Synopsis int RC LS CANopenSendNMT int Handle int NodeID int NMTTyp Description Parameter int Handle int NodeID int NMTTyp Return values int RC If no error occurs the return will be null 0 Otherwise the returncode will be different null 0 143 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSendSYNC LS CANopenSendSYNC Synopsis int RC LS CANopenSendSYNC int Handle Description Parameter int Handle Return values int RC If no error occurs the return will be null 0 Otherwise the returncode will be different null 0 144 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSendTIME LS CANopenSendTIME Synopsis int RC LS CANopenSendTIME int Handle int Day int Milliseconds Description Parameter int Handle int Day int Milliseconds R ckgabewerte int RC If no error occurs the return will be null 0 Otherwise the returncode will be different null 0 145 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSendPDO LS_CANopenSendPDO Synopsis int RC LS_CANopenSendPDO int Handle int NodeID int PDOTyp int DataLength table 1 8 SendData Description Parameter in
114. rue false false Endlosschleife REDE Er 1 Datenpackete auf dem 1 AnaGate CAN Device versenden nRC LS_CANWrite nHandle 1 8 aSendData LS_Sleep 20 20Millisekunden warten Datenpacket auf 2 AnaGate CAN Devic mpfangen nAvail ID Len Data Sec Microsec LS_CANGetMessage nHandle2 10 while nAvail gt 0 do nAvail ID Len Data Sec Microsec LS_CANGetMessage nHandle2 10 end until false Verbindungen beenden LS_CANCloseDevice nHandle LS_CANCloseDevice nHandle2 end 153 2007 2010 Analytica GmbH LUA programming examples 14 2 Examples for devices with SPI interface Example 14 2 RAK KKK KKK KKK KKK ck ck ck ck ckck ck ck ckckckckckckckckckck ck ck EX HH KH HH ck ck ck ck ck ck ck ck ck ko FUEL Loja Pin tee io write string format TORES AEE end EK KK KKK KKK KKK KKK K F K H K K V K V KKK FK K K V KH KH Kk K Kk ko AH ck AK ko V k VK ko K k k function main Verbindung zu AnaGate SPI Device herstellen nRC nHandle LS_SPIOpenDevice 10 1 2 162 5000 if nRC 0 then errortext LS_SPIErrorMessage nRC print errortext exit end Setzen der globalen Einstellungen WIRE ELS SPISetGlobalts niandre 400724 OW 0 NT OP Codes des SPI Partners mit Daten OPWriteEnab 0x06 OPStatusReg 0x05 0x00 OPRead 0x03 0x00 0x00 0x00 WriteEnable Flag des SPI Partners setzen nRC Value LS_SPIDataReq nHandle 1 1 OPWriteE
115. s Byte As Int32 Declare Function SPIDataReq Lib AnaGateSPI ByVal Handle As Int32 lt MarshalAs UnmanagedType LPArray gt ByVal BufferWrite As Byte ByVal BufferWriteLen As Int32 lt MarshalAs UnmanagedType LPArray gt ByVal BufferRead As Byte ByVal BufferReadLen As Int32 As Int32 Declare Function SPIErrorMessage Lib AnaGateSPI ByVal RC As Int32 ByVal Buffer As IntPtr ByVal Bufferlen As Int32 As Int32 End Module End Namespace 71 2007 2010 Analytica GmbH Part Il Scripting language LUA Table of Contents 8 The LUA scripting interface of the AnaGate product line 75 8 1 Creating Scripts ra A RR GO eR aio 76 8 2 Running scripts on personal computer nenn nn nun nn nn 76 8 3 Running scripts on AnaGate hardware nn nennen nenn 77 9 Common function reference uansunnennnnnnnnnn nennen emissa iaa aaa naa 80 ES Devicelnfo ver E EA Dex TU ves e Hr 81 ES GetTiImie ss TN 82 ES Sleep zen m Homie tran Pewee nate date vv athlete a DOS n P A ERAL COAT 83 l OS CANTRET T NES oos esaet ctus sue EN RIDE AA Re E d Sd Er E el A E 84 ESZCANOpenDevick a I ea DANS AR RD MED UR SETA TEE 85 ES CANGIOSE DEVICE soie rd Vra wes rye sae tra uer a aea aa DO 87 LS CANRestart DEVICE oorr Pede a E E oe dae e eve A a 88 LS CANSetGlobals ri 89 LS CANGetGlobals 52 2 aa Dil e ES E TE E 91 LS CAINWEIEG SSL aida e EE 93 ES CANW
116. s a return value of a succesfull call to the function LS_I2COpenDevice i Important It is recommended to close the connection because all internally allocated system resources are freed again and the connected AnaGate device is signalled that the active connection is not longer in use and can be used again for new connect requests See also LS I2COpenDevice 122 2007 2010 Analytica GmbH I2C Reference LS I2CReset LS I2CReset Resets the I2C Controller in an AnaGate I2C device Syntax int RC LS I2CReset int hHandle Parameter hHandle Valid access handle Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description Resets the I2C Controller in an AnaGate I2C device 123 2007 2010 Analytica GmbH I2C Reference LS I2CRead LS I2CRead Reads data from an I2C partner Syntax int RC table nBufferLen tabBuffer LS I2CRead int hHandle unsigned short nSlaveAddress int nBufferLen Parameter hHandle Valid access handle nSlaveAddress Slave address of the I2C partner The slave address can represent a so called 7 bit or 10 bit address siehe Appendix B I2C slave address formats nBufferLen Number of bytes to read Return values RC Returns 0 if successful or an error value otherwise Appendix A API return codes tabBuffer Byte buffer in which the data received from the I2C partner is stored Description Reads dat
117. s connected to the AnaGate CAN aka the CAN network it is not possible to send CAN telegrams the AnaGate CAN gets a NAK from the CAN controller These NAK errors are send to the AnaGate client via a data confirmation telegram Warning If data confirmations are switched off no erros are sent to the client The option confirmations for data requeste can be set via the 166 2007 2010 Analytica GmbH FAQ Frequent asked questions CANSetGlobals function In Highspeed Mode the data confirmations are always switched off D 3 Questions concerning AnaGate I2C Q What is the correct order to connect the GND SCL and SDA when using an external power supply A To avoid potential damage to the AnaGate I2C the GND pin MUST be connected to the application board first Only then can the SCL SDA pins be allowed to make contact with the application board 167 2007 2010 Analytica GmbH Appendix E FAQ Programming API Here is a list of frequently asked questions concerning the programming API and the communication protocol E 1 Questions concerning the communication protocol Q A The calculation of the check sum CRC do not work The following figure illustrates the princible layout of an AnaGate telegram 0x00 0x02 0x04 0x06 N 6 The checksum is defined as a byte calculated by XOR from all the existing bytes in an AnaGate telegram excluding the length bytes and the CRC byte The fol
118. sed CAN interface These settings are effective for all concurrent connections to the CAN interface The settings are not saved permantently on the device and are reset every device restart Remarks The settings of the integrated CAN bus termination the high speed mode and the time stamp are not supported by the AnaGate CAN hardware version 1 1 A These settings are ignored by the device See also CANGetGlobals 14 2007 2010 Analytica GmbH CAN API reference CANGetGlobals CANGetGlobals Returns the currently used global settings on the CAN bus Syntax include lt AnaGateDIICAN h gt int CANGetGlobals int hHandle int pnBaudrate unsigned char pnOperatingMode BOOL pbTermination BOOL pbHighSpeedMode BOOL pbTimeStampOn Parameter hHandle Valid access handle pnBaudrate The baud rate currently used on the CAN bus pnOperatingMode The operating mode to be used Following values are returned e O default mode e 1 loop back mode All telegrams sent by a connected partner is routed back to all active connected partners e 2 listen mode Device operates as passive bus partner this means no telegrams are sent to the CAN bus no ACKs for incoming telegrams too pbTermination Is the integrated CAN bus termination used TRUE yes FALSE no This setting is not supported by all AnaGate CAn modells pbHighSpeedMode Is the high speed mode switched on TRUE yes no This setting is n
119. ser Datagram Protocol SOCK_DGRAM Return value Returns null if successful or an error value otherwise Appendix A API return codes Description Opens a TCP IP connection to an CAN interface of a AnaGate CAN device With CANOpenDeviceEx it is possible to set the ethernet layer4 protocol tcp or udp If the connection is established CAN telegrams can be sent and received The connection should be closed with the function CANCloseDevice if not longer needed Important It is recommended to close the connection because all internally allocated system resources are freed again and the connected AnaGate device is signalled that the active connection is not longer in use and can be used again for new connect requests See the following example for the initial programming steps include lt AnaGateCAND11 h gt int main int hHandle int nRC CANOpenDevice amp hHandle TRUE TRUE 0 192 168 0 254 5000 if nRC now do something CANCloseDevice hHandle return 0 Remarks The CANOpenDeviceEx function is supported for library versions 1 5 1 10 or higher and firmware version 1 3 7 or higher Device models of type AnaGate CAN hardware version 1 1 A do not listen for UPD connection requests If trying to connect such a device via UPD the CANOpenDeviceEx returns with a timeout error See also CANCloseDevice CANRestart 11 2007 2010 Analyti
120. sible support please keep the following information and details at hand when you contact our Support Team e Version number of the used programming tool or AnaGate library e AnaGate hardware series model and firmware version e Name and version of the operating system you are using 169 2007 2010 Analytica GmbH Bibliography Books LuaRef2006 EN Roberto Ierusalimschy Luiz Henrique Figueiredo and Waldemar Celes Copyright 2006 R Ierusalimschy L H de Figueiredo W Celes Isbn 85 903798 3 3 Lua org Lua 5 1 Reference Manual LuaProg2006 EN Roberto Ierusalimschy Copyright 2006 Roberto Ierusalimschy Rio de Janeiro Isbn 85 903798 2 5 Lua org Programming in LUA second edition Other publications NXP I2C NXP Semiconductors Copyright 2007 NXP Semiconductors UM10204 I2C bus specification and user manual Rev 03 19 06 2007 TCP 2010 Analytica GmbH Copyright 2010 Analytica GmbH Manual TCP IP communication Version 1 2 6 15 05 2008 Prog 2010 Analytica GmbH Copyright 2010 Analytica GmbH AnaGate API Programmer s Manual Version 1 4 01 10 2010 CiA DS301 Copyright 2002 CAN in Automation CiA e V CAN in Automation CiA e V 13 02 2002 Cia 301 CANopen Application Layer and Communication Profile 170 2007 2010 Analytica GmbH
121. t Handle int NodeID int PDOTyp int DataLength table 1 8 SendData Return values int RC If no error occurs the return will be null 0 Otherwise the returncode will be different null 0 146 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSendSDORead LS_CANopenSendSDORead Synopsis int RC int SDOReadType int SDOReadData LS CANopenSendSDORead int Handle int NodeID int Index int Subindex int Timeout Description Parameter int Handle int NodeID int Index int Subindex int TimeOut Return values int RC If no error occurs the return will be null 0 Otherwise the returncode will be different null 0 int SDOReadType int SDOReadData 147 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSendSDOWrite LS_CANopenSendSDOWrite Synopsis int RC int SDOReadType int SDOReadData LS CANopenSendSDOWrite int Handle int NodeID int SDOWriteTyp int Index int Subindex int Timeout int SDOWriteData Description Parameter int Handle int NodeID int SDOWriteTyp int Index int Subindex int Timeout int SDOWriteData Return values int RC If no error occurs the return will be null 0 Otherwise the returncode will be different null 0 int SDOReadTyp int SDOReadData 148 2007 2010 Analytica GmbH Draft CANOpen functions Draft LS CANopenSendSDOReadBlock LS CANopenSendSDOReadBlock Synopsis int
122. t of frequently asked questions concerning installation and usage of the AnaGate product D 1 Common questions Q A No network connection 1 Please check first the physical connection to the device Basically the AnaGate have to be connected directly to a personal computer or to an active network component hub switch If the AnaGate device is connected to a personal computer a cross wired network cable must be used to connect the device otherwise the included network cable is to be used USB Digital IO OUT IN gt 1 4 1 4 Reset Act The physical interconnection is ok if the yellow link LED changes to light on if LAN cable is plug in The yellow light keeps beeing on until the connection break down On some hardware models the link LED flickers synchronous to the green activity LED if there is traffic on the network line If the link LED is always off then please check the wiring between the AnaGate and the hub switch or the personal computer No network connection 2 If the link LED indicates a proper ethernet connection see previous FAQ but you still can t connect to the AnaGate then please try the following 1 Check if the AnaGate can be reached via ping To do so in Windows opena command prompt and enter the command ping a b c d where a b c d is the device IP address 2 In case the AnaGate is unreachable via ping reset the device to factory settings Set the IP adress of your PC to 192 168 1 253 a
123. tAlive an RE TR EEE 30 CANEITORMESSAGDE po PEERS 31 5 SPI APT reference i cerne e ai 32 SPIOPENDEVICE lt tee iis E a IO nennen 33 SPICloseDevliCe si ee AT RR REI E AR eae 35 SPISetGIoDAIS tai Ren nee 36 SPIGetGlobals ne im EDER a dee pas 38 SPIDataReq ui ARE ARR en AAE E rn nee po 40 SPIReadDigital sata nes cte ET ane a ARA Ai 42 SPIWriteDigital 5 nen eu 44 SPIErFOrMess ge ee xn Se ne cele nie RER RER 45 6 12C API r f rences dia aan Dale nn Den ne IRR ATI cate bs 46 I2COpenDevice ciere Ene id 47 I2CCIOSEDOVICE e is ne enden re 49 I2CReset na RI ii 50 BLEUE ee 51 ples 52 I2CSequence in Re Sex e MERE E MR eee eH 53 I2CReadDigital zone e er een ee le rei 55 I2CWriteDigital 5 2 mtem yx tay sc PERF salsa REN ERE aaa E dares 57 12 CErr r Message ee enger HR RI teas iR e neue 58 I2CReadEEPRO Mii Re xe rix nn Gin a EA CEN MER 59 I2CWFIteEEPROM an Ri 61 7 Programming examples eect eee eee ee eee nennen nenn nenne nennen 64 7 1 Programming language C C iss nennen nennen nn 64 7 2 Programming language Visual Basic 6 65 7 3 Programming language VB NET sisters 69 II Scripting language LUA nun nennen nennen eee en une nennen 72 8 The LUA scripting interface of the AnaGate product line 75 8 1 Cr ating SCrIDES er ee ee nee ae xum eere 76 iii 2007 2010 Analytica GmbH AnaG
124. tBytes 1024 for Address 0 CountBytes 64 CountBytes do nRC Value LS I2CReadEEProm nHandle 1 Address CountBytes 16 for j l table getn Value 1 do a OT We Meda ore if j 16 0 then BIS en end end end Write EEPROM CountBytes table getn aSendData for Address 0 CountBytes 10 CountBytes do nRC LS I2CWriteEEProm nHandle 1 Address 16 CountBytes aSendData end LS I2CWriteDigital nHandle 0 LS I2CCloseDevice nHandle end 155 2007 2010 Analytica GmbH LUA programming examples Example 14 4 RAK KKK KKK KKK ck ck ck ck ck ck ck ck ckck ck AAA AA AAA ARA ARA KH KH ck ck ck ck ck ck ck ck ck A ok une tni nu Print E lo 96 io write string format HOUSE end KKK KKK KKK KKK KKK ck ck ck KKK ck HK KH ck V DAC DAC A HH KH KH ACH AH KH KH A AAA AA function getn t if type t n local max 0 nono ale suo le if type i end return max end KKK k k k k k k k k k k k k k k k X k k k k k k k k k k k k k k k k k k k k k k k k k k k k KEK number then return t n end number and i gt max then max i end function main aSendData For Uk MZ o I cle table insert aSendData i 1 end nRC nHandle LS_I2COpenDevice 1000000 10 1 2 162 if nRC 0 then print LS I2CErrorMessage nRC exit end Write aData 0x00 0x05 ab Adresse 5 lesen nRC Value LS_I2CWrite nHandle 0xa2 2 aData Read nRC Value
125. ta bytes nRC LS_CANWrite hHandle nCANId 4 tabData 0x02 LS CANCloseDevice hHandle end Remarks For devices of type AnaGate CAN hardware version 1 1 A the function CANWriteEx is equal to CANWrite the return values nSeconds and pnMicroseconds will remain unchanged See also LS_CANWriteEx 94 2007 2010 Analytica GmbH CAN Reference LS CANWriteEx CANWriteEx Send a CAN telegram to the CAN bus via the AnaGate device Syntax RC int nSeconds int nMicroseconds CANWriteEx int hHandle int nCANId int nDataLen table nDataLen tabData int nFlags Parameter hHandle Valid access handle nCANId CAN identifier of the sender Parameter nFlags defines if the address is in extended format 29 bit or standard format 11 bit nDataLen Length of data buffer max 8 bytes tabData Data buffer with telegram data nFlags The format flags are defined as follows e Bit O If set the CAN identifier is in extended format 29 bit otherwise not 11 bit e Bit 1 If set the telegram is marked as remote frame Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes nSeconds Timestamp of the confirmation of the CAN controller seconds from 01 01 1970 nMicroseconds Micro seconds portion of the timestamp Description Both functions sends a CAN telegram to the CAN bus via the AnaGate device like the LS_CANWrite function The LS
126. te I2C X7 5100 5200 5300 5400 5500 5600 5700 AnaGate CAN 5001 AnaGate CAN USB 5001 AnaGate CAN uno 5001 AnaGate CAN duo 5001 5101 AnaGate CAN quattro 5001 5101 5201 5301 AnaGate SPI 5002 AnaGate Renesas 5008 AnaGate Universal Programmer 5000 5002 5008 D 2 Questions concerning AnaGate CAN Q A What is the value of the termination resistor when the termination option of the device is activated The termination resistor of the AnaGate is driven by an FET transistor The resistor itself has 110 Ohm while the internal resistance of the FET is 10 Ohm if the FET is activated So the resulting resitance is 120 Ohm as required by the CAN bus Does Analytica offer a CAN gateway which does not have an galvanically isolated CAN interface Any device that is actively connected to a CAN bus should be galvanically isolated Especially when using USB operated devices like the AnaGate USB it is essential to have an galvanically isolated device because the device is power supplied by the PC How to direct interconnect two CAN ports If you want to interconnect two AnaGate CAN just via a direkt link CAN cable you have to switch on the internal termination on both AnaGate CAN devices A CAN bus network must have a termination on each side C Note Maybe it is working with lower baurates without termination but it is recommend to use a termination Receiving a NAK when sending a CAN telegram If no CAN partner i
127. telegram and sent to the AnaGate SPI The AnaGate SPI makes the real data transfer on the SPI bus and send back a confirmation including the data received from the bus Important It is impossible to detect that no device is present at the SPI bus So if no device is attached the requested number of bytes are returned anyway in this case the read buffer is filled with 0 See the following example for sending a command to the connected SPI bus tabWrite fom a d0 1 clo table insert tabWrite i end nRC hHandle SPIOpenDevice 192 168 1 254 5000 if nRC then send 1 byte and receive 1 byt 114 2007 2010 Analytica GmbH SPI Reference nRC tabRead LS SPIDataReq hHandle 1 1 tabWrite li send i byte me receive 5 byt nRC tabRead LS_SPIDataReq hHandle 1 5 tabWrite send 2 byte and receive 1 byt nRC tabRead LS_SPIDataReq hHandle 2 1 tabWrite LS_SPICloseDevice hHandle end 115 2007 2010 Analytica GmbH SPI Reference LS SPlErrorMessage LS_SPIErrorMessage Returns a description of the given error code as a text string Syntax string sErrorMsg LS_SPIErrorMessage int nRetCode Parameter nRetCode Error code for which the error description is to be determined Return value sErrorMsg Textual description of the error code Description Returns a textual description of the parsed error code see App
128. ter entries 4 mask and 4 range filter entries A filter entry contains of two 32 bit values Unused mask filter entries must be initialized with O values Unused range filter entries must be initialized with a O for the start value and 0x1FFFFFFF for the end value Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description This function sets the current filter settings for the current connection Filter can be used to suppress messages with specific CAN message ids A mask filter contains of a mask value which defines the bits of the CAN identifier to examine and the appropriate filter value If the CAN identifier matches in the indicated filter mask with the filter value the incoming CAN telegram is sent to the PC otherwise not A range filter defines an address range with a appropriate start and end address If the CAN identifier do not lie in the indicated filter range the incoming CAN telegram is not sent to the PC Filter are only active if the parameter bSendDataInd is set via the LS_CANOpenDevice function See also LS CANGetFilter 101 2007 2010 Analytica GmbH CAN Reference LS CANGetFilter LS CANGetFilter Returns the current filter settings for the connection Syntax int RC table 16 tabFilter LS_CANGetFilter int hHandle Parameter hHandle Valid access handle Return value RC Returns 0 if successful or an error value other
129. th the CANWriteDigital function A simple example for reading writing of the IOs can be found at the description of CANReadDigital See also CANReadDigital 27 2007 2010 Analytica GmbH CAN API reference CANRestart CANRestart Restarts a AnaGate CAN device Syntax include lt AnaGateDllCan h gt int CANRestart const char pcIPAddress int nTimeout Parameter pcIPAddress Network address of the AnaGate partner nTimeout Default timeout for accessing the AnaGate in milliseconds A timeout is reported if the AnaGate partner does not respond within the defined timeout period Return value Returns Null if successful or an error value otherwise Appendix A API return codes Description Restarts the AnaGate CAN device at the specified network address It disconnects implicitly all open network connections to all existing CAN interfaces The Restart command is even possible if the maximum number of allowed connections is reached f Important It is recommended to use this command only in emergency cases if there is a need to connect even if the maximum number of concurrent connections is reached See also CANOpenDevice 28 2007 2010 Analytica GmbH CAN API reference CANDeviceConnectState CANDeviceConnectState Retrieves the current network connection state of the current AnaGate connection Syntax include lt AnaGateDIICAN h gt int CANDeviceConnectState int hHandle
130. tica GmbH I2C Reference LS_12CReadEEPROM LS_I2CReadEEPROM Reads data from an EEPROM on the I2C bus Syntax int RC tabData nDatLen LS_I2CReadEEPROM int hHandle unsigned short nSubAddress nDataLen Parameter hHandle nSubAddress nOffset nOffsetFormat nDataLenLen Return values unsigned int nOffset unsigned int nOffsetFormat int Valid access handle Subaddress of the EEPROM to communicate with The valid values for nSubAddress are governed by the setting used in the parameter nOffsetFormat bits 8 10 If the EEPROM type needs to use bits of the Chip Enable Address to address the internal memory only the remaining bits can be used to select the device itself e No bit is used for addressing 0 to 7 e 1 bit is used for addressing O to 3 e 2 bits are used for addressing O to 1 e 3 bits are used for addressing O Data offset on the EEPROM from which the transferred data is to be read Defines how a memory address of EEPROM has to be specified when accessing the device Bits 0 7 indicate the number of bits which are used in the address byte word of the I2C command for addressing the device memory Bits 8 10 indicate how much and which bits of the Chip Enable Bits are used for addressing the device memory see Table C 1 Usage of the CHIP Enable Bits of I2C EEPROMs for allowed values Note C The maximum addressable size of an EEPROM is derived from the sum of all the bits F
131. tion for all commands and functions which do not offer a specific timeout value Return values RC Returns 0 if successful or an error value otherwise Appendix A API return codes Handle Access handle if successfully connected to the AnaGate device Description Opens a TCP IP connection to an AnaGate I2C resp AnaGate Universal Programmer After the connection is established access to the I2C bus is possible Note The AnaGate I2C resp the I2C interface of an AnaGate Universal Programmer does not allow more than one concurrent network connection During an established network connection all new connections are refused See the following example for the initial programming steps 120 2007 2010 Analytica GmbH I2C Reference nRC nHandle LS I2COpenDevice 1000000 if nRC 0 then print LS_I2CErrorMessage nRC ext end now do something LS_I2CCloseDevice nHandle visa AUS 5 254 SOOO dp See also LS_I2CCloseDevice 121 2007 2010 Analytica GmbH I2C Reference LS 12CCloseDevice LS I2CCloseDevice Closes an open network connection to an AnaGate I2C device Syntax int RC LS I2CCloseDevice int hHandle Parameter hHandle Valid access handle Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description Closes an open network connection to an AnaGate I2C device The hHandle parameter i
132. uilds a bidirectional software interface and is called socket The AnaGate device offers its functionality as so called TCP server It creates a socket with its IP address and a device specific port number On the models with CAN interface s a seperate socket with different port number is created for each existing CAN interface on every socket up to 5 concurrent client connections are accepted The SPI I2C and Renesas interfaces accept only one concurrent connection at the same time Table 2 1 AnaGate devices and related port numbers Device Port number AnaGate I2C AnaGate Universal Programmer 5000 AnaGate CAN AnaGate CAN uno 5001 AnaGate CAN duo 5001 5101 AnaGate CAN quattro 5001 5101 5201 5301 AnaGate SPI AnaGate Universal Programmer 5002 AnaGate Renesas AnaGate Universal 5008 Programmer i Important Please ensure that all used ports are set active on the personal computer to grant access to the AnaGate device Any existing firewalls are to be configured accordingly 2 1 Important properties of the network protocol In most cases TCP is based on the internet protocol IP IP is package oriented whereby it is possible that data packets are lost or the packets can be received in wrong order or perhaps more than once TCP eliminates this behaviour and ensures that the the data packets are received in correct order at the recipient Is a sent data packet not confirmed by the recipient within a timeout limit
133. unction writes data to an I2C EEPROM Of course all access to the memory of an EEPROM is done by standard I2C read or write commands So when writing to the memory only the matching slave address the memory offset address and the data has to be sent to the I2C bus I2CWriteEEPROM translates the given memory address on the chip by means of the sub address and the addressing mode of the present EEPROM type The slave address of the EEPROM is automatically determined and not mandatory for the fucntion call Tip It is important to note that an EEPROM is divided into memory pages and that a single write command can only program data within a page Users of I2CWriteEEPROM must ensure to do not write across page limits The page size depends on the EEEPOM type See the following example for writing data to a ST24C1024 include AnaGateDllSPI h int main char cBufferPage 256 nt hHandle 0 int HRC Op unsigned short nSubAddress 0 H unsigned int nOffsetFormat 0x10 0x0F El int nRC I2COpenDevice amp hHandle 400000 192 168 0 254 5000 if nRC 0 memset cBufferPage 0 256 clear page buffer rojo int sic 4512474494 I2CWriteEEPROM hHandle nSubAddress i 256 cBufferPage 256 nOffsetFormat H I2CCloseDevice hHandle return 0 E Itis possible to address 4 individual ST24C1024 on a single I2C bus By selection of subaddress 0 th
134. us To write and read data by the PC only the sPIDataReq function is required Public Declare Function SPIDataReq Lib AnaGateSPIVB6 Alias _SPIDataReq 20 ByVal hHandle As Long ByVal lpBufferWrite As Any _ ByVal nBufferWriteLen As Long _ ByVal lpBufferRead As Any _ ByVal nBufferReadlLen As Long As Long The event procedure btnStart_Click is called on click of the Execute command button Private Sub btnStart Click Dim nRC As Long sText As String I As Integer sByteText As String Dim nBaudrate As Long nSigLevel As Byte nAuxVoltage As Byte nClockMode As Byte Dim nBufferWriteLen As Long nBufferReadLen As Long Dim arrWrite l To 255 As Byte arrRead l To 255 As Byte nRC SPIOpenDevice hHandle Me IPAddresse Text 2000 If nRC lt gt 0 Then SText Fehler bei SPIOpenDevice amp GetErrorMsg nRC Else nBaudrate CLng Me txtBaudrate nSigLevel CLng Me cmbSigLevel ListIndex nAuxVoltage CLng Me cmbAuxVoltage ListIndex nClockMode CLng Me cmbClockMode ListIndex nRC SPISetGlobals hHandle nBaudrate nSigLevel nAuxVoltage nClockMode H If nRC lt gt 0 Then sText sText amp Fehler bei SPISetGlobals amp GetErrorMsg nRC vbCrLf End I Me lblDeviceInfo Caption GetAnagateInfo hHandle nBufferWriteLen GetCommand arrWrite El nBufferReadLen nBufferWriteLen nRC SPIDataReq hHandle VarPtr arrWrite 1 nBufferWriteLen _ VarPtr arrRead 1 nBufferReadLen E If nRC 0 Then
135. wise Appendix A API return codes tabFilter Pointer to an array of 8 filter entries 4 mask and 4 range filter entries A filter entry contains of two 32 bit values Unused mask filter entries are initialized with O values Unused range filter entries are initialized with 0 0x1FFFFFFF value pairs Description This function retrieves the current filter settings for the current connection Filter can be used to suppress messages with specific CAN message ids See also LS CANSetFilter 102 2007 2010 Analytica GmbH CAN Reference LS CANSetTime LS_CANSetTime Sets the current system time on the AnaGate device Syntax int RC LS_CANSetTime int hHandle long nSeconds long nMicroseconds Parameter hHandle Valid access handle nSeconds Time in seconds from 01 01 1970 nMicroseconds Micro seconds Return value RC Returns 0 if successful or an error value otherwise Appendix A API return codes Description The LS_CANSet Time function sets the system time on the AnaGate hardware If the time stamp mode is switched on by the LS_CANSetGlobals function the AnaGate hardware adds a time stamp to each incoming CAN telegram and a time stamp to the confirmation of a telegram sent via the API only if confirmations are switched on for data requests Remarks The setting ofthe base time for the time stamp mode is not supported by the AnaGate CAN hardware version 1 1 A This setting is ignored by the
136. x A APT return codes Description This function retrieves the current filter settings for the current connection Filter can be used to suppress messages with specific CAN message ids See also CANSetFilter 19 2007 2010 Analytica GmbH CAN API reference CANSetTime CANSetTime Sets the current system time on the AnaGate device Syntax include lt AnaGateDIICAN h gt int CANSetTime int hHandle long nSeconds long nMicroseconds Parameter hHandle Valid access handle nSeconds Time in seconds from 01 01 1970 nMicroseconds Micro seconds Return value Returns null if successful or an error value otherwise Appendix A API return codes Description The CANSetTime function sets the system time on the AnaGate hardware If the time stamp mode is switched on by the CANSetGlobals function the AnaGate hardware adds a time stamp to each incoming CAN telegram and a time stamp to the confirmation of a telegram sent via the API only if confirmations are switched on for data requests Remarks The CANSetTime function is supported by library version 1 4 1 8 or higher The setting ofthe base time for the time stamp mode is not supported by the AnaGate CAN hardware version 1 1 A This setting is ignored by the device 20 2007 2010 Analytica GmbH CAN API reference CANWrite CANWriteEx CANWrite CANWriteEx Send a CAN telegram to the CAN bus via the AnaGate device Syntax
137. xecutable 76 2007 2010 Analytica GmbH The LUA scripting interface of the AnaGate product line named LUA exe which includes all functional extensions to operate the AnaGate hardware o The lastest version of LUA exe can be downloaded free of charge via the support pages of the product homepage http www anagate de support download htm Except of the program executable LUA exe no other program files are needed so that there is only one single file to copy to the computer harddisk or file server SUB stick A script file is executed easily via the command line shell only the name of the scriptfile has to specified to start it Following example shows how a script file named Get_Serial lua is executed in the windows command shell T Tools LUA gt LUA exe Get_Serial lua H Conncercdlivo ISPs SA Fl I have successfully retrieved the current serial and MAC SN 01 02 02 1D MAC 00 50 C2 3C B2 1D T Tools LUA gt EI The filename of the script to execute has to be supplied as parameter on start of the interpreter E The serial number and MAC address of a device at IP address 192 168 1 254 is retrieved and written to the standard output 8 3 Running scripts on AnaGate hardware Like already mentioned before it is possible to execute self created application scripts with an installed LUA script interpreter directly on the AnaGate hardware Via the HTTP interface of each device LUA script

Download Pdf Manuals

image

Related Search

Related Contents

SM-8/2 V1 - Highlite  HEALTHone User Manual Version 7.1  Samsung HT-D355 User Manual  Hama DIN A4 A40  System Functions - Samco Software Inc.  Samsung LE46C Εγχειρίδιο χρήσης  Euro-Pro EP171 Iron User Manual  

Copyright © All rights reserved.
Failed to retrieve file