fdlgdl.c 3.94 KB
Newer Older
Marcus Nordenberg's avatar
Marcus Nordenberg committed
1 2 3 4 5 6 7 8 9 10 11 12
/******************************************************************************
*                                                                             *
*                      SOFTING Industrial Automation GmbH                     *
*                          Richard-Reitzner-Allee 6                           *
*                                D-85540 Haar                                 *
*                        Phone: (++49)-(0)89-45656-0                          *
*                        Fax:   (++49)-(0)89-45656-399                        *
*                                                                             *
*            Copyright (C) SOFTING Industrial Automation GmbH 1995-2012       *
*                              All Rights Reserved                            *
*                                                                             *
*******************************************************************************
13 14 15 16 17 18 19 20 21 22

FILE_NAME               FDLGDL.C

PROJECT_NAME            PROFIBUS

MODULE                  FDLGDL

COMPONENT_LIBRARY       PAPI Lib
                        PAPI DLL

Marcus Nordenberg's avatar
Marcus Nordenberg committed
23
AUTHOR                  SOFTING
24 25 26

VERSION                 5.23.0.00.release

Marcus Nordenberg's avatar
Marcus Nordenberg committed
27
DATE                    October-2000
28 29 30 31 32

STATUS                  finished

FUNCTIONAL_MODULE_DESCRIPTION

33 34
This modul contains the FDL(IF)-Service-Specific-Functions which return the
length
35 36 37 38 39 40 41 42 43
length of the Request- or Response-Datas.


RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"

INCLUDES

44
#if defined(WIN16) || defined(WIN32)
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#include <windows.h>
#endif

#include "pb_type.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fdl.h"

GLOBAL_DEFINES

LOCAL_DEFINES

EXPORT_TYPEDEFS

LOCAL_TYPEDEFS

FUNCTION_DECLARATIONS

EXPORT_DATA

IMPORT_DATA

LOCAL_DATA

69 70
#if defined(WIN32) || defined(_WIN32) || defined(WIN16) || defined(_WIN16)
#pragma check_stack(off)
71 72
#endif

Marcus Nordenberg's avatar
Marcus Nordenberg committed
73 74 75 76
FUNCTION PUBLIC INT16 fdlgdl_get_data_len(
    IN INT16 result,         /* Service-Result */
    IN USIGN8 service,       /* Service */
    IN USIGN8 primitive,     /* Service-Primitive */
77
    IN USIGN8 FAR* data_ptr, /* pointer to data */
Marcus Nordenberg's avatar
Marcus Nordenberg committed
78 79
    OUT INT16* data_len_ptr  /* length of data */
    )
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95

/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION

this function is used to return the data length of FDL-SERVICES

possible return values:
- Data-length

-----------------------------------------------------------------------------*/
{
  LOCAL_VARIABLES

  FUNCTION_BODY

  *data_len_ptr = 0;
96 97
  result = E_OK;

Marcus Nordenberg's avatar
Marcus Nordenberg committed
98 99 100 101
  if (primitive == REQ)
  {
    switch (service)
    {
102 103
    case FDLIF_SDA:
    case FDLIF_SDN:
Marcus Nordenberg's avatar
Marcus Nordenberg committed
104 105
    case FDLIF_SRD:
    {
106 107
      T_FDLIF_SDN_SDA_SRD_REQ FAR* req = (T_FDLIF_SDN_SDA_SRD_REQ FAR*)data_ptr;
      *data_len_ptr = sizeof(T_FDLIF_SDN_SDA_SRD_REQ) + req->length;
Marcus Nordenberg's avatar
Marcus Nordenberg committed
108 109
    }
    break;
110 111

    case FDLIF_REPLY_UPDATE:
Marcus Nordenberg's avatar
Marcus Nordenberg committed
112 113
    case FDLIF_REPLY_UPDATE_MULTIPLE:
    {
114 115
      T_FDLIF_RUP_REQ FAR* req = (T_FDLIF_RUP_REQ FAR*)data_ptr;
      *data_len_ptr = sizeof(T_FDLIF_RUP_REQ) + req->length;
Marcus Nordenberg's avatar
Marcus Nordenberg committed
116 117
    }
    break;
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150

    case FDLIF_SET_BUSPARAMETER:
      *data_len_ptr = sizeof(T_FDLIF_SET_BUSPARAMETER_REQ);
      break;

    case FDLIF_READ_BUSPARAMETER:
      *data_len_ptr = 0;
      break;

    case FDLIF_SAP_ACTIVATE:
      *data_len_ptr = sizeof(T_FDLIF_SAP_ACTIVATE_REQ);
      break;

    case FDLIF_RSAP_ACTIVATE:
      *data_len_ptr = sizeof(T_FDLIF_RSAP_ACTIVATE_REQ);
      break;

    case FDLIF_SAP_CHANGE_ACCESS:
      *data_len_ptr = sizeof(T_FDLIF_SAP_CHANGE_REQ);
      break;

    case FDLIF_SAP_DEACTIVATE:
      *data_len_ptr = sizeof(T_FDLIF_SAP_DEACTIVATE_REQ);
      break;

    case FDLIF_EXIT:
      *data_len_ptr = 0;
      break;

    default:
      *data_len_ptr = 0;
      result = E_IF_INVALID_SERVICE;
      break;
151
    }
Marcus Nordenberg's avatar
Marcus Nordenberg committed
152 153 154
  }
  else
  {
155 156
    result = E_IF_INVALID_PRIMITIVE;
  }
157 158

  return (result);
159 160
}

161
#if defined(WIN32) || defined(_WIN32) || defined(WIN16) || defined(_WIN16)
162
#pragma check_stack
163
#endif