author | etisserant |
Sat, 12 May 2007 23:06:43 +0200 | |
changeset 193 | 0487270d441c |
parent 192 | 9dd6f17ef7e5 |
child 196 | 65aa7a664f6f |
permissions | -rw-r--r-- |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
1 |
/* |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
2 |
This file is part of CanFestival, a library implementing CanOpen Stack. |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
3 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
4 |
Copyright (C): Edouard TISSERANT and Francis DUPIN |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
5 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
6 |
See COPYING file for copyrights details. |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
7 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
8 |
This library is free software; you can redistribute it and/or |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
9 |
modify it under the terms of the GNU Lesser General Public |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
10 |
License as published by the Free Software Foundation; either |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
11 |
version 2.1 of the License, or (at your option) any later version. |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
12 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
13 |
This library is distributed in the hope that it will be useful, |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
16 |
Lesser General Public License for more details. |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
17 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
18 |
You should have received a copy of the GNU Lesser General Public |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
19 |
License along with this library; if not, write to the Free Software |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
21 |
*/ |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
22 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
23 |
#include <stdio.h> |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
24 |
#include <string.h> |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
25 |
#include <stdlib.h> |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
26 |
#include <stddef.h> /* for NULL */ |
192 | 27 |
#include <errno.h> |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
28 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
29 |
#include "config.h" |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
30 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
31 |
#ifdef RTCAN_SOCKET |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
32 |
#include "rtdm/rtcan.h" |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
33 |
#define CAN_IFNAME "rtcan%s" |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
34 |
#define CAN_SOCKET rt_dev_socket |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
35 |
#define CAN_CLOSE rt_dev_close |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
36 |
#define CAN_RECV rt_dev_recv |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
37 |
#define CAN_SEND rt_dev_send |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
38 |
#define CAN_BIND rt_dev_bind |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
39 |
#define CAN_IOCTL rt_dev_ioctl |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
40 |
#else |
187 | 41 |
#include <sys/socket.h> |
42 |
#include <sys/ioctl.h> |
|
43 |
#include "linux/can.h" |
|
44 |
#include "linux/can/raw.h" |
|
45 |
#include "net/if.h" |
|
46 |
#define PF_CAN 29 |
|
47 |
#define AF_CAN PF_CAN |
|
48 |
//#include "af_can.h" |
|
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
49 |
#define CAN_IFNAME "can%s" |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
50 |
#define CAN_SOCKET socket |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
51 |
#define CAN_CLOSE close |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
52 |
#define CAN_RECV recv |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
53 |
#define CAN_SEND send |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
54 |
#define CAN_BIND bind |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
55 |
#define CAN_IOCTL ioctl |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
56 |
#endif |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
57 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
58 |
#include "can_driver.h" |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
59 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
60 |
/*********functions which permit to communicate with the board****************/ |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
47
diff
changeset
|
61 |
UNS8 canReceive_driver(CAN_HANDLE fd0, Message *m) |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
62 |
{ |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
63 |
int res; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
64 |
struct can_frame frame; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
65 |
|
187 | 66 |
res = CAN_RECV(*(int*)fd0, &frame, sizeof(frame), 0); |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
67 |
if (res < 0) |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
68 |
return 1; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
69 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
70 |
m->cob_id.w = frame.can_id & CAN_EFF_MASK; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
71 |
m->len = frame.can_dlc; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
72 |
if (frame.can_id & CAN_RTR_FLAG) |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
73 |
m->rtr = 1; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
74 |
else |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
75 |
m->rtr = 0; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
76 |
memcpy(m->data, frame.data, 8); |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
77 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
78 |
return 0; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
79 |
} |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
80 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
81 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
82 |
/***************************************************************************/ |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
47
diff
changeset
|
83 |
UNS8 canSend_driver(CAN_HANDLE fd0, Message *m) |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
84 |
{ |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
85 |
int res; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
86 |
struct can_frame frame; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
87 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
88 |
frame.can_id = m->cob_id.w; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
89 |
if (frame.can_id >= 0x800) |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
90 |
frame.can_id |= CAN_EFF_FLAG; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
91 |
frame.can_dlc = m->len; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
92 |
if (m->rtr) |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
93 |
frame.can_id |= CAN_RTR_FLAG; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
94 |
else |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
95 |
memcpy(frame.data, m->data, 8); |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
96 |
|
187 | 97 |
res = CAN_SEND(*(int*)fd0, &frame, sizeof(frame), 0); |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
98 |
if (res < 0) |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
99 |
return 1; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
100 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
101 |
return 0; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
102 |
} |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
103 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
104 |
/***************************************************************************/ |
192 | 105 |
#ifdef RTCAN_SOCKET |
106 |
int TranslateBaudRate(const char* optarg) { |
|
107 |
int baudrate; |
|
108 |
int val, len; |
|
109 |
char *pos = NULL; |
|
110 |
||
111 |
len = strlen(optarg); |
|
112 |
if (!len) |
|
113 |
return 0; |
|
114 |
||
115 |
switch ((int)optarg[len - 1]) { |
|
116 |
case 'M': |
|
117 |
baudrate = 1000000; |
|
118 |
break; |
|
119 |
case 'K': |
|
120 |
baudrate = 1000; |
|
121 |
break; |
|
122 |
default: |
|
123 |
baudrate = 1; |
|
124 |
break; |
|
125 |
} |
|
126 |
if ((sscanf(optarg, "%i", &val)) == 1) |
|
127 |
baudrate *= val; |
|
128 |
else |
|
129 |
baudrate = 0;; |
|
130 |
||
131 |
printf("baudrate=%d (%s)\n", baudrate, optarg); |
|
132 |
return baudrate; |
|
133 |
} |
|
134 |
#endif |
|
135 |
||
136 |
/***************************************************************************/ |
|
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
47
diff
changeset
|
137 |
CAN_HANDLE canOpen_driver(s_BOARD *board) |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
138 |
{ |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
139 |
struct ifreq ifr; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
140 |
struct sockaddr_can addr; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
141 |
int err; |
187 | 142 |
CAN_HANDLE fd0 = malloc(sizeof(int)); |
192 | 143 |
#ifdef RTCAN_SOCKET |
144 |
can_baudrate_t *baudrate; |
|
145 |
can_mode_t *mode; |
|
146 |
#endif |
|
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
147 |
|
189 | 148 |
*(int*)fd0 = CAN_SOCKET(PF_CAN, SOCK_RAW, CAN_RAW); |
192 | 149 |
if (*(int*)fd0 < 0) { |
150 |
perror("Socket creation failed"); |
|
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
151 |
goto error_ret; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
152 |
} |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
153 |
|
192 | 154 |
if (*board->busname >= '0' && *board->busname <= '9') |
155 |
snprintf(ifr.ifr_name, IFNAMSIZ, CAN_IFNAME, |
|
156 |
board->busname); |
|
157 |
else |
|
158 |
strncpy(ifr.ifr_name, board->busname, IFNAMSIZ); |
|
187 | 159 |
err = CAN_IOCTL(*(int*)fd0, SIOCGIFINDEX, &ifr); |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
160 |
if (err) { |
192 | 161 |
fprintf(stderr, "Getting IF index for %s failed: %s\n", |
162 |
ifr.ifr_name, strerror(errno)); |
|
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
163 |
goto error_close; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
164 |
} |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
165 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
166 |
addr.can_family = AF_CAN; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
167 |
addr.can_ifindex = ifr.ifr_ifindex; |
187 | 168 |
err = CAN_BIND(*(int*)fd0, (struct sockaddr *)&addr, |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
169 |
sizeof(addr)); |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
170 |
if (err) { |
192 | 171 |
perror("Binding failed"); |
172 |
goto error_close; |
|
173 |
} |
|
174 |
||
175 |
#ifdef RTCAN_SOCKET |
|
176 |
baudrate = (can_baudrate_t *)&ifr.ifr_ifru; |
|
177 |
*baudrate = TranslateBaudRate(board->baudrate); |
|
178 |
if (!*baudrate) |
|
179 |
goto error_close; |
|
180 |
||
181 |
err = CAN_IOCTL(*(int*)fd0, SIOCSCANBAUDRATE, &ifr); |
|
182 |
if (err) { |
|
183 |
fprintf(stderr, |
|
184 |
"Setting baudrate %d failed: %s\n", |
|
185 |
*baudrate, strerror(errno)); |
|
186 |
goto error_close; |
|
187 |
} |
|
188 |
||
189 |
mode = (can_mode_t *)&ifr.ifr_ifru; |
|
190 |
*mode = CAN_MODE_START; |
|
191 |
err = CAN_IOCTL(*(int*)fd0, SIOCSCANMODE, &ifr); |
|
192 |
if (err) { |
|
193 |
perror("Starting CAN device failed"); |
|
194 |
goto error_close; |
|
195 |
} |
|
196 |
#endif |
|
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
197 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
198 |
return fd0; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
199 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
200 |
error_close: |
189 | 201 |
CAN_CLOSE(*(int*)fd0); |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
202 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
203 |
error_ret: |
187 | 204 |
free(fd0); |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
205 |
return NULL; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
206 |
} |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
207 |
|
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
208 |
/***************************************************************************/ |
145
e747d2e26af0
Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
47
diff
changeset
|
209 |
int canClose_driver(CAN_HANDLE fd0) |
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
210 |
{ |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
211 |
if (fd0) { |
187 | 212 |
CAN_CLOSE(*(int*)fd0); |
213 |
free(fd0); |
|
47
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
214 |
} |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
215 |
return 0; |
8a1047ab51f4
SOCKET-CAN support added. Many thanks to Jan Kiszka !
etisserant
parents:
diff
changeset
|
216 |
} |