drivers/can_copcican_linux/co_pcicanops.h
author fbeaulier
Mon, 29 Aug 2011 17:44:49 +0200
changeset 666 9febdd6fdc71
parent 629 b9274b595650
permissions -rw-r--r--
patch from Stefan Kratochwil <entwicklung@inovel.de> : canfestival-3-fm3_698.patch
Bug:
If an object dictionary entry was requested whose size exceeds
SDO_MAX_LENGTH_TRANSFERT, the memcpy() call at line 139 of objacces.c overwrites
the memory after *pDestData which causes stack corruption.
-> Bugfix:
The bug was corrected by size checking the requested data. An 'Out of
memory' error message will be generated if the requested data exceeds
SDO_MAX_LENGTH_TRANSFERT.

Additional changes:
Added dynamic buffer allocation for the SDO transfer. This feature can be used
if SDO_DYNAMIC_BUFFER_ALLOCATION is defined in config.h. The size of the
dynamically allocated buffer is controlled with
SDO_DYNAMIC_BUFFER_ALLOCATION_SIZE.
-> Note:
This change removes the detection of OD_LENGTH_DATA_INVALID errors!
629
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
     1
/*
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack.
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
     3
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
     4
Copyright (C): Cosateq GmbH & Co.KG
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
     5
               http://www.cosateq.com/
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
     6
               http://www.scale-rt.com/
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
     7
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
     8
See COPYING file for copyrights details.
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
     9
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    10
This library is free software; you can redistribute it and/or
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    11
modify it under the terms of the GNU Lesser General Public
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    12
License as published by the Free Software Foundation; either
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    13
version 2.1 of the License, or (at your option) any later version.
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    14
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    15
This library is distributed in the hope that it will be useful,
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    16
but WITHOUT ANY WARRANTY; without even the implied warranty of
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    18
Lesser General Public License for more details.
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    19
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    20
You should have received a copy of the GNU Lesser General Public
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    21
License along with this library; if not, write to the Free Software
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    22
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    23
*/
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    24
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    25
/*
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    26
	CAN driver interface for CO-PCICAN card.
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    27
*/
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    28
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    29
#ifndef _CO_PCICANOPS_
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    30
#define _CO_PCICANOPS_
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    31
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    32
#define NUM_CAN_CHANNELS 4
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    33
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    34
#define CMDQ_OPC_ENTER_RUN_MODE     0x01
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    35
#define CMDQ_OPC_ENTER_CONFIG_MODE  0x02
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    36
#define CMDQ_OPC_SET_CONFIG_CHANNEL 0xA2
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    37
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    38
typedef struct
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    39
{
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    40
  unsigned char opcode;
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    41
  unsigned long param[15];
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    42
} co_pcican_config_t;
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    43
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    44
typedef struct
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    45
{
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    46
  unsigned char channelnum;
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    47
  unsigned long type;
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    48
  unsigned long size;
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    49
  unsigned long id;
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    50
  unsigned char data[8];
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    51
  unsigned long timestamp_lo;
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    52
  unsigned long timestamp_hi;
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    53
} co_pcican_message_t;
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    54
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    55
/*=============================================================================
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    56
  supported operations
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    57
  ===========================================================================*/
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    58
#define CAN_CONFIG 2
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    59
#define CAN_WRITE  3
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    60
#define CAN_READ   4
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    61
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    62
/*=============================================================================
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    63
  directions
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    64
  ===========================================================================*/
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    65
#define RX         0
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    66
#define TX         1
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    67
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    68
/*=============================================================================
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    69
  supported types
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    70
  ===========================================================================*/
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    71
#define MSG_EXT    0x00000001
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    72
#define MSG_RTR    0x00000002
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    73
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    74
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    75
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    76
#endif
b9274b595650 CosateQ contribution.
edouard
parents:
diff changeset
    77