drivers/can_can4linux/can_can4linux.c
author Christian Taedcke
Fri, 28 Jan 2011 14:51:18 +0100
changeset 657 c0e68a63f600
parent 631 08b6b903f84a
permissions -rwxr-xr-x
FIX: - if a sdo transfer timeout occurres, reset the sdo line even if the callback function does not.
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
     1
/*
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack.
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
     3
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
     4
Copyright (C): Jorge BERZOSA
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
     5
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
     6
See COPYING file for copyrights details.
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
     7
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    12
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    16
Lesser General Public License for more details.
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    17
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    21
*/
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    22
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    23
/*
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    24
* can4linux driver
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    25
*/
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    26
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    27
#include <stdio.h>
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    28
#include <string.h>
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    29
#include <errno.h>
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    30
#include <fcntl.h>
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    31
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    32
#include "can4linux.h" 
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    33
#include "can_driver.h"
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    34
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
    35
//struct timeval init_time,current_time;
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    36
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    37
/*********functions which permit to communicate with the board****************/
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    38
UNS8 canReceive_driver(CAN_HANDLE fd0, Message *m)
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    39
{
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    40
  int res,i;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    41
  canmsg_t canmsg;
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
    42
  //long int time_period;
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    43
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    44
	canmsg.flags = 0; 
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    45
	do{
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    46
   		res = read(fd0,&canmsg,1);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    47
   		if((res<0)&&(errno == -EAGAIN)) res = 0;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    48
	}while(res==0);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    49
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    50
	if(res !=1) // No new message
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    51
   	return 1;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    52
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    53
	if(canmsg.flags&MSG_EXT){
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    54
   		/* There is no mark for extended messages in CanFestival */;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    55
	}
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    56
  		
365
9b76e0881beb Changed cob_id from struct{UNS32} to UNS16
etisserant
parents: 364
diff changeset
    57
	m->cob_id = canmsg.id;
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    58
	m->len = canmsg.length;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    59
	if(canmsg.flags&MSG_RTR){
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    60
 		m->rtr = 1;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    61
	}else{
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    62
 		m->rtr = 0;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    63
 		memcpy(m->data,canmsg.data,8);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    64
	}
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    65
	
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    66
	
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    67
 	/*gettimeofday(&current_time,NULL);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    68
 	time_period=(current_time.tv_sec - init_time.tv_sec)* 1000000 + current_time.tv_usec - init_time.tv_usec;
365
9b76e0881beb Changed cob_id from struct{UNS32} to UNS16
etisserant
parents: 364
diff changeset
    69
 	printf("%3ld.%3ld.%3ld - Receive ID: %lx ->",time_period/1000000,(time_period%1000000)/1000,time_period%1000,m->cob_id);
9b76e0881beb Changed cob_id from struct{UNS32} to UNS16
etisserant
parents: 364
diff changeset
    70
 	printf("Receive ID: %lx ->",m->cob_id);
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    71
 	for(i=0; i<canmsg.length;i++)printf("%x, ", m->data[i]);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    72
 	printf("\n");*/
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    73
 
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    74
  return 0;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    75
}
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    76
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    77
/***************************************************************************/
631
08b6b903f84a Piotr Trojanek (ptroja) cleanup patche. Thanks.
edouard
parents: 471
diff changeset
    78
UNS8 canSend_driver(CAN_HANDLE fd0, Message const *m)
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    79
{
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    80
  int res;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    81
  canmsg_t canmsg;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    82
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    83
  canmsg.flags = 0;
365
9b76e0881beb Changed cob_id from struct{UNS32} to UNS16
etisserant
parents: 364
diff changeset
    84
  canmsg.id = m->cob_id;
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    85
  canmsg.length = m->len;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    86
  if(m->rtr){
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    87
    canmsg.flags |= MSG_RTR;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    88
  }else{
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    89
    memcpy(canmsg.data,m->data,8);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    90
  }
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    91
  
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    92
 /*printf("Send ID: %lx ->",canmsg.id); 
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    93
 for(i=0; i<canmsg.length;i++)printf("%x, ", canmsg.data[i]);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    94
 printf("\n");*/
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    95
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    96
  if(canmsg.id >= 0x800){
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    97
    canmsg.flags |= MSG_EXT;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    98
  }
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
    99
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   100
  res = write(fd0,&canmsg,1);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   101
  if(res!=1)
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   102
    return 1;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   103
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   104
  return 0;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   105
}
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   106
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   107
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   108
/***************************************************************************/
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   109
int TranslateBaudRate(char* optarg){
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   110
	if(!strcmp( optarg, "1M")) return (int)1000;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   111
	if(!strcmp( optarg, "500K")) return (int)500;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   112
	if(!strcmp( optarg, "250K")) return (int)250;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   113
	if(!strcmp( optarg, "125K")) return (int)125;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   114
	if(!strcmp( optarg, "100K")) return (int)100;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   115
	if(!strcmp( optarg, "50K")) return (int)50;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   116
	if(!strcmp( optarg, "20K")) return (int)20;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   117
	if(!strcmp( optarg, "10K")) return (int)10;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   118
	if(!strcmp( optarg, "5K")) return (int)5;
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   119
	return 0;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   120
}
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   121
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   122
UNS8 _canChangeBaudRate( CAN_HANDLE fd, int baud)
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   123
{
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   124
    Config_par_t  cfg;	
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   125
    volatile Command_par_t cmd;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   126
    
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   127
    cmd.cmd = CMD_STOP;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   128
    ioctl(fd, COMMAND, &cmd);
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   129
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   130
	cfg.target = CONF_TIMING; 
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   131
    cfg.val1  = baud;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   132
    ioctl(fd, CONFIG, &cfg);
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   133
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   134
    cmd.cmd = CMD_START;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   135
    ioctl(fd, COMMAND, &cmd);
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   136
    
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   137
    return 0;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   138
}
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   139
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   140
UNS8 canChangeBaudRate_driver( CAN_HANDLE fd, char* baud)
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   141
{
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   142
    int temp=TranslateBaudRate(baud);
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   143
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   144
    if(temp==0)return 1;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   145
    _canChangeBaudRate(fd, temp);
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   146
    printf("Baudrate changed to=>%s\n", baud);
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   147
    return 0;
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   148
}
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   149
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   150
/***************************************************************************/
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   151
static const char lnx_can_dev_prefix[] = "/dev/can";
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   152
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   153
CAN_HANDLE canOpen_driver(s_BOARD *board)
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   154
{
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   155
  int name_len = strlen(board->busname);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   156
  int prefix_len = strlen(lnx_can_dev_prefix);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   157
  char dev_name[prefix_len+name_len+1];
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   158
  int o_flags = 0;
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   159
  //int baud = TranslateBaudeRate(board->baudrate);
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   160
  int fd0;
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   161
  int res;
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   162
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   163
  
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   164
  /*o_flags = O_NONBLOCK;*/
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   165
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   166
  memcpy(dev_name,lnx_can_dev_prefix,prefix_len);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   167
  memcpy(dev_name+prefix_len,board->busname,name_len);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   168
  dev_name[prefix_len+name_len] = 0;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   169
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   170
  fd0 = open(dev_name, O_RDWR|o_flags);
471
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   171
  if(fd0 == -1){
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   172
    fprintf(stderr,"!!! %s is unknown. See can4linux.c\n", dev_name);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   173
    goto error_ret;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   174
  }
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   175
  
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   176
  res=TranslateBaudRate(board->baudrate);
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   177
  if(res == 0){
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   178
    fprintf(stderr,"!!! %s baudrate not supported. See can4linux.c\n", board->baudrate);
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   179
    goto error_ret;
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   180
  }
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   181
	
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 365
diff changeset
   182
  _canChangeBaudRate( (CAN_HANDLE)fd0, res);
364
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   183
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   184
  printf("CAN device dev/can%s opened. Baudrate=>%s\n",board->busname, board->baudrate);
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   185
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   186
  return (CAN_HANDLE)fd0;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   187
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   188
 error_ret:
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   189
  return NULL;
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   190
}
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   191
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   192
/***************************************************************************/
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   193
int canClose_driver(CAN_HANDLE fd0)
17edd8a028fa Added can4linux driver support.
groke6
parents:
diff changeset
   194
{
471
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   195
  if((int)fd0 != -1) {
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   196
      return close((int)fd0);
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   197
  }
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   198
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   199
  return -1;
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   200
}
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   201
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   202
int canfd_driver(CAN_HANDLE fd0)
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   203
{
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   204
        return ((int)fd0);
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   205
}
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   206
bea45a091214 Applied James patch that fixes can_cn4linux.c file descriptor handling and make it compatible with can_serial_hub.
etisserant
parents: 384
diff changeset
   207