1 /** 2 * CAN module object for Linux socketCAN. 3 * 4 * This file is a template for other microcontrollers. 5 * 6 * @file CO_msgs.h 7 * @ingroup CO_driver 8 * @author Martin Wagner 9 * @copyright 2020 Neuberger Gebaeudeautomation GmbH 10 * 11 * 12 * This file is part of CANopenNode, an opensource CANopen Stack. 13 * Project home page is <https://github.com/CANopenNode/CANopenNode>. 14 * For more information on CANopen see <http://www.can-cia.org/>. 15 * 16 * Licensed under the Apache License, Version 2.0 (the "License"); 17 * you may not use this file except in compliance with the License. 18 * You may obtain a copy of the License at 19 * 20 * http://www.apache.org/licenses/LICENSE-2.0 21 * 22 * Unless required by applicable law or agreed to in writing, software 23 * distributed under the License is distributed on an "AS IS" BASIS, 24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 * See the License for the specific language governing permissions and 26 * limitations under the License. 27 */ 28 29 30 #ifndef CO_MSGS_H 31 #define CO_MSGS_H 32 33 #include <stdio.h> 34 #include <syslog.h> 35 #include "CO_msgs.h" 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif /* __cplusplus */ 40 41 /* 42 * message printing function 43 */ 44 #define log_printf(macropar_prio, macropar_message, ...) \ 45 if (macropar_prio < LOG_DEBUG) { \ 46 printf(macropar_message, ##__VA_ARGS__); \ 47 } 48 49 /* 50 * message logging function. You need to open the log previous to this. 51 */ 52 //#define log_printf(macropar_prio, macropar_message, ...) syslog(macropar_prio, macropar_message, ##__VA_ARGS__); 53 54 55 56 /* 57 * Message definitions for Linux CANopen socket driver (notice and errors) 58 */ 59 #define CAN_NOT_FOUND "CAN Interface \"%s\" not found" 60 #define CAN_INIT_FAILED "CAN Interface \"%s\" Init failed" 61 #define CAN_NAMETOINDEX "Interface \"%s\" -> Index %d" 62 #define CAN_SOCKET_BUF_SIZE "CAN Interface \"%s\" Buffer set to %d messages (%d Bytes)" 63 #define CAN_BINDING_FAILED "Binding CAN Interface \"%s\" failed" 64 #define CAN_ERROR_FILTER_FAILED "Setting CAN Interface \"%s\" error filter failed" 65 #define CAN_FILTER_FAILED "Setting CAN Interface \"%s\" message filter failed" 66 #define CAN_RX_SOCKET_QUEUE_OVERFLOW "CAN Interface \"%s\" has lost %d messages" 67 #define CAN_BUSOFF "CAN Interface \"%s\" changed to \"Bus Off\". Switching to Listen Only mode..." 68 #define CAN_NOACK "CAN Interface \"%s\" no \"ACK\" received. Switching to Listen Only mode..." 69 #define CAN_RX_PASSIVE "CAN Interface \"%s\" changed state to \"Rx Passive\"" 70 #define CAN_TX_PASSIVE "CAN Interface \"%s\" changed state to \"Tx Passive\"" 71 #define CAN_TX_LEVEL_ACTIVE "CAN Interface \"%s\" changed state to \"Active\"" 72 #define CAN_RX_BUF_OVERFLOW "CAN Interface \"%s\" Rx buffer overflow. Message dropped" 73 #define CAN_TX_BUF_OVERFLOW "CAN Interface \"%s\" Tx buffer overflow. Message dropped" 74 #define CAN_RX_LEVEL_WARNING "CAN Interface \"%s\" reached Rx Warning Level" 75 #define CAN_TX_LEVEL_WARNING "CAN Interface \"%s\" reached Tx Warning Level" 76 77 /* 78 * Debug 79 */ 80 #define DBG_ERRNO "(%s) OS error \"%s\" in %s", __func__, strerror(errno) 81 #define DBG_CAN_TX_FAILED "(%s) Transmitting CAN msg OID 0x%08x failed(%s)", __func__ 82 #define DBG_CAN_RX_PARAM_FAILED "(%s) Setting CAN rx buffer failed (%s)", __func__ 83 #define DBG_CAN_RX_FAILED "(%s) Receiving CAN msg failed (%s)", __func__ 84 #define DBG_CAN_ERROR_GENERAL "(%s) Socket error msg ID: 0x%08x, Data[0..7]: 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x (%s)", __func__ 85 #define DBG_CAN_RX_EPOLL "(%s) CAN Epoll error (0x%02x - %s)", __func__ 86 #define DBG_CAN_SET_LISTEN_ONLY "(%s) %s Set Listen Only", __func__ 87 #define DBG_CAN_CLR_LISTEN_ONLY "(%s) %s Leave Listen Only", __func__ 88 89 90 #ifdef __cplusplus 91 } 92 #endif /* __cplusplus */ 93 94 /** @} */ 95 #endif 96