include/sdo.h
author etisserant
Sat, 07 Apr 2007 09:49:05 +0200
changeset 150 d2fc5d5f8a36
parent 149 fe50ada8020b
child 172 0248c2b148bb
permissions -rw-r--r--
Some win32 fixes following yesterday's API changes.
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
See COPYING file for copyrights details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    12
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    16
Lesser General Public License for more details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    17
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    21
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    22
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
#ifndef __sdo_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
#define __sdo_h__
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
typedef void (*SDOtimeoutError_t)(UNS8 line);
149
fe50ada8020b Changes in the API:
etisserant
parents: 74
diff changeset
    27
void _SDOtimeoutError (UNS8);
fe50ada8020b Changes in the API:
etisserant
parents: 74
diff changeset
    28
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
struct struct_s_transfer;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
#include "timer.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
32
8afa33692372 SDO callbacks.
etisserant
parents: 0
diff changeset
    33
typedef void (*SDOCallback_t)(CO_Data* d, UNS8 nodeId);
8afa33692372 SDO callbacks.
etisserant
parents: 0
diff changeset
    34
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
/* The Transfer structure
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
Used to store the different segments of 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
 - a SDO received before writing in the dictionary  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
 - the reading of the dictionary to put on a SDO to transmit 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
struct struct_s_transfer {
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    42
  UNS8           nodeId;     /*own ID if server, or node ID of the server if client */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    43
  
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    44
  UNS8           whoami;     /* Takes the values SDO_CLIENT or SDO_SERVER */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    45
  UNS8           state;      /* state of the transmission : Takes the values SDO_... */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
  UNS8           toggle;
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    47
  UNS32          abortCode;  /* Sent or received */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    48
  /* index and subindex of the dictionary where to store */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    49
  /* (for a received SDO) or to read (for a transmit SDO) */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
  UNS16          index; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
  UNS8           subIndex; 
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    52
  UNS32          count;      /* Number of data received or to be sent. */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    53
  UNS32          offset;     /* stack pointer of data[]
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    54
                              * Used only to tranfer part of a line to or from a SDO.
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    55
                              * offset is always pointing on the next free cell of data[].
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    56
                              * WARNING s_transfer.data is subject to ENDIANISATION 
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    57
                              * (with respect to CANOPEN_BIG_ENDIAN)
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    58
                              */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
  UNS8           data [SDO_MAX_LENGTH_TRANSFERT];
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    60
  UNS8           dataType;   /* Defined in objdictdef.h Value is visible_string 
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    61
                              * if it is a string, any other value if it is not a string, 
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    62
                              * like 0. In fact, it is used only if client.
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    63
                              */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    64
  TIMER_HANDLE   timer;      /* Time counter to implement a timeout in milliseconds.
74
c0b4b2ef7579 compiler compatibility : comments
frdupin
parents: 71
diff changeset
    65
                              * It is automatically incremented whenever 
c0b4b2ef7579 compiler compatibility : comments
frdupin
parents: 71
diff changeset
    66
                              * the line state is in SDO_DOWNLOAD_IN_PROGRESS or 
c0b4b2ef7579 compiler compatibility : comments
frdupin
parents: 71
diff changeset
    67
                              * SDO_UPLOAD_IN_PROGRESS, and reseted to 0 
c0b4b2ef7579 compiler compatibility : comments
frdupin
parents: 71
diff changeset
    68
                              * when the response SDO have been received.
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    69
                              */
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    70
  SDOCallback_t Callback;   /* The user callback func to be called at SDO transaction end */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
};
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
typedef struct struct_s_transfer s_transfer;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
#include "data.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    77
/* The 8 bytes data of the SDO */
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
struct BODY{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
    UNS8 data[8];
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
};
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    82
/* The SDO structure ...*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
struct struct_s_SDO {
71
95cd3376cc9f compilator compatitibility
frdupin
parents: 53
diff changeset
    84
  UNS8 nodeId;		/*in any case, Node ID of the server (case sender or receiver).*/
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
  struct BODY body;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    86
};
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    87
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    88
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
typedef struct struct_s_SDO s_SDO;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
53
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    91
/** Reset of a SDO exchange on timeout. 
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    92
 * Send a SDO abort
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    93
 */
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    94
void SDOTimeoutAlarm(CO_Data* d, UNS32 id);
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
    95
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
/** Reset all sdo buffers
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    98
void resetSDO (CO_Data* d);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    99
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   100
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
/** Copy the data received from the SDO line transfert to the object dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   102
 * Returns SDO error code if error. Else, returns 0; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   104
UNS32 SDOlineToObjdict (CO_Data* d, UNS8 line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   105
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   106
/** Copy the data from the object dictionary to the SDO line for a network transfert.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   107
 * Returns SDO error code if error. Else, returns 0; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
UNS32 objdictToSDOline (CO_Data* d, UNS8 line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   110
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   111
/** copy data from an existant line in the argument "* data"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
 * Returns 0xFF if error. Else, returns 0; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   113
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   114
UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   115
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
/** Add data to an existant line
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
 * Returns 0xFF if error. Else, returns 0; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
/** Called when an internal SDO abort occurs.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
 * Release the line * Only if server * 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   123
 * If client, the line must be released manually in the core application.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   124
 * The reason of that is to permit the program to read the transfers[][] structure before its reset,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   125
 * because many informations are stored on it : index, subindex, data received or trasmited, ...
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
 * In all cases, sends a SDO abort.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   127
 * Returns 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   128
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   129
UNS8 failedSDO (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS16 index, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
		UNS8 subIndex, UNS32 abortCode);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   131
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
/** Reset an unused line.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
 * 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
void resetSDOline (CO_Data* d, UNS8 line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   136
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   137
/** Initialize some fields of the structure.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   138
 * Returns 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   139
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   140
UNS8 initSDOline (CO_Data* d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   142
/** Search for an unused line in the transfers array
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
 * to store a new SDO.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   144
 * ie a line which value of the field "state" is "SDO_RESET"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   145
 * An unused line have the field "state" at the value SDO_RESET
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   146
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   147
 * whoami : create the line for a SDO_SERVER or SDO_CLIENT.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   148
 * return 0xFF if all the lines are on use. Else, return 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   149
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
UNS8 getSDOfreeLine (CO_Data* d, UNS8 whoami, UNS8 *line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   152
/** Search for the line, in the transfers array, which contains the
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
 * beginning of the reception of a fragmented SDO
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
 * whoami takes 2 values : look for a line opened as SDO_CLIENT or SDO_SERVER
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
 * nodeId correspond to the message node-id 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
 * return 0xFF if error.  Else, return 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
UNS8 getSDOlineOnUse (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
/** Close a transmission.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   162
 * nodeId : Node id of the server if both server or client
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   163
 * whoami : Line opened as SDO_CLIENT or SDO_SERVER
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165
UNS8 closeSDOtransfer (CO_Data* d, UNS8 nodeId, UNS8 whoami);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   167
/** Bytes in the line structure which must be transmited (or received)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
 * bus_id is hardware dependant.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
 * return 0.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   171
UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 * nbBytes);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   173
/** Store in the line structure the nb of bytes which must be transmited (or received)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   174
 * bus_id is hardware dependant.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   175
 * return 0 if success, 0xFF if error.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 nbBytes);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   178
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   179
/** Transmit a SDO frame on the bus bus_id
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   180
 * sdo is a structure which contains the sdo to transmit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   181
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   182
 * whoami takes 2 values : SDO_CLIENT or SDO_SERVER
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   183
 * return canSend(bus_id,&m) or 0xFF if error
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   184
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   185
UNS8 sendSDO (CO_Data* d, UNS8 whoami, s_SDO sdo);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   186
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   187
/** Transmit a SDO error to the client. The reasons may be :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   188
 * Read/Write to a undefined object
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   189
 * Read/Write to a undefined subindex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   190
 * Read/write a not valid length object
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   191
 * Write a read only object
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
 * whoami takes 2 values : SDO_CLIENT or SDO_SERVER
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   193
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   194
UNS8 sendSDOabort (CO_Data* d, UNS8 whoami, UNS16 index, UNS8 subIndex, UNS32 abortCode);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   195
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
/** Treat a SDO frame reception
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   197
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   198
 * call the function sendSDO
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   199
 * return 0xFF if error
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   200
 *        0x80 if transfert aborted by the server
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   201
 *        0x0  ok
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   202
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   203
UNS8 proceedSDO (CO_Data* d, Message *m);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   204
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   205
/** Used by the application to send a SDO request frame to write the data *data
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   206
 * at the index and subIndex indicated
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   207
 * in the dictionary of the slave whose node_id is nodeId
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   208
 * Count : nb of bytes to write in the dictionnary.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   209
 * datatype (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   210
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
 * return 0xFF if error, else return 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   212
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   214
		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data); 
53
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   215
/** Used to send a SDO request frame to write in a distant node dictionnary.
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   216
 * The function Callback	which must be defined in the user code is called at the
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   217
 * end of the exchange. (on succes or abort).
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   218
 */       		       
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   219
UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index, 
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   220
		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
/** Used by the application to send a SDO request frame to read
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   222
 * in the dictionary of a server node whose node_id is ID
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   223
 * at the index and subIndex indicated
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   224
 * bus_id is hardware dependant
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   225
 * datatype (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   226
 * return 0xFF if error, else return 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   227
 */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   228
UNS8 readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   229
		      UNS8 subIndex, UNS8 dataType);
53
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   230
		       
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   231
/** Used to send a SDO request frame to read in a distant node dictionnary.
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   232
 * The function Callback	which must be defined in the user code is called at the
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   233
 * end of the exchange. (on succes or abort).
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   234
 */   
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   235
UNS8 readNetworkDictCallback (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   236
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   237
/** Use this function after a readNetworkDict to get the result.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   238
  Returns : SDO_FINISHED             // data is available
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   239
            SDO_ABORTED_RCV          // Transfert failed. (abort SDO received)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   240
            SDO_ABORTED_INTERNAL     // Transfert failed. Internal abort.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   241
            SDO_UPLOAD_IN_PROGRESS   // Data not yet available
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   242
	    SDO_DOWNLOAD_IN_PROGRESS // Should not arrive ! 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   243
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   244
  dataType (defined in objdictdef.h) : type expected. put "visible_string" for strings, 0 for integers or reals.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   245
  abortCode : 0 = not available. Else : SDO abort code. (received if return SDO_ABORTED_RCV)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   246
  example :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   247
  UNS32 data;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   248
  UNS8 size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   249
  readNetworkDict(0, 0x05, 0x1016, 1, 0) // get the data index 1016 subindex 1 of node 5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   250
  while (getReadResultNetworkDict (0, 0x05, &data, &size) != SDO_UPLOAD_IN_PROGRESS);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   251
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   252
UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   253
			       UNS8 *size, UNS32 * abortCode);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   254
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   255
/**
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   256
  Use this function after a writeNetworkDict to get the result of the write
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   257
  It is mandatory to call this function because it is releasing the line used for the transfer.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   258
  Returns : SDO_FINISHED             // data is available
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   259
            SDO_ABORTED_RCV          // Transfert failed. (abort SDO received)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   260
            SDO_ABORTED_INTERNAL     // Transfert failed. Internal abort.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   261
            SDO_DOWNLOAD_IN_PROGRESS // Data not yet available
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   262
	    SDO_UPLOAD_IN_PROGRESS   // Should not arrive ! 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   263
  abortCode : 0 = not available. Else : SDO abort code. (received if return SDO_ABORTED_RCV)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   264
  example :
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   265
  UNS32 data = 0x50;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   266
  UNS8 size;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   267
  UNS32 abortCode;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   268
  writeNetworkDict(0, 0x05, 0x1016, 1, size, &data) // write the data index 1016 subindex 1 of node 5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   269
  while ( getWriteResultNetworkDict (0, 0x05, &abortCode) != SDO_DOWNLOAD_IN_PROGRESS);  
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   270
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   271
UNS8 getWriteResultNetworkDict (CO_Data* d, UNS8 nodeId, UNS32 * abortCode);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   272
53
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   273
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   274
 
73bc47a0db55 Add prototypes
frdupin
parents: 32
diff changeset
   275
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   276
#endif