tCanDevice.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
24 //----------------------------------------------------------------------
25 
27 
28 #include <icl_core/os_lxrt.h>
29 
31 
32 #ifdef _IC_BUILDER_CAN_MCA_
34 namespace icl_hardware {
35 namespace can {
36 typedef tCanDeviceMCA tCanDeviceImpl;
37 }
38 }
39 #elif defined _IC_BUILDER_CAN_PEAK_
41 namespace icl_hardware {
42 namespace can {
43 typedef tCanDevicePeak tCanDeviceImpl;
44 }
45 }
46 #elif defined _IC_BUILDER_CAN_ITEC_
48 namespace icl_hardware {
49 namespace can {
50 typedef tCanDeviceITEC tCanDeviceImpl;
51 }
52 }
53 #else
56 namespace icl_hardware {
57 namespace can {
59 }
60 }
61 #endif
62 
63 namespace icl_hardware {
64 namespace can {
65 
67 
69 {
70 }
71 
73 {
74 #ifdef _SYSTEM_LXRT_
75  if (!icl_core::os::IsLxrtAvailable())
76  {
77  LOGGING_WARNING_C(CAN, tCanDevice, "LXRT not available!" << endl);
78  return;
79  }
80  int user = CreateCanFifoUser(0, 0xff, 0xff, 1000, 500, 500);
81  if (user == -ENOSYS)
82  {
83  LOGGING_WARNING_C(CAN, tCanDevice, "No LXRT CAN functions available (Probe failed)!" << endl);
84  return;
85  }
86  else
87  {
88  DestroyCanFifoUser(0, user);
89  }
90 
91  LLOGGING_INFO_C(CAN, tCanDevice, "CAN: LXRT interface available\n");
92  m_canlxrt_available = true;
93 #endif
94 }
95 
96 tCanDevice *tCanDevice::Create(const char *device_name, int flags,
97  unsigned char acceptance_code, unsigned char acceptance_mask, unsigned int baud_rate,
98  unsigned send_fifo_size, unsigned receive_fifo_size)
99 {
100  return new tCanDeviceImpl(device_name, flags, acceptance_code, acceptance_mask, baud_rate, send_fifo_size, receive_fifo_size);
101 }
102 
103 }
104 }
int DestroyCanFifoUser(int device_id, int user_id)
Destroys a can FIFO in kernel space.
Definition: UseCanNoLxrt.h:50
int CreateCanFifoUser(int device_id, unsigned acceptance_code, unsigned acceptance_mask, unsigned int baud_rate, unsigned send_fifo_size, unsigned receive_fifo_size)
Creates a can FIFO in kernel space.
Definition: UseCanNoLxrt.h:41
static tCanDevice * Create(const char *device_name, int flags, unsigned char acceptance_code, unsigned char acceptance_mask, unsigned int baud_rate, unsigned send_fifo_size, unsigned receive_fifo_size)
Definition: tCanDevice.cpp:96
Contains tCanDevice.
#define LOGGING_WARNING_C(streamname, classname, arg)
static void CheckLXRTInterface()
Definition: tCanDevice.cpp:72
Contains tCanDevice.
tCanDeviceT< tCanDescriptor > tCanDeviceImpl
Definition: tCanDevice.cpp:58
ThreadStream & endl(ThreadStream &stream)
Contains dummy CAN driver interface functions.
#define LLOGGING_INFO_C(streamname, classname, arg)
Contains tCanDevice.
Contains tCanDevice.


fzi_icl_can
Author(s):
autogenerated on Mon Jun 10 2019 13:17:02