Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00024
00025
00026 #include "icl_hardware_can/tCanDevice.h"
00027
00028 #include <icl_core/os_lxrt.h>
00029
00030 #include "icl_hardware_can/Logging.h"
00031
00032 #ifdef _IC_BUILDER_CAN_MCA_
00033 # include "icl_hardware_can/tCanDeviceMCA.h"
00034 namespace icl_hardware {
00035 namespace can {
00036 typedef tCanDeviceMCA tCanDeviceImpl;
00037 }
00038 }
00039 #elif defined _IC_BUILDER_CAN_PEAK_
00040 # include "icl_hardware_can/tCanDevicePeak.h"
00041 namespace icl_hardware {
00042 namespace can {
00043 typedef tCanDevicePeak tCanDeviceImpl;
00044 }
00045 }
00046 #elif defined _IC_BUILDER_CAN_ITEC_
00047 # include "icl_hardware_can/tCanDeviceITEC.h"
00048 namespace icl_hardware {
00049 namespace can {
00050 typedef tCanDeviceITEC tCanDeviceImpl;
00051 }
00052 }
00053 #else
00054 # include "icl_hardware_can/UseDummyCan.h"
00055 # include "icl_hardware_can/tCanDeviceT.h"
00056 namespace icl_hardware {
00057 namespace can {
00058 typedef tCanDeviceT<tCanDescriptor> tCanDeviceImpl;
00059 }
00060 }
00061 #endif
00062
00063 namespace icl_hardware {
00064 namespace can {
00065
00066 bool tCanDevice::m_canlxrt_available = false;
00067
00068 tCanDevice::~tCanDevice()
00069 {
00070 }
00071
00072 void tCanDevice::CheckLXRTInterface()
00073 {
00074 #ifdef _SYSTEM_LXRT_
00075 if (!icl_core::os::IsLxrtAvailable())
00076 {
00077 LOGGING_WARNING_C(CAN, tCanDevice, "LXRT not available!" << endl);
00078 return;
00079 }
00080 int user = CreateCanFifoUser(0, 0xff, 0xff, 1000, 500, 500);
00081 if (user == -ENOSYS)
00082 {
00083 LOGGING_WARNING_C(CAN, tCanDevice, "No LXRT CAN functions available (Probe failed)!" << endl);
00084 return;
00085 }
00086 else
00087 {
00088 DestroyCanFifoUser(0, user);
00089 }
00090
00091 LLOGGING_INFO_C(CAN, tCanDevice, "CAN: LXRT interface available\n");
00092 m_canlxrt_available = true;
00093 #endif
00094 }
00095
00096 tCanDevice *tCanDevice::Create(const char *device_name, int flags,
00097 unsigned char acceptance_code, unsigned char acceptance_mask, unsigned int baud_rate,
00098 unsigned send_fifo_size, unsigned receive_fifo_size)
00099 {
00100 return new tCanDeviceImpl(device_name, flags, acceptance_code, acceptance_mask, baud_rate, send_fifo_size, receive_fifo_size);
00101 }
00102
00103 }
00104 }