include/unix/canfestival.h
author Edouard Tisserant
Sat, 04 Feb 2012 17:08:48 +0100
changeset 714 ab83333fee78
parent 561 f9be4262c68d
permissions -rwxr-xr-x
Merged JaFojtik Peak Win32 update
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
     1
#ifndef UNIX_H_
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
     2
#define UNIX_H_
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
     3
251
cab66ef3e68e Some fixes for C++
etisserant
parents: 167
diff changeset
     4
#ifdef __cplusplus
cab66ef3e68e Some fixes for C++
etisserant
parents: 167
diff changeset
     5
extern "C" {
cab66ef3e68e Some fixes for C++
etisserant
parents: 167
diff changeset
     6
#endif
cab66ef3e68e Some fixes for C++
etisserant
parents: 167
diff changeset
     7
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
     8
#include "timerscfg.h"
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
     9
#include "can_driver.h"
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
    10
#include "data.h"
167
b2f8b91d89b5 Removed compilation warnings with some GCC.
etisserant
parents: 149
diff changeset
    11
#include "timers_driver.h"
329
7717252e3ed9 Changes to compile for win32
greg
parents: 251
diff changeset
    12
391
7802a7d5584f Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents: 384
diff changeset
    13
#ifndef __KERNEL__
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
    14
#include <dlfcn.h>
391
7802a7d5584f Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents: 384
diff changeset
    15
#endif
7802a7d5584f Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents: 384
diff changeset
    16
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
    17
typedef void* LIB_HANDLE;
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
    18
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    19
/** @defgroup userapi User API */
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    20
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    21
/** @defgroup can CAN management
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    22
 *  @ingroup userapi
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    23
 */
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    24
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    25
/**
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    26
 * @ingroup can
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    27
 * @brief Unload CAN driver interface
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    28
 * @param handle The library handle
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    29
 * @return
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    30
 *       -  0 is returned upon success.
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    31
 *       - -1 is returned if the CAN driver interface can't be unloaded.
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    32
 */
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
    33
UNS8 UnLoadCanDriver(LIB_HANDLE handle);
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    34
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    35
/**
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    36
 * @ingroup can
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    37
 * @brief Load CAN driver interface.
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    38
 * @param *driver_name The location of the library to load
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    39
 * @return
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    40
 *       - handle of the CAN driver interface is returned upon success.
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    41
 *       - NULL is returned if the CAN driver interface can't be loaded.
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    42
 */
480
d0d76932ad74 Added missing const for dll names strings
etisserant
parents: 391
diff changeset
    43
LIB_HANDLE LoadCanDriver(const char* driver_name);
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    44
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    45
/**
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    46
 * @brief Send a CAN message
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    47
 * @param port CanFestival file descriptor
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    48
 * @param *m The CAN message to send
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    49
 * @return 0 if succes
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    50
 */
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
    51
UNS8 canSend(CAN_PORT port, Message *m);
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    52
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    53
/**
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    54
 * @ingroup can
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    55
 * @brief Open a CANOpen device
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    56
 * @param *board Pointer to the board structure that contains busname and baudrate 
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    57
 * @param *d Pointer to the CAN object data structure
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    58
 * @return
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    59
 *       - CanFestival file descriptor is returned upon success.
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    60
 *       - NULL is returned if the CANOpen board can't be opened.
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    61
 */
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
    62
CAN_PORT canOpen(s_BOARD *board, CO_Data * d);
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    63
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    64
/**
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    65
 * @ingroup can
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    66
 * @brief Close a CANOpen device
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    67
 * @param *d Pointer to the CAN object data structure
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    68
 * @return
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    69
 *       - 0 is returned upon success.
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    70
 *       - errorcode if error. (if implemented)  
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    71
 */
149
fe50ada8020b Changes in the API:
etisserant
parents: 145
diff changeset
    72
int canClose(CO_Data * d);
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    73
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    74
/**
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    75
 * @ingroup can
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    76
 * @brief Change the CANOpen device baudrate 
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    77
 * @param port CanFestival file descriptor 
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    78
 * @param *baud The new baudrate to assign
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    79
 * @return
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    80
 *       - 0 is returned upon success or if not supported by the CAN driver.
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    81
 *       - errorcode from the CAN driver is returned if an error occurs. (if implemented in the CAN driver)
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    82
 */
384
83793fc7ce48 added canChangeBaudRate to the driver interface
groke6
parents: 329
diff changeset
    83
UNS8 canChangeBaudRate(CAN_PORT port, char* baud);
561
f9be4262c68d Add doxygen comments in headers file
greg
parents: 529
diff changeset
    84
528
0a30e161d63c Re-write doxygen tags in headers files to generate User API documentation
greg
parents: 480
diff changeset
    85
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
    86
251
cab66ef3e68e Some fixes for C++
etisserant
parents: 167
diff changeset
    87
#ifdef __cplusplus
cab66ef3e68e Some fixes for C++
etisserant
parents: 167
diff changeset
    88
};
cab66ef3e68e Some fixes for C++
etisserant
parents: 167
diff changeset
    89
#endif
cab66ef3e68e Some fixes for C++
etisserant
parents: 167
diff changeset
    90
145
e747d2e26af0 Win32 Native support and dynamicaly loaded CAN drivers for Linux, Cygwin and Win32.
etisserant
parents:
diff changeset
    91
#endif /*UNIX_H_*/