📄 #objdict.c#
字号:
/**************************************************************************//* Object Dictionary for the node Linux_slave, default node_id : 0x01 *//* *//* Computed by "makeobjetdict.php" *//**************************************************************************//* Computed by strComputed *//********************************************************* * * * Master/slave CANopen Library * * * * LIVIC : Laboratoire Interractions V庨hicule * * Infrastructure Conducteur * * ---- * * INRETS/LIVIC : http://www.inrets.fr * * Institut National de Recherche sur * * les Transports * * et leur S庨curit庨 * * LCPC Laboratoire Central des Ponts et Chauss庨es * * Laboratoire Interractions V庨hicule Infrastructure * * Conducteur * * * * Authors : Camille BOSSARD * * Francis DUPIN * * Laurent ROMIEUX * * Zakaria BELAMRI * * Contact : bossard.ca@voila.fr * * francis.dupin@inrets.fr * * zakaria_belamri@hotmail.com * * Date : 2003 * * This work is based on * * - CanOpenMatic by Edouard TISSERANT * * http://sourceforge.net/projects/canfestival/ * * - slavelib by Raphael Zulliger * * http://sourceforge.net/projects/canopen/ * ********************************************************* * * ********************************************************* * This program is free software; you can redistribute * * it and/or modify it under the terms of the GNU General* * Public License as published by the Free Software * * Foundation; either version 2 of the License, or (at * * your option) any later version. * * * * This program is distributed in the hope that it will * * be useful, but WITHOUT ANY WARRANTY; without even the * * implied warranty of MERCHANTABILITY or FITNESS FOR A * * PARTICULAR PURPOSE. See the GNU General Public * * License for more details. * * * * You should have received a copy of the GNU General * * Public License along with this program; if not, write * * to The Free Software Foundation, Inc. * * 675 Mass Ave * * Cambridge * * MA 02139 * * USA. * ********************************************************* File : objdict.c *-------------------------------------------------------* * This is where you defined the dictionary of your * * application * * * *********************************************************/ /* Computed by strEntete *///#define DEBUG_CAN#include <stddef.h>#include <time.h>#include <def.h>#include <pdo.h>#include <sdo.h>#include <sync.h>#include <objdictdef.h>#include <nmtSlave.h>#include <lifegrd.h>/**************************************************************************//* The node id *//**************************************************************************//* Computed by strNode *//* node_id default value. You should always overwrite this by using the function setNodeId(UNS8 nodeId) in your C code.*/#define NODE_ID 0x01UNS8 bDeviceNodeId = NODE_ID;/**************************************************************************//* Declaration of the mapped variables *//**************************************************************************//* Computed by strDeclareMapVar */UNS8 seconds; // Mapped at index 0x2000, subindex 0x1UNS8 minutes; // Mapped at index 0x2000, subindex 0x2UNS8 hours; // Mapped at index 0x2000, subindex 0x3UNS8 day; // Mapped at index 0x2000, subindex 0x4UNS32 canopenErrNB; // Mapped at index 0x6000, subindex 0x0UNS32 canopenErrVAL; // Mapped at index 0x6001, subindex 0x0UNS8 essaiTable[5]; // Mapped at index 0x2001, subindex 0x1 - 0x5//*****************************************************************************//* Computed by strStartDico *//* Array of message processing information *//* Should not be modified */proceed_info proceed_infos[] = { {NMT, "NMT", proceedNMTstateChange}, {SYNC, "SYNC", proceedSYNC}, {TIME_STAMP, "TIME_STAMP", NULL}, {PDO1tx, "PDO1tx", proceedPDO}, {PDO1rx, "PDO1rx", proceedPDO}, {PDO2tx, "PDO2tx", proceedPDO}, {PDO2rx, "PDO2rx", proceedPDO}, {PDO3tx, "PDO3tx", proceedPDO}, {PDO3rx, "PDO3rx", proceedPDO}, {PDO4tx, "PDO4tx", proceedPDO}, {PDO4rx, "PDO4rx", proceedPDO}, {SDOtx, "SDOtx", proceedSDO}, {SDOrx, "SDOrx", proceedSDO}, {0xD, "Unknown", NULL}, {NODE_GUARD, "NODE GUARD", proceedNMTerror}, {0xF, "Unknown", NULL}};//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$//// OBJECT DICTIONARY// //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$// Make your change, depending of your application /** index 1000h: device type. You have to change the value below, so * it fits your canopen-slave-module *//* Not used, so, should not be modified */#define OBJNAME devicetype/*const*/ UNS32 OBJNAME = 0x0;/*const*/ subindex Index1000[] ={ { RO, uint32, sizeof(UNS32), (void*)&OBJNAME }};#undef OBJNAME/** index 1001: error register. Change the entries to fit your application *//* Not used, so, should not be modified */#define OBJNAME errorRegister/*const*/ UNS8 OBJNAME = 0x0;/*const*/ subindex Index1001[] ={ { RO, uint8, sizeof(UNS8), (void*)&OBJNAME }};#undef OBJNAME/** index 1005: COB_ID SYNC*//* Should not be modified */#define OBJNAME CobIdSync/*const*/ UNS32 OBJNAME = 0x40000080; // bit 30 = 1 : device can generate a SYNC message/*const*/ subindex Index1005[] ={ { RW, uint32, sizeof(UNS32), (void*)&OBJNAME }};#undef OBJNAME/** index 1006: SYNC period*/#define OBJNAME SyncPeriod// For producing the SYNC signal every n micro-seconds.// Put O to not producing SYNC/*const*/ UNS32 OBJNAME = 0x0; /* Default 0 to not produce SYNC *//*const*/ subindex Index1006[] ={ { RW, uint32, sizeof(UNS32), (void*)&OBJNAME }};#undef OBJNAME/** index 1007: Synchronous Window Length*/// Seems to be needed by DS401 to generate the SYNC signal.#define OBJNAME SyncWindowLength// For producing the SYNC signal every n micro-seconds.// Put O to not producing SYNC/*const*/ UNS32 OBJNAME = 0x0; /* Default 0 *//*const*/ subindex Index1007[] ={ { RW, uint32, sizeof(UNS32), (void*)&OBJNAME }};#undef OBJNAME/**************************************************************************//* HeartBeat consumers : The nodes which can send a heartbeat *//**************************************************************************//* Computed by strHeartBeatConsumers */static UNS32 HBConsumerTimeArray[] = { 0x00000000}; // Format 0x00NNTTTT (N=Node T=time in ms)static UNS8 HBConsumerCount = 1; // 1 nodes could send me their heartbeat.subindex Index1016[] = { { RO, uint8, sizeof(UNS8), (void*)&HBConsumerCount }, { RW, uint32, sizeof(UNS32), (void*)&HBConsumerTimeArray[0] }};/**************************************************************************//* The node produce an heartbeat *//**************************************************************************//* Computed by strHeartBeatProducer *//* Every HBProducerTime, the node sends its heartbeat */static UNS16 HBProducerTime = 0; /* in ms. If 0 : not activated */ subindex Index1017[] ={ { RW, uint16, sizeof(UNS16), &HBProducerTime }};/**************************************************************************//* Next to 0x1018 *//**************************************************************************//* Computed by strVaria1 *//** index 1018: identify object. Adjust the entries for your node/company *//* Values can be modified */#define OBJNAME theIdentity/*const*/ s_identity OBJNAME ={ 4, // number of supported entries 0x1234, // Vendor-ID (given by the can-cia) 0x5678, // Product Code 0x1364, // Revision number 0x7964, // serial number} ;/* Should not be modified *//*const*/ subindex Index1018[] ={ { RO, uint8, sizeof(UNS8), (void*)&OBJNAME.count }, { RO, uint32, sizeof(UNS32), (void*)&OBJNAME.vendor_id}, { RO, uint32, sizeof(UNS32), (void*)&OBJNAME.product_code}, { RO, uint32, sizeof(UNS32), (void*)&OBJNAME.revision_number}, { RO, uint32, sizeof(UNS32), (void*)&OBJNAME.serial_number}};#undef OBJNAME/** now the communication profile entries are grouped together, so they * can be accessed in a standardised manner. This could be memory-optimized * if the empty entries wouldn't be added, but then the communication profile * area must be accessed different (see objacces.c file) *//* Should not be modified */const indextable CommunicationProfileArea[] ={ DeclareIndexTableEntry(Index1000), // creates a line like: { Index1000, 1 }, DeclareIndexTableEntry(Index1001), { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, DeclareIndexTableEntry(Index1005), DeclareIndexTableEntry(Index1006), DeclareIndexTableEntry(Index1007), { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, DeclareIndexTableEntry(Index1016), DeclareIndexTableEntry(Index1017), DeclareIndexTableEntry(Index1018),};/**************************************************************************//* The SDO Server parameters *//**************************************************************************//* Computed by strSdoServer *//* BEWARE You cannot define more than one SDO server */#define INDEX_LAST_SDO_SERVER 0x1200#define DEF_MAX_COUNT_OF_SDO_SERVER INDEX_LAST_SDO_SERVER - 0x11FF/* The values should not be modified here, but can be changed at runtime */#define OBJNAME serverSDO1static s_sdo_parameter OBJNAME = { 3, // Number of entries. Always 3 for the SDO 0x600 + NODE_ID, // The cob_id transmited in CAN msg to the server 0x580 + NODE_ID, // The cob_id received in CAN msg from the server NODE_ID // The node id of the client. Should not be modified };static subindex Index1200[] ={ { RO, uint8, sizeof( UNS8 ), (void*)&OBJNAME.count }, { RO, uint32, sizeof( UNS32), (void*)&OBJNAME.cob_id_client }, { RO, uint32, sizeof( UNS32), (void*)&OBJNAME.cob_id_server }, { RW, uint8, sizeof( UNS8), (void*)&OBJNAME.node_id }};#undef OBJNAME/** Create the server SDO Parameter area. *//* Should not be modified */const indextable serverSDOParameter[] ={ DeclareIndexTableEntry(Index1200)};/**************************************************************************//* The SDO(s) clients *//**************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -