include/none/canfestival.h
author fbeaulier
Mon, 29 Aug 2011 17:44:49 +0200
changeset 666 9febdd6fdc71
parent 619 96f84395154f
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!
618
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
     1
#ifndef CANFESTIVAL_H_
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
     2
#define CANFESTIVAL_H_
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
     3
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
     4
#include "timerscfg.h"
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
     5
#include "can_driver.h"
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
     6
#include "data.h"
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
     7
#include "timers_driver.h"
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
     8
619
96f84395154f Enhancements for 'None' target : produce pre-linked object, remove some windows CRLF problems, fixed pedantic compiler warnings
edouard
parents: 618
diff changeset
     9
typedef void* LIB_HANDLE;
618
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    10
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    11
/** @defgroup userapi User API */
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    12
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    13
/** @defgroup can CAN management
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    14
 *  @ingroup userapi
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    15
 */
619
96f84395154f Enhancements for 'None' target : produce pre-linked object, remove some windows CRLF problems, fixed pedantic compiler warnings
edouard
parents: 618
diff changeset
    16
/**
96f84395154f Enhancements for 'None' target : produce pre-linked object, remove some windows CRLF problems, fixed pedantic compiler warnings
edouard
parents: 618
diff changeset
    17
 * @ingroup can
96f84395154f Enhancements for 'None' target : produce pre-linked object, remove some windows CRLF problems, fixed pedantic compiler warnings
edouard
parents: 618
diff changeset
    18
 * @brief Load CAN driver interface.
96f84395154f Enhancements for 'None' target : produce pre-linked object, remove some windows CRLF problems, fixed pedantic compiler warnings
edouard
parents: 618
diff changeset
    19
 * @param *driver_name The location of the library to load
96f84395154f Enhancements for 'None' target : produce pre-linked object, remove some windows CRLF problems, fixed pedantic compiler warnings
edouard
parents: 618
diff changeset
    20
 * @return
96f84395154f Enhancements for 'None' target : produce pre-linked object, remove some windows CRLF problems, fixed pedantic compiler warnings
edouard
parents: 618
diff changeset
    21
 *       - handle of the CAN driver interface is returned upon success.
96f84395154f Enhancements for 'None' target : produce pre-linked object, remove some windows CRLF problems, fixed pedantic compiler warnings
edouard
parents: 618
diff changeset
    22
 *       - NULL is returned if the CAN driver interface can't be loaded.
96f84395154f Enhancements for 'None' target : produce pre-linked object, remove some windows CRLF problems, fixed pedantic compiler warnings
edouard
parents: 618
diff changeset
    23
 */
96f84395154f Enhancements for 'None' target : produce pre-linked object, remove some windows CRLF problems, fixed pedantic compiler warnings
edouard
parents: 618
diff changeset
    24
#define LoadCanDriver(driver_name) 1
618
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    25
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    26
/**
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    27
 * @brief Send a CAN message
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    28
 * @param port CanFestival file descriptor
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    29
 * @param *m The CAN message to send
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    30
 * @return 0 if succes
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    31
 */
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    32
UNS8 canSend(CAN_PORT port, Message *m);
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    33
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    34
/**
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    35
 * @ingroup can
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    36
 * @brief Open a CANOpen device
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    37
 * @param *board Pointer to the board structure that contains busname and baudrate 
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    38
 * @param *d Pointer to the CAN object data structure
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    39
 * @return
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    40
 *       - CanFestival file descriptor is returned upon success.
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    41
 *       - NULL is returned if the CANOpen board can't be opened.
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    42
 */
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    43
CAN_PORT canOpen(s_BOARD *board, CO_Data * d);
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    44
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    45
/**
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    46
 * @ingroup can
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    47
 * @brief Close a CANOpen device
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    48
 * @param *d Pointer to the CAN object data structure
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    49
 * @return
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    50
 *       - 0 is returned upon success.
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    51
 *       - errorcode if error. (if implemented)  
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    52
 */
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    53
int canClose(CO_Data * d);
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    54
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    55
/**
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    56
 * @ingroup can
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    57
 * @brief Change the CANOpen device baudrate 
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    58
 * @param port CanFestival file descriptor 
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    59
 * @param *baud The new baudrate to assign
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    60
 * @return
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    61
 *       - 0 is returned upon success or if not supported by the CAN driver.
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    62
 *       - errorcode from the CAN driver is returned if an error occurs. (if implemented in the CAN driver)
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    63
 */
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    64
UNS8 canChangeBaudRate(CAN_PORT port, char* baud);
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    65
564a4a9862b1 added 'none' taget for building standalone library
edouard
parents:
diff changeset
    66
#endif