Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
0135e84d
Commit
0135e84d
authored
Jan 12, 2007
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Profibus I/O-routines adapted to new Softing API and driver
parent
a202d657
Changes
38
Show whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
12015 additions
and
1116 deletions
+12015
-1116
profibus/lib/rt/src/os_linux/Papi.c
profibus/lib/rt/src/os_linux/Papi.c
+2485
-0
profibus/lib/rt/src/os_linux/buildnr.papi.h
profibus/lib/rt/src/os_linux/buildnr.papi.h
+8
-0
profibus/lib/rt/src/os_linux/busparam.c
profibus/lib/rt/src/os_linux/busparam.c
+785
-0
profibus/lib/rt/src/os_linux/ccrl.c
profibus/lib/rt/src/os_linux/ccrl.c
+727
-0
profibus/lib/rt/src/os_linux/dpgdl.c
profibus/lib/rt/src/os_linux/dpgdl.c
+309
-0
profibus/lib/rt/src/os_linux/dpsgdl.c
profibus/lib/rt/src/os_linux/dpsgdl.c
+187
-0
profibus/lib/rt/src/os_linux/fdlgdl.c
profibus/lib/rt/src/os_linux/fdlgdl.c
+165
-0
profibus/lib/rt/src/os_linux/fm7gdl.c
profibus/lib/rt/src/os_linux/fm7gdl.c
+535
-0
profibus/lib/rt/src/os_linux/fmbgdl.c
profibus/lib/rt/src/os_linux/fmbgdl.c
+157
-0
profibus/lib/rt/src/os_linux/fmsgdl.c
profibus/lib/rt/src/os_linux/fmsgdl.c
+935
-0
profibus/lib/rt/src/os_linux/hw_x86/special.mk
profibus/lib/rt/src/os_linux/hw_x86/special.mk
+26
-0
profibus/lib/rt/src/os_linux/keywords.h
profibus/lib/rt/src/os_linux/keywords.h
+51
-0
profibus/lib/rt/src/os_linux/papiaux.c
profibus/lib/rt/src/os_linux/papiaux.c
+233
-0
profibus/lib/rt/src/os_linux/pb_conf.h
profibus/lib/rt/src/os_linux/pb_conf.h
+35
-137
profibus/lib/rt/src/os_linux/pb_dp.h
profibus/lib/rt/src/os_linux/pb_dp.h
+31
-39
profibus/lib/rt/src/os_linux/pb_dps.h
profibus/lib/rt/src/os_linux/pb_dps.h
+420
-0
profibus/lib/rt/src/os_linux/pb_err.h
profibus/lib/rt/src/os_linux/pb_err.h
+88
-36
profibus/lib/rt/src/os_linux/pb_fdl.h
profibus/lib/rt/src/os_linux/pb_fdl.h
+287
-0
profibus/lib/rt/src/os_linux/pb_fm7.h
profibus/lib/rt/src/os_linux/pb_fm7.h
+883
-0
profibus/lib/rt/src/os_linux/pb_fmb.h
profibus/lib/rt/src/os_linux/pb_fmb.h
+24
-37
profibus/lib/rt/src/os_linux/pb_fms.h
profibus/lib/rt/src/os_linux/pb_fms.h
+1374
-0
profibus/lib/rt/src/os_linux/pb_if.h
profibus/lib/rt/src/os_linux/pb_if.h
+1046
-62
profibus/lib/rt/src/os_linux/pb_ioctl.h
profibus/lib/rt/src/os_linux/pb_ioctl.h
+83
-0
profibus/lib/rt/src/os_linux/pb_ntdrv.h
profibus/lib/rt/src/os_linux/pb_ntdrv.h
+132
-0
profibus/lib/rt/src/os_linux/pb_tools.h
profibus/lib/rt/src/os_linux/pb_tools.h
+239
-0
profibus/lib/rt/src/os_linux/pb_type.h
profibus/lib/rt/src/os_linux/pb_type.h
+38
-44
profibus/lib/rt/src/os_linux/rt_io_m_pb_ao.c
profibus/lib/rt/src/os_linux/rt_io_m_pb_ao.c
+6
-1
profibus/lib/rt/src/os_linux/rt_io_m_pb_di.c
profibus/lib/rt/src/os_linux/rt_io_m_pb_di.c
+6
-1
profibus/lib/rt/src/os_linux/rt_io_m_pb_do.c
profibus/lib/rt/src/os_linux/rt_io_m_pb_do.c
+6
-1
profibus/lib/rt/src/os_linux/rt_io_m_pb_dp_slave.c
profibus/lib/rt/src/os_linux/rt_io_m_pb_dp_slave.c
+19
-30
profibus/lib/rt/src/os_linux/rt_io_m_pb_ii.c
profibus/lib/rt/src/os_linux/rt_io_m_pb_ii.c
+8
-2
profibus/lib/rt/src/os_linux/rt_io_m_pb_io.c
profibus/lib/rt/src/os_linux/rt_io_m_pb_io.c
+6
-1
profibus/lib/rt/src/os_linux/rt_io_m_pb_module.c
profibus/lib/rt/src/os_linux/rt_io_m_pb_module.c
+6
-1
profibus/lib/rt/src/os_linux/rt_io_m_pb_profiboard.c
profibus/lib/rt/src/os_linux/rt_io_m_pb_profiboard.c
+619
-224
profibus/lib/rt/src/os_linux/rt_io_pb_locals.h
profibus/lib/rt/src/os_linux/rt_io_pb_locals.h
+8
-2
profibus/lib/rt/src/os_linux/rt_io_profiboard.c
profibus/lib/rt/src/os_linux/rt_io_profiboard.c
+5
-429
profibus/lib/rt/src/os_linux/rt_io_profiboard.h
profibus/lib/rt/src/os_linux/rt_io_profiboard.h
+1
-69
profibus/lib/rt/src/os_linux/version.h
profibus/lib/rt/src/os_linux/version.h
+42
-0
No files found.
profibus/lib/rt/src/os_linux/Papi.c
0 → 100644
View file @
0135e84d
/******************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
* D-85540 Haar *
* Phone: (++49)-(0)89-45656-0 *
* Fax: (++49)-(0)89-45656-399 *
* *
* Copyright (C) SOFTING AG 1995-2003 *
* All Rights Reserved *
* *
*******************************************************************************
FILE_NAME PAPI.C
PROJECT_NAME PROFIBUS
MODULE PAPI
COMPONENT_LIBRARY PAPI Lib
PAPI DLL
AUTHOR SOFTING AG
VERSION 5.26.1.00.release
DATE 27-June-2003
STATUS finished
FUNCTIONAL_MODULE_DESCRIPTION
PROFIBUS FMS/DPV1 Master and DP-Slave Application Program Interface (PAPI) for WinXP/Win2K/WinNT
------------------------------------------------------------------------------------------------
This modul contains the PROFIBUS FMS/DPV1 Master and DP-Slave Application Program Interface
functions.
RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"
INCLUDES
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#include <windows.h>
#include <winioctl.h>
#endif
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "pb_type.h"
#if defined (WIN32) || defined (_WIN32)
#include "pb_ntdrv.h"
#endif
#ifdef _LINUX
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "pb_ioctl.h"
#endif
#include "pb_err.h"
#include "pb_if.h"
#include "pb_fms.h"
#include "pb_fm7.h"
#include "pb_fmb.h"
#include "version.h"
GLOBAL_DEFINES
LOCAL_DEFINES
EXPORT_TYPEDEFS
LOCAL_TYPEDEFS
FUNCTION_DECLARATIONS
#if defined (WIN32) || defined (_WIN32)
extern
BOOL
ReadBoardRegistryEntries
(
USIGN8
,
USIGN32
*
);
#endif
extern
USIGN16
swap_16_intel_motorola
(
USIGN16
);
extern
USIGN32
swap_32_intel_motorola
(
USIGN32
);
extern
INT16
dpgdl_get_data_len
(
INT16
,
USIGN8
,
USIGN8
,
USIGN8
*
,
INT16
*
);
extern
INT16
dpsgdl_get_data_len
(
INT16
,
USIGN8
,
USIGN8
,
USIGN8
*
,
INT16
*
);
extern
INT16
fdlgdl_get_data_len
(
INT16
,
USIGN8
,
USIGN8
,
USIGN8
*
,
INT16
*
);
extern
INT16
fm7gdl_get_data_len
(
INT16
,
USIGN8
,
USIGN8
,
USIGN8
*
,
INT16
*
);
extern
INT16
fmsgdl_get_data_len
(
INT16
,
USIGN8
,
USIGN8
,
USIGN8
*
,
INT16
*
);
extern
INT16
fmbgdl_get_data_len
(
INT16
,
USIGN8
,
USIGN8
,
USIGN8
*
,
INT16
*
);
EXPORT_DATA
IMPORT_DATA
LOCAL_DATA
// --- copyright
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
static
const
char
copyright
[]
=
"PROFIBUS WinXP/Win2K/WinNT API (c) Copyright 1995-2005. SOFTING AG. All Rights Reserved."
;
// --- Operation Mode
static
USIGN32
OperationMode
;
#endif
#ifdef _LINUX
static
const
char
copyright
[]
=
"PROFIBUS Linux API (c) Copyright 1995-2005. SOFTING AG. All Rights Reserved."
;
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack (off)
#endif
// ***************************************************************************
// ***************************************************************************
// *
// * LOCAL FUNCTIONs
// * ---------------
// *
// ***************************************************************************
// ***************************************************************************
FUNCTION
LOCAL
INT16
papi_get_last_error
(
VOID
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the last error code generated by the PROFIBUS
driver.
Possible return values:
- last error code
- E_IF_OS_ERROR
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
DWORD
LastErrorCode
;
#endif
FUNCTION_BODY
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
LastErrorCode
=
GetLastError
();
if
(
CUSTOMER_FLAG_SET
(
LastErrorCode
))
return
((
INT16
)
LastErrorCode
);
else
return
(
E_IF_OS_ERROR
);
#endif
#ifdef _LINUX
return
((
INT16
)
errno
);
#endif
}
// ***************************************************************************
// ***************************************************************************
// *
// * EXTENDED API
// * ------------
// *
// ***************************************************************************
// ***************************************************************************
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
HANDLE
CALL_CONV
profi_open_basic_management
(
IN
USIGN8
Board
,
IN
USIGN8
Channel
,
IN
INT32
DesiredAccess
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to initialize the enhanced mode of the PROFIBUS API.
It opens the the BASIC MANAGEMENT DEVICE and updates the PROFIBUS firmware onto
PROFIBUS controller if necessary.
IN: Board -> number of the PROFIBUS board (0..9)
IN: Channel -> channel number
IN: DesiredAccess -> GENERIC_READ specifies the read access to the device
GENERIC_WRITE specifies the write access to the device
Possible return values:
- open handle of BASIC MANAGEMENT DEVICE if function succeeds successfully
- INVALID_HANDLE_VALUE if function fails
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
char
DeviceName
[
64
];
FUNCTION_BODY
Channel
=
0
;
// for future use
// --- open basic management device
sprintf
(
DeviceName
,
"
\\\\
.
\\
PROFIBUS
\\
Board%u
\\
Pb%u
\\
Management"
,
Board
,
Channel
);
return
(
CreateFile
(
DeviceName
,
DesiredAccess
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
));
}
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
HANDLE
CALL_CONV
profi_open
(
IN
HANDLE
hBasicMgmtDevice
,
IN
INT32
DeviceType
,
IN
USIGN32
Index
,
IN
INT32
DesiredAccess
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to open a PROFIBUS device specified by 'device_type'.
IN: hBasicMgmtDevice -> basic management device handle
IN: DeviceType -> type of the device to open
DEVICE_DP_MANAGEMENT -> DP management device
DEVICE_DP_SERVICE -> DP service device
DEVICE_DP_SLAVE_DATA -> DP slave data device
DEVICE_DP_MSAC -> DP master slave acyclic device
DEVICE_FDL_MANAGEMENT -> FDL management device
DEVICE_FDL_SAP -> FDL SAP device
DEVICE_FMS_MANAGEMENT -> FMS management device
DEVICE_FMS_CR -> FMS CR device
IN: Index -> index of the device to open
1..128 DP service-, DP slave data- and DP/V1 service devices
0..63,DEFAUT_SAP FDL SAP device
1..64 FMS CR device
IN: DesiredAccess -> GENERIC_READ specifies the read access to the device
GENERIC_WRITE specifies the write access to the device
Possible return values:
- open handle of the specified device if function succeeds successfuly
- INVALID_HANDLE_VALUE if function fails
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
DWORD
IOControlCode
;
char
DeviceName
[
64
];
DWORD
BytesReturned
;
FUNCTION_BODY
// --- select IOCTL code specified by device type
switch
(
DeviceType
)
{
case
DEVICE_DP_MANAGEMENT
:
IOControlCode
=
(
DWORD
)
IOCTL_PROFI_CREATE_DP_MANAGEMENT
;
break
;
case
DEVICE_DP_SERVICE
:
IOControlCode
=
(
DWORD
)
IOCTL_PROFI_CREATE_DP_SERVICE
;
break
;
case
DEVICE_DP_SLAVE_DATA
:
IOControlCode
=
(
DWORD
)
IOCTL_PROFI_CREATE_DP_SLAVE_DATA
;
break
;
case
DEVICE_DP_MSAC
:
IOControlCode
=
(
DWORD
)
IOCTL_PROFI_CREATE_DP_MSAC
;
break
;
case
DEVICE_FDL_MANAGEMENT
:
IOControlCode
=
(
DWORD
)
IOCTL_PROFI_CREATE_FDL_MANAGEMENT
;
break
;
case
DEVICE_FDL_SAP
:
IOControlCode
=
(
DWORD
)
IOCTL_PROFI_CREATE_FDL_SAP
;
break
;
case
DEVICE_FMS_MANAGEMENT
:
IOControlCode
=
(
DWORD
)
IOCTL_PROFI_CREATE_FMS_MANAGEMENT
;
break
;
case
DEVICE_FMS_CR
:
IOControlCode
=
(
DWORD
)
IOCTL_PROFI_CREATE_FMS_CR
;
break
;
default:
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
(
INVALID_HANDLE_VALUE
);
}
// --- get device name
if
(
!
DeviceIoControl
((
HANDLE
)
hBasicMgmtDevice
,
(
DWORD
)
IOControlCode
,
(
LPVOID
)
&
Index
,
(
DWORD
)
sizeof
(
ULONG
),
(
LPVOID
)
DeviceName
,
(
DWORD
)
128
,
(
LPDWORD
)
&
BytesReturned
,
NULL
))
{
return
(
INVALID_HANDLE_VALUE
);
}
// --- open device
return
(
CreateFile
(
DeviceName
,
DesiredAccess
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
OPEN_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
));
}
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
BOOL
CALL_CONV
profi_close
(
IN
HANDLE
hDevice
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to close a device opened with 'profi_open_basic_management'
function or 'profi_open' function.
IN: hDevice -> handle of the device to close
Possible return values:
- TRUE -> device is closed
- FALSE -> device can not be closed
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
if
(
CloseHandle
(
hDevice
))
return
TRUE
;
else
return
FALSE
;
}
#endif
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_read_service
(
IN
HANDLE
hDevice
,
OUT
T_PROFI_SERVICE_DESCR
*
pSdb
,
OUT
VOID
*
pData
,
INOUT
USIGN16
*
pDataLength
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to receive a Service-Indication or a Service-Confirmation
from a PROFIBUS service device.
IN: hDevice -> device handle
OUT: pSdb -> pointer to SERVICE-DESCRIPTION-BLOCK
OUT: pData -> pointer to data buffer
INOUT: pDatalen -> IN: length of data buffer
OUT: length of received data
Possible return values:
- CON_IND_RECEIVED -> a confirmation or indication has been received
- NO_CON_IND_RECEIVED -> no confirmation or indication has been received
- E_IF_NO_CNTRL_RES -> controller does not respond
- E_IF_FATAL_ERROR -> unrecoverable error in PROTOCOL SW
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_OS_ERROR -> NT system error
- E_IF_RESOURCE_UNAVAILABLE -> no resource available
-----------------------------------------------------------------------------*/
{
// LOCAL_VARIABLES
USIGN8
*
pSdbData
;
ssize_t
BytesRead
=
0
;
// FUNCTION_BODY
// printf("papi: profi_read_service\n");
// --- allocate memory for SDB and DATABLOCK
if
(
!
(
pSdbData
=
malloc
((
*
pDataLength
+
sizeof
(
T_PROFI_SERVICE_DESCR
)))))
{
return
(
E_IF_OS_ERROR
);
}
while
((
BytesRead
=
read
(
hDevice
,
pSdbData
,
(
int
)
(
*
pDataLength
+
sizeof
(
T_PROFI_SERVICE_DESCR
)))
)
<
0
)
{
if
(
errno
!=
EAGAIN
)
{
free
(
pSdbData
);
printf
(
"%s
\n
"
,
strerror
(
errno
));
// printf("bytesRead=%u\n",BytesRead);
return
(
papi_get_last_error
());
}
else
{
*
pDataLength
=
0
;
free
(
pSdbData
);
// printf("bytesRead=%u\n",BytesRead);
// printf ("%s errno=%u hdevice=%u 2\n", strerror (errno), errno, hDevice);
return
(
NO_CON_IND_RECEIVED
);
}
}
//printf("bytesRead=%u\n",BytesRead);
// --- check if IND or CON is available
if
(
BytesRead
==
0
)
{
*
pDataLength
=
0
;
// printf ("%s 3\n", strerror (errno));
free
(
pSdbData
);
return
(
NO_CON_IND_RECEIVED
);
}
else
{
// printf("bytesRead=%u\n",BytesRead);
}
// --- copy SDB
memcpy
(
pSdb
,
pSdbData
,
sizeof
(
T_PROFI_SERVICE_DESCR
));
pSdb
->
comm_ref
&=
0xFF
;
// --- calculate size of read data
*
pDataLength
=
(
USIGN16
)
BytesRead
-
sizeof
(
T_PROFI_SERVICE_DESCR
);
// --- copy DATABLOCK
if
(
*
pDataLength
)
{
memcpy
(
pData
,
&
pSdbData
[
sizeof
(
T_PROFI_SERVICE_DESCR
)],
*
pDataLength
);
}
// --- free allocated memory
free
(
pSdbData
);
return
(
CON_IND_RECEIVED
);
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_write_service
(
IN
HANDLE
hDevice
,
IN
T_PROFI_SERVICE_DESCR
*
pSdb
,
IN
VOID
*
pData
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to send a Service-Request or a Service-Response
to a PROFIBUS service device.
IN: hDevice -> device handle
IN: pSdp -> pointer to SERVICE-DESCRIPTION-BLOCK
IN: pData -> pointer to service specific data
Possible return values:
- E_OK -> no error occured
- E_IF_INVALID_LAYER -> invalid layer
- E_IF_INVALID_SERVICE -> invalid service identifier
- E_IF_INVALID_PRIMITIVE -> invalid service primitive
- E_IF_RESOURCE_UNAVAILABLE -> no resource available
- E_IF_NO_PARALLEL_SERVICES -> no parallel services allowed
- E_IF_SERVICE_CONSTR_CONFLICT -> service temporarily not executable
- E_IF_SERVICE_NOT_SUPPORTED -> service not supported in subset
- E_IF_SERVICE_NOT_EXECUTABLE -> service not executable
- E_IF_NO_CNTRL_RES -> controller does not respond (CMI_TIMEOUT)
- E_IF_INVALID_DATA_SIZE -> not enough CMI memory available for REQ or RES
- E_IF_INVALID_PARAMETER -> invalid wrong parameter in REQ or RES
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_CMI_CALL -> invalid CMI call
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
INT16
RetVal
;
// return value
INT16
DataLength
;
// size of DATABLOCK
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
DWORD
BytesWritten
;
#endif
USIGN8
*
pSdbData
;
// pointer to SdbData buffer
FUNCTION_BODY
RetVal
=
E_OK
;
DataLength
=
0
;
pSdb
->
comm_ref
&=
0x00FF
;
// clear all BITs in upper byte
// --- check Service-Primitive
if
((
pSdb
->
primitive
==
IND
)
||
(
pSdb
->
primitive
==
CON
))
{
return
(
E_IF_INVALID_PRIMITIVE
);
}
// --- set the result parameter to POS if a request is send
if
(
pSdb
->
primitive
==
REQ
)
pSdb
->
result
=
POS
;
// --- get service specific data length
switch
(
pSdb
->
layer
)
{
case
FMS
:
RetVal
=
fmsgdl_get_data_len
(
pSdb
->
result
,
pSdb
->
service
,
pSdb
->
primitive
,
pData
,
&
DataLength
);
break
;
case
FM7
:
RetVal
=
fm7gdl_get_data_len
(
pSdb
->
result
,
pSdb
->
service
,
pSdb
->
primitive
,
pData
,
&
DataLength
);
break
;
case
FDLIF
:
RetVal
=
fdlgdl_get_data_len
(
pSdb
->
result
,
pSdb
->
service
,
pSdb
->
primitive
,
pData
,
&
DataLength
);
break
;
case
DP
:
RetVal
=
dpgdl_get_data_len
(
pSdb
->
result
,
pSdb
->
service
,
pSdb
->
primitive
,
pData
,
&
DataLength
);
break
;
case
FMB
:
RetVal
=
fmbgdl_get_data_len
(
pSdb
->
result
,
pSdb
->
service
,
pSdb
->
primitive
,
pData
,
&
DataLength
);
break
;
case
DPS
:
RetVal
=
dpsgdl_get_data_len
(
pSdb
->
result
,
pSdb
->
service
,
pSdb
->
primitive
,
pData
,
&
DataLength
);
break
;
default:
RetVal
=
E_IF_INVALID_LAYER
;
break
;
}
if
(
RetVal
==
E_OK
)
{
// allocate memory for SDB and DATABLOCK
if
(
!
(
pSdbData
=
(
USIGN8
*
)
malloc
((
DataLength
+
sizeof
(
T_PROFI_SERVICE_DESCR
)))))
{
return
(
E_IF_OS_ERROR
);
}
// copy SDB and DATABLOCK to allocated memory
memcpy
(
pSdbData
,
pSdb
,
sizeof
(
T_PROFI_SERVICE_DESCR
));
memcpy
(
&
pSdbData
[
sizeof
(
T_PROFI_SERVICE_DESCR
)],
pData
,
DataLength
);
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
// write SDB and DATABLOCK
if
(
!
WriteFile
((
HANDLE
)
hDevice
,
(
LPVOID
)
pSdbData
,
(
DWORD
)
(
DataLength
+
sizeof
(
T_PROFI_SERVICE_DESCR
)),
(
LPDWORD
)
&
BytesWritten
,
NULL
))
#endif
#ifdef _LINUX
if
((
write
(
hDevice
,
pSdbData
,
DataLength
+
sizeof
(
T_PROFI_SERVICE_DESCR
)))
<
0
)
#endif
{
free
(
pSdbData
);
return
(
papi_get_last_error
());
}
// free allocated memory
free
(
pSdbData
);
}
return
(
RetVal
);
}
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_read_multi
(
OUT
T_PROFI_SERVICE_DESCR
*
pSdb
,
OUT
VOID
*
pData
,
INOUT
USIGN16
*
pDataLength
,
IN
USIGN16
NrOfHandles
,
IN
HANDLE
*
phDevices
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to receive a Service-Indication or a Service-Confirmation
from one ore more PROFIBUS service devices.
OUT: pSdb -> pointer to SERVICE-DESCRIPTION-BLOCK
OUT: pData -> pointer to data buffer
INOUT: pDataLength -> IN: length of data buffer
OUT: length of received data
IN: NrOfHandles -> number of device handles
IN: phDevices -> pointer to list of device handles
Possible return values:
- CON_IND_RECEIVED -> a confirmation or indication has been received
- NO_CON_IND_RECEIVED -> no confirmation or indication has been received
- E_IF_NO_CNTRL_RES -> controller does not respond
- E_IF_FATAL_ERROR -> unrecoverable error in PROTOCOL SW
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_OS_ERROR -> NT system error
- E_IF_RESOURCE_UNAVAILABLE -> no resource available
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
USIGN8
*
pSdbData
;
DWORD
BytesRead
=
0
;
FUNCTION_BODY
// --- allocate memory for SDB and DATABLOCK
if
(
!
(
pSdbData
=
malloc
((
*
pDataLength
+
sizeof
(
T_PROFI_SERVICE_DESCR
)))))
{
return
(
E_IF_OS_ERROR
);
}
// --- read service data from device
if
(
!
DeviceIoControl
((
HANDLE
)
*
phDevices
,
(
DWORD
)
IOCTL_PROFI_READ_MULTI
,
(
LPVOID
)
phDevices
,
(
DWORD
)
NrOfHandles
*
sizeof
(
HANDLE
),
(
LPVOID
)
pSdbData
,
(
DWORD
)
(
*
pDataLength
+
sizeof
(
T_PROFI_SERVICE_DESCR
)),
(
LPDWORD
)
&
BytesRead
,
NULL
))
{
free
(
pSdbData
);
return
(
papi_get_last_error
());
}
// --- check if IND or CON is available
if
(
BytesRead
==
0
)
{
*
pDataLength
=
0
;
free
(
pSdbData
);
return
(
NO_CON_IND_RECEIVED
);
}
// --- copy SDB
memcpy
((
VOID
*
)
pSdb
,(
VOID
*
)
pSdbData
,
sizeof
(
T_PROFI_SERVICE_DESCR
));
pSdb
->
comm_ref
&=
0xFF
;
// --- calculate size of read data
*
pDataLength
=
(
USIGN16
)
BytesRead
-
sizeof
(
T_PROFI_SERVICE_DESCR
);
// --- copy DATABLOCK
if
(
*
pDataLength
)
{
memcpy
(
pData
,
&
pSdbData
[
sizeof
(
T_PROFI_SERVICE_DESCR
)],
*
pDataLength
);
}
// --- free allocated memory
free
(
pSdbData
);
return
(
CON_IND_RECEIVED
);
}
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_read_data
(
IN
HANDLE
hDevice
,
OUT
VOID
*
pData
,
INOUT
USIGN16
*
pDataLength
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to read DP-Slave-I/O-Data from a DP SLAVE DATA DEVICE.
IN: hDevice -> device handle
OUT: pData -> pointer to data buffer
INOUT: pDataLength -> IN: length of data buffer
OUT: length of received data
Possible return values:
- E_OK -> no error occured
- E_IF_INVALID_DP_STATE -> DP is not in operational state
- E_IF_SLAVE_ERROR -> no valid communication with DP-Slave
- E_IF_SLAVE_DIAG_DATA -> new DP diagnostics data available
- E_IF_INVALID_CMI_CALL -> invalid offset inside data image
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
DWORD
BytesRead
=
0
;
FUNCTION_BODY
if
(
!
ReadFile
(
hDevice
,
pData
,
*
pDataLength
,
&
BytesRead
,
NULL
))
{
*
pDataLength
=
0
;
return
(
papi_get_last_error
());
}
else
{
*
pDataLength
=
(
USIGN16
)
BytesRead
;
return
(
E_OK
);
}
}
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_write_data
(
IN
HANDLE
hDevice
,
IN
VOID
*
pData
,
IN
USIGN16
DataLength
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to write DP-Slave-I/O-Data to a DP SLAVE DATA DEVICE.
IN: hDevice -> device handle
IN: pData -> pointer to data buffer
IN: DataLength -> length of data to write
Possible return values:
- E_OK -> no error occured
- E_IF_INVALID_DP_STATE -> DP is not in operational state
- E_IF_SLAVE_ERROR -> no valid communication with DP-Slave
- E_IF_SLAVE_DIAG_DATA -> new DP diagnostics data available
- E_IF_INVALID_CMI_CALL -> invalid offset inside data image
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
DWORD
BytesWritten
=
0
;
FUNCTION_BODY
// write data
if
(
!
WriteFile
(
hDevice
,
pData
,
DataLength
,
&
BytesWritten
,
NULL
))
{
return
(
papi_get_last_error
());
}
else
{
return
(
E_OK
);
}
}
#endif
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_read_dps_data
(
IN
HANDLE
hDevice
,
OUT
USIGN8
*
pData
,
INOUT
USIGN8
*
pDataLength
,
OUT
USIGN8
*
pState
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to read data from CMI DPS_SLAVE_INPUT_IMAGE or
DPS_SLAVE_OUTPUT_IMAGE.
IN: hDevice -> device handle
OUT: pData -> destination buffer for input data
INOUT: pDataLength -> IN: length of destination buffer
OUT: number of bytes read
OUT: pState -> status of input or output data if read or write was successfully
Possible return values:
- E_OK -> no error occured
- E_IF_INVALID_CMI_CALL -> invalid offset inside data image
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
DWORD
BytesRead
=
0
;
#endif
#ifdef _LINUX
ssize_t
BytesRead
=
0
;
#endif
char
DataBuffer
[
256
];
FUNCTION_BODY
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
// --- read DPS input/output data and status
if
(
ReadFile
(
hDevice
,(
LPVOID
)
DataBuffer
,(
DWORD
)
(
*
pDataLength
+
1
),(
LPDWORD
)
&
BytesRead
,
NULL
))
#endif
#ifdef _LINUX
if
((
BytesRead
=
read
(
hDevice
,
DataBuffer
,
(
int
)
(
*
pDataLength
)))
>
0
)
#endif
{
*
pState
=
(
USIGN8
)
DataBuffer
[
BytesRead
-
1
];
*
pDataLength
=
(
USIGN8
)
(
BytesRead
-
1
);
memcpy
(
pData
,
DataBuffer
,
*
pDataLength
);
return
(
E_OK
);
}
else
{
*
pDataLength
=
0
;
return
(
papi_get_last_error
());
}
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_write_dps_data
(
IN
HANDLE
hDevice
,
IN
USIGN8
*
pData
,
IN
USIGN8
DataLength
,
OUT
USIGN8
*
pState
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to write DP-Slave input data to DPS_SLAVE_INPUT_IMAGE
IN: hDevice -> device handle
IN: pData -> pointer to new input data
IN: DataLength -> number bytes of input data
OUT: pState -> pointer to a status variable for the recent input data status
possible return values:
- E_OK -> OK
- E_IF_INVALID_DATA_SIZE -> data_size does not match the expected input data size
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
DWORD
BytesReturned
=
0
;
#endif
#ifdef _LINUX
NTIoctl
SlaveInput
;
#endif
FUNCTION_BODY
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
// --- write DPS input data and read status
if
(
!
DeviceIoControl
((
HANDLE
)
hDevice
,
(
DWORD
)
IOCTL_PROFI_SET_DPS_DATA
,
(
LPVOID
)
pData
,
(
DWORD
)
DataLength
,
(
LPVOID
)
pState
,
(
DWORD
)
sizeof
(
USIGN8
),
(
LPDWORD
)
&
BytesReturned
,
NULL
))
#endif
#ifdef _LINUX
SlaveInput
.
InBuf
=
(
USIGN8
*
)
pData
;
SlaveInput
.
InBufLength
=
(
int
)
DataLength
;
SlaveInput
.
OutBuf
=
(
USIGN8
*
)
pData
;
SlaveInput
.
OutBufLength
=
DataLength
;
if
(
ioctl
(
hDevice
,
IOCTL_PROFI_SET_SLAVE_IN
,
&
SlaveInput
)
==
-
1
)
#endif
{
return
(
papi_get_last_error
());
}
else
{
return
(
E_OK
);
}
}
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
BOOL
CALL_CONV
profi_get_cntrl_info
(
IN
USIGN8
Board
,
OUT
char
*
pFirmwareVersion
,
OUT
USIGN32
*
pSerialDeviceNumber
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the version of the firmware and the serial
device number of PROFIBUS controller.
IN: Board -> board number
OUT: pFirmwareVersion -> data buffer for firmware version string
OUT: pSerialDeviceNumber -> serial device number
NOTE: There must be at least 100 Bytes (VERSION_STRING_LENGTH) free space for
firmware version buffer.
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
DWORD
BytesRead
=
0
;
HANDLE
hDevice
;
PROFI_DATA_IMAGE_DESCR
DataImageDescr
;
char
DeviceName
[
64
];
FUNCTION_BODY
// --- open BOARD device
sprintf
(
DeviceName
,
"
\\\\
.
\\
PROFIBUS
\\
Board%u
\\
Board"
,
Board
);
if
(
INVALID_HANDLE_VALUE
==
(
hDevice
=
CreateFile
(
DeviceName
,
GENERIC_READ
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
)))
{
return
(
FALSE
);
}
// --- get FIRMWARE VERSION
DataImageDescr
.
imageId
=
ID_FW_VERS_IMAGE
;
DataImageDescr
.
offset
=
0
;
DataImageDescr
.
bus
=
0
;
if
(
!
DeviceIoControl
((
HANDLE
)
hDevice
,
(
DWORD
)
IOCTL_PROFI_GET_DATA_IMAGE
,
(
LPVOID
)
&
DataImageDescr
,
(
DWORD
)
sizeof
(
DataImageDescr
),
(
LPVOID
)
pFirmwareVersion
,
(
DWORD
)
VERSION_STRING_LENGTH
,
(
LPDWORD
)
&
BytesRead
,
NULL
))
{
CloseHandle
(
hDevice
);
return
(
FALSE
);
}
// --- get SERIAL DEVICE NUMBER
DataImageDescr
.
imageId
=
ID_SERIAL_DEVICE_NUMBER
;
DataImageDescr
.
offset
=
0
;
DataImageDescr
.
bus
=
0
;
if
(
!
DeviceIoControl
((
HANDLE
)
hDevice
,
(
DWORD
)
IOCTL_PROFI_GET_DATA_IMAGE
,
(
LPVOID
)
(
VOID
*
)
&
DataImageDescr
,
(
DWORD
)
sizeof
(
DataImageDescr
),
(
LPVOID
)
pSerialDeviceNumber
,
(
DWORD
)
sizeof
(
USIGN32
),
(
LPDWORD
)
&
BytesRead
,
NULL
))
{
CloseHandle
(
hDevice
);
return
(
FALSE
);
}
CloseHandle
(
hDevice
);
return
(
TRUE
);
}
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
BOOL
CALL_CONV
profi_set_timeout
(
IN
HANDLE
hBasicMgmtDevice
,
IN
USIGN32
ReadTimeout
,
IN
USIGN32
WriteTimeout
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to set send and receive TIMEOUTs for SEND/RECEIVE interface
functions
IN: hBasicMgmtDevice -> basic management device handle
IN: ReadTimeout -> receive timeout in ms (WAIT_FOREVER for infinite wait)
IN: WriteTimeout -> send timeout in ms (WAIT_FOREVER for infinite wait)
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
DWORD
BytesReturned
;
USIGN32
ReadWriteTimeout
[
2
];
FUNCTION_BODY
ReadWriteTimeout
[
0
]
=
ReadTimeout
;
ReadWriteTimeout
[
1
]
=
WriteTimeout
;
return
(
DeviceIoControl
((
HANDLE
)
hBasicMgmtDevice
,
(
DWORD
)
IOCTL_PROFI_SET_TIMEOUT
,
(
LPVOID
)
ReadWriteTimeout
,
(
DWORD
)
2
*
sizeof
(
USIGN32
),
(
LPVOID
)
NULL
,
(
DWORD
)
0
,
(
LPDWORD
)
&
BytesReturned
,
NULL
));
}
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
BOOL
CALL_CONV
profi_get_timeout
(
IN
HANDLE
hBasicMgmtDevice
,
OUT
USIGN32
*
pReadTimeout
,
OUT
USIGN32
*
pWriteTimeout
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the set send and receive TIMEOUTs for SEND/RECEIVE
interface functions
IN: hBasicMgmtDevice -> basic management device handle
OUT: pReadTimeout -> pointer to receive timeout in ms (WAIT_FOREVER for infinite wait)
OUT: pWriteTimeout -> pointer to send timeout in ms (WAIT_FOREVER for infinite wait)
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
DWORD
BytesReturned
;
USIGN32
ReadWriteTimeout
[
2
];
FUNCTION_BODY
if
(
!
DeviceIoControl
((
HANDLE
)
hBasicMgmtDevice
,
(
DWORD
)
IOCTL_PROFI_GET_TIMEOUT
,
(
LPVOID
)
NULL
,
(
DWORD
)
0
,
(
LPVOID
)
ReadWriteTimeout
,
(
DWORD
)
2
*
sizeof
(
USIGN32
),
(
LPDWORD
)
&
BytesReturned
,
NULL
))
{
return
(
FALSE
);
}
if
(
BytesReturned
==
8
)
{
*
pReadTimeout
=
ReadWriteTimeout
[
0
];
*
pWriteTimeout
=
ReadWriteTimeout
[
1
];
return
(
TRUE
);
}
else
{
SetLastError
(
ERROR_INVALID_DATA
);
return
(
FALSE
);
}
}
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
BOOL
CALL_CONV
profi_set_queue_size
(
IN
HANDLE
hBasicMgmtDevice
,
IN
USIGN32
QueueSize
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to set the max. receive queue size for the PROFIBUS driver.
IN: hBasicMgmtDevice -> basic management device handle
IN: QueueSize -> max. receive queue size
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
DWORD
BytesReturned
;
FUNCTION_BODY
return
(
DeviceIoControl
((
HANDLE
)
hBasicMgmtDevice
,
(
DWORD
)
IOCTL_PROFI_SET_QUEUE_SIZE
,
(
LPVOID
)
&
QueueSize
,
(
DWORD
)
sizeof
(
USIGN32
),
(
LPVOID
)
NULL
,
(
DWORD
)
0
,
(
LPDWORD
)
&
BytesReturned
,
NULL
));
}
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
BOOL
CALL_CONV
profi_get_queue_size
(
IN
HANDLE
hBasicMgmtDevice
,
OUT
USIGN32
*
pQueueSize
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the set max. receive queue size for the PROFIBUS driver.
IN: hBasicMgmtDevice -> basic management device handle
OUT: pQueueSize -> pointer to max. receive queue size
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
DWORD
BytesReturned
;
FUNCTION_BODY
return
(
DeviceIoControl
((
HANDLE
)
hBasicMgmtDevice
,
(
DWORD
)
IOCTL_PROFI_GET_QUEUE_SIZE
,
(
LPVOID
)
NULL
,
(
DWORD
)
0
,
(
LPVOID
)
pQueueSize
,
(
DWORD
)
sizeof
(
USIGN32
),
(
LPDWORD
)
&
BytesReturned
,
NULL
));
}
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
GLOBAL
BOOL
CALL_CONV
profi_get_overrun_count
(
IN
HANDLE
hBasicMgmtDevice
,
OUT
USIGN32
*
pOverrunCount
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
IN: hBasicMgmtDevice -> basic management device handle
OUT: pOverrunCount -> pointer to overrun counts
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
DWORD
BytesReturned
;
FUNCTION_BODY
return
(
DeviceIoControl
((
HANDLE
)
hBasicMgmtDevice
,
(
DWORD
)
IOCTL_PROFI_GET_OVERRUN_COUNT
,
(
LPVOID
)
NULL
,
(
DWORD
)
0
,
(
LPVOID
)
pOverrunCount
,
(
DWORD
)
sizeof
(
USIGN32
),
(
LPDWORD
)
&
BytesReturned
,
NULL
));
}
#endif
// ***************************************************************************
// ***************************************************************************
// *
// * COMPATIBILITY API
// * -----------------
// *
// ***************************************************************************
// ***************************************************************************
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_set_default
(
OUT
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
USIGN8
Board
,
IN
USIGN8
Channel
,
IN
USIGN32
ReadTimeout
,
IN
USIGN32
WriteTimeout
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to initialize the WIN32 PROFIBUS-API. The function function
has to be called before any other function of PROFIBUS-API is called.
IN: Board -> number of the PROFIBUS board (0..9)
IN: Channel -> channel number (0)
IN: ReadTimeout -> receive timeout in ms (WAIT_FOREVER for infinite wait)
IN: Writetimeout -> send timeout in ms (WAIT_FOREVER for infinite wait)
Possible return values:
- E_OK -> Interface is initialized
- E_IF_NO_CNTRL_RES -> controller does not respond
- E_IF_INVALID_CNTRL_TYPE_VERSION -> invalid controller type or software version
- E_IF_INIT_INVALID_PARAMETER -> invalid initialize parameter
- E_IF_INVALID_VERSION -> invalid version
- E_IF_NO_CNTRL_PRESENT -> no controller present
- E_IF_INIT_FAILED -> initialization failed
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
char
DeviceName
[
64
];
USIGN32
ReadWriteTimeout
[
2
];
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
DWORD
BytesReturned
;
#endif
FUNCTION_BODY
if
(
hDevice
->
hServiceReadDevice
||
hDevice
->
hServiceWriteDevice
||
hDevice
->
hDpDataDevice
)
{
return
E_IF_SERVICE_NOT_EXECUTABLE
;
// Application has called init_profibus before
}
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
if
(
!
ReadBoardRegistryEntries
(
Board
,
&
OperationMode
))
{
return
(
E_IF_READING_REGISTRY
);
}
// get service device name
sprintf
(
DeviceName
,
"
\\\\
.
\\
PROFIBUS
\\
Board%u
\\
Pb%u
\\
Service"
,
Board
,
Channel
);
// Open service device for read access
hServiceReadDevice
=
CreateFile
(
DeviceName
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
hServiceReadDevice
==
INVALID_HANDLE_VALUE
)
{
hServiceReadDevice
=
NULL
;
return
(
E_IF_OS_ERROR
);
}
// Open service device for write access
hServiceWriteDevice
=
CreateFile
(
DeviceName
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
hServiceWriteDevice
==
INVALID_HANDLE_VALUE
)
{
CloseHandle
(
hServiceReadDevice
);
hServiceReadDevice
=
NULL
;
hServiceWriteDevice
=
NULL
;
return
(
E_IF_OS_ERROR
);
}
if
(
OperationMode
==
FMS_DPV1_MASTER_MODE
)
{
// --- get DP-Master's Data device name
sprintf
(
DeviceName
,
"
\\\\
.
\\
PROFIBUS
\\
Board%u
\\
Pb%u
\\
DpData"
,
Board
,
Channel
);
hDpDataDevice
=
CreateFile
(
DeviceName
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
hDpDataDevice
==
INVALID_HANDLE_VALUE
)
{
CloseHandle
(
hServiceReadDevice
);
CloseHandle
(
hServiceWriteDevice
);
hServiceReadDevice
=
NULL
;
hServiceWriteDevice
=
NULL
;
hDpDataDevice
=
NULL
;
return
(
E_IF_OS_ERROR
);
}
}
else
{
// get DP-Slave Input-Data device name
sprintf
(
DeviceName
,
"
\\\\
.
\\
PROFIBUS
\\
Board%u
\\
Pb%u
\\
DpSlaveInputData"
,
Board
,
Channel
);
hDpsInputDataDevice
=
CreateFile
(
DeviceName
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
hDpsInputDataDevice
==
INVALID_HANDLE_VALUE
)
{
CloseHandle
(
hServiceReadDevice
);
CloseHandle
(
hServiceWriteDevice
);
hServiceReadDevice
=
NULL
;
hServiceWriteDevice
=
NULL
;
hDpsInputDataDevice
=
NULL
;
return
(
E_IF_OS_ERROR
);
}
// get DP-Slave Output-Data device name
sprintf
(
DeviceName
,
"
\\\\
.
\\
PROFIBUS
\\
Board%u
\\
Pb%u
\\
DpSlaveOutputData"
,
Board
,
Channel
);
hDpsOutputDataDevice
=
CreateFile
(
DeviceName
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
hDpsOutputDataDevice
==
INVALID_HANDLE_VALUE
)
{
CloseHandle
(
hServiceReadDevice
);
CloseHandle
(
hServiceWriteDevice
);
CloseHandle
(
hDpsInputDataDevice
);
hServiceReadDevice
=
NULL
;
hServiceWriteDevice
=
NULL
;
hDpsInputDataDevice
=
NULL
;
hDpsOutputDataDevice
=
NULL
;
return
(
E_IF_OS_ERROR
);
}
}
ReadWriteTimeout
[
0
]
=
ReadTimeout
;
ReadWriteTimeout
[
1
]
=
WriteTimeout
;
if
(
!
DeviceIoControl
((
HANDLE
)
hServiceReadDevice
,
(
DWORD
)
IOCTL_PROFI_SET_TIMEOUT
,
(
LPVOID
)
ReadWriteTimeout
,
(
DWORD
)
2
*
sizeof
(
USIGN32
),
(
LPVOID
)
NULL
,
(
DWORD
)
0
,
(
LPDWORD
)
&
BytesReturned
,
NULL
))
{
CloseHandle
(
hServiceReadDevice
);
CloseHandle
(
hServiceWriteDevice
);
if
(
hDpDataDevice
)
CloseHandle
(
hDpDataDevice
);
if
(
hDpsInputDataDevice
)
CloseHandle
(
hDpsInputDataDevice
);
if
(
hDpsOutputDataDevice
)
CloseHandle
(
hDpsOutputDataDevice
);
hServiceReadDevice
=
NULL
;
hServiceWriteDevice
=
NULL
;
hDpDataDevice
=
NULL
;
hDpsInputDataDevice
=
NULL
;
hDpsOutputDataDevice
=
NULL
;
return
(
E_IF_CMI_ERROR
);
}
CurrentBoardNumber
=
Board
;
#endif
#ifdef _LINUX
ReadWriteTimeout
[
0
]
=
ReadTimeout
;
ReadWriteTimeout
[
1
]
=
WriteTimeout
;
// get service device name
sprintf
(
DeviceName
,
"/dev/pbservice%u"
,
Board
+
Channel
);
// Open service device for read access
hDevice
->
hServiceReadDevice
=
open
(
DeviceName
,
O_RDWR
|
O_NONBLOCK
);
if
(
hDevice
->
hServiceReadDevice
==
INVALID_HANDLE_VALUE
)
{
hDevice
->
hServiceReadDevice
=
(
HANDLE
)
NULL
;
return
(
E_IF_OS_ERROR
);
}
// Open service device for write access
hDevice
->
hServiceWriteDevice
=
hDevice
->
hServiceReadDevice
;
// --- get DP-Master's Data device name
sprintf
(
DeviceName
,
"/dev/pbdata%u"
,
Board
+
Channel
);
hDevice
->
hDpDataDevice
=
open
(
DeviceName
,
O_RDWR
|
O_NONBLOCK
);
// get DP-Slave Input-Data device name
sprintf
(
DeviceName
,
"/dev/pbslin%u"
,
Board
+
Channel
);
hDevice
->
hDpsInputDataDevice
=
open
(
DeviceName
,
O_RDWR
|
O_NONBLOCK
);
// get DP-Slave Output-Data device name
sprintf
(
DeviceName
,
"/dev/pbslout%u"
,
Board
+
Channel
);
hDevice
->
hDpsOutputDataDevice
=
open
(
DeviceName
,
O_RDWR
|
O_NONBLOCK
);
if
(
(
hDevice
->
hDpDataDevice
==
INVALID_HANDLE_VALUE
)
&&
(
hDevice
->
hDpsInputDataDevice
==
INVALID_HANDLE_VALUE
)
&&
(
hDevice
->
hDpsOutputDataDevice
==
INVALID_HANDLE_VALUE
)
)
{
close
(
hDevice
->
hServiceReadDevice
);
close
(
hDevice
->
hServiceWriteDevice
);
close
(
hDevice
->
hDpDataDevice
);
close
(
hDevice
->
hDpsInputDataDevice
);
close
(
hDevice
->
hDpsOutputDataDevice
);
hDevice
->
hServiceReadDevice
=
(
HANDLE
)
NULL
;
hDevice
->
hServiceWriteDevice
=
(
HANDLE
)
NULL
;
hDevice
->
hDpDataDevice
=
(
HANDLE
)
NULL
;
hDevice
->
hDpsInputDataDevice
=
(
HANDLE
)
NULL
;
hDevice
->
hDpsOutputDataDevice
=
(
HANDLE
)
NULL
;
return
(
E_IF_OS_ERROR
);
}
hDevice
->
CurrentBoardNumber
=
Board
+
Channel
;
#endif
return
(
E_OK
);
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_init
(
OUT
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
USIGN8
Board
,
IN
USIGN32
ReadTimeout
,
IN
USIGN32
WriteTimeout
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to initialize the WIN32 PROFIBUS-API. The function function
has to be called before any other function of PROFIBUS-API is called.
IN: Board -> number of the PROFIBUS board (0..9)
IN: Channel -> channel number (0)
IN: ReadTimeout -> receive timeout in ms (WAIT_FOREVER for infinite wait)
IN: Writetimeout -> send timeout in ms (WAIT_FOREVER for infinite wait)
Possible return values:
- E_OK -> Interface is initialized
- E_IF_NO_CNTRL_RES -> controller does not respond
- E_IF_INVALID_CNTRL_TYPE_VERSION -> invalid controller type or software version
- E_IF_INIT_INVALID_PARAMETER -> invalid initialize parameter
- E_IF_INVALID_VERSION -> invalid version
- E_IF_NO_CNTRL_PRESENT -> no controller present
- E_IF_INIT_FAILED -> initialization failed
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
if
(
(
hDevice
->
hServiceReadDevice
&&
hDevice
->
hServiceWriteDevice
)
&&
(
hDevice
->
hDpDataDevice
||
(
hDevice
->
hDpsInputDataDevice
&&
hDevice
->
hDpsOutputDataDevice
))
)
{
return
(
E_OK
);
// PAPI is already initialized
}
else
{
return
(
profi_set_default
(
hDevice
,
Board
,
0
,
ReadTimeout
,
WriteTimeout
));
// initalize PAPI
}
}
FUNCTION
GLOBAL
INT16
CALL_CONV
init_profibus
(
IN
USIGN32
DprAdress
,
IN
USIGN16
IoPortAdress
,
IN
PB_BOOL
Dummy
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used initialize the PROFIBUS-API with default values and start
the PROFIBUS controller. The function function has to be called before any other
function of PROFIBUS-API is called.
IN: DprAdress -> dummy
IN: IoPortAdress -> dummy
IN: Dummy -> dummy
Possible return values:
- E_OK -> Interface is initialized
- E_IF_NO_CNTRL_RES -> controller does not respond
- E_IF_INVALID_CNTRL_TYPE_VERSION -> invalid controller type or software version
- E_IF_INIT_INVALID_PARAMETER -> invalid initialize parameter
- E_IF_INVALID_VERSION -> invalid version
- E_IF_NO_CNTRL_PRESENT -> no controller present
- E_IF_INIT_FAILED -> initialization failed
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
T_PROFI_DEVICE_HANDLE
hDevice
;
FUNCTION_BODY
if
(
(
hDevice
.
hServiceReadDevice
&&
hDevice
.
hServiceWriteDevice
)
&&
(
hDevice
.
hDpDataDevice
||
(
hDevice
.
hDpsInputDataDevice
&&
hDevice
.
hDpsOutputDataDevice
))
)
{
return
(
E_OK
);
// PAPI is already initialized
}
else
{
return
(
profi_set_default
(
&
hDevice
,
0
,
0
,
0
,
0
));
// initalize PAPI
}
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_end
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to shutdown the PROFIBUS-API and shutdown the PROFIBUS
controller.
Possible return values:
- E_OK
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
// close service device
if
(
hDevice
->
hServiceReadDevice
)
{
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
CloseHandle
(
hServiceReadDevice
);
#endif
#ifdef _LINUX
close
(
hDevice
->
hServiceReadDevice
);
#endif
hDevice
->
hServiceReadDevice
=
(
HANDLE
)
NULL
;
}
if
(
hDevice
->
hServiceWriteDevice
)
{
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
CloseHandle
(
hServiceWriteDevice
);
#endif
#ifdef _LINUX
close
(
hDevice
->
hServiceWriteDevice
);
#endif
hDevice
->
hServiceWriteDevice
=
(
HANDLE
)
NULL
;
}
// close DP-Data device
if
(
hDevice
->
hDpDataDevice
)
{
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
CloseHandle
(
hDpDataDevice
);
#endif
#ifdef _LINUX
close
(
hDevice
->
hDpDataDevice
);
#endif
hDevice
->
hDpDataDevice
=
(
HANDLE
)
NULL
;
}
// close DP-Slave Input-Data device
if
(
hDevice
->
hDpsInputDataDevice
)
{
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
CloseHandle
(
hDpsInputDataDevice
);
#endif
#ifdef _LINUX
close
(
hDevice
->
hDpsInputDataDevice
);
#endif
hDevice
->
hDpsInputDataDevice
=
(
HANDLE
)
NULL
;
}
// close DP-Slave Output-Data device
if
(
hDevice
->
hDpsOutputDataDevice
)
{
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
CloseHandle
(
hDpsOutputDataDevice
);
#endif
#ifdef _LINUX
close
(
hDevice
->
hDpsOutputDataDevice
);
#endif
hDevice
->
hDpsOutputDataDevice
=
(
HANDLE
)
NULL
;
}
return
(
E_OK
);
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_snd_req_res
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
T_PROFI_SERVICE_DESCR
*
pSdb
,
IN
VOID
*
pData
,
IN
PB_BOOL
dummy
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to send a Service-Request or a Service-Response
to the PROFIBUS controller.
IN: pSdb -> pointer to SERVICE-DESCRIPTION-BLOCK
IN: pData -> pointer to service specific data
IN: dummy -> dummy
Possible return values:
- E_OK -> no error occured
- E_IF_INVALID_LAYER -> invalid layer
- E_IF_INVALID_SERVICE -> invalid service identifier
- E_IF_INVALID_PRIMITIVE -> invalid service primitive
- E_IF_RESOURCE_UNAVAILABLE -> no resource available
- E_IF_NO_PARALLEL_SERVICES -> no parallel services allowed
- E_IF_SERVICE_CONSTR_CONFLICT -> service temporarily not executable
- E_IF_SERVICE_NOT_SUPPORTED -> service not supported in subset
- E_IF_SERVICE_NOT_EXECUTABLE -> service not executable
- E_IF_NO_CNTRL_RES -> controller does not respond (CMI_TIMEOUT)
- E_IF_INVALID_DATA_SIZE -> not enough CMI memory available for REQ or RES
- E_IF_INVALID_VERSION -> invalid version (only PROFDI-IF)
- E_IF_INVALID_PARAMETER -> invalid parameter in REQ or RES
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
// --- check if service device is open
if
(
!
hDevice
->
hServiceWriteDevice
)
return
(
E_IF_PAPI_NOT_INITIALIZED
);
return
(
profi_write_service
(
hDevice
->
hServiceWriteDevice
,
pSdb
,
pData
));
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_rcv_con_ind
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
OUT
T_PROFI_SERVICE_DESCR
*
pSdb
,
OUT
VOID
*
pData
,
INOUT
USIGN16
*
pDataLength
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to receive a Service-Indication or a Service-Confirmation
from the PROFIBUS controller.
OUT: pSdb -> pointer to SERVICE-DESCRIPTION-BLOCK
OUT: pData -> pointer to data buffer
INOUT: pDataLength -> IN: length of data buffer
OUT: length of received data
Possible return values:
- CON_IND_RECEIVED -> a confirmation or indication has been received
- NO_CON_IND_RECEIVED -> no confirmation or indication has been received
- E_IF_FATAL_ERROR -> unrecoverable error in PROTOCOL SW
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
// --- check if service device is open
if
(
!
hDevice
->
hServiceReadDevice
)
return
(
E_IF_PAPI_NOT_INITIALIZED
);
return
(
profi_read_service
(
hDevice
->
hServiceReadDevice
,
pSdb
,
pData
,
pDataLength
));
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_set_data
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
USIGN8
DataId
,
IN
USIGN16
Offset
,
IN
USIGN16
DataLength
,
IN
VOID
*
pData
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to write data to CMI data area
IN: DataId -> data image identifier
- ID_DP_SLAVE_IO_IMAGE (DPM: image for slave io data)
- ID_DP_STATUS_IMAGE (DPM: image for status data)
IN: Offset -> write at offset in data image
IN: DataLength -> length of data to write
IN: pData -> pointer to data to write
possible return values:
- E_OK -> OK
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_SERVICE_NOT_SUPPORTED -> service not supported
- E_IF_INVALID_DATA_SIZE -> invalid user data size
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
OVERLAPPED
overlapped
;
DWORD
BytesWritten
;
#endif
FUNCTION_BODY
// --- check if DP-Data device is open
if
(
!
hDevice
->
hDpDataDevice
)
return
(
E_IF_PAPI_NOT_INITIALIZED
);
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
// --- init overlapped structure
memset
(
&
overlapped
,
0
,
sizeof
(
OVERLAPPED
));
overlapped
.
Offset
=
Offset
;
// write data
if
(
!
WriteFile
(
hDpDataDevice
,
pData
,
DataLength
,
&
BytesWritten
,
&
overlapped
))
{
return
(
papi_get_last_error
());
}
#endif
#ifdef _LINUX
if
(
lseek
(
hDevice
->
hDpDataDevice
,
Offset
,
SEEK_SET
)
<
0
)
{
return
(
papi_get_last_error
());
}
if
(
write
(
hDevice
->
hDpDataDevice
,
pData
,
DataLength
)
<
0
)
{
return
(
papi_get_last_error
());
}
#endif
return
(
E_OK
);
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_get_data
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
USIGN8
DataId
,
IN
USIGN16
Offset
,
INOUT
USIGN16
*
pDataLength
,
OUT
VOID
*
pData
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to read data from CMI data area
IN: DataId -> data image identifier
- ID_DP_SLAVE_IO_IMAGE (DPM: image for slave io data)
- ID_DP_STATUS_IMAGE (DPM: image for status data)
IN: Offset -> read at offset in data image
INOUT: pDataLength IN: length of data buffer
OUT: length of received data
OUT: pData -> pointer to data buffer
possible return values:
- E_OK -> OK
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_SERVICE_NOT_SUPPORTED -> service not supported
- E_IF_INVALID_DATA_SIZE -> invalid user data size
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
INT16
RetVal
=
E_OK
;
HANDLE
hBoard
=
(
HANDLE
)
NULL
;
char
DeviceName
[
64
];
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
DWORD
BytesRead
=
0
;
T_PROFI_DATA_IMAGE_DESCR
DataImageDescr
;
OVERLAPPED
Overlapped
;
#endif
#ifdef _LINUX
ssize_t
BytesRead
=
0
;
DataImage
DataImageDescr
;
#endif
switch
(
DataId
)
{
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
case
ID_SERIAL_DEVICE_NUMBER
:
case
ID_FW_VERS_IMAGE
:
case
ID_EXCEPTION_IMAGE
:
// --- open BOARD-Device
sprintfprofi_get_data
(
DeviceName
,
"
\\\\
.
\\
PROFIBUS
\\
Board%u
\\
Board"
,
CurrentBoardNumber
);
if
(
INVALID_HANDLE_VALUE
==
(
hBoard
=
CreateFile
(
DeviceName
,
0
,
0
,
NULL
,
OPEN_ALWAYS
,
profi_get_data
FILE_ATTRIBUTE_NORMAL
,
NULL
)))
{
BytesRead
return
(
E_IF_OS_ERROR
);
}
// --- set input IOCTL data structure
DataImageDescr
.
imageId
=
DataId
;
DataImageDescr
.
offset
=
Offset
;
DataImageDescr
.
bus
=
0
;
// --- read DATA-Image
if
(
DeviceIoprofi_get_dataControl
((
HANDLE
)
hBoard
,
(
DWORD
)
IOCTL_PROFI_GET_DATA_IMAGE
,
(
LPVOID
)
&
DataImageDescr
,
BytesRead
(
DWORD
)
sizeof
(
DataImageDescr
),
(
LPVOID
)
pData
,
(
DWORD
)
*
pDataLength
,
(
LPDWORD
)
&
BytesRead
,
NULL
))
{
profi_get_data
*
pDataLength
=
(
USIGN16
)
BytesRead
;
RetVal
=
E_OK
;
}
else
{
*
pDataLength
=
0
;
RetVal
=
papi_get_last_error
();
}
CloseHandle
(
hBoard
);
#endif //BytesRead
#ifdef _LINUX
case
ID_SERIAL_DEVICE_NUMBER
:
case
ID_FW_VERS_IMAGE
:
sprintf
(
DeviceName
,
"/dev/pbboard%u"
,
hDevice
->
CurrentBoardNumber
);
if
((
hBoard
=
open
(
DeviceName
,
O_RDONLY
))
<
0
)
{
return
(
papi_get_last_error
());
}
if
(
DataId
==
ID_SERIAL_DEVICE_NUMBER
)
{
if
(
lseek
(
hBoard
,
Offset
,
SEEK_SET
)
<
0
)
{
return
(
papi_get_last_error
());
}
DataImageDescr
.
id
=
ID_SERIAL_DEVICE_NUMBER
;
DataImageDescr
.
Buf
=
pData
;
DataImageDescr
.
Length
=
*
pDataLength
;
if
(
ioctl
(
hBoard
,
IOCTL_PROFI_SERIAL_NUMBER
,
&
DataImageDescr
)
==
-
1
)
{
*
pDataLength
=
0
;
RetVal
=
papi_get_last_error
();
}
else
{
*
pDataLength
=
(
USIGN16
)
4
;
*
(
USIGN32
*
)
pData
=
*
(
USIGN32
*
)
&
DataImageDescr
;
RetVal
=
E_OK
;
// printf("papi: Serialnumber = %lu len = %hu\n",*(USIGN32*)pData, BytesRead);
}
}
else
{
if
((
BytesRead
=
read
(
hBoard
,
pData
,
*
pDataLength
))
<
0
)
{
*
pDataLength
=
0
;
RetVal
=
papi_get_last_error
();
}
else
{
*
pDataLength
=
(
USIGN16
)
BytesRead
;
RetVal
=
E_OK
;
}
}
close
(
hBoard
);
#endif
return
(
RetVal
);
case
ID_DP_SLAVE_IO_IMAGE
:
// --- check if DP-Data device is open
if
(
!
hDevice
->
hDpDataDevice
)
return
(
E_IF_PAPI_NOT_INITIALIZED
);
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
// --- init overlapped structure
memset
(
&
Overlapped
,
0
,
sizeof
(
OVERLAPPED
));
Overlapped
.
OfhBoardfset
=
Offset
;
if
(
!
ReadFile
(
hDpDataDevice
,
pData
,
*
pDataLength
,
&
BytesRead
,
&
Overlapped
))
{
return
(
papi_get_last_error
());
}
#endif
#ifdef _LINUX
if
(
lseek
(
hDevice
->
hDpDataDevice
,
Offset
,
SEEK_SET
)
<
0
)
{
return
(
papi_get_last_error
());
}
DataImageDescr
.
id
=
ID_DP_SLAVE_IO_IMAGE
;
DataImageDescr
.
Buf
=
pData
;
DataImageDescr
.
Length
=
*
pDataLength
;
/*printf("papi: ioctl = 0x%x board=0x%x, desc=0x%x boardnr=%u\n",
IOCTL_PROFI_GET_DATA_IMAGE,
hDpDataDevice,
&DataImageDescr,
CurrentBoardNumber);
*/
if
(
ioctl
(
hDevice
->
hDpDataDevice
,
IOCTL_PROFI_GET_DATA_IMAGE
,
&
DataImageDescr
)
==
-
1
)
{
BytesRead
=
0
;
RetVal
=
papi_get_last_error
();
}
else
{
BytesRead
=
(
USIGN16
)
DataImageDescr
.
Length
;
// printf("papi data length = %u\n", BytesRead);
RetVal
=
E_OK
;
}
#endif
*
pDataLength
=
(
USIGN16
)
BytesRead
;
return
(
E_OK
);
default:
return
(
E_IF_SERVICE_NOT_SUPPORTED
);
}
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_set_dps_input_data
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
USIGN8
*
pData
,
IN
USIGN8
DataLength
,
OUT
USIGN8
*
pState
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to write DP Slave input data to DPS_SLAVE_INPUT_IMAGE
IN: pData -> pointer to new input data
IN: DataLength -> number bytes of input data
OUT: pState -> pointer to a status variable for the recent input data status
possible return values:
- E_OK -> OK
- E_IF_INVALID_DATA_SIZE -> data_size does not match the expected input data size
- E_IF_NO_CNTRL_RES -> timeout controller does not response
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
if
(
hDevice
->
hDpsInputDataDevice
==
(
HANDLE
)
NULL
)
{
return
(
E_IF_PAPI_NOT_INITIALIZED
);
}
return
(
profi_write_dps_data
(
hDevice
->
hDpsInputDataDevice
,
pData
,
DataLength
,
pState
));
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_get_dps_input_data
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
OUT
USIGN8
*
pData
,
INOUT
USIGN8
*
pDataLength
,
OUT
USIGN8
*
pState
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to read data CMI DPS_SLAVE_INPUT_IMAGE
OUT: pData -> destination buffer for input data
INOUT: pDataLength -> sizeof destination buffer and number of bytes read
OUT: pState -> status of input data if read successfully
possible return values:
- E_OK -> OK
- E_IF_INVALID_DATA_SIZE -> invalid user data size
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
if
(
hDevice
->
hDpsInputDataDevice
==
(
HANDLE
)
NULL
)
{
return
(
E_IF_PAPI_NOT_INITIALIZED
);
}
return
(
profi_read_dps_data
(
hDevice
->
hDpsInputDataDevice
,
pData
,
pDataLength
,
pState
));
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_get_dps_output_data
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
OUT
USIGN8
*
pData
,
INOUT
USIGN8
*
pDataLength
,
OUT
USIGN8
*
pState
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to read data from DPS_SLAVE_OUTPUT_IMAGE.
OUT: pData -> destination buffer for output data
INOUT: pDataLength -> sizeof destination buffer and number of bytes read
OUT: pState -> status of output data if read successfully
possible return values:
- E_OK -> OK
- E_IF_SERVICE_NOT_SUPPORTED -> service not supported
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_INVALID_DATA_SIZE -> invalid user data size
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
if
(
hDevice
->
hDpsOutputDataDevice
==
(
HANDLE
)
NULL
)
{
return
(
E_IF_PAPI_NOT_INITIALIZED
);
}
return
(
profi_read_dps_data
(
hDevice
->
hDpsOutputDataDevice
,
pData
,
pDataLength
,
pState
));
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_get_versions
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
OUT
CSTRING
*
pPapiVersion
,
OUT
CSTRING
*
pFirmwareVersion
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the vesrion strings of PAPI and firmware.
OUT: pPapiVersion -> data buffer for PAPI version string
OUT: pFirmwareVersion -> data buffer for firmware version string
NOTE: There must be at least 100 Bytes (VERSION_STRING_LENGTH) free space for
each INOUT buffer.
Possible return values:
- E_OK
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
USIGN16
DataLength
;
USIGN16
i
;
FUNCTION_BODY
// --- PAPI version
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
strcpy
(
pPapiVersion
,(
CSTRING
*
)
"PROFIBUS WinXP/Win2K/WinNT API "
);
#endif
#ifdef _LINUX
strcpy
(
pPapiVersion
,(
CSTRING
*
)
"PROFIBUS Linux API "
);
#endif
strcat
(
pPapiVersion
,(
CSTRING
*
)
SW_VERSION
);
strcat
(
pPapiVersion
,(
CSTRING
*
)
__DATE__
);
// --- get PROFIBUS firmware version
DataLength
=
(
USIGN16
)
VERSION_STRING_LENGTH
;
if
(
profi_get_data
(
hDevice
,
ID_FW_VERS_IMAGE
,
0
,
&
DataLength
,
pFirmwareVersion
)
!=
E_OK
)
{
strcpy
(
pFirmwareVersion
,(
CSTRING
*
)
"controller not initialized"
);
}
// --- convert \n to ' '
for
(
i
=
0
;
i
<
VERSION_STRING_LENGTH
;
i
++
)
{
if
(
pFirmwareVersion
[
i
]
==
'\n'
)
pFirmwareVersion
[
i
]
=
' '
;
else
if
(
pFirmwareVersion
[
i
]
==
'\0'
)
break
;
else
continue
;
}
return
(
E_OK
);
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_get_serial_device_number
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
OUT
USIGN32
*
pSerialDeviceNumber
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the serial device number of the PROFIBUS
controller
OUT: pSerialDeviceNumber -> serial device number
Possible return values:
- E_OK
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
USIGN16
DataLength
;
FUNCTION_BODY
DataLength
=
(
USIGN16
)
sizeof
(
USIGN32
);
// --- get serial device number
return
(
profi_get_data
(
hDevice
,
ID_SERIAL_DEVICE_NUMBER
,
0
,
&
DataLength
,
pSerialDeviceNumber
));
}
FUNCTION
GLOBAL
INT16
CALL_CONV
profi_get_last_error
(
VOID
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is returns the additional last error code for INTERFACE-ERRORs
controller
Possible return values:
- additional last error code
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
DWORD
LastErrorCode
;
#endif
FUNCTION_BODY
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
LastErrorCode
=
GetLastError
();
if
(
CUSTOMER_FLAG_SET
(
LastErrorCode
))
return
((
INT16
)
LastErrorCode
);
else
return
(
E_IF_OS_ERROR
);
#endif
#ifdef _LINUX
return
((
INT16
)
errno
);
#endif
}
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
FUNCTION
BOOL
WINAPI
DllMain
(
IN
HINSTANCE
hInstDLL
,
IN
ULONG
Reason
,
IN
LPVOID
pReserved
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
32Bit-DLL main function.
The function is called by MS-Windows during loading DLL.
Possible return values:
- TRUE
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
Reason
)
{
case
DLL_PROCESS_ATTACH
:
hServiceReadDevice
=
NULL
;
hServiceWriteDevice
=
NULL
;
hDpDataDevice
=
NULL
;
hDpsInputDataDevice
=
NULL
;
hDpsOutputDataDevice
=
NULL
;
CurrentBoardNumber
=
0
;
break
;
case
DLL_THREAD_ATTACH
:
break
;
case
DLL_THREAD_DETACH
:
break
;
case
DLL_PROCESS_DETACH
:
profi_end
();
break
;
default:
break
;
}
return
TRUE
;
}
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack
#endif
profibus/lib/rt/src/os_linux/buildnr.papi.h
0 → 100644
View file @
0135e84d
#define BUILD_NUMBER 52
#define BUILD_NUMBER_STR "52"
#define MAJOR_VERSION_NUMBER 5
#define MINOR_VERSION_NUMBER 26
#define VERSION_TEXT "5.26.1.00.release"
profibus/lib/rt/src/os_linux/busparam.c
0 → 100644
View file @
0135e84d
/*****************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
* D-85540 Haar *
* Phone: ++49-89-4 56 56-0 *
* Fax: ++49-89-4 56 56-3 99 *
* *
* Copyright (C) SOFTING AG 1995-2003 *
* All Rights Reserved *
* *
******************************************************************************
FILE_NAME BUSPARAM.C
PROJECT_NAME PROFIBUS
MODULE BUSPARAM
COMPONENT_LIBRARY PBT LIBs and DLL (16-Bit)
PBTOOLS DLL (32-Bit)
AUTHOR SOFTING AG
VERSION 5.00
5.01
5.02
5.10
5.11
5.20.0.00.alpha
5.20.0.00.release
5.21.0.00.release
DATE 24-November-1995
31-January-1996
14-July-1996
20-Febrary-1997
18-March-1997
30-July-1997
17-October-1997
27-February-1998
STATUS finished
FUNCTIONAL_MODULE_DESCRIPTION
RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"
INCLUDES
#include <stdlib.h>
#include <string.h>
#if defined (WIN16) || defined (WIN32)
#include <windows.h>
#endif
#include "pb_type.h"
#include "pb_dp.h"
#include "pb_fm7.h"
#include "pb_fdl.h"
#include "pb_fmb.h"
#include "pb_tools.h"
LOCAL_DEFINES
#define HSA 126
/* highest station address */
LOCAL_TYPEDEFS
FUNCTION_DECLARATIONS
EXPORT_DATA
IMPORT_DATA
LOCAL_DATA
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack (off)
#endif
FUNCTION
LOCAL
PB_BOOL
pbt_get_bus_param_for_dp
(
IN
USIGN8
baud_rate
,
OUT
T_FMB_SET_BUSPARAMETER_REQ
*
bus_param_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for DP operation
using ASPC2
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
baud_rate
)
{
case
0
:
/* 9,6 KBaud */
case
1
:
/* 19,2 KBaud */
case
2
:
/* 93,75 KBaud */
case
3
:
/* 187,5 KBaud */
bus_param_ptr
->
tsl
=
100
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
60
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
1
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
ttr
=
50000
;
bus_param_ptr
->
max_retry_limit
=
1
;
return
(
PB_TRUE
);
case
4
:
/* 500 KBaud */
bus_param_ptr
->
tsl
=
200
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
100
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
1
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
ttr
=
100000
;
bus_param_ptr
->
max_retry_limit
=
1
;
return
(
PB_TRUE
);
case
6
:
/* 1,5 MBaud */
bus_param_ptr
->
tsl
=
300
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
150
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
1
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
300000
;
bus_param_ptr
->
max_retry_limit
=
1
;
return
(
PB_TRUE
);
case
7
:
/* 3 MBaud */
bus_param_ptr
->
tsl
=
400
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
250
;
bus_param_ptr
->
tqui
=
3
;
bus_param_ptr
->
tset
=
4
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
600000
;
bus_param_ptr
->
max_retry_limit
=
2
;
return
(
PB_TRUE
);
case
8
:
/* 6 MBaud */
bus_param_ptr
->
tsl
=
600
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
450
;
bus_param_ptr
->
tqui
=
6
;
bus_param_ptr
->
tset
=
8
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
1200000
;
bus_param_ptr
->
max_retry_limit
=
3
;
return
(
PB_TRUE
);
case
9
:
/* 12 MBaud */
bus_param_ptr
->
tsl
=
1000
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
800
;
bus_param_ptr
->
tqui
=
9
;
bus_param_ptr
->
tset
=
16
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
2400000
;
bus_param_ptr
->
max_retry_limit
=
4
;
return
(
PB_TRUE
);
case
11
:
/* 45,45 Kbaud */
bus_param_ptr
->
tsl
=
640
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
400
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
95
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
50000
;
bus_param_ptr
->
max_retry_limit
=
1
;
return
(
PB_TRUE
);
default:
return
(
PB_FALSE
);
}
}
FUNCTION
LOCAL
PB_BOOL
pbt_get_bus_param_for_fms
(
IN
USIGN8
baud_rate
,
OUT
T_FMB_SET_BUSPARAMETER_REQ
*
bus_param_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for FMS/FM7 operation
using ASPC2
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
baud_rate
)
{
case
0
:
/* 9,6 KBaud */
bus_param_ptr
->
tsl
=
100
;
bus_param_ptr
->
min_tsdr
=
30
;
bus_param_ptr
->
max_tsdr
=
50
;
bus_param_ptr
->
tqui
=
22
;
bus_param_ptr
->
tset
=
5
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
10000
;
return
(
PB_TRUE
);
case
1
:
/* 19,2 KBaud */
bus_param_ptr
->
tsl
=
200
;
bus_param_ptr
->
min_tsdr
=
60
;
bus_param_ptr
->
max_tsdr
=
100
;
bus_param_ptr
->
tqui
=
22
;
bus_param_ptr
->
tset
=
10
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
15000
;
return
(
PB_TRUE
);
case
2
:
/* 93,75 KBaud */
bus_param_ptr
->
tsl
=
500
;
bus_param_ptr
->
min_tsdr
=
125
;
bus_param_ptr
->
max_tsdr
=
250
;
bus_param_ptr
->
tqui
=
22
;
bus_param_ptr
->
tset
=
15
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
30000
;
return
(
PB_TRUE
);
case
3
:
/* 187,5 KBaud */
bus_param_ptr
->
tsl
=
1000
;
bus_param_ptr
->
min_tsdr
=
250
;
bus_param_ptr
->
max_tsdr
=
500
;
bus_param_ptr
->
tqui
=
22
;
bus_param_ptr
->
tset
=
25
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
50000
;
return
(
PB_TRUE
);
case
4
:
/* 500 KBaud */
bus_param_ptr
->
tsl
=
2000
;
bus_param_ptr
->
min_tsdr
=
500
;
bus_param_ptr
->
max_tsdr
=
1000
;
bus_param_ptr
->
tqui
=
22
;
bus_param_ptr
->
tset
=
50
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
100000
;
return
(
PB_TRUE
);
case
6
:
/* 1,5 MBaud */
bus_param_ptr
->
tsl
=
3000
;
bus_param_ptr
->
min_tsdr
=
150
;
bus_param_ptr
->
max_tsdr
=
980
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
240
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
300000
;
return
(
PB_TRUE
);
case
7
:
/* 3 MBaud */
bus_param_ptr
->
tsl
=
400
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
250
;
bus_param_ptr
->
tqui
=
3
;
bus_param_ptr
->
tset
=
4
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
600000
;
bus_param_ptr
->
max_retry_limit
=
2
;
return
(
PB_TRUE
);
case
8
:
/* 6 MBaud */
bus_param_ptr
->
tsl
=
600
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
450
;
bus_param_ptr
->
tqui
=
6
;
bus_param_ptr
->
tset
=
8
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
1200000
;
bus_param_ptr
->
max_retry_limit
=
3
;
return
(
PB_TRUE
);
case
9
:
/* 12 MBaud */
bus_param_ptr
->
tsl
=
1000
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
800
;
bus_param_ptr
->
tqui
=
9
;
bus_param_ptr
->
tset
=
16
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
2400000
;
bus_param_ptr
->
max_retry_limit
=
4
;
return
(
PB_TRUE
);
default:
return
(
PB_FALSE
);
}
}
FUNCTION
LOCAL
PB_BOOL
pbt_get_bus_param_for_dpfms
(
IN
USIGN8
baud_rate
,
OUT
T_FMB_SET_BUSPARAMETER_REQ
*
bus_param_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for mixed DP/FMS operation
using ASPC2
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
baud_rate
)
{
case
0
:
/* 9,6 KBaud */
bus_param_ptr
->
tsl
=
125
;
bus_param_ptr
->
min_tsdr
=
30
;
bus_param_ptr
->
max_tsdr
=
60
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
1
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
10000
;
return
(
PB_TRUE
);
case
1
:
/* 19,2 KBaud */
bus_param_ptr
->
tsl
=
250
;
bus_param_ptr
->
min_tsdr
=
60
;
bus_param_ptr
->
max_tsdr
=
120
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
1
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
15000
;
return
(
PB_TRUE
);
case
2
:
/* 93,75 KBaud */
bus_param_ptr
->
tsl
=
600
;
bus_param_ptr
->
min_tsdr
=
125
;
bus_param_ptr
->
max_tsdr
=
250
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
1
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
30000
;
return
(
PB_TRUE
);
case
3
:
/* 187,5 KBaud */
bus_param_ptr
->
tsl
=
1500
;
bus_param_ptr
->
min_tsdr
=
250
;
bus_param_ptr
->
max_tsdr
=
500
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
1
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
max_retry_limit
=
2
;
bus_param_ptr
->
ttr
=
50000
;
return
(
PB_TRUE
);
case
4
:
/* 500 KBaud */
bus_param_ptr
->
tsl
=
3500
;
bus_param_ptr
->
min_tsdr
=
500
;
bus_param_ptr
->
max_tsdr
=
1000
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
1
;
bus_param_ptr
->
g
=
1
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
100000
;
return
(
PB_TRUE
);
case
6
:
/* 1,5 MBaud */
bus_param_ptr
->
tsl
=
3000
;
bus_param_ptr
->
min_tsdr
=
150
;
bus_param_ptr
->
max_tsdr
=
980
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
240
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
max_retry_limit
=
1
;
bus_param_ptr
->
ttr
=
300000
;
return
(
PB_TRUE
);
case
7
:
/* 3 MBaud */
bus_param_ptr
->
tsl
=
400
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
250
;
bus_param_ptr
->
tqui
=
3
;
bus_param_ptr
->
tset
=
4
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
600000
;
bus_param_ptr
->
max_retry_limit
=
2
;
return
(
PB_TRUE
);
case
8
:
/* 6 MBaud */
bus_param_ptr
->
tsl
=
600
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
450
;
bus_param_ptr
->
tqui
=
6
;
bus_param_ptr
->
tset
=
8
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
1200000
;
bus_param_ptr
->
max_retry_limit
=
3
;
return
(
PB_TRUE
);
case
9
:
/* 12 MBaud */
bus_param_ptr
->
tsl
=
1000
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
800
;
bus_param_ptr
->
tqui
=
9
;
bus_param_ptr
->
tset
=
16
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
2400000
;
bus_param_ptr
->
max_retry_limit
=
4
;
return
(
PB_TRUE
);
case
11
:
/* 45,45 Kbaud */
bus_param_ptr
->
tsl
=
640
;
bus_param_ptr
->
min_tsdr
=
11
;
bus_param_ptr
->
max_tsdr
=
400
;
bus_param_ptr
->
tqui
=
0
;
bus_param_ptr
->
tset
=
95
;
bus_param_ptr
->
g
=
10
;
bus_param_ptr
->
ttr
=
50000
;
bus_param_ptr
->
max_retry_limit
=
1
;
return
(
PB_TRUE
);
default:
return
(
PB_FALSE
);
}
}
FUNCTION
GLOBAL
PB_BOOL
CALL_CONV
pbt_get_dp_def_bus_param
(
IN
USIGN8
baud_rate
,
IN
USIGN8
station_addr
,
IN
USIGN16
mode
,
OUT
T_DP_BUS_PARA_SET
FAR
*
bus_param_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for DP operation
using ASPC2. (use this function only to version 5.02)
IN: baud_rate -> desired baudrate (see valid baudrates)
IN: station_addr -> desired station address (0..126)
IN: mode: -> DP_MODE standalone DP operation
DP_FMS_FM7_MODE simultaneous DP/FMS/FM7 operation
OUT: bus_param_ptr -> pointer to DP bus parameter structure
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
PB_BOOL
ret_val
;
T_FMB_SET_BUSPARAMETER_REQ
bus_param
;
FUNCTION_BODY
ret_val
=
PB_TRUE
;
switch
(
mode
)
{
case
DP_MODE
:
/* only DP mode */
ret_val
=
pbt_get_bus_param_for_dp
(
baud_rate
,
&
bus_param
);
break
;
case
DP_FMS_FM7_MODE
:
/* mixed mode FMS-FM7 and DP */
ret_val
=
pbt_get_bus_param_for_dpfms
(
baud_rate
,
&
bus_param
);
break
;
default:
ret_val
=
PB_FALSE
;
break
;
}
if
(
ret_val
==
PB_TRUE
)
{
/* -- set variable busparametes ---------------------------------------- */
bus_param_ptr
->
tsl
=
bus_param
.
tsl
;
bus_param_ptr
->
min_tsdr
=
bus_param
.
min_tsdr
;
bus_param_ptr
->
max_tsdr
=
bus_param
.
max_tsdr
;
bus_param_ptr
->
tqui
=
bus_param
.
tqui
;
bus_param_ptr
->
tset
=
bus_param
.
tset
;
bus_param_ptr
->
ttr
=
bus_param
.
ttr
;
bus_param_ptr
->
g
=
bus_param
.
g
;
bus_param_ptr
->
max_retry_limit
=
bus_param
.
max_retry_limit
;
/* -- set fix busparametes -------------------------------------------- */
bus_param_ptr
->
bus_para_len
=
32
;
bus_param_ptr
->
fdl_add
=
station_addr
;
bus_param_ptr
->
baud_rate
=
baud_rate
;
bus_param_ptr
->
hsa
=
HSA
;
bus_param_ptr
->
bp_flag
=
0x00
;
bus_param_ptr
->
min_slave_interval
=
200
;
/* [100us] */
bus_param_ptr
->
poll_timeout
=
1000
;
/* [ 1ms] */
bus_param_ptr
->
data_control_time
=
100
;
/* [ 10ms] */
bus_param_ptr
->
master_user_data_len
=
34
;
memcpy
((
USIGN8
FAR
*
)
bus_param_ptr
->
master_class2_name
,
(
USIGN8
FAR
*
)
"SOFTING PROFIBUS DP MASTER "
,
32
);
bus_param_ptr
->
bus_para_len
+=
bus_param_ptr
->
master_user_data_len
;
}
return
ret_val
;
}
FUNCTION
GLOBAL
PB_BOOL
CALL_CONV
pbt_get_fms_fm7_def_bus_param
(
IN
USIGN8
baud_rate
,
IN
USIGN8
station_addr
,
IN
PB_BOOL
in_ring_desired
,
IN
USIGN16
mode
,
OUT
T_SET_BUSPARAMETER_REQ
FAR
*
bus_param_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for FMS/FM7 operation
using ASPC2. (use this function only to version 5.02)
IN: baud_rate -> desired baudrate (see valid baudrates)
IN: station_addr -> desired station address (0..126)
IN: in_ring_desired -> PB_TRUE active station (master)
PB_FALSE passive station (slave)
IN: mode -> FMS_FM7_MODE standalone FMS/FM7 operation
DP_FMS_FM7_MODE simultaneous DP/FMS/FM7 operation
OUT: bus_param_ptr -> pointer to FM7 bus parameter structure
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
T_FMB_SET_BUSPARAMETER_REQ
bus_param
;
FUNCTION_BODY
if
(
pbt_get_bus_param_for_fms
(
baud_rate
,
&
bus_param
))
{
/* -- set variable busparametes -------------------------------------- */
bus_param_ptr
->
tsl
=
bus_param
.
tsl
;
bus_param_ptr
->
min_tsdr
=
bus_param
.
min_tsdr
;
bus_param_ptr
->
max_tsdr
=
bus_param
.
max_tsdr
;
bus_param_ptr
->
tqui
=
bus_param
.
tqui
;
bus_param_ptr
->
tset
=
bus_param
.
tset
;
bus_param_ptr
->
ttr
=
bus_param
.
ttr
;
bus_param_ptr
->
g
=
bus_param
.
g
;
bus_param_ptr
->
max_retry_limit
=
bus_param
.
max_retry_limit
;
/* -- set fix busparametes -------------------------------------------- */
bus_param_ptr
->
loc_add
=
station_addr
;
bus_param_ptr
->
loc_segm
=
NO_SEGMENT
;
bus_param_ptr
->
baud_rate
=
baud_rate
;
bus_param_ptr
->
medium_red
=
NO_REDUNDANCY
;
bus_param_ptr
->
in_ring_desired
=
in_ring_desired
;
bus_param_ptr
->
hsa
=
HSA
;
bus_param_ptr
->
ident
[
0
]
=
0
;
bus_param_ptr
->
ident
[
1
]
=
0
;
bus_param_ptr
->
ident
[
2
]
=
0
;
bus_param_ptr
->
ident
[
3
]
=
0
;
return
(
PB_TRUE
);
}
else
{
return
(
PB_FALSE
);
}
}
FUNCTION
GLOBAL
PB_BOOL
CALL_CONV
pbt_get_fdlif_def_bus_param
(
IN
USIGN8
baud_rate
,
IN
USIGN8
station_addr
,
IN
PB_BOOL
in_ring_desired
,
IN
USIGN16
mode
,
OUT
T_FDLIF_SET_BUSPARAMETER_REQ
FAR
*
bus_param_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for FDL operation
using ASPC2. (use this function only to version 5.02)
IN: baud_rate -> desired baudrate (see valid baudrates)
IN: station_addr -> desired station address (0..126)
IN: in_ring_desired -> PB_TRUE active station (master)
PB_FALSE passive station (slave)
IN: mode -> FMS_FM7_MODE standalone FMS/FM7 operation
DP_MODE standalone DP operation
DP_FMS_FM7_MODE simultaneous DP/FMS/FM7 operation
OUT: bus_param_ptr -> pointer to FDLIF bus parameter structure
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
PB_BOOL
ret_val
=
PB_TRUE
;
T_FMB_SET_BUSPARAMETER_REQ
bus_param
;
FUNCTION_BODY
switch
(
mode
)
{
case
DP_MODE
:
/* only DP mode */
ret_val
=
pbt_get_bus_param_for_dp
(
baud_rate
,
&
bus_param
);
break
;
case
DP_FMS_FM7_MODE
:
/* mixed mode FMS-FM7 and DP */
ret_val
=
pbt_get_bus_param_for_dpfms
(
baud_rate
,
&
bus_param
);
break
;
case
FMS_FM7_MODE
:
/* only FMS mode */
ret_val
=
pbt_get_bus_param_for_fms
(
baud_rate
,
&
bus_param
);
break
;
default:
ret_val
=
PB_FALSE
;
break
;
}
if
(
ret_val
==
PB_TRUE
)
{
/* -- set variable busparametes ---------------------------------------- */
bus_param_ptr
->
tsl
=
bus_param
.
tsl
;
bus_param_ptr
->
min_tsdr
=
bus_param
.
min_tsdr
;
bus_param_ptr
->
max_tsdr
=
bus_param
.
max_tsdr
;
bus_param_ptr
->
tqui
=
bus_param
.
tqui
;
bus_param_ptr
->
tset
=
bus_param
.
tset
;
bus_param_ptr
->
ttr
=
bus_param
.
ttr
;
bus_param_ptr
->
g
=
bus_param
.
g
;
bus_param_ptr
->
max_retry_limit
=
bus_param
.
max_retry_limit
;
/* -- set fix busparametes -------------------------------------------- */
bus_param_ptr
->
in_ring_desired
=
in_ring_desired
;
bus_param_ptr
->
loc_add
=
station_addr
;
bus_param_ptr
->
loc_segm
=
0xFF
;
bus_param_ptr
->
baud_rate
=
baud_rate
;
bus_param_ptr
->
hsa
=
HSA
;
bus_param_ptr
->
medium_red
=
NO_REDUNDANCY
;
bus_param_ptr
->
ident
[
0
]
=
0
;
bus_param_ptr
->
ident
[
1
]
=
0
;
bus_param_ptr
->
ident
[
2
]
=
0
;
bus_param_ptr
->
ident
[
3
]
=
0
;
}
return
(
ret_val
);
}
FUNCTION
GLOBAL
PB_BOOL
CALL_CONV
pbt_get_fmb_def_bus_param
(
IN
USIGN8
baud_rate
,
IN
USIGN8
station_addr
,
IN
PB_BOOL
in_ring_desired
,
IN
USIGN16
mode
,
OUT
T_FMB_SET_BUSPARAMETER_REQ
FAR
*
bus_param_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for FMB operation
using ASPC2.
IN: baud_rate -> desired baudrate (see valid baudrates)
IN: station_addr -> desired station address (0..126)
IN: in_ring_desired -> PB_TRUE active station (master)
PB_FALSE passive station (slave)
IN: mode -> DP_MODE standalone DP operation
DP_FMS_FM7_MODE simultaneous DP/FMS/FM7 operation
FMS_FM7_MODE standalone FMS/FM7 operation
OUT: bus_param_ptr -> pointer to FMB bus parameter structure
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
PB_BOOL
ret_val
=
PB_TRUE
;
T_FMB_SET_BUSPARAMETER_REQ
bus_param
;
FUNCTION_BODY
switch
(
mode
)
{
case
DP_MODE
:
/* only DP mode */
ret_val
=
pbt_get_bus_param_for_dp
(
baud_rate
,
&
bus_param
);
break
;
case
DP_FMS_FM7_MODE
:
/* mixed mode FMS-FM7 and DP */
ret_val
=
pbt_get_bus_param_for_dpfms
(
baud_rate
,
&
bus_param
);
break
;
case
FMS_FM7_MODE
:
/* only FMS mode */
ret_val
=
pbt_get_bus_param_for_fms
(
baud_rate
,
&
bus_param
);
break
;
default:
ret_val
=
PB_FALSE
;
break
;
}
if
(
ret_val
==
PB_TRUE
)
{
/* -- set variable busparametes ---------------------------------------- */
bus_param_ptr
->
tsl
=
bus_param
.
tsl
;
bus_param_ptr
->
min_tsdr
=
bus_param
.
min_tsdr
;
bus_param_ptr
->
max_tsdr
=
bus_param
.
max_tsdr
;
bus_param_ptr
->
tqui
=
bus_param
.
tqui
;
bus_param_ptr
->
tset
=
bus_param
.
tset
;
bus_param_ptr
->
ttr
=
bus_param
.
ttr
;
bus_param_ptr
->
g
=
bus_param
.
g
;
bus_param_ptr
->
max_retry_limit
=
bus_param
.
max_retry_limit
;
/* -- set fix busparametes -------------------------------------------- */
bus_param_ptr
->
in_ring_desired
=
in_ring_desired
;
bus_param_ptr
->
loc_add
=
station_addr
;
bus_param_ptr
->
loc_segm
=
0xFF
;
bus_param_ptr
->
baud_rate
=
baud_rate
;
bus_param_ptr
->
hsa
=
HSA
;
bus_param_ptr
->
medium_red
=
NO_REDUNDANCY
;
}
return
(
ret_val
);
}
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack
#endif
profibus/lib/rt/src/os_linux/ccrl.c
0 → 100644
View file @
0135e84d
/*****************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
* D-85540 Haar *
* Phone: ++49-89-4 56 56-0 *
* Fax: ++49-89-4 56 56-3 99 *
* *
* Copyright (C) SOFTING AG 1995-2003 *
* All Rights Reserved *
* *
******************************************************************************
FILE_NAME CCRL.C
PROJECT_NAME PROFIBUS
MODULE CCRL
COMPONENT_LIBRARY PBT LIBs and DLL (16-Bit)
PBTOOLS.DLL (32-Bit)
AUTHOR SOFTING AG
VERSION 5.00
5.01
5.02
5.10
5.11
5.20.0.00.alpha
5.20.0.00.release
5.21.0.00.release
DATE 24-November-1995
31-January-1996
14-July-1996
20-Febrary-1997
18-March-1997
30-July-1997
17-October-1997
27-February-1998
STATUS finished
FUNCTIONAL_MODULE_DESCRIPTION
If you, as a PROFIBUS-API programmer, configurate your PROFIBUS board,
you must know - among other things - how many resources are allocated by your
CRL. The functions 'ccrl_resrces_init' and 'ccrl_resrces_add_entry' will
help you to get this information.
The CRL-resources are of different types. There are FAL-SDBs, FDL-SDBs,
Data-Buffers, API-Buffers, Poll-List-Entries and Subscriber-List-Entries.
If you use the 'ccrl_resrces_...' functions, you must know neither the
meaning of the resource types nor the algorithm for calculating the number
of resources!
You get the number of resources as follows:
At first, call 'ccrl_resrces_init' with a pointer to the CRL-Header as input
parameter.
Then, for every CRL-Entry, call 'ccrl_resrces_add_entry'. This function has
three parameter:
first: input / communication reference
second: transient / pointer to CRL entry
third: output / pointer to a buffer with a minimum length of
sizeof(T_FMB_CONFIG_CRL) bytes
'ccrl_resrces_add_entry' does two action. First, it checks the CRL entry.
If the entry incorrect it tries to make it correct, otherwise it returns
with a negative result. If the entry is OK, 'ccrl_resrces_add_entry'
calculates resources. After function return, the output buffer holds the
sum of resources that are needed by all CRL entries that where put into
'ccrl_resrces_add_entry' since last call of 'ccrl_resrces_init'.
So, if you have put all entries of your CRL into 'ccrl_resrces_add_entry'
the output buffer of the last function call contains the number of resources
that are needed for your whole CRL. You can use this result as input for the
PROFIBUS configuration service (see typedef T_FMB_SET_CONFIGURATION_REQ).
A detailed description of the algorithm within 'ccrl_resrces_add_entry' is
given in the user manual.
RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"
INCLUDES
#include <stdio.h>
#include <stdlib.h>
#if defined (WIN16) || defined (WIN32)
#include <windows.h>
#endif
#include <pb_type.h>
#include <pb_if.h>
#include <pb_fmb.h>
#include <pb_fm7.h>
#include <pb_err.h>
#include <pb_tools.h>
LOCAL_DEFINES
#define M_MM 0x00
/* Master in Master/Master connection */
#define M_MS 0x02
/* Master in Master/Slave connection */
#define S_MS 0x03
/* Slave in a Master/Slave connection */
#define S_CL 0x08
/* Broadcast/Multicast Sender */
#define R_CL 0x09
/* Broadcast/Multicast Receiver */
#define LLI_EVT_BIT LLI_E
/* LLI events are enabled/disabled */
#define _CCRL_MAP_SAP_NR(sap) (USIGN8)((sap == 128)?64:sap)
#define _IS_I_CONN(x) ((x & 0x03) == I_CONN)
#define _IS_CYCLIC(type) (type & 0x02)
#define _WITHOUT_SLAVE_INITIATIVE(type) (!(type & 0x04))
#define _IS_CONN_LESS(x) ((x & 0x09) == BRCT)
#define _IS_CONN_ORIENTED(x) (!_IS_CONN_LESS(x))
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
LOCAL_TYPEDEFS
typedef
struct
_T_CCRL_CONN_RESRCES
{
USIGN8
no_of_fal_sdbs
;
USIGN8
no_of_fdl_sdbs
;
USIGN8
no_of_data_buffer
;
USIGN8
no_of_api_buffer
;
}
T_CCRL_CONN_RESRCES
;
typedef
struct
_T_CCRL
{
T_FMB_CONFIG_CRL
ccrl
;
USIGN8
poll_sap
;
PB_BOOL
mms_exist
;
USIGN8
rcv_resrces
;
T_CCRL_CONN_RESRCES
isap_resrces
[
65
];
}
T_CCRL
;
FUNCTION_DECLARATIONS
EXPORT_DATA
IMPORT_DATA
LOCAL_DATA
static
T_CCRL
ccrl_obj
;
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack (off)
#endif
FUNCTION
LOCAL
USIGN16
ccrl_determine_role
(
IN
T_CRL_STATIC
FAR
*
crl_ptr
,
IN
USIGN8
*
role_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function determines the role in which the station acts in a connection.
The possible roles are:
M_MM -> Master in a Master/Master connection
M_MS -> Master in a Master/Slave connection
S_MS -> Slave in a Master/Slave connection
S_CL -> Sender of multicast/broadcast messages
R_CL -> Receiver of multicast/broadcast messages
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
((
USIGN8
)
(
crl_ptr
->
conn_type
&
0x0F
))
{
case
MMAC
:
*
role_ptr
=
M_MM
;
return
(
E_OK
);
case
MSAC
:
case
MSAC_SI
:
case
MSCY
:
case
MSCY_SI
:
if
(
crl_ptr
->
loc_lsap
==
ccrl_obj
.
poll_sap
)
*
role_ptr
=
M_MS
;
else
*
role_ptr
=
S_MS
;
return
(
E_OK
);
case
MULT
:
case
BRCT
:
if
(
crl_ptr
->
rem_add
==
127
)
*
role_ptr
=
S_CL
;
else
*
role_ptr
=
R_CL
;
return
(
E_OK
);
default:
return
(
E_FM7_CRL_INVALID_ENTRY
);
}
}
FUNCTION
LOCAL
VOID
ccrl_correct_crl_entry
(
IN
USIGN16
cr
,
IN
USIGN8
role
,
INOUT
T_CRL_STATIC
FAR
*
crl_ptr
)
/*------------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
------------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
if
(
crl_ptr
->
lli_sap
==
1
)
{
if
(
cr
>
1
)
{
/* There is a management client ----------------------------------------- */
crl_ptr
->
max_scc
=
1
;
crl_ptr
->
max_sac
=
0
;
crl_ptr
->
max_rcc
=
0
;
crl_ptr
->
max_rac
=
0
;
}
else
/* (cr == 1) */
{
/* There is a management server ----------------------------------------- */
crl_ptr
->
max_scc
=
0
;
crl_ptr
->
max_sac
=
0
;
crl_ptr
->
max_rcc
=
1
;
crl_ptr
->
max_rac
=
0
;
}
}
if
(
role
==
M_MS
)
{
crl_ptr
->
max_rcc
=
0
;
if
(
_IS_CYCLIC
(
crl_ptr
->
conn_type
))
crl_ptr
->
max_scc
=
0
;
if
(
_WITHOUT_SLAVE_INITIATIVE
(
crl_ptr
->
conn_type
))
crl_ptr
->
max_rac
=
0
;
}
else
if
(
role
==
S_MS
)
{
crl_ptr
->
max_scc
=
0
;
if
(
_IS_CYCLIC
(
crl_ptr
->
conn_type
))
crl_ptr
->
max_rcc
=
0
;
if
(
_WITHOUT_SLAVE_INITIATIVE
(
crl_ptr
->
conn_type
))
crl_ptr
->
max_sac
=
0
;
}
return
;
}
FUNCTION
LOCAL
VOID
ccrl_update_resrc_ctr
(
INOUT
USIGN8
*
stored_number_ptr
,
INOUT
USIGN8
*
current_number_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
USIGN8
diff
;
FUNCTION_BODY
if
(
*
stored_number_ptr
<
*
current_number_ptr
)
{
diff
=
(
USIGN8
)
(
*
current_number_ptr
-
*
stored_number_ptr
);
*
stored_number_ptr
=
*
current_number_ptr
;
*
current_number_ptr
=
diff
;
}
else
{
*
current_number_ptr
=
0
;
}
return
;
}
FUNCTION
LOCAL
VOID
ccrl_adapt_resrces
(
IN
T_CCRL_CONN_RESRCES
*
in_resrces_ptr
,
INOUT
T_CCRL_CONN_RESRCES
*
out_resrces_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
ccrl_update_resrc_ctr
(
&
in_resrces_ptr
->
no_of_fal_sdbs
,
&
out_resrces_ptr
->
no_of_fal_sdbs
);
ccrl_update_resrc_ctr
(
&
in_resrces_ptr
->
no_of_fdl_sdbs
,
&
out_resrces_ptr
->
no_of_fdl_sdbs
);
ccrl_update_resrc_ctr
(
&
in_resrces_ptr
->
no_of_data_buffer
,
&
out_resrces_ptr
->
no_of_data_buffer
);
ccrl_update_resrc_ctr
(
&
in_resrces_ptr
->
no_of_api_buffer
,
&
out_resrces_ptr
->
no_of_api_buffer
);
return
;
}
/******************************************************************************/
/* EXPORTED FUNCTIONS */
/******************************************************************************/
FUNCTION
GLOBAL
VOID
CALL_CONV
ccrl_resrces_init
(
IN
T_CRL_HDR
FAR
*
crl_hdr_ptr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
At first this function has to be called to initialize the internal structures
for calculating the memory requirements.
possible return values:
- NONE
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
USIGN8
i
;
FUNCTION_BODY
ccrl_obj
.
ccrl
.
max_no_fal_sdbs
=
0
;
ccrl_obj
.
ccrl
.
max_no_fdl_sdbs
=
0
;
ccrl_obj
.
ccrl
.
max_no_data_buffer
=
0
;
ccrl_obj
.
ccrl
.
max_no_api_buffer
=
0
;
ccrl_obj
.
ccrl
.
max_no_poll_entries
=
0
;
ccrl_obj
.
ccrl
.
max_no_subscr_entries
=
0
;
ccrl_obj
.
poll_sap
=
crl_hdr_ptr
->
poll_sap
;
ccrl_obj
.
mms_exist
=
PB_FALSE
;
for
(
i
=
0
;
i
<
65
;
i
++
)
{
ccrl_obj
.
isap_resrces
[
i
].
no_of_fal_sdbs
=
0
;
ccrl_obj
.
isap_resrces
[
i
].
no_of_fdl_sdbs
=
0
;
ccrl_obj
.
isap_resrces
[
i
].
no_of_data_buffer
=
0
;
ccrl_obj
.
isap_resrces
[
i
].
no_of_api_buffer
=
0
;
}
return
;
}
FUNCTION
GLOBAL
USIGN16
CALL_CONV
ccrl_resrces_add_entry
(
IN
USIGN16
cr
,
IN
T_CRL_STATIC
FAR
*
crl_ptr
,
OUT
T_FMB_CONFIG_CRL
FAR
*
config_ptr
)
/*------------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
For each CRL entry this function has to be called to evaluate the number of resources.
Two actions are performed by this function. First, it checks the CRL entry.
If the entry is incorrect it tries to correct it. If the entry cannot be corrected
it returns with a negative result. If the entry is OK, this function calculates the
resources. After function return, the output buffer holds the sum of resources that
are needed by all CRL entries that where put into ccrl_resrces_add_entry since last
call of ccrl_resrces_init. The result after the last call of ccrl_resrces_add_entry
this is the number of all needed resources for the whole CRL. This result can be used
as input for the PROFIBUS configuration service.
IN: cr -> communication reference
IN: crl_ptr -> pointer to static part of the CRL entry
OUT: config_ptr -> pointer to CRL configuraton structure
possible return values:
- E_OK -> function executed correctly
- E_FM7_CRL_INVALID_ENTRY -> invalid entry found in CRL, resources are not
calculated
----------------------------------------------------------------------------- */
{
LOCAL_VARIABLES
USIGN8
role
;
USIGN8
max_scc
;
USIGN8
max_sac
;
USIGN8
max_rcc
;
USIGN8
max_rac
;
USIGN32
ci
;
USIGN8
multiplier
;
USIGN8
snd_req
;
USIGN8
snd_req_csrd
;
USIGN8
snd_req_srd
;
USIGN8
rcv_res
;
USIGN8
rcv_ind
;
USIGN8
rcv_ind_csrd
;
USIGN8
snd_res_srd
;
USIGN8
lli_api_resrc
;
USIGN8
lli_api_snd_resrc
;
USIGN8
lli_sr_snd_resrc
;
USIGN8
lli_rcv_ind
;
USIGN8
lli_poll_elem
;
USIGN8
lli_idm
;
USIGN8
lli_evt_resrc
;
USIGN8
fdl_sap
;
USIGN8
fdl_rsap
;
USIGN16
no_of_fal_sdbs
;
USIGN16
no_of_fdl_sdbs
;
USIGN16
no_of_data_buffer
;
USIGN16
no_of_api_buffer
;
USIGN16
result
;
T_CCRL_CONN_RESRCES
conn_resrc
;
FUNCTION_BODY
if
((
result
=
ccrl_determine_role
(
crl_ptr
,
&
role
))
!=
E_OK
)
return
(
result
);
ccrl_correct_crl_entry
(
cr
,
role
,
crl_ptr
);
max_scc
=
crl_ptr
->
max_scc
;
max_sac
=
crl_ptr
->
max_sac
;
max_rcc
=
crl_ptr
->
max_rcc
;
max_rac
=
crl_ptr
->
max_rac
;
ci
=
crl_ptr
->
ci
;
multiplier
=
crl_ptr
->
multiplier
;
snd_req
=
0
;
/* (FAL + DATA) + FDL */
snd_req_csrd
=
0
;
/* (FAL + DATA) */
snd_req_srd
=
0
;
/* (FDL + DATA) */
rcv_res
=
0
;
/* (FDL + DATA) */
rcv_ind
=
0
;
/* (FDL + DATA) + FAL */
rcv_ind_csrd
=
0
;
/* (FAL + DATA) */
snd_res_srd
=
0
;
/* (FDL + API) */
lli_api_resrc
=
0
;
/* (FAL + API) */
lli_api_snd_resrc
=
0
;
/* (FAL + API) + FDL */
lli_sr_snd_resrc
=
0
;
/* (FAL + DATA) + FDL */
lli_rcv_ind
=
0
;
/* (FDL + DATA) */
lli_poll_elem
=
0
;
/* (POLL + API) + (FDL + DATA) */
lli_idm
=
0
;
/* (DATA) */
lli_evt_resrc
=
0
;
/* (FAL + DATA) */
fdl_sap
=
0
;
/* (FDL) */
fdl_rsap
=
0
;
/* (DATA or FDL + DATA) */
switch
(
role
)
{
case
M_MM
:
/* Master in Master/Master Connection ----------------------------- */
snd_req
=
(
USIGN8
)
(
max
(
1
,
/* snd ASS.req */
(
max_scc
/* snd DTC.req */
+
max_sac
))
/* snd DTA.req */
+
1
/* snd ABT.req */
);
lli_api_snd_resrc
=
(
USIGN8
)
(
min
(
ci
,
1
)
/* snd IDLE.req */
+
1
/* LLI abort resrc */
);
rcv_res
=
(
USIGN8
)
(
max
(
1
,
/* rcv ASS_RES_PDU */
(
max_scc
/* rcv DTC_RES_PDU */
+
max_sac
))
/* rcv DTA_ACK_PDU */
);
rcv_ind
=
(
USIGN8
)
(
max
(
1
,
/* rcv ASS_REQ_PDU */
(
max_rcc
/* rcv DTC_REQ_PDU */
+
max_rac
))
/* rcv DTA_REQ_PDU */
+
1
/* rcv ABT_REQ_PDU */
);
lli_rcv_ind
=
(
USIGN8
)
min
(
ci
,
1
);
/* rcv IDLE_REQ_PDU */
fdl_sap
=
1
;
/* act/deact LSAP */
break
;
case
M_MS
:
/* Master in a cyclic master/slave connection --------------------- */
if
(
_IS_CYCLIC
(
crl_ptr
->
conn_type
))
{
max_scc
=
1
;
ci
=
0
;
lli_idm
=
1
;
/* image data memory */
if
(
crl_ptr
->
conn_type
&
LLI_EVT_BIT
)
lli_evt_resrc
=
1
;
}
else
/* _IS_ACYCLIC (crl_ptr->conn_type) */
{
multiplier
=
1
;
}
lli_poll_elem
=
(
USIGN8
)
(
max
(
multiplier
,
1
));
/* poll_list_element */
lli_api_resrc
=
(
USIGN8
)
(
min
(
ci
,
1
)
/* snd IDLE_REQ_PDU */
+
1
/* LLI abort resrc */
);
snd_req_csrd
=
(
USIGN8
)
(
max
(
1
,
/* snd ASS.req */
(
max_scc
/* snd DTC.req */
+
max_sac
))
/* snd DTA.req */
+
1
/* snd ABT.req */
);
snd_req_srd
=
max_sac
;
/* snd DTA.req (high) */
rcv_ind_csrd
=
(
USIGN8
)
(
max_rac
/* rcv DTA_REQ_PDU */
+
1
/* rcv ABT_REQ_PDU */
);
snd_res_srd
=
max_rac
;
/* snd DTA.ack (high)*/
if
(
!
ccrl_obj
.
mms_exist
)
{
fdl_sap
=
1
;
ccrl_obj
.
mms_exist
=
PB_TRUE
;
}
break
;
case
S_MS
:
/* Slave in a master/slave connection ----------------------------- */
fdl_rsap
=
1
;
/* reply update buffer */
if
(
_IS_CYCLIC
(
crl_ptr
->
conn_type
))
{
max_rcc
=
1
;
ci
=
0
;
lli_idm
=
1
;
/* image data memory */
}
snd_req
=
(
USIGN8
)
(
max_sac
/* snd DTA.req */
+
1
/* snd ABT.req */
);
rcv_res
=
max_sac
;
/* rcv DTA_ACK_PDU */
lli_sr_snd_resrc
=
(
USIGN8
)
(
min
(
ci
,
1
)
/* snd IDLE.req */
+
1
/* LLI abort resrc */
);
rcv_ind
=
(
USIGN8
)
(
max
(
1
,
/* rcv ASS_REQ_PDU */
(
max_rcc
/* rcv DTC_REQ_PDU */
+
max_rac
))
/* rcv DTA_REQ_PDU */
+
1
/* rcv ABT_REQ_PDU */
);
lli_rcv_ind
=
(
USIGN8
)
(
min
(
ci
,
1
)
/* rcv IDLE_REQ_PDU */
+
2
/* rcv poll telegrams */
);
fdl_sap
=
1
;
/* act/deact LSAP */
break
;
case
S_CL
:
/* Broadcast/Multicast Sender ------------------------------------- */
snd_req
=
(
USIGN8
)
max
(
1
,
max_sac
);
/* snd DTU.req */
fdl_sap
=
1
;
/* act/deact LSAP */
break
;
case
R_CL
:
/* Broadcast/Multicast Receiver ----------------------------------- */
rcv_ind
=
(
USIGN8
)
max
(
1
,
max_rac
);
/* rcv DTU_REQ_PDU */
fdl_sap
=
1
;
/* act/deact LSAP */
break
;
default:
return
(
E_FM7_CRL_INVALID_ENTRY
);
}
no_of_fal_sdbs
=
(
USIGN16
)
(
snd_req
+
snd_req_csrd
+
rcv_ind
+
rcv_ind_csrd
+
lli_api_resrc
+
lli_api_snd_resrc
+
lli_sr_snd_resrc
+
lli_evt_resrc
);
no_of_fdl_sdbs
=
(
USIGN16
)
(
snd_req
+
snd_req_srd
+
rcv_res
+
rcv_ind
+
snd_res_srd
+
lli_api_snd_resrc
+
lli_sr_snd_resrc
+
lli_rcv_ind
+
fdl_sap
+
lli_poll_elem
);
no_of_fdl_sdbs
=
(
USIGN16
)
(
no_of_fdl_sdbs
+
fdl_rsap
);
no_of_data_buffer
=
(
USIGN16
)
(
snd_req
+
snd_req_csrd
+
snd_req_srd
+
rcv_res
+
rcv_ind
+
rcv_ind_csrd
+
lli_sr_snd_resrc
+
lli_poll_elem
+
lli_idm
+
lli_rcv_ind
+
fdl_rsap
+
lli_evt_resrc
);
no_of_api_buffer
=
(
USIGN16
)
(
snd_res_srd
+
lli_api_resrc
+
lli_api_snd_resrc
+
lli_poll_elem
);
if
(
(
no_of_fal_sdbs
>
0xFF
)
||
(
no_of_fdl_sdbs
>
0xFF
)
||
(
no_of_data_buffer
>
0xFF
)
||
(
no_of_api_buffer
>
0xFF
)
)
{
return
(
E_FM7_CRL_INVALID_ENTRY
);
}
ccrl_obj
.
rcv_resrces
=
(
USIGN8
)
(
rcv_ind
+
lli_rcv_ind
);
conn_resrc
.
no_of_fal_sdbs
=
(
USIGN8
)
no_of_fal_sdbs
;
conn_resrc
.
no_of_fdl_sdbs
=
(
USIGN8
)
no_of_fdl_sdbs
;
conn_resrc
.
no_of_data_buffer
=
(
USIGN8
)
no_of_data_buffer
;
conn_resrc
.
no_of_api_buffer
=
(
USIGN8
)
no_of_api_buffer
;
if
((
role
==
M_MM
)
&&
(
_IS_I_CONN
(
crl_ptr
->
conn_attr
)))
{
ccrl_adapt_resrces
(
&
ccrl_obj
.
isap_resrces
[
_CCRL_MAP_SAP_NR
(
crl_ptr
->
loc_lsap
)],
&
conn_resrc
);
}
ccrl_obj
.
ccrl
.
max_no_fal_sdbs
=
(
USIGN16
)
(
ccrl_obj
.
ccrl
.
max_no_fal_sdbs
+
conn_resrc
.
no_of_fal_sdbs
);
ccrl_obj
.
ccrl
.
max_no_fdl_sdbs
=
(
USIGN16
)
(
ccrl_obj
.
ccrl
.
max_no_fdl_sdbs
+
conn_resrc
.
no_of_fdl_sdbs
);
ccrl_obj
.
ccrl
.
max_no_data_buffer
=
(
USIGN16
)
(
ccrl_obj
.
ccrl
.
max_no_data_buffer
+
conn_resrc
.
no_of_data_buffer
);
ccrl_obj
.
ccrl
.
max_no_api_buffer
=
(
USIGN16
)
(
ccrl_obj
.
ccrl
.
max_no_api_buffer
+
conn_resrc
.
no_of_api_buffer
);
ccrl_obj
.
ccrl
.
max_no_poll_entries
=
(
USIGN16
)
(
ccrl_obj
.
ccrl
.
max_no_poll_entries
+
lli_poll_elem
);
*
config_ptr
=
ccrl_obj
.
ccrl
;
return
(
result
);
}
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack
#endif
profibus/lib/rt/src/os_linux/dpgdl.c
0 → 100644
View file @
0135e84d
/*****************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
* D-85540 Haar *
* Phone: ++49-89-4 56 56-0 *
* Fax: ++49-89-4 56 56-3 99 *
* *
* Copyright (C) SOFTING AG 1995-2003 *
* All Rights Reserved *
* *
******************************************************************************
FILE_NAME DPGDL.C
PROJECT_NAME PROFIBUS
MODULE DPGDL
COMPONENT_LIBRARY PAPI Lib
PAPI DLL
AUTHOR SOFTING AG
VERSION 5.22.0.00.release
DATE 26-February-1999
STATUS finished
FUNCTIONAL_MODULE_DESCRIPTION
This modul contains DP-Service-Specific-Functions which return the length
length of the Request- or Response-Datas.
RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"
INCLUDES
#if defined (WIN16) || defined (WIN32)
#include <windows.h>
#endif
#include "pb_type.h"
#include "pb_if.h"
#include "pb_dp.h"
#include "pb_err.h"
FUNCTION_DECLARATIONS
extern
USIGN16
swap_16_intel_motorola
(
USIGN16
);
LOCAL_DEFINES
LOCAL_TYPEDEFS
EXPORT_DATA
IMPORT_DATA
LOCAL_DATA
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack (off)
#endif
FUNCTION
PUBLIC
INT16
dpgdl_get_data_len
(
IN
INT16
result
,
IN
USIGN8
service
,
IN
USIGN8
primitive
,
IN
USIGN8
FAR
*
data_ptr
,
OUT
INT16
FAR
*
data_len_ptr
)
/*------------------------------------------------------------------------*/
/* FUNCTIONAL_DESCRIPTION */
/*------------------------------------------------------------------------*/
/* - returns the data length of any called PROFIBUS DP service */
/*------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
USIGN16
service_data_len
;
FUNCTION_BODY
switch
(
primitive
)
{
/*--- USER REQUESTS ----------------------------------------------------*/
case
REQ
:
{
switch
(
service
)
{
case
DP_DATA_TRANSFER
:
*
data_len_ptr
=
0
;
break
;
case
DP_GLOBAL_CONTROL
:
*
data_len_ptr
=
sizeof
(
T_DP_GLOBAL_CONTROL_REQ
);
break
;
case
DP_ACT_PARAM_LOC
:
case
DP_ACT_PARA_BRCT
:
case
DP_ACT_PARAM
:
*
data_len_ptr
=
sizeof
(
T_DP_ACT_PARAM_REQ
);
break
;
case
DP_INIT_MASTER
:
*
data_len_ptr
=
sizeof
(
T_DP_INIT_MASTER_REQ
);
break
;
case
DP_UPLOAD_LOC
:
case
DP_UPLOAD
:
*
data_len_ptr
=
sizeof
(
T_DP_UPLOAD_REQ
);
break
;
case
DP_DOWNLOAD_LOC
:
case
DP_DOWNLOAD
:
{
if
(((
T_DP_DOWNLOAD_REQ
FAR
*
)
(
data_ptr
))
->
data_len
>
DP_MAX_DOWNLOAD_DATA_LEN
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DP_DOWNLOAD_REQ
)
+
((
T_DP_DOWNLOAD_REQ
FAR
*
)
(
data_ptr
))
->
data_len
;
break
;
}
case
DP_START_SEQ_LOC
:
case
DP_START_SEQ
:
*
data_len_ptr
=
sizeof
(
T_DP_START_SEQ_REQ
);
break
;
case
DP_END_SEQ_LOC
:
case
DP_END_SEQ
:
*
data_len_ptr
=
sizeof
(
T_DP_END_SEQ_REQ
);
break
;
case
DP_GET_SLAVE_DIAG
:
*
data_len_ptr
=
0
;
break
;
case
DP_SET_PRM
:
case
DP_SET_PRM_LOC
:
{
service_data_len
=
swap_16_intel_motorola
(((
T_DP_SET_PRM_REQ
FAR
*
)
(
data_ptr
))
->
prm_data
.
prm_data_len
);
if
(
service_data_len
>
DP_MAX_PRM_DATA_LEN
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DP_SET_PRM_REQ
)
-
sizeof
(
T_DP_PRM_DATA
)
+
service_data_len
;
break
;
}
case
DP_CHK_CFG
:
{
service_data_len
=
swap_16_intel_motorola
(((
T_DP_CHK_CFG_REQ
FAR
*
)
(
data_ptr
))
->
cfg_data
.
cfg_data_len
);
if
(
service_data_len
>
DP_MAX_CFG_DATA_LEN
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DP_CHK_CFG_REQ
)
-
sizeof
(
T_DP_CFG_DATA
)
+
service_data_len
;
break
;
}
case
DP_GET_CFG
:
*
data_len_ptr
=
sizeof
(
T_DP_GET_CFG_REQ
);
break
;
case
DP_SLAVE_DIAG
:
*
data_len_ptr
=
sizeof
(
T_DP_SLAVE_DIAG_REQ
);
break
;
case
DP_RD_INP
:
*
data_len_ptr
=
sizeof
(
T_DP_RD_INP_REQ
);
break
;
case
DP_RD_OUTP
:
*
data_len_ptr
=
sizeof
(
T_DP_RD_OUTP_REQ
);
break
;
case
DP_DATA_EXCHANGE
:
{
if
(((
T_DP_DATA_EXCHANGE_REQ
FAR
*
)
(
data_ptr
))
->
outp_data_len
>
DP_MAX_OUTPUT_DATA_LEN
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DP_DATA_EXCHANGE_REQ
)
+
((
T_DP_DATA_EXCHANGE_REQ
FAR
*
)
(
data_ptr
))
->
outp_data_len
;
break
;
}
case
DP_SET_SLAVE_ADD
:
{
if
(((
T_DP_SET_SLAVE_ADD_REQ
FAR
*
)
(
data_ptr
))
->
rem_slave_data_len
>
DP_MAX_REM_SLAVE_DATA_LEN
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DP_SET_SLAVE_ADD_REQ
)
+
((
T_DP_SET_SLAVE_ADD_REQ
FAR
*
)
(
data_ptr
))
->
rem_slave_data_len
;
break
;
}
case
DP_GET_MASTER_DIAG_LOC
:
case
DP_GET_MASTER_DIAG
:
*
data_len_ptr
=
sizeof
(
T_DP_GET_MASTER_DIAG_REQ
);
break
;
case
DP_GET_SLAVE_PARAM
:
*
data_len_ptr
=
sizeof
(
T_DP_GET_SLAVE_PARAM_REQ
);
break
;
case
DP_EXIT_MASTER
:
*
data_len_ptr
=
0
;
break
;
case
DP_SET_BUSPARAMETER
:
{
if
(
(((
T_DP_SET_BUSPARAMETER_REQ
FAR
*
)
(
data_ptr
))
->
master_user_data_len
>
DP_MAX_SET_BUSPARAMETER_LEN
)
||
(((
T_DP_SET_BUSPARAMETER_REQ
FAR
*
)
(
data_ptr
))
->
master_user_data_len
<
DP_MASTER_USER_DATA_LEN
)
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DP_SET_BUSPARAMETER_REQ
)
+
((
T_DP_SET_BUSPARAMETER_REQ
FAR
*
)
(
data_ptr
))
->
master_user_data_len
-
DP_MASTER_USER_DATA_LEN
;
break
;
}
case
DP_SET_MASTER_PARAM
:
{
if
(
((
T_DP_SET_MASTER_PARAM_REQ
FAR
*
)
(
data_ptr
))
->
data_len
>
DP_MAX_TELEGRAM_LEN
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DP_SET_MASTER_PARAM_REQ
)
+
((
T_DP_SET_MASTER_PARAM_REQ
FAR
*
)
(
data_ptr
))
->
data_len
;
break
;
}
case
DP_INITIATE
:
*
data_len_ptr
=
sizeof
(
T_DP_INITIATE_REQ
)
+
((
T_DP_INITIATE_REQ
FAR
*
)
(
data_ptr
))
->
add_addr_param
.
s_len
+
((
T_DP_INITIATE_REQ
FAR
*
)
(
data_ptr
))
->
add_addr_param
.
d_len
;
break
;
case
DP_ABORT
:
*
data_len_ptr
=
sizeof
(
T_DP_ABORT_REQ
);
break
;
case
DP_READ
:
*
data_len_ptr
=
sizeof
(
T_DP_READ_REQ
);
break
;
case
DP_WRITE
:
*
data_len_ptr
=
sizeof
(
T_DP_WRITE_REQ
)
+
((
T_DP_WRITE_REQ
FAR
*
)
(
data_ptr
))
->
length
;
break
;
case
DP_DATA_TRANSPORT
:
*
data_len_ptr
=
sizeof
(
T_DP_DATA_TRANSPORT_REQ
)
+
((
T_DP_DATA_TRANSPORT_REQ
FAR
*
)
(
data_ptr
))
->
length
;
break
;
default:
result
=
E_IF_INVALID_SERVICE
;
return
(
E_IF_INVALID_SERVICE
);
}
/* switch serivce */
break
;
}
/* case REQ */
/*---- USER RESPONSES --------------------------------------------------*/
case
RES
:
{
switch
(
service
)
{
case
DP_ACT_PARAM
:
*
data_len_ptr
=
sizeof
(
T_DP_ACT_PARAM_RES_CON
);
break
;
case
DP_DOWNLOAD
:
*
data_len_ptr
=
sizeof
(
T_DP_DOWNLOAD_RES_CON
);
break
;
case
DP_START_SEQ
:
*
data_len_ptr
=
sizeof
(
T_DP_START_SEQ_RES_CON
);
break
;
case
DP_END_SEQ
:
*
data_len_ptr
=
sizeof
(
T_DP_END_SEQ_RES_CON
);
break
;
case
DP_UPLOAD
:
{
if
(((
T_DP_UPLOAD_RES_CON
FAR
*
)
(
data_ptr
))
->
data_len
>
DP_MAX_UPLOAD_DATA_LEN
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DP_UPLOAD_RES_CON
)
+
((
T_DP_UPLOAD_RES_CON
FAR
*
)
(
data_ptr
))
->
data_len
;
break
;
}
case
DP_GET_MASTER_DIAG
:
{
if
(((
T_DP_GET_MASTER_DIAG_RES_CON
FAR
*
)
(
data_ptr
))
->
data_len
>
DP_MAX_TELEGRAM_LEN
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DP_GET_MASTER_DIAG_RES_CON
)
+
((
T_DP_GET_MASTER_DIAG_RES_CON
FAR
*
)
(
data_ptr
))
->
data_len
;
break
;
}
default:
result
=
E_IF_INVALID_SERVICE
;
return
(
E_IF_INVALID_SERVICE
);
}
/* switch serivce */
break
;
}
/* case RES */
/*---- WRONG PRIMITIVE -------------------------------------------------*/
default:
result
=
E_IF_INVALID_PRIMITIVE
;
return
(
E_IF_INVALID_PRIMITIVE
);
}
/* switch primitive */
result
=
E_OK
;
return
(
E_OK
);
}
/* dp_get_data_len */
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack
#endif
profibus/lib/rt/src/os_linux/dpsgdl.c
0 → 100644
View file @
0135e84d
/*****************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
* D-85540 Haar *
* Phone: ++49-89-4 56 56-0 *
* Fax: ++49-89-4 56 56-3 99 *
* *
* Copyright (C) SOFTING AG 1998-2003 *
* All Rights Reserved *
* *
******************************************************************************
FILE_NAME DPSGDL.C
PROJECT_NAME PROFIBUS
MODULE DPSGDL
COMPONENT_LIBRARY PAPI Lib
PAPI DLL
AUTHOR SOFTING AG
VERSION 1.20.0.00.release (DP-Slave Stand-Alone for DOS)
5.22.0.00.release (WIN95/WIN98 and WinNT)
DATE 26-February-1999
STATUS finished
FUNCTIONAL_MODULE_DESCRIPTION
This modul contains DP-Slave-Service-Specific-Functions which return the length
length of the Request- or Response-Datas.
RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"
INCLUDES
#if defined (WIN16) || defined (WIN32)
#include <windows.h>
#endif
#include "pb_type.h"
#include "pb_if.h"
#ifndef DPS_STANDALONE_MODE
#include "pb_err.h"
#include "pb_dp.h"
#endif
#include "pb_dps.h"
FUNCTION_DECLARATIONS
LOCAL_DEFINES
LOCAL_TYPEDEFS
EXPORT_DATA
IMPORT_DATA
LOCAL_DATA
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack (off)
#endif
FUNCTION
PUBLIC
INT16
dpsgdl_get_data_len
(
IN
INT16
result
,
IN
USIGN8
service
,
IN
USIGN8
primitive
,
IN
USIGN8
FAR
*
data_ptr
,
OUT
INT16
FAR
*
data_len_ptr
)
/*------------------------------------------------------------------------*/
/* FUNCTIONAL_DESCRIPTION */
/*------------------------------------------------------------------------*/
/* - returns the data length of any called PROFIBUS DP-Slave service */
/*------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
T_DPS_INIT_SLAVE_REQ
FAR
*
init_slave_req_ptr
;
T_DPS_SLAVE_DIAG_REQ
FAR
*
slave_diag_req_ptr
;
FUNCTION_BODY
switch
(
primitive
)
{
/*--- USER REQUESTS ----------------------------------------------------*/
case
REQ
:
{
switch
(
service
)
{
case
DPS_INIT_SLAVE
:
{
init_slave_req_ptr
=
(
T_DPS_INIT_SLAVE_REQ
FAR
*
)
data_ptr
;
if
(
(
init_slave_req_ptr
->
cfg_data_len
==
0
)
||
(
init_slave_req_ptr
->
cfg_data_len
>
DP_MAX_CFG_DATA_LEN
)
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
if
(
init_slave_req_ptr
->
enhanced_init_data_len
>
sizeof
(
init_slave_req_ptr
->
enhanced_init_data
))
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DPS_INIT_SLAVE_REQ
)
-
(
sizeof
(
init_slave_req_ptr
->
enhanced_init_data
)
-
init_slave_req_ptr
->
enhanced_init_data_len
);
break
;
}
/* case DPS_INIT_SLAVE */
case
DPS_EXIT_SLAVE
:
*
data_len_ptr
=
0
;
break
;
case
DPS_SLAVE_DIAG
:
{
slave_diag_req_ptr
=
(
T_DPS_SLAVE_DIAG_REQ
FAR
*
)
data_ptr
;
if
(
slave_diag_req_ptr
->
ext_diag_data_len
>
DP_MAX_EXT_DIAG_DATA_LEN
)
{
result
=
E_IF_INVALID_DATA_SIZE
;
return
(
E_IF_INVALID_DATA_SIZE
);
}
*
data_len_ptr
=
sizeof
(
T_DPS_SLAVE_DIAG_REQ
)
-
(
DP_MAX_EXT_DIAG_DATA_LEN
-
slave_diag_req_ptr
->
ext_diag_data_len
);
break
;
}
case
DPS_GET_STATUS
:
*
data_len_ptr
=
0
;
break
;
case
DPS_CHK_CFG
:
case
DPS_SET_PRM
:
case
DPS_SET_SLAVE_ADD
:
result
=
E_IF_INVALID_PRIMITIVE
;
return
(
E_IF_INVALID_PRIMITIVE
);
default
:
result
=
E_IF_INVALID_SERVICE
;
return
(
E_IF_INVALID_SERVICE
);
}
/* switch serivce */
break
;
}
/* case REQ */
/*---- USER RESPONSES --------------------------------------------------*/
case
RES
:
{
switch
(
service
)
{
case
DPS_CHK_CFG
:
*
data_len_ptr
=
sizeof
(
T_DPS_CHK_CFG_RES
);
break
;
case
DPS_SET_PRM
:
*
data_len_ptr
=
sizeof
(
T_DPS_SET_PRM_RES
);
break
;
default:
result
=
E_IF_INVALID_SERVICE
;
return
(
E_IF_INVALID_SERVICE
);
}
/* switch serivce */
break
;
}
/* case RES */
/*---- WRONG PRIMITIVE -------------------------------------------------*/
default:
result
=
E_IF_INVALID_PRIMITIVE
;
return
(
E_IF_INVALID_PRIMITIVE
);
}
/* switch primitive */
result
=
E_OK
;
return
(
E_OK
);
}
/* dpsgdl_get_data_len */
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack
#endif
profibus/lib/rt/src/os_linux/fdlgdl.c
0 → 100644
View file @
0135e84d
/*****************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
* D-85540 Haar *
* Phone: ++49-89-4 56 56-0 *
* Fax: ++49-89-4 56 56-3 99 *
* *
* Copyright (C) SOFTING AG 1995-2003 *
* All Rights Reserved *
* *
******************************************************************************
FILE_NAME FDLGDL.C
PROJECT_NAME PROFIBUS
MODULE FDLGDL
COMPONENT_LIBRARY PAPI Lib
PAPI DLL
AUTHOR SOFTING AG
VERSION 5.23.0.00.release
DATE 30-October-2000
STATUS finished
FUNCTIONAL_MODULE_DESCRIPTION
This modul contains the FDL(IF)-Service-Specific-Functions which return the length
length of the Request- or Response-Datas.
RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"
INCLUDES
#if defined (WIN16) || defined (WIN32)
#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
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack (off)
#endif
FUNCTION
PUBLIC
INT16
fdlgdl_get_data_len
(
IN
INT16
result
,
/* Service-Result */
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
,
/* pointer to data */
OUT
INT16
*
data_len_ptr
/* length of data */
)
/*-----------------------------------------------------------------------------
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
;
result
=
E_OK
;
if
(
primitive
==
REQ
)
{
switch
(
service
)
{
case
FDLIF_SDA
:
case
FDLIF_SDN
:
case
FDLIF_SRD
:
{
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
;
}
break
;
case
FDLIF_REPLY_UPDATE
:
case
FDLIF_REPLY_UPDATE_MULTIPLE
:
{
T_FDLIF_RUP_REQ
FAR
*
req
=
(
T_FDLIF_RUP_REQ
FAR
*
)
data_ptr
;
*
data_len_ptr
=
sizeof
(
T_FDLIF_RUP_REQ
)
+
req
->
length
;
}
break
;
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
;
}
}
else
{
result
=
E_IF_INVALID_PRIMITIVE
;
}
return
(
result
);
}
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack
#endif
profibus/lib/rt/src/os_linux/fm7gdl.c
0 → 100644
View file @
0135e84d
/*****************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
* D-85540 Haar *
* Phone: ++49-89-4 56 56-0 *
* Fax: ++49-89-4 56 56-3 99 *
* *
* Copyright (C) SOFTING AG 1995-2003 *
* All Rights Reserved *
* *
******************************************************************************
FILE_NAME FM7GDL.C
PROJECT_NAME PROFIBUS
MODULE FM7GDL
COMPONENT_LIBRARY PAPI Lib
PAPI DLL
AUTHOR SOFTING AG
VERSION 5.21.0.00.release
DATE 27-February-1998
STATUS finished
FUNCTIONAL_MODULE_DESCRIPTION
This modul contains the FM7-Service-Specific-Functions which return the length
length of the Request- or Response-Datas.
CHANGE_NOTES
Date Name Change
------------------------------------------------------------------------------
RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"
INCLUDES
#if defined (WIN16) || defined (WIN32)
#include <windows.h>
#endif
#include "pb_type.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fm7.h"
GLOBAL_DEFINES
LOCAL_DEFINES
EXPORT_TYPEDEFS
LOCAL_TYPEDEFS
FUNCTION_DECLARATIONS
EXPORT_DATA
IMPORT_DATA
LOCAL_DATA
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack (off)
#endif
FUNCTION
LOCAL
INT16
fm7gdl_get_ctxt_data_len
(
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
/* Service-Primitive */
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following FM7-Context-Management-Services.
- FM7_INITIATE
- FM7_ABORT
possible return values:
- Data-length
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
if
(
service
==
FM7_ABORT
&&
primitive
==
REQ
)
{
return
(
sizeof
(
T_FM7_ABORT_REQ
));
}
else
{
return
(
0
);
}
}
FUNCTION
LOCAL
INT16
fm7gdl_get_crl_data_len
(
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
/* pointer to data */
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following CRL-Services.
- FM7_INIT_LOAD_CRL_LOC
- FM7_INIT_LOAD_CRL_REM
- FM7_LOAD_CRL_LOC
- FM7_LOAD_CRL_REM
- FM7_TERM_LOAD_CRL_LOC
- FM7_TERM_LOAD_CRL_REM
- FM7_READ_CRL_LOC
- FM7_READ_CRL_REM
possible return values:
- Data-length
----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FM7_LOAD_CRL_LOC
:
case
FM7_LOAD_CRL_REM
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_LOAD_CRL_REQ
));
else
return
(
0
);
case
FM7_READ_CRL_LOC
:
case
FM7_READ_CRL_REM
:
if
(
primitive
==
REQ
)
{
return
(
sizeof
(
T_READ_CRL_REQ
));
}
else
{
T_READ_CRL_CNF
FAR
*
rsp
=
(
T_READ_CRL_CNF
FAR
*
)
data_ptr
;
if
(
rsp
->
desired_cr
==
0
)
return
(
sizeof
(
T_READ_CRL_CNF
));
else
return
(
sizeof
(
T_READ_CRL_CNF
)
+
rsp
->
id
.
crl_entry
.
crl_status_len
);
}
default:
return
(
0
);
}
}
FUNCTION
LOCAL
INT16
fm7gdl_get_s_r_value_data_len
(
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
/* pointer to data */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following SET- / Read-Value-Services.
- FM7_SET_BUSPARAMETER
- FM7_READ_BUSPARAMETER
- FM7_SET_VALUE_LOC
- FM7_SET_VALUE_REM
- FM7_READ_VALUE_LOC
- FM7_READ_VALUE_REM
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FM7_SET_VALUE_LOC
:
case
FM7_SET_VALUE_REM
:
if
(
primitive
==
REQ
)
{
T_SET_VALUE_REQ
FAR
*
req
=
(
T_SET_VALUE_REQ
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_SET_VALUE_REQ
)
+
req
->
length
);
}
else
return
(
0
);
case
FM7_SET_BUSPARAMETER
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_SET_BUSPARAMETER_REQ
));
else
return
(
0
);
case
FM7_READ_VALUE_LOC
:
case
FM7_READ_VALUE_REM
:
if
(
primitive
==
REQ
)
{
return
(
sizeof
(
T_READ_VALUE_REQ
));
}
else
{
T_READ_VALUE_CNF
FAR
*
rsp
=
(
T_READ_VALUE_CNF
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_READ_VALUE_CNF
)
+
rsp
->
length
);
}
default:
return
(
0
);
}
}
FUNCTION
LOCAL
INT16
fm7gdl_get_ident_data_len
(
IN
USIGN8
primitive
/* Service-Primitive */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following Ident-Services.
- IDENT_LOC
- IDENT_REM
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_IDENT_REQ
));
else
return
(
sizeof
(
T_IDENT_CNF
));
}
FUNCTION
LOCAL
INT16
fm7gdl_get_live_list_data_len
(
IN
VOID
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas
of the Get-Live-List Service.
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
return
(
0
);
}
FUNCTION
LOCAL
INT16
fm7gdl_get_lsap_status_data_len
(
IN
USIGN8
primitive
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following LSAP-Status Services.
- LSAP_STATUS_LOC
- LSAP_STATUS_REM
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_LSAP_STATUS_REQ
));
else
return
(
sizeof
(
T_LSAP_STATUS_CNF
));
}
FUNCTION
LOCAL
INT16
fm7gdl_get_fault_mngt_data_len
(
IN
VOID
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas
of the following Fault-Management Services.
- RESET
- EXIT
- FM7_EVENT
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
return
(
0
);
}
FUNCTION
LOCAL
INT16
fm7gdl_get_error_data_len
(
IN
USIGN8
service
/* Service */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of response-error-datas
of the following FM7-Services.
- FM7_INITIATE
- FM7_READ_CRL_REM
- FM7_INIT_LOAD_CRL_REM
- FM7_LOAD_CRL_REM
- FM7_TERM_LOAD_CRL_REM
- FM7_SET_VALUE_REM
- FM7_READ_VALUE_REM
- FM7_LSAP_STATUS_REM
- FM7_IDENT_REM
- FM7_READ_CRL_LOC
- FM7_INIT_LOAD_CRL_LOC
- FM7_LOAD_CRL_LOC
- FM7_TERM_LOAD_CRL_LOC
- FM7_SET_VALUE_LOC
- FM7_READ_VALUE_LOC
- FM7_LSAP_STATUS_LOC
- FM7_IDENT_LOC
- FM7_EVENT
- FM7_RESET
- FM7_EXIT
- FM7_SET_BUSPARAMETER
- FM7_READ_BUSPARAMETER
- FM7_GET_LIVE_LIST
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FM7_INITIATE
:
return
(
sizeof
(
T_FM7_INIT_ERR_CNF
));
case
FM7_READ_CRL_REM
:
case
FM7_INIT_LOAD_CRL_REM
:
case
FM7_LOAD_CRL_REM
:
case
FM7_SET_VALUE_REM
:
case
FM7_READ_VALUE_REM
:
case
FM7_LSAP_STATUS_REM
:
case
FM7_IDENT_REM
:
case
FM7_READ_CRL_LOC
:
case
FM7_INIT_LOAD_CRL_LOC
:
case
FM7_LOAD_CRL_LOC
:
case
FM7_SET_VALUE_LOC
:
case
FM7_READ_VALUE_LOC
:
case
FM7_LSAP_STATUS_LOC
:
case
FM7_IDENT_LOC
:
case
FM7_EVENT
:
case
FM7_RESET
:
case
FM7_EXIT
:
case
FM7_SET_BUSPARAMETER
:
case
FM7_READ_BUSPARAMETER
:
case
FM7_GET_LIVE_LIST
:
return
(
sizeof
(
T_ERROR
));
case
FM7_TERM_LOAD_CRL_LOC
:
case
FM7_TERM_LOAD_CRL_REM
:
return
(
sizeof
(
T_CRL_ERROR
));
default:
return
(
0
);
}
}
FUNCTION
PUBLIC
INT16
fm7gdl_get_data_len
(
IN
INT16
result
,
/* Service-Result */
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
,
/* pointer to data */
OUT
INT16
*
data_len_ptr
/* length of data */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
this function is used to return the data length of FM7-SERVICES
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
*
data_len_ptr
=
0
;
switch
(
service
)
{
case
FM7_READ_CRL_LOC
:
case
FM7_INIT_LOAD_CRL_LOC
:
case
FM7_LOAD_CRL_LOC
:
case
FM7_TERM_LOAD_CRL_LOC
:
case
FM7_READ_CRL_REM
:
case
FM7_INIT_LOAD_CRL_REM
:
case
FM7_LOAD_CRL_REM
:
case
FM7_TERM_LOAD_CRL_REM
:
if
(
result
==
POS
)
*
data_len_ptr
=
fm7gdl_get_crl_data_len
(
service
,
primitive
,
data_ptr
);
else
*
data_len_ptr
=
fm7gdl_get_error_data_len
(
service
);
break
;
case
FM7_SET_VALUE_LOC
:
case
FM7_READ_VALUE_LOC
:
case
FM7_SET_BUSPARAMETER
:
case
FM7_READ_BUSPARAMETER
:
case
FM7_SET_VALUE_REM
:
case
FM7_READ_VALUE_REM
:
if
(
result
==
POS
)
*
data_len_ptr
=
fm7gdl_get_s_r_value_data_len
(
service
,
primitive
,
data_ptr
);
else
*
data_len_ptr
=
fm7gdl_get_error_data_len
(
service
);
break
;
case
FM7_LSAP_STATUS_LOC
:
case
FM7_LSAP_STATUS_REM
:
if
(
result
==
POS
)
*
data_len_ptr
=
fm7gdl_get_lsap_status_data_len
(
primitive
);
else
*
data_len_ptr
=
fm7gdl_get_error_data_len
(
service
);
break
;
case
FM7_IDENT_LOC
:
case
FM7_IDENT_REM
:
if
(
result
==
POS
)
*
data_len_ptr
=
fm7gdl_get_ident_data_len
(
primitive
);
else
*
data_len_ptr
=
fm7gdl_get_error_data_len
(
service
);
break
;
case
FM7_EVENT
:
case
FM7_RESET
:
case
FM7_EXIT
:
if
(
result
==
POS
)
*
data_len_ptr
=
fm7gdl_get_fault_mngt_data_len
();
else
*
data_len_ptr
=
fm7gdl_get_error_data_len
(
service
);
break
;
case
FM7_GET_LIVE_LIST
:
if
(
result
==
POS
)
*
data_len_ptr
=
fm7gdl_get_live_list_data_len
();
else
*
data_len_ptr
=
fm7gdl_get_error_data_len
(
service
);
break
;
case
FM7_INITIATE
:
case
FM7_ABORT
:
if
(
result
==
POS
)
*
data_len_ptr
=
fm7gdl_get_ctxt_data_len
(
service
,
primitive
);
else
*
data_len_ptr
=
fm7gdl_get_error_data_len
(
service
);
break
;
default:
return
(
E_IF_INVALID_SERVICE
);
break
;
}
return
(
E_OK
);
}
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack
#endif
profibus/lib/rt/src/os_linux/fmbgdl.c
0 → 100644
View file @
0135e84d
/*****************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
* D-85540 Haar *
* Phone: ++49-89-4 56 56-0 *
* Fax: ++49-89-4 56 56-3 99 *
* *
* Copyright (C) SOFTING AG 1995-2003 *
* All Rights Reserved *
* *
******************************************************************************
FILE_NAME FMBGDL.C
PROJECT_NAME PROFIBUS
MODULE FMBGDL
COMPONENT_LIBRARY PAPI Lib
PAPI DLL
AUTHOR SOFTING AG
VERSION 5.21.0.00.release
DATE 27-February-1998
STATUS finished
FUNCTIONAL_MODULE_DESCRIPTION
This modul contains the Fieldbus Basic Management function which returns the
length of the request datas.
RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"
INCLUDES
#if defined (WIN16) || defined (WIN32)
#include <windows.h>
#endif
#include "pb_type.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
GLOBAL_DEFINES
LOCAL_DEFINES
EXPORT_TYPEDEFS
LOCAL_TYPEDEFS
FUNCTION_DECLARATIONS
EXPORT_DATA
IMPORT_DATA
LOCAL_DATA
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack (off)
#endif
FUNCTION
PUBLIC
INT16
fmbgdl_get_data_len
(
IN
INT16
result
,
/* Service-Result */
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
,
/* pointer to data */
OUT
INT16
*
data_len_ptr
/* length of data */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the request data length of FMB-SERVICES
possible return values:
- E_OK
- E_IF_INVALID_SERVICE
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
INT16
ret_val
=
E_OK
;
FUNCTION_BODY
if
(
primitive
==
REQ
)
{
switch
(
service
)
{
case
FMB_SET_CONFIGURATION
:
{
T_FMB_SET_CONFIGURATION_REQ
FAR
*
req_ptr
=
(
T_FMB_SET_CONFIGURATION_REQ
FAR
*
)
data_ptr
;
#ifdef WIN32
req_ptr
->
sm7_active
&=
0xFE
;
#else
req_ptr
->
sm7_active
=
PB_FALSE
;
#endif
*
data_len_ptr
=
sizeof
(
T_FMB_SET_CONFIGURATION_REQ
);
}
break
;
case
FMB_SET_BUSPARAMETER
:
*
data_len_ptr
=
sizeof
(
T_FMB_SET_BUSPARAMETER_REQ
);
break
;
case
FMB_SET_VALUE
:
{
T_FMB_SET_VALUE_REQ
FAR
*
req
=
(
T_FMB_SET_VALUE_REQ
FAR
*
)
data_ptr
;
*
data_len_ptr
=
(
sizeof
(
T_FMB_SET_VALUE_REQ
)
+
req
->
length
);
break
;
}
case
FMB_READ_VALUE
:
*
data_len_ptr
=
sizeof
(
T_FMB_READ_VALUE_REQ
);
break
;
case
FMB_LSAP_STATUS
:
*
data_len_ptr
=
sizeof
(
T_FMB_LSAP_STATUS_REQ
);
break
;
case
FMB_GET_LIVE_LIST
:
case
FMB_READ_BUSPARAMETER
:
case
FMB_EXIT
:
case
FMB_RESET
:
*
data_len_ptr
=
0
;
break
;
default:
*
data_len_ptr
=
0
;
ret_val
=
E_IF_INVALID_SERVICE
;
break
;
}
}
else
{
ret_val
=
E_IF_INVALID_PRIMITIVE
;
}
return
(
ret_val
);
}
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack
#endif
profibus/lib/rt/src/os_linux/fmsgdl.c
0 → 100644
View file @
0135e84d
/*****************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
* D-85540 Haar *
* Phone: ++49-89-4 56 56-0 *
* Fax: ++49-89-4 56 56-3 99 *
* *
* Copyright (C) SOFTING AG 1995-2003 *
* All Rights Reserved *
* *
******************************************************************************
FILE_NAME FMSGDL.C
PROJECT_NAME PROFIBUS
MODULE FMSGDL
COMPONENT_LIBRARY PAPI Lib
PAPI DLL
AUTHOR SOFTING AG
VERSION 5.21.0.00.release
DATE 27-February-1998
STATUS finished
FUNCTIONAL_MODULE_DESCRIPTION
This modul contains FMS-Service-Specific-Functions which return the length
length of the Request- or Response-Datas.
RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"
INCLUDES
#if defined (WIN16) || defined (WIN32)
#include <windows.h>
#endif
#include "pb_type.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fms.h"
GLOBAL_DEFINES
LOCAL_DEFINES
EXPORT_TYPEDEFS
LOCAL_TYPEDEFS
FUNCTION_DECLARATIONS
EXPORT_DATA
IMPORT_DATA
LOCAL_DATA
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack (off)
#endif
FUNCTION
LOCAL
INT16
fmsgdl_get_ctxt_data_len
(
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
/* Service-Primitive */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following FMS-Context-Management-Services.
- FMS_INITIATE
- FMS_ABORT
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FMS_INITIATE
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_CTXT_INIT_REQ
));
else
return
(
sizeof
(
T_CTXT_INIT_CNF
));
case
FMS_ABORT
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_CTXT_ABORT_REQ
));
else
return
(
0
);
default:
return
(
0
);
}
}
FUNCTION
LOCAL
INT16
fmsgdl_get_vfd_data_len
(
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
/* Service-Primitive */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following VFD-Services.
- FMS_STATUS
- FMS_IDENTIFY
- FMS_UNSOLICITEDSTATUS
- FMS_CREATE_VFD_LOC
- FMS_VFD_SET_PHYS_STATUS_LOC
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FMS_STATUS
:
if
(
primitive
==
RES
)
return
(
sizeof
(
T_VFD_STATUS_CNF
));
else
return
(
0
);
case
FMS_IDENTIFY
:
if
(
primitive
==
RES
)
return
(
sizeof
(
T_VFD_IDENTIFY_CNF
));
else
return
(
0
);
case
FMS_UNSOLICITEDSTATUS
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_VFD_UNSOL_STATUS_REQ
));
else
return
(
0
);
case
FMS_CREATE_VFD_LOC
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_VFD_CREATE_REQ
));
else
return
(
0
);
case
FMS_VFD_SET_PHYS_STATUS_LOC
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_VFD_SET_PHYS_STATUS_REQ
));
else
return
(
0
);
default:
return
(
0
);
}
}
FUNCTION
LOCAL
INT16
fmsgdl_get_od_data_len
(
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
/* pointer to data */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following OD-Services.
- FMS_INIT_PUT_OD
- FMS_PUT_OD
- FMS_TERM_PUT_OD
- FMS_INIT_LOAD_OD_LOC
- FMS_LOAD_OD_LOC
- FMS_TERM_LOAD_OD_LOC
- FMS_GET_OD
- FMS_OD_READ_LOC
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FMS_GET_OD
:
if
(
primitive
==
REQ
)
{
return
(
sizeof
(
T_GET_OD_REQ
));
}
else
{
T_GET_OD_CNF
FAR
*
rsp
=
(
T_GET_OD_CNF
FAR
*
)
data_ptr
;
USIGN8
FAR
*
obj_descr_ptr
=
(
USIGN8
FAR
*
)
(
rsp
+
1
);
USIGN16
offset
=
0
;
USIGN16
size
=
0
;
USIGN8
i
;
if
(
rsp
->
no_of_od_descr
!=
0
)
{
for
(
i
=
0
;
i
<
rsp
->
no_of_od_descr
;
i
++
)
{
size
+=
(
obj_descr_ptr
[
offset
]
+
1
);
offset
=
size
;
}
return
(
sizeof
(
T_GET_OD_CNF
)
+
size
);
}
else
{
return
(
0
);
}
}
case
FMS_INIT_PUT_OD
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_INIT_PUT_OD_REQ
));
else
return
(
0
);
case
FMS_PUT_OD
:
if
(
primitive
==
REQ
)
{
T_PUT_OD_REQ
FAR
*
req
=
(
T_PUT_OD_REQ
FAR
*
)
data_ptr
;
USIGN8
FAR
*
obj_descr_ptr
=
(
USIGN8
FAR
*
)
(
req
+
1
);
USIGN16
offset
=
0
;
USIGN16
size
=
0
;
USIGN8
i
;
for
(
i
=
0
;
i
<
req
->
no_of_od_descr
;
i
++
)
{
size
+=
(
obj_descr_ptr
[
offset
]
+
1
);
offset
=
size
;
}
return
(
sizeof
(
T_PUT_OD_REQ
)
+
size
);
}
else
return
(
0
);
case
FMS_INIT_LOAD_OD_LOC
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_INIT_LOAD_OD_REQ
));
else
return
(
0
);
case
FMS_TERM_LOAD_OD_LOC
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_TERM_LOAD_OD_REQ
));
else
return
(
0
);
case
FMS_LOAD_OD_LOC
:
if
(
primitive
==
REQ
)
{
T_LOAD_OD_REQ
FAR
*
req
=
(
T_LOAD_OD_REQ
FAR
*
)
data_ptr
;
T_OD_NULL_OBJECT
FAR
*
object
=
(
T_OD_NULL_OBJECT
FAR
*
)
&
req
->
obj_descr
.
id
.
null_obj_descr
;
switch
(
object
->
obj_code
)
{
case
TYPE_STRUCT_OBJECT
:
return
(
sizeof
(
T_LOAD_OD_REQ
)
+
(
req
->
obj_descr
.
id
.
ds_obj_descr
.
no_of_elements
*
sizeof
(
T_OD_DT_LIST
))
);
case
RECORD_OBJECT
:
return
(
sizeof
(
T_LOAD_OD_REQ
)
+
(
req
->
obj_descr
.
id
.
r_var_obj_descr
.
no_of_address
*
sizeof
(
USIGN32
))
);
case
VAR_LIST_OBJECT
:
return
(
sizeof
(
T_LOAD_OD_REQ
)
+
(
req
->
obj_descr
.
id
.
vlist_obj_descr
.
no_of_var
*
sizeof
(
USIGN16
))
);
case
INVOCATION_OBJECT
:
return
(
sizeof
(
T_LOAD_OD_REQ
)
+
(
req
->
obj_descr
.
id
.
pi_obj_descr
.
cnt_dom
*
sizeof
(
USIGN16
))
);
default:
return
(
sizeof
(
T_LOAD_OD_REQ
));
}
}
else
return
(
0
);
case
FMS_OD_READ_LOC
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_OD_READ_LOC_REQ
));
else
return
(
0
);
default:
return
(
0
);
}
}
FUNCTION
LOCAL
INT16
fmsgdl_get_var_data_len
(
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
/* pointer to data */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following Variable-Access-Services.
- FMS_READ
- FMS_READ_WITH_TYPE
- FMS_WRITE
- FMS_WRITE_WITH_TYPE
- FMS_INFO_RPT
- FMS_INFO_RPT_WITH_TYPE
- FMS_PHYS_READ
- FMS_PHYS_WRITE
- FMS_DEF_VAR_LIST
- FMS_DEL_VAR_LIST
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FMS_READ
:
if
(
primitive
==
REQ
)
{
return
(
sizeof
(
T_VAR_READ_REQ
));
}
else
{
T_VAR_READ_CNF
FAR
*
rsp
=
(
T_VAR_READ_CNF
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_VAR_READ_CNF
)
+
rsp
->
length
);
}
case
FMS_READ_WITH_TYPE
:
if
(
primitive
==
REQ
)
{
return
(
sizeof
(
T_VAR_READ_WITH_TYPE_REQ
));
}
else
{
T_VAR_READ_WITH_TYPE_CNF
FAR
*
rsp
=
(
T_VAR_READ_WITH_TYPE_CNF
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_VAR_READ_WITH_TYPE_CNF
)
+
(
sizeof
(
T_TYPE_DESCR
)
*
rsp
->
no_of_type_descr
)
+
rsp
->
length
);
}
case
FMS_WRITE
:
if
(
primitive
==
REQ
)
{
T_VAR_WRITE_REQ
FAR
*
req
=
(
T_VAR_WRITE_REQ
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_VAR_WRITE_REQ
)
+
req
->
length
);
}
else
return
(
0
);
case
FMS_WRITE_WITH_TYPE
:
if
(
primitive
==
REQ
)
{
T_VAR_WRITE_WITH_TYPE_REQ
FAR
*
req
=
(
T_VAR_WRITE_WITH_TYPE_REQ
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_VAR_WRITE_WITH_TYPE_REQ
)
+
(
sizeof
(
T_TYPE_DESCR
)
*
req
->
no_of_type_descr
)
+
req
->
length
);
}
else
return
(
0
);
case
FMS_INFO_RPT
:
if
(
primitive
==
REQ
)
{
T_VAR_INFO_RPT_REQ
FAR
*
req
=
(
T_VAR_INFO_RPT_REQ
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_VAR_INFO_RPT_REQ
)
+
req
->
length
);
}
else
return
(
0
);
case
FMS_INFO_RPT_WITH_TYPE
:
if
(
primitive
==
REQ
)
{
T_VAR_INFO_RPT_WITH_TYPE_REQ
FAR
*
req
=
(
T_VAR_INFO_RPT_WITH_TYPE_REQ
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_VAR_INFO_RPT_WITH_TYPE_REQ
)
+
(
sizeof
(
T_TYPE_DESCR
)
*
req
->
no_of_type_descr
)
+
req
->
length
);
}
else
return
(
0
);
case
FMS_PHYS_READ
:
if
(
primitive
==
REQ
)
{
return
(
sizeof
(
T_VAR_PHYS_READ_REQ
));
}
else
{
T_VAR_PHYS_READ_CNF
FAR
*
rsp
=
(
T_VAR_PHYS_READ_CNF
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_VAR_PHYS_READ_CNF
)
+
rsp
->
length
);
}
case
FMS_PHYS_WRITE
:
if
(
primitive
==
REQ
)
{
T_VAR_PHYS_WRITE_REQ
FAR
*
req
=
(
T_VAR_PHYS_WRITE_REQ
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_VAR_PHYS_WRITE_REQ
)
+
req
->
length
);
}
else
return
(
0
);
case
FMS_DEF_VAR_LIST
:
if
(
primitive
==
REQ
)
{
T_VAR_DEFINE_VAR_LIST_REQ
FAR
*
req
=
(
T_VAR_DEFINE_VAR_LIST_REQ
FAR
*
)
data_ptr
;
USIGN8
FAR
*
d_acc_spec_list
=
(
USIGN8
FAR
*
)
(
req
+
1
);
USIGN16
offset
=
0
;
USIGN16
acc_spec_list_size
=
0
;
USIGN8
i
=
0
;
for
(
i
=
0
;
i
<
req
->
no_of_var
;
i
++
)
{
offset
++
;
/* offset to length of acc_spec */
acc_spec_list_size
+=
sizeof
(
T_DYN_ACC_SPEC
)
+
d_acc_spec_list
[
offset
];
offset
=
acc_spec_list_size
;
}
return
(
sizeof
(
T_VAR_DEFINE_VAR_LIST_REQ
)
+
acc_spec_list_size
);
}
else
{
return
(
sizeof
(
T_VAR_DEFINE_VAR_LIST_CNF
));
}
case
FMS_DEL_VAR_LIST
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_VAR_DELETE_VAR_LIST_REQ
));
else
return
(
0
);
default:
return
(
0
);
}
}
FUNCTION
LOCAL
INT16
fmsgdl_get_evn_data_len
(
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
/* pointer to data */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following Event-Management-Services.
- FMS_EVN_NOTIFY
- FMS_EVN_NOTIFY_WITH_TYPE
- FMS_ALT_EVN_CND_MNT
- FMS_ACK_EVN_NOTIFY
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FMS_EVN_NOTIFY
:
if
(
primitive
==
REQ
)
{
T_EVENT_NOTIFY_REQ
FAR
*
req
=
(
T_EVENT_NOTIFY_REQ
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_EVENT_NOTIFY_REQ
)
+
req
->
data_length
);
}
else
return
(
0
);
case
FMS_EVN_NOTIFY_WITH_TYPE
:
if
(
primitive
==
REQ
)
{
T_EVENT_NOTIFY_WITH_TYPE_REQ
FAR
*
req
=
(
T_EVENT_NOTIFY_WITH_TYPE_REQ
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_EVENT_NOTIFY_WITH_TYPE_REQ
)
+
req
->
data_length
);
}
else
return
(
0
);
case
FMS_ALT_EVN_CND_MNT
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_ALT_EVN_CND_MNT_REQ
));
else
return
(
0
);
case
FMS_ACK_EVN_NOTIFY
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_ACK_EVN_NOTIFY_REQ
));
else
return
(
0
);
default:
return
(
0
);
}
}
FUNCTION
LOCAL
INT16
fmsgdl_get_dom_data_len
(
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
/* pointer to data */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following Domain-Management-Services.
- FMS_INIT_DOWNL_SEQ
- FMS_DOWNL_SEG
- FMS_TERM_DOWNL_SEQ
- FMS_GEN_INIT_DOWNL_SEQ
- FMS_GEN_DOWNL_SEG
- FMS_GEN_TERM_DOWNL_SEQ
- FMS_INI_UPL_SEQ
- FMS_UPL_SEG
- FMS_TERM_UPL_SEQ
- FMS_REQ_DOM_DOWNL
- FMS_REQ_DOM_UPL
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FMS_INIT_DOWNL_SEQ
:
case
FMS_GEN_INIT_DOWNL_SEQ
:
case
FMS_INIT_UPL_SEQ
:
case
FMS_TERM_UPL_SEQ
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_DOM_REQ
));
else
return
(
0
);
case
FMS_DOWNL_SEG
:
case
FMS_UPL_SEG
:
if
(
primitive
==
REQ
)
{
return
(
sizeof
(
T_DOM_REQ
));
}
else
{
T_DNL_UPL_SEG_CNF
FAR
*
rsp
=
(
T_DNL_UPL_SEG_CNF
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_DNL_UPL_SEG_CNF
)
+
rsp
->
data_len
);
}
case
FMS_TERM_DOWNL_SEQ
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_TERM_DNL_REQ
));
else
return
(
0
);
case
FMS_GEN_DOWNL_SEG
:
if
(
primitive
==
REQ
)
{
T_GEN_DNL_SEG_REQ
FAR
*
req
=
(
T_GEN_DNL_SEG_REQ
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_GEN_DNL_SEG_REQ
)
+
req
->
data_len
);
}
else
return
(
0
);
case
FMS_GEN_TERM_DOWNL_SEQ
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_DOM_REQ
));
else
return
(
sizeof
(
T_GEN_TERM_DNL_CNF
));
case
FMS_REQ_DOM_DOWNL
:
case
FMS_REQ_DOM_UPL
:
if
(
primitive
==
REQ
)
{
T_REQUEST_DOM_REQ
FAR
*
req
=
(
T_REQUEST_DOM_REQ
FAR
*
)
data_ptr
;
return
(
sizeof
(
T_REQUEST_DOM_REQ
)
+
req
->
add_info_length
);
}
else
return
(
0
);
default:
return
(
0
);
}
}
FUNCTION
LOCAL
INT16
fmsgdl_get_pi_data_len
(
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
/* pointer to data */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of request-datas or response-datas
of the following Program-Invocation-Management-Services.
- FMS_PI_CREATE
- FMS_PI_DELETE
- FMS_PI_START
- FMS_PI_STOP
- FMS_PI_RESUME
- FMS_PI_RESET
- FMS_PI_KILL
- FMS_PI_SET_STATE_LOC
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FMS_PI_CREATE
:
if
(
primitive
==
REQ
)
{
T_PI_CR8_REQ
FAR
*
req
=
(
T_PI_CR8_REQ
FAR
*
)
data_ptr
;
USIGN8
FAR
*
d_acc_spec_list
=
(
USIGN8
FAR
*
)
(
req
+
1
);
USIGN16
offset
=
0
;
USIGN16
acc_spec_list_size
=
0
;
USIGN8
i
=
0
;
/* - dynamic access specification list --------------------------*/
for
(
i
=
0
;
i
<
req
->
cnt_dom
;
i
++
)
{
offset
++
;
/* offset to length of acc_spec */
acc_spec_list_size
+=
sizeof
(
T_DYN_ACC_SPEC
)
+
d_acc_spec_list
[
offset
];
offset
=
acc_spec_list_size
;
}
return
(
sizeof
(
T_PI_CR8_REQ
)
+
acc_spec_list_size
);
}
else
{
return
(
sizeof
(
T_PI_CR8_CNF
));
}
case
FMS_PI_DELETE
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_PI_DEL_REQ
));
else
return
(
0
);
case
FMS_PI_START
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_PI_START_REQ
));
else
return
(
0
);
case
FMS_PI_STOP
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_PI_STOP_REQ
));
else
return
(
0
);
case
FMS_PI_RESUME
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_PI_RESUME_REQ
));
else
return
(
0
);
case
FMS_PI_RESET
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_PI_RESET_REQ
));
else
return
(
0
);
case
FMS_PI_KILL
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_PI_KILL_REQ
));
else
return
(
0
);
case
FMS_PI_SET_STATE_LOC
:
if
(
primitive
==
REQ
)
return
(
sizeof
(
T_PI_SET_STATE_REQ
));
else
return
(
0
);
default:
return
(
0
);
}
}
FUNCTION
LOCAL
INT16
fmsgdl_get_error_data_len
(
IN
USIGN8
service
/* Service */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to return the length of response-error-datas
of the following FMS-Services.
- FMS_INITIATE
- FMS_STATUS
- FMS_IDENTIFY
- FMS_READ
- FMS_WRITE
- FMS_GET_OD
- FMS_READ_WITH_TYPE
- FMS_WRITE_WITH_TYPE
- FMS_DEF_VAR_LIST
- FMS_DEL_VAR_LIST
- FMS_INIT_DOWNL_SEQ
- FMS_DOWNL_SEG
- FMS_TERM_DOWNL_SEQ
- FMS_GEN_INIT_DOWNL_SEQ
- FMS_GEN_DOWNL_SEG
- FMS_GEN_TERM_DOWNL_SEQ
- FMS_INIT_UPL_SEQ
- FMS_UPL_SEG
- FMS_TERM_UPL_SEQ
- FMS_REQ_DOM_DOWNL
- FMS_REQ_DOM_UPL
- FMS_PI_CREATE
- FMS_PI_DELETE
- FMS_PI_START
- FMS_PI_STOP
- FMS_PI_RESUME
- FMS_PI_RESET
- FMS_PI_KILL
- FMS_ALT_EVN_CND_MNT
- FMS_ACK_EVN_NOTIFY
- FMS_PHYS_READ
- FMS_PHYS_WRITE
- FMS_INIT_PUT_OD
- FMS_PUT_OD
- FMS_TERM_PUT_OD
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
switch
(
service
)
{
case
FMS_INITIATE
:
return
(
sizeof
(
T_CTXT_INIT_ERR_CNF
));
case
FMS_STATUS
:
case
FMS_IDENTIFY
:
case
FMS_READ
:
case
FMS_WRITE
:
case
FMS_GET_OD
:
case
FMS_READ_WITH_TYPE
:
case
FMS_WRITE_WITH_TYPE
:
case
FMS_DEF_VAR_LIST
:
case
FMS_DEL_VAR_LIST
:
case
FMS_INIT_DOWNL_SEQ
:
case
FMS_DOWNL_SEG
:
case
FMS_TERM_DOWNL_SEQ
:
case
FMS_GEN_INIT_DOWNL_SEQ
:
case
FMS_GEN_DOWNL_SEG
:
case
FMS_GEN_TERM_DOWNL_SEQ
:
case
FMS_INIT_UPL_SEQ
:
case
FMS_UPL_SEG
:
case
FMS_TERM_UPL_SEQ
:
case
FMS_REQ_DOM_DOWNL
:
case
FMS_REQ_DOM_UPL
:
case
FMS_PI_CREATE
:
case
FMS_PI_DELETE
:
case
FMS_ALT_EVN_CND_MNT
:
case
FMS_ACK_EVN_NOTIFY
:
case
FMS_PHYS_READ
:
case
FMS_PHYS_WRITE
:
case
FMS_INIT_PUT_OD
:
case
FMS_PUT_OD
:
return
(
sizeof
(
T_ERROR
));
case
FMS_TERM_PUT_OD
:
return
(
sizeof
(
T_OD_ERROR
));
case
FMS_PI_START
:
case
FMS_PI_STOP
:
case
FMS_PI_RESUME
:
case
FMS_PI_RESET
:
case
FMS_PI_KILL
:
return
(
sizeof
(
T_PI_ERROR
));
default:
return
(
0
);
}
}
FUNCTION
PUBLIC
INT16
fmsgdl_get_data_len
(
IN
INT16
result
,
/* Service-Result */
IN
USIGN8
service
,
/* Service */
IN
USIGN8
primitive
,
/* Service-Primitive */
IN
USIGN8
FAR
*
data_ptr
,
/* pointer to data */
OUT
INT16
*
data_len_ptr
/* length of data */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
this function is used to return the data length of FMS-SERVICES
possible return values:
- Data-length
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
FUNCTION_BODY
*
data_len_ptr
=
0
;
switch
(
service
)
{
case
FMS_INITIATE
:
case
FMS_ABORT
:
if
(
result
==
POS
)
*
data_len_ptr
=
fmsgdl_get_ctxt_data_len
(
service
,
primitive
);
else
*
data_len_ptr
=
fmsgdl_get_error_data_len
(
service
);
break
;
case
FMS_STATUS
:
case
FMS_IDENTIFY
:
case
FMS_UNSOLICITEDSTATUS
:
case
FMS_CREATE_VFD_LOC
:
case
FMS_VFD_SET_PHYS_STATUS_LOC
:
if
(
result
==
POS
)
*
data_len_ptr
=
fmsgdl_get_vfd_data_len
(
service
,
primitive
);
else
*
data_len_ptr
=
fmsgdl_get_error_data_len
(
service
);
break
;
case
FMS_INIT_DOWNL_SEQ
:
case
FMS_DOWNL_SEG
:
case
FMS_TERM_DOWNL_SEQ
:
case
FMS_GEN_INIT_DOWNL_SEQ
:
case
FMS_GEN_DOWNL_SEG
:
case
FMS_GEN_TERM_DOWNL_SEQ
:
case
FMS_INIT_UPL_SEQ
:
case
FMS_UPL_SEG
:
case
FMS_TERM_UPL_SEQ
:
case
FMS_REQ_DOM_DOWNL
:
case
FMS_REQ_DOM_UPL
:
if
(
result
==
POS
)
*
data_len_ptr
=
fmsgdl_get_dom_data_len
(
service
,
primitive
,
data_ptr
);
else
*
data_len_ptr
=
fmsgdl_get_error_data_len
(
service
);
break
;
case
FMS_EVN_NOTIFY
:
case
FMS_EVN_NOTIFY_WITH_TYPE
:
case
FMS_ALT_EVN_CND_MNT
:
case
FMS_ACK_EVN_NOTIFY
:
if
(
result
==
POS
)
*
data_len_ptr
=
fmsgdl_get_evn_data_len
(
service
,
primitive
,
data_ptr
);
else
*
data_len_ptr
=
fmsgdl_get_error_data_len
(
service
);
break
;
case
FMS_GET_OD
:
case
FMS_INIT_PUT_OD
:
case
FMS_PUT_OD
:
case
FMS_TERM_PUT_OD
:
case
FMS_OD_READ_LOC
:
case
FMS_INIT_LOAD_OD_LOC
:
case
FMS_LOAD_OD_LOC
:
case
FMS_TERM_LOAD_OD_LOC
:
if
(
result
==
POS
)
*
data_len_ptr
=
fmsgdl_get_od_data_len
(
service
,
primitive
,
data_ptr
);
else
*
data_len_ptr
=
fmsgdl_get_error_data_len
(
service
);
break
;
case
FMS_PI_CREATE
:
case
FMS_PI_DELETE
:
case
FMS_PI_START
:
case
FMS_PI_STOP
:
case
FMS_PI_RESUME
:
case
FMS_PI_RESET
:
case
FMS_PI_KILL
:
case
FMS_PI_SET_STATE_LOC
:
if
(
result
==
POS
)
*
data_len_ptr
=
fmsgdl_get_pi_data_len
(
service
,
primitive
,
data_ptr
);
else
*
data_len_ptr
=
fmsgdl_get_error_data_len
(
service
);
break
;
case
FMS_READ
:
case
FMS_READ_WITH_TYPE
:
case
FMS_WRITE
:
case
FMS_WRITE_WITH_TYPE
:
case
FMS_INFO_RPT
:
case
FMS_INFO_RPT_WITH_TYPE
:
case
FMS_DEF_VAR_LIST
:
case
FMS_DEL_VAR_LIST
:
case
FMS_PHYS_READ
:
case
FMS_PHYS_WRITE
:
if
(
result
==
POS
)
*
data_len_ptr
=
fmsgdl_get_var_data_len
(
service
,
primitive
,
data_ptr
);
else
*
data_len_ptr
=
fmsgdl_get_error_data_len
(
service
);
break
;
default:
return
(
E_IF_INVALID_SERVICE
);
}
return
(
E_OK
);
}
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma check_stack
#endif
profibus/lib/rt/src/os_linux/hw_x86/special.mk
0 → 100644
View file @
0135e84d
ifndef
variables_mk
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef
variables_mk
include
$(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
vpath %.c $(hw_source)
:
$(os_source):$(co_source)
c_sources
:=
$(
sort
\
$(
foreach
file,
\
$(
foreach
dir
,
\
$(source_dirs)
,
\
$(
wildcard
$(dir)
/
*
.c
)
\
)
,
$(
notdir
$(file)
)
\
)
\
)
export_c
:=
$(
addprefix
$(bld_dir)
/,
$(
patsubst
%.c, %.o,
$(c_sources)
))
lib
:
$(export_lib) export_lib_local
export_lib_local
:
$(export_c)
@
echo
"Inserting local lib"
@
$(ar)
-r
$(export_lib)
$(export_c)
profibus/lib/rt/src/os_linux/keywords.h
0 → 100644
View file @
0135e84d
/*****************************************************************************/
/* */
/* SOFTING AG */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* KEYWORDS */
/* */
/* Filename : KEYWORDS.H */
/* Version : 5.21.0.00.release */
/* Date : 27-February-1998 */
/* Author : SOFTING AG */
/* */
/* Description : This include file defines some keywords which are used */
/* for structuring and formatting the PROFIBUS source files. These */
/* keywords are ignored by the the compiler. */
/* */
/*****************************************************************************/
#ifndef __KEYWORDS__
#define __KEYWORDS__
#define INCLUDES
#define GLOBAL_DEFINES
#define LOCAL_DEFINES
#define EXPORT_TYPEDEFS
#define LOCAL_TYPEDEFS
#define EXPORT_DATA
#define IMPORT_DATA
#define LOCAL_DATA
#define FUNCTION
#define IN
#define OUT
#define INOUT
#define FUNCTIONAL_DESCRIPTION
#define ASSERTIONS
#define LOCAL_VARIABLES
#define FUNCTION_BODY
#define FUNCTION_DECLARATIONS
#define PUBLIC
#define GLOBAL
#endif
profibus/lib/rt/src/os_linux/papiaux.c
0 → 100644
View file @
0135e84d
/*****************************************************************************
* *
* SOFTING AG *
* Richard-Reitzner-Allee 6 *
* D-85540 Haar *
* Phone: ++49-89-4 56 56-0 *
* Fax: ++49-89-4 56 56-3 99 *
* *
* Copyright (C) SOFTING AG 1999-2003 *
* All Rights Reserved *
* *
******************************************************************************
FILE_NAME PAPIAUX.C
PROJECT_NAME PROFIBUS
MODULE PAPIAUX
COMPONENT_LIBRARY PAPI Lib
PAPI DLL
AUTHOR SOFTING GmbH
VERSION 5.22.0.00.release
DATE 26-February-1999
STATUS finished
FUNCTIONAL_MODULE_DESCRIPTION
This modul contains auxiliary functions to
- get registry entries
- to swap data from little endian to big endian
RELATED_DOCUMENTS
=============================================================================*/
#include "keywords.h"
INCLUDES
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#include <windows.h>
#endif
#include <stdio.h>
#ifdef _LINUX
#include <sys/select.h>
#endif
#include "pb_type.h"
#if defined (WIN32) || defined (_WIN32)
#include "pb_ntdrv.h"
#endif
FUNCTION_DECLARATIONS
LOCAL_DEFINES
LOCAL_TYPEDEFS
EXPORT_DATA
IMPORT_DATA
LOCAL_DATA
// ***************************************************************************
// * FUNCTIONs to access system registry
// ***************************************************************************
#if defined (WIN32) || defined (_WIN32)
FUNCTION
PUBLIC
BOOL
ReadBoardRegistryEntries
(
IN
USIGN8
BoardNumber
,
OUT
USIGN32
*
OperationMode
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used read the OperationMode from the system registry specified
by the BoardNumber.
return value:
- TRUE read registry entry is successfully
- FALSE read registry entry is not successfully
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
LONG
RetVal
;
HKEY
keyParameters
=
NULL
;
HKEY
keyBoard
=
NULL
;
char
szKeyBoard
[
100
];
char
szBoardType
[
100
];
DWORD
sizeULONG
=
sizeof
(
ULONG
);
DWORD
SizeofBoardType
;
FUNCTION_BODY
if
(
ERROR_SUCCESS
==
RegOpenKeyEx
(
HKEY_LOCAL_MACHINE
,
REGPATH_PARAMETER_FROM_HLM
,
0
,
KEY_READ
,
&
keyParameters
))
{
sprintf
(
szKeyBoard
,
"%s
\\
%d"
,
REGPATH_PARAMETER_FROM_HLM
,
BoardNumber
);
if
(
ERROR_SUCCESS
==
RegOpenKeyEx
(
HKEY_LOCAL_MACHINE
,
szKeyBoard
,
0
,
KEY_READ
,
&
keyBoard
))
{
SizeofBoardType
=
sizeof
(
szBoardType
);
szBoardType
[
0
]
=
'\0'
;
if
((
RetVal
=
RegQueryValueEx
(
keyBoard
,
"Type"
,
NULL
,
NULL
,(
LPBYTE
)
szBoardType
,
&
SizeofBoardType
))
==
ERROR_SUCCESS
)
{
RetVal
|=
RegQueryValueEx
(
keyBoard
,
"OperationMode"
,
NULL
,
NULL
,(
LPBYTE
)
OperationMode
,
&
sizeULONG
);
if
(
!
RetVal
)
return
(
TRUE
);
}
}
}
return
(
FALSE
);
}
#endif
/****************************************************************************/
#ifdef _LINUX
FUNCTION
PUBLIC
int
kbhit
(
VOID
)
/*------------------------------------------------------------------------*/
/* FUNCTIONAL_DESCRIPTION */
/*------------------------------------------------------------------------*/
/* */
/*------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
fd_set
rd_fds
;
struct
timeval
timeout
;
FUNCTION_BODY
FD_ZERO
(
&
rd_fds
);
FD_SET
(
0
,
&
rd_fds
);
timeout
.
tv_sec
=
0L
;
timeout
.
tv_usec
=
1000L
;
/* wait 1 ms */
if
(
select
(
1
,
&
rd_fds
,
NULL
,
NULL
,
&
timeout
)
>
0
)
{
return
(
1
);
}
return
(
0
);
}
/* kbhit */
#endif
// ***************************************************************************
// * FUNCTIONs to convert data from LITTLE ENDIAN to BIG-ENDIAN format
// ***************************************************************************
FUNCTION
PUBLIC
USIGN16
swap_16_intel_motorola
(
IN
USIGN16
input16
/* value to swap */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to swap a INTEGER16 or USIGN16 value from LITTLE ENDIAN to
BIG-ENDIAN format.
IN: input16 -> 16-Bit value to swap
return value:
- swapped INTEGER16 or USIGN16 value
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
USIGN16
inp16
;
FUNCTION_BODY
((
USIGN8
*
)
&
inp16
)
[
0
]
=
((
USIGN8
*
)
&
input16
)
[
1
];
((
USIGN8
*
)
&
inp16
)
[
1
]
=
((
USIGN8
*
)
&
input16
)
[
0
];
return
(
inp16
);
}
FUNCTION
PUBLIC
USIGN32
swap_32_intel_motorola
(
IN
USIGN32
input32
/* value to swap */
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to swap a INTEGER32 or USIGN32 value from LITTLE ENDIAN to
BIG-ENDIAN format.
IN: input32 -> 32-Bit value to swap
return value:
- swapped INTEGER32 or USIGN32 value
-----------------------------------------------------------------------------*/
{
LOCAL_VARIABLES
USIGN32
inp32
;
FUNCTION_BODY
((
USIGN8
*
)
&
inp32
)
[
0
]
=
((
USIGN8
*
)
&
input32
)
[
3
];
((
USIGN8
*
)
&
inp32
)
[
1
]
=
((
USIGN8
*
)
&
input32
)
[
2
];
((
USIGN8
*
)
&
inp32
)
[
2
]
=
((
USIGN8
*
)
&
input32
)
[
1
];
((
USIGN8
*
)
&
inp32
)
[
3
]
=
((
USIGN8
*
)
&
input32
)
[
0
];
return
(
inp32
);
}
profibus/lib/rt/src/os_linux/pb_conf.h
View file @
0135e84d
/*
* Proview $Id: pb_conf.h,v 1.2 2006-02-01 08:35:51 claes Exp $
* Copyright (C) SOFTING GmbH 1995-1999.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/*****************************************************************************/
/* */
/* */
/*
SOFTING GmbH
*/
/*
SOFTING AG
*/
/* Richard-Reitzner-Allee 6 */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* */
/* Copyright (C) SOFTING GmbH 1995-1999 */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/* */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/* PROFIBUS CONFIGURATION AND IMPLEMENTATION DEFINITIONS */
/* PROFIBUS CONFIGURATION AND IMPLEMENTATION DEFINITIONS */
/* */
/* */
/* Filename : PB_CONF.H */
/* Filename : PB_CONF.H */
/* Version : 5.2
2
.0.00.release */
/* Version : 5.2
6
.0.00.release */
/* Date :
26-February-1999
*/
/* Date :
14-February-2002
*/
/* Author : SOFTING
-BG2
*/
/* Author : SOFTING
AG
*/
/* */
/* */
/* Description : This file contains the PROFIBUS configuration and */
/* Description : This file contains the PROFIBUS configuration and */
/* implementation definitions */
/* implementation definitions using Windows ME/98/95 or */
/* */
/* Windows XP / 2000 / NT operating system */
/* CHANGE_NOTES */
/* */
/* */
/* date name change */
/* ----------------------------------------------------------------------- */
/* 18.03.97 BG2-BOE modify compiler switches */
/* 18.03.97 BG2-BOE rename #define PAGE_SIZE to #define DPR_PAGE_SIZE */
/* 18.03.97 BG2-BOE rename #define PB_VER 500 to #define PB_VER 511 */
/* 19.06.97 BG2-BOE correct macro _NAME_LENGTH */
/* 22.07.97 BG2-BOE remove #pragma pack(2) */
/* 22.07.97 BG2-BOE modify #define CMI_TIMEOUT */
/* 23.07.97 BG2-BOE add #define LOCK_UNLOCK_TIMEOUT */
/* 23.07.97 BG2-BOE add defines for supported services */
/* 15.09.97 BG2-BOE add new IRQ identifiers */
/* 16.09.97 BG2-BOE add new define EXPORT */
/* 06.02.98 BG2-BOE set MAX_COMREF 48 to MAX_COMREF 64 */
/* 06.02.98 BG2-BOE set #define CMI_V400 0xA1 */
/* 06.02.98 BG2-BOE set #define PB_VER 520 to #define PB_VER 521 */
/* 26.02.99 BG2-BOE set #define PB_VER 521 to #define PB_VER 522 */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
#ifndef __PB_CONF__
#ifndef __PB_CONF__
...
@@ -69,10 +33,7 @@
...
@@ -69,10 +33,7 @@
#ifndef PB_VER
#ifndef PB_VER
/* --- for new applications running with PROFIBUS V500 --------------------- */
#define PB_VER 526
/* --- NOTE: For applications developed with PROFIBUS V4XX invoke compiler */
/* with compiler switch "/DPB_VER=400" */
#define PB_VER 522
#endif
#endif
...
@@ -96,6 +57,23 @@
...
@@ -96,6 +57,23 @@
#undef CALL_CONV
#undef CALL_CONV
#define CALL_CONV
/* call convention using NT-DDK */
#define CALL_CONV
/* call convention using NT-DDK */
#endif
#endif
#elif defined (_LINUX)
/* compiling as LINUX */
#undef DOS16
#undef WIN32
#undef EXPORT
#define EXPORT
#define FAR
#define HUGE
#define CALL_CONV
#define CALLBACK
#define INVALID_HANDLE_VALUE ((HANDLE) NULL)
#define getch() getchar()
typedef
int
HANDLE
;
typedef
unsigned
long
DWORD
;
#ifdef PB_API_FUNC_NOT_USED
#undef CALL_CONV
#define CALL_CONV
#endif
#else
/* compiling as WIN16 */
#else
/* compiling as WIN16 */
#if defined (WIN_DLL) || defined (_WINDOWS) || defined (_WINDLL)
#if defined (WIN_DLL) || defined (_WINDOWS) || defined (_WINDLL)
#undef DOS16
#undef DOS16
...
@@ -107,105 +85,26 @@
...
@@ -107,105 +85,26 @@
#undef DOS16
#undef DOS16
#undef WIN16
#undef WIN16
#undef EXPORT
#undef EXPORT
#undef PASCAL
#define WIN16
#define WIN16
#define EXPORT __export
#define EXPORT __export
#define FAR __far
#define FAR _far
#define HUGE __huge
#define PASCAL _pascal
#define CDECL _cdecl
#define HUGE _huge
#define CALL_CONV FAR pascal
/* calling convention using WIN16 */
#define CALL_CONV FAR pascal
/* calling convention using WIN16 */
#else
#error 16-BIT DOS compilation not supported !!!!
#endif
#endif
#endif
#endif
#if !defined (WIN16) && !defined (WIN32)
/* compiling as DOS16 */
#undef DOS16
#undef EXPORT
#define DOS16
#define EXPORT
#define FAR __far
#define HUGE __huge
#define CALL_CONV
#endif
/*****************************************************************************/
/*****************************************************************************/
/* SUPPORTED SERVICES */
/* SUPPORTED SERVICES */
/*****************************************************************************/
/*****************************************************************************/
#define FMS_SERVICES_SUPPORTED
#define FMS_SERVICES_SUPPORTED
#define DP_SERVICES_SUPPORTED
#define DP_SERVICES_SUPPORTED
#define DPS_SERVICES_SUPPORTED
/*****************************************************************************/
/* HW Implementation Constants */
/*****************************************************************************/
/* --- DPR access mode ---------------------------------------------------- */
#define USING_8BIT 1
#define USING_16BIT_LA 2
#define USING_16BIT_SA 3
#define DPR_ACCESS_MODE USING_16BIT_SA
/* --- DPR page size ------------------------------------------------------ */
#define USING_64K_PAGE 0
#define USING_16K_PAGES 1
#define DPR_PAGE_SIZE USING_16K_PAGES
/* --- IRQ line to host --------------------------------------------------- */
#define NO_INT 0x00
/* no PC-IRQ is used */
#define INT_5 0x10
/* PC-IRQ 5 */
#define INT_10 0x20
/* PC-IRQ 10 */
#define INT_11 0x30
/* PC-IRQ 11 */
#define INT_12 0x40
/* PC-IRQ 12 */
#define INT_15 0x50
/* PC-IRQ 15 */
#define NO_INT_TO_HOST NO_INT
#define H1_INT_5 INT_5
#define H1_INT_10 INT_10
#define H1_INT_11 INT_11
#define H1_INT_12 INT_12
#define H1_INT_15 INT_15
#define INT_TO_HOST NO_INT
/*****************************************************************************/
/* CMI Implementation Constants */
/*****************************************************************************/
/* --- timeouts to wait for controller response ---------------------------- */
#define CMI_TIMEOUT (03*19)
/* CMI timeout in 55ms units */
#define LOCK_UNLOCK_TIMEOUT 2
/* Lock/Unlock Data image in 55ms units */
/* --- host identifiers ---------------------------------------------------- */
#define CMI_V410 0xA1
/* host driver CMI version 4.10 */
#define HOST_TYPE CMI_V410
/* --- controller identifier ----------------------------------------------- */
#define ID_PROFI_BOARD 0xCA
/* PROFIboard */
#define ID_PROFI_104 0xCA
/* PROFI104 */
#define ID_PROFI_CARD 0xBA
/* PROFIcard */
#define TYPE_PCMCIA 0xBA
/* old PROFIcard */
#define CONTROLLER_TYPE ID_PROFI_BOARD
/* --- polling or interrupt mode --------------------------------------------*/
#define REQ_ACK_BY_POLLING 0
/* request and ackn. by polling */
#define REQ_BY_IR_ACK_BY_POLLING 1
/* request by IR, ackn. by polling */
#define REQ_BY_POLLING_ACK_BY_IR 2
/* request by polling, ackn. by IR */
#define REQ_ACK_BY_IR 3
/* request and acknowledge by IR */
#define POLL_INT_MODE REQ_ACK_BY_POLLING
/* --- address mode -------------------------------------------------------- */
#define ABS_32BIT_MOTOROLA 0
/* linear absolute 32 bit Motorola */
#define ABS_16BIT_MOTOROLA 1
/* linear absolute 16 bit Motorola */
#define REL_32BIT_MOTOROLA 2
/* linear relative 32 bit Motorola */
#define REL_16BIT_MOTOROLA 3
/* linear relative 16 bit Motorola */
#define ABS_32BIT_INTEL 8
/* linear absolute 32 bit Intel */
#define ABS_16BIT_INTEL 9
/* linear absolute 16 bit Intel */
#define REL_32BIT_INTEL 10
/* linear relative 32 bit Intel */
#define REL_16BIT_INTEL 11
/* linear relative 32 bit Intel */
#define SEGMENT_OFFSET_INTEL 12
/* SEGEMENT/OFFSET Intel */
#define ADDRESS_SWAP_MODE SEGMENT_OFFSET_INTEL
/*****************************************************************************/
/*****************************************************************************/
...
@@ -269,4 +168,3 @@
...
@@ -269,4 +168,3 @@
#define _NAME_LENGTH(length) ((length) + ALIGNMENT - ((length) % ALIGNMENT))
#define _NAME_LENGTH(length) ((length) + ALIGNMENT - ((length) % ALIGNMENT))
#endif
#endif
profibus/lib/rt/src/os_linux/pb_dp.h
View file @
0135e84d
/*
* Proview $Id: pb_dp.h,v 1.2 2006-02-01 08:35:51 claes Exp $
* Copyright (C) SOFTING GmbH 1995-1999.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/*****************************************************************************/
/* */
/* */
/*
SOFTING GmbH
*/
/*
SOFTING AG
*/
/* Richard-Reitzner-Allee 6 */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* */
/* Copyright (C) SOFTING GmbH 1995-1999 */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/* */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
...
@@ -32,31 +16,28 @@
...
@@ -32,31 +16,28 @@
/* Filename : PB_DP.H */
/* Filename : PB_DP.H */
/* Version : 5.22.0.00.release */
/* Version : 5.22.0.00.release */
/* Date : 26-February-1999 */
/* Date : 26-February-1999 */
/* Author : SOFTING
-BG2
*/
/* Author : SOFTING
AG
*/
/* */
/* */
/* Description : This file contains the global defines and types of */
/* Description : This file contains the global defines and types of */
/* component DP */
/* component DP */
/* */
/* */
/* CHANGE_NOTES */
/* */
/* date name change */
/* ----------------------------------------------------------------------- */
/* 22.07.97 BG2-BOE set #pragma pack(2) and reset to #pragma pack() */
/* 24.09.97 BG2-BOE add new baudrate #defines */
/* - #define DP_KBAUD_45_45 */
/* 07.10.97 BG2-NI add new types for DP/V1 */
/* 07.02.98 BG2-BOE set #pragma pack(1) */
/* 01.02.99 BG2-BOE add new service identifier and data structure for */
/* DP_DATA_TRANSPORT service */
/* */
/* */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
#ifndef __PB_DP__
#ifndef __PB_DP__
#define __PB_DP__
#define __PB_DP__
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to change alignment */
#ifdef WIN32
#pragma pack(push,1)
#else
#pragma pack(1)
#endif
#pragma warning (default : 4103)
#endif
/****************************************************************************/
/****************************************************************************/
/*** DEFINES ****************************************************************/
/*** DEFINES ****************************************************************/
/****************************************************************************/
/****************************************************************************/
...
@@ -258,7 +239,9 @@
...
@@ -258,7 +239,9 @@
#define DP_OP_MODE_OFFLINE 0x00
#define DP_OP_MODE_OFFLINE 0x00
#define DP_OP_MODE_STOP 0x40
#define DP_OP_MODE_STOP 0x40
#define DP_OP_MODE_CLEAR 0x80
#define DP_OP_MODE_CLEAR 0x80
#define DP_OP_MODE_RED_CLEAR 0x81
/* new redundancy state */
#define DP_OP_MODE_OPERATE 0xC0
#define DP_OP_MODE_OPERATE 0xC0
#define DP_OP_MODE_RED_OPERATE 0xC1
/* new redundancy state */
/*--- DP MASTER DIAG IDENTIFIERS -------------------------------------------*/
/*--- DP MASTER DIAG IDENTIFIERS -------------------------------------------*/
...
@@ -743,7 +726,7 @@ typedef struct _T_DP_GET_MASTER_DIAG_RES_CON
...
@@ -743,7 +726,7 @@ typedef struct _T_DP_GET_MASTER_DIAG_RES_CON
/*==========================================================================*/
/*==========================================================================*/
typedef
void
T_DP_GET_SLAVE_DIAG_REQ
;
typedef
VOID
T_DP_GET_SLAVE_DIAG_REQ
;
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
...
@@ -764,7 +747,7 @@ typedef T_DP_GET_SLAVE_DIAG_CON T_DP_GET_SLAVE_DIAG_IND; /* dito */
...
@@ -764,7 +747,7 @@ typedef T_DP_GET_SLAVE_DIAG_CON T_DP_GET_SLAVE_DIAG_IND; /* dito */
/*==========================================================================*/
/*==========================================================================*/
typedef
void
T_DP_DATA_TRANSFER_REQ
;
/* no SDU */
typedef
VOID
T_DP_DATA_TRANSFER_REQ
;
/* no SDU */
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
...
@@ -1141,7 +1124,7 @@ typedef struct _T_DP_WRITE_REQ
...
@@ -1141,7 +1124,7 @@ typedef struct _T_DP_WRITE_REQ
USIGN8
slot_number
;
/* 0..254, 255 is reserved */
USIGN8
slot_number
;
/* 0..254, 255 is reserved */
USIGN8
index
;
/* 0..254, 255 is reserved */
USIGN8
index
;
/* 0..254, 255 is reserved */
USIGN8
length
;
/* 0..DP_MSAC2_DATA_LEN */
USIGN8
length
;
/* 0..DP_MSAC2_DATA_LEN */
/* OCTET data [length] */
/* OCTET data [length] */
}
T_DP_WRITE_REQ
;
}
T_DP_WRITE_REQ
;
...
@@ -1216,5 +1199,14 @@ typedef struct _T_DP_ERROR_CON
...
@@ -1216,5 +1199,14 @@ typedef struct _T_DP_ERROR_CON
/****************************************************************************/
/****************************************************************************/
#endif
/* __PB_DP__ */
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to reset alignment */
#ifdef WIN32
#pragma pack(pop)
#else
#pragma pack()
#endif
#pragma warning (default : 4103)
#endif
#endif
/* __PB_DP__ */
profibus/lib/rt/src/os_linux/pb_dps.h
0 → 100644
View file @
0135e84d
/*****************************************************************************/
/* */
/* SOFTING AG */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* */
/* Filename : PB_DPS.H */
/* Version : 5.22.0.00.release */
/* Date : 26-February-1999 */
/* Author : SOFTING AG */
/* */
/* Description : This file contains the global defines and types of DPS */
/* */
/*****************************************************************************/
#ifndef __PB_DPS__
#define __PB_DPS__
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to change alignment */
#ifdef WIN32
#pragma pack(push,2)
#else
#pragma pack(2)
#endif
#pragma warning (default : 4103)
#endif
/****************************************************************************/
/*** DEFINES ****************************************************************/
/****************************************************************************/
/*--- COMMON DP SLAVE CONSTANTS --------------------------------------------*/
#define DPS_KBAUD_9_6 0x00
#define DPS_KBAUD_19_2 0x01
#define DPS_KBAUD_93_75 0x02
#define DPS_KBAUD_187_5 0x03
#define DPS_KBAUD_500 0x04
#define DPS_KBAUD_RESERVED 0x05
#define DPS_KBAUD_1500 0x06
#define DPS_MBAUD_1_5 0x06
#define DPS_KBAUD_3000 0x07
#define DPS_MBAUD_3 0x07
#define DPS_KBAUD_6000 0x08
#define DPS_MBAUD_6 0x08
#define DPS_KBAUD_12000 0x09
#define DPS_MBAUD_12 0x09
#define DPS_KBAUD_31_25 0x0A
#define DPS_KBAUD_45_45 0x0B
#define DPS_NO_BUS_TRAFFIC 0xFF
#define DPS_MIN_SERVICE_IF_LEN 512
/* required service IF size by DPS */
#define DPS_DEFAULT_MIN_TSDR 11
#define DPS_DEFAULT_IDENT_NUMBER 0x0000
#define DPS_USER_WATCHDOG_DISABLED 0
#define DPS_NON_VOLATILE_SLAVE_ADD 0xFF
#define DPS_DEFAULT_SLAVE_ADD DP_DEFAULT_SLAVE_ADDRESS
#define DPS_MIN_SLAVE_DIAG_LEN DP_MIN_SLAVE_DIAG_LEN
#define DPS_MAX_SLAVE_DIAG_LEN DP_MAX_SLAVE_DIAG_DATA_LEN
#define DPS_MIN_PRM_DATA_LEN 7
#define DPS_MAX_PRM_DATA_LEN DP_MAX_PRM_DATA_LEN
#define DPS_MIN_CFG_DATA_LEN 1
#define DPS_MAX_CFG_DATA_LEN DP_MAX_CFG_DATA_LEN
#define DPS_MIN_SSA_DATA_LEN 4
/****************************************************************************/
/*** DPS SERVICE CODES ******************************************************/
/****************************************************************************/
/*--- DPS_SUBTASK ----------------------------------------------------------*/
#define DPS_SUBTASK 0xE0
#define DPS_SUBTASK_MSG 0x00
#define DPS_SUBTASK_USIF 0x20
#define DPS_SUBTASK_MSAC2 0x40
/*--- DPS_STATE_MACHINE ----------------------------------------------------*/
#define DPS_STATE_MACHINE 0x18
#define DPS_STATE_MACHINE_0 0x00
#define DPS_STATE_MACHINE_1 0x08
#define DPS_STATE_MACHINE_2 0x10
#define DPS_STATE_MACHINE_3 0x08
/*--- DPS_SUBTASK / DPS_STATE_MACHINE --------------------------------------*/
#define DPS_SUBTASK_STATE_MACHINE (DPS_SUBTASK | DPS_STATE_MACHINE)
#define DPS_SM_MSG_MAIN (DPS_SUBTASK_MSG | DPS_STATE_MACHINE_0)
#define DPS_SM_USIF_MAIN (DPS_SUBTASK_USIF | DPS_STATE_MACHINE_0)
#define DPS_SM_USIF_SLAVE (DPS_SUBTASK_USIF | DPS_STATE_MACHINE_1)
#define DPS_SM_USIF_STATE (DPS_SUBTASK_USIF | DPS_STATE_MACHINE_2)
#define DPS_SM_MSAC2_MAIN (DPS_SUBTASK_MSAC2 | DPS_STATE_MACHINE_0)
/*--- DPS_SERVICE_CODE -----------------------------------------------------*/
#define DPS_INIT_SLAVE (DPS_SM_MSG_MAIN | 0x01)
#define DPS_EXIT_SLAVE (DPS_SM_MSG_MAIN | 0x02)
#define DPS_EXCEPTION (DPS_SM_MSG_MAIN | 0x07)
#define DPS_CHK_CFG (DPS_SM_USIF_MAIN | 0x01)
#define DPS_SET_PRM (DPS_SM_USIF_MAIN | 0x02)
#define DPS_SET_SLAVE_ADD (DPS_SM_USIF_MAIN | 0x03)
#define DPS_SLAVE_DIAG (DPS_SM_USIF_SLAVE | 0x01)
#define DPS_GET_STATUS (DPS_SM_USIF_STATE | 0x01)
/****************************************************************************/
/*** DPS SERVICE CONSTANTS **************************************************/
/****************************************************************************/
/*--- DPS STATUS -----------------------------------------------------------*/
#define DPS_STATE_IDLE 0xFF
#define DPS_STATE_WAIT_PRM 0x00
#define DPS_STATE_WAIT_CFG 0x01
#define DPS_STATE_DATA_EXCHANGE 0x02
#define DPS_STATE_CONTROLLER_ERROR 0x03
/*--- DPS DIAGNOSTIC BITS --------------------------------------------------*/
#define DPS_DIAG_BIT_EXT_DIAG 0x01
#define DPS_DIAG_BIT_STAT_DIAG 0x02
#define DPS_DIAG_BIT_EXT_DIAG_OVERFLOW 0x04
#define DPS_DIAG_BIT_WAIT_UNTIL_FETCHED 0x80
#define DPS_DIAG_BIT_STATUS_MASK (DPS_DIAG_BIT_EXT_DIAG | \
DPS_DIAG_BIT_STAT_DIAG | \
DPS_DIAG_BIT_EXT_DIAG_OVERFLOW)
#define DPS_DIAG_BIT_MASK (DPS_DIAG_BIT_EXT_DIAG | \
DPS_DIAG_BIT_STAT_DIAG | \
DPS_DIAG_BIT_EXT_DIAG_OVERFLOW | \
DPS_DIAG_BIT_WAIT_UNTIL_FETCHED)
/*--- DPS SPC3 SPECIAL USR_PRM_BYTE ----------------------------------------*/
#define DPS_SPC3_USR_PRM_DISABLE_STARTBIT 0x01
#define DPS_SPC3_USR_PRM_DISABLE_STOPBIT 0x02
#define DPS_SPC3_USR_PRM_WD_BASE_1MS 0x04
#define DPS_SPC3_USR_PRM_MASK (DPS_SPC3_USR_PRM_DISABLE_STARTBIT | \
DPS_SPC3_USR_PRM_DISABLE_STOPBIT | \
DPS_SPC3_USR_PRM_WD_BASE_1MS)
/*--- DPS INPUT / OUTPUT STATUS --------------------------------------------*/
#define DPS_INPUT_STATE_FREEZE_ENABLED 0x01
#define DPS_INPUT_STATE_FREEZE_COMMAND 0x02
#define DPS_OUTPUT_STATE_SYNC_ENABLED 0x01
#define DPS_OUTPUT_STATE_SYNC_COMMAND 0x02
#define DPS_OUTPUT_STATE_CLEAR_DATA 0x04
#define DPS_OUTPUT_STATE_VALID_DATA 0x08
#define DPS_OUTPUT_STATE_NEW_DATA 0x10
#define DPS_OUTPUT_STATE_GLOBAL_CONTROL 0x20
/****************************************************************************/
/*** DPS SERVICE TYPES ******************************************************/
/****************************************************************************/
/*--------------------------------------------------------------------------*/
/*--- DPS USER INTERFACE STRUCTURES ----------------------------------------*/
/*--------------------------------------------------------------------------*/
typedef
struct
_T_DPS_INPUT_DATA_HEADER
{
USIGN8
input_data_len
;
/* length of DPS_USR input data, 0..244 */
USIGN8
input_state
;
/* status of input image: DPS_INPUT_STATE_xxx */
USIGN8
input_data
[
DP_MAX_INPUT_DATA_LEN
];
}
T_DPS_INPUT_DATA_HEADER
;
/*--------------------------------------------------------------------------*/
typedef
struct
_T_DPS_OUTPUT_DATA_HEADER
{
USIGN8
output_data_len
;
/* length of DP master output data, 0..244 */
USIGN8
output_state
;
/* status of output image: DPS_OUTPUT_STATE_xxx */
USIGN8
output_data
[
DP_MAX_OUTPUT_DATA_LEN
];
}
T_DPS_OUTPUT_DATA_HEADER
;
/*--------------------------------------------------------------------------*/
typedef
struct
_T_DPS_CON_IND
{
USIGN16
status
;
}
T_DPS_CON_IND
;
/*--------------------------------------------------------------------------*/
/*--- DPS USIF SERVICE STRUCTURES ------------------------------------------*/
/*--------------------------------------------------------------------------*/
typedef
struct
_T_DPS_INIT_SLAVE_REQ
{
USIGN8
slave_add
;
/* 0..125, DPS_DEFAULT_SLAVE_ADD, DPS_NON_VOLATILE_SLAVE_ADD */
USIGN8
min_tsdr
;
/* min. station delay responder, default 0, 11..255 */
PB_BOOL
auto_cfg_response
;
/* CFG check by DPS_USR ? PB_FALSE : PB_TRUE */
PB_BOOL
auto_prm_response
;
/* PRM check by DPS_USR ? PB_FALSE : PB_TRUE */
PB_BOOL
auto_startup_inputs
;
/* first input values by DPS at startup ? */
PB_BOOL
sync_mode_supported
;
/* activation of DPS operation modes ? */
PB_BOOL
freeze_mode_supported
;
PB_BOOL
set_slave_add_supported
;
/* activation of DPS service ? */
USIGN8
max_input_data_len
;
/* 0..DP_MAX_INPUT_DATA_LEN */
USIGN8
max_output_data_len
;
/* 0..DP_MAX_OUTPUT_DATA_LEN */
USIGN8
max_cfg_data_len
;
/* 1..DP_MAX_CFG_DATA_LEN */
USIGN8
max_usr_prm_data_len
;
/* 0..DP_MAX_USER_PRM_DATA_LEN */
USIGN8
max_ext_diag_data_len
;
/* 0..DP_MAX_EXT_DIAG_DATA_LEN */
USIGN8
max_address_data_len
;
/* 0..DP_MAX_TELEGRAM_LEN */
USIGN16
ident_number
;
/* 0 == Softing IdentNumber (Default) */
USIGN16
user_watchdog_timeout
;
/* WD timeout [1 ms], 0 == WD disabled */
USIGN8
reserved
[
4
];
/* reserved for extensions, set to 0 */
USIGN8
cfg_data_len
;
/* length of cfg_data, 1..DP_MAX_CFG_DATA_LEN */
USIGN8
enhanced_init_data_len
;
/* reserved for extensions, set to 0 */
USIGN8
cfg_data
[
DP_MAX_CFG_DATA_LEN
];
/* initial CFG data */
USIGN8
enhanced_init_data
[
DPS_MIN_SERVICE_IF_LEN
-
DP_MAX_CFG_DATA_LEN
-
24
];
}
T_DPS_INIT_SLAVE_REQ
;
/*--------------------------------------------------------------------------*/
typedef
struct
_T_DPS_INIT_SLAVE_CON
{
USIGN16
status
;
/* OK, IV, NO */
INT16
remaining_frame_memory
;
/* left memory for telegram buffers */
}
T_DPS_INIT_SLAVE_CON
;
/*==========================================================================*/
typedef
VOID
T_DPS_EXIT_SLAVE_REQ
;
/* no request parameters */
/*--------------------------------------------------------------------------*/
typedef
struct
_T_DPS_EXIT_SLAVE_CON
{
USIGN16
status
;
/* OK */
}
T_DPS_EXIT_SLAVE_CON
;
/*==========================================================================*/
typedef
VOID
T_DPS_GET_STATUS_REQ
;
/* no request parameters */
/*--------------------------------------------------------------------------*/
typedef
struct
_T_DPS_GET_STATUS_CON_IND
{
USIGN16
status
;
/* OK, TO */
USIGN8
slave_state
;
/* operation state of DP slave, DPS_STATE_xxx */
USIGN8
diag_state
;
/* diagnostic state of DP slave, DPS_DIAG_BIT_xxx */
USIGN16
ident_number
;
/* PNO ident number of this station */
USIGN8
number_inputs
;
/* I/O configuration in bytes */
USIGN8
number_outputs
;
USIGN8
slave_add
;
/* current station address, 0..125, 126 */
USIGN8
non_volatile_slave_add
;
/* via Set_Slave_Add set address */
USIGN8
master_add
;
/* 0..125 or DP_NO_MASTER_ADDRESS */
USIGN8
baud_rate
;
/* DPS_KBAUD_xxx, DPS_MBAUD_xxx, DPS_NO_BUS_TRAFFIC */
PB_BOOL
sync_enabled
;
/* sync mode enabled by DP master ? */
PB_BOOL
freeze_enabled
;
/* freeze mode enabled by DP master ? */
PB_BOOL
clear_data
;
/* DP master in CLEAR operation mode ? */
PB_BOOL
prm_await_response
;
/* waits for DPS_Set_Prm.res from DPS_USR */
PB_BOOL
cfg_await_response
;
/* waits for DPS_Chk_Cfg.res from DPS_USR */
PB_BOOL
await_startup_inputs
;
/* waits for first inputs from DPS_USR */
USIGN8
reserved
[
16
];
/* reserved for extensions, ignore 0 value */
}
T_DPS_GET_STATUS_CON_IND
;
/*==========================================================================*/
typedef
struct
_T_DPS_SLAVE_DIAG_REQ
{
USIGN8
diag_state
;
/* diagnostic state of DP slave, DPS_DIAG_BIT_xxx */
USIGN8
ext_diag_data_len
;
/* 0..DP_MAX_EXT_DIAG_DATA_LEN */
USIGN8
ext_diag_data
[
DP_MAX_EXT_DIAG_DATA_LEN
];
/* ext_diag_data_len */
}
T_DPS_SLAVE_DIAG_REQ
;
/*--------------------------------------------------------------------------*/
typedef
struct
_T_DPS_SLAVE_DIAG_CON
{
USIGN16
status
;
/* OK, IV, NO */
}
T_DPS_SLAVE_DIAG_CON
;
/*==========================================================================*/
typedef
struct
_T_DPS_CHK_CFG_IND
{
USIGN16
status
;
/* OK */
USIGN8
cfg_data_len
;
/* CFG from DP master, see EN 50170 */
PB_BOOL
cfg_await_response
;
/* the indication has to be acknowledged */
USIGN8
cfg_data
[
DP_MAX_CFG_DATA_LEN
];
/* cfg_data_len */
}
T_DPS_CHK_CFG_IND
;
/*--------------------------------------------------------------------------*/
typedef
struct
_T_DPS_CHK_CFG_RES
{
USIGN16
status
;
/* OK, NO */
}
T_DPS_CHK_CFG_RES
;
/*==========================================================================*/
typedef
struct
_T_DPS_SET_PRM_IND
{
USIGN16
status
;
/* OK */
USIGN8
user_prm_data_len
;
/* 0..DP_MAX_USER_PRM_DATA_LEN */
PB_BOOL
prm_await_response
;
/* the indication has to be acknowledged */
USIGN8
station_status
;
/* DP_PRM_xxx */
USIGN8
wd_fact_1
;
/* watch dog time factors */
USIGN8
wd_fact_2
;
/* WD time = wd_fact_1 * wd_fact_2 * [1ms/10ms] */
USIGN8
min_tsdr
;
/* minimum station delay responder */
USIGN16
ident_number
;
/* PNO ident number */
USIGN8
group_ident
;
/* groups for GLOBAL_CONTROL */
USIGN8
user_prm_data
[
DP_MAX_USER_PRM_DATA_LEN
];
/* user_prm_data_len */
/* user_prm_data [0]: special SPC3 user PRM byte -> DPS_SPC3_USR_PRM_xxx */
}
T_DPS_SET_PRM_IND
;
/*--------------------------------------------------------------------------*/
typedef
struct
_T_DPS_SET_PRM_RES
{
USIGN16
status
;
/* OK, NO */
}
T_DPS_SET_PRM_RES
;
/*==========================================================================*/
typedef
struct
_T_DPS_SET_SLAVE_ADD_IND
{
USIGN16
status
;
/* OK */
USIGN8
rem_slave_data_len
;
/* 0..DP_MAX_REM_SLAVE_DATA_LEN */
USIGN8
new_slave_add
;
/* new slave address set by DP master, 0..125 */
USIGN16
ident_number
;
/* PNO ident_number */
PB_BOOL
no_add_chg
;
/* PB_TRUE: address change after reset only */
/* rem_slave_data_len */
USIGN8
rem_slave_data
[
DP_MAX_REM_SLAVE_DATA_LEN
];
}
T_DPS_SET_SLAVE_ADD_IND
;
/*==========================================================================*/
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to reset alignment */
#ifdef WIN32
#pragma pack(pop)
#else
#pragma pack()
#endif
#pragma warning (default : 4103)
#endif
#endif
/* __PB_DPS__ */
profibus/lib/rt/src/os_linux/pb_err.h
View file @
0135e84d
/*
* Proview $Id: pb_err.h,v 1.2 2006-02-01 08:35:51 claes Exp $
* Copyright (C) SOFTING GmbH 1995-1999.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/*****************************************************************************/
/* */
/* */
/*
SOFTING GmbH
*/
/*
SOFTING AG
*/
/* Richard-Reitzner-Allee 6 */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* */
/* Copyright (C) SOFTING GmbH 1995-1999 */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/* */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/* PROFIBUS ABORT-, REJECT-, EVENT- and ERROR DEFINES and -TYPES */
/* PROFIBUS ABORT-, REJECT-, EVENT- and ERROR DEFINES and -TYPES */
/* */
/* */
/* Filename : PB_ERR.H */
/* Filename : PB_ERR.H */
/* Version : 5.2
1.0
.00.release */
/* Version : 5.2
6.1
.00.release */
/* Date : 27-
February-1998
*/
/* Date : 27-
June-2003
*/
/* Author : SOFTING
-FE3
*/
/* Author : SOFTING
AG
*/
/* */
/* */
/* Description : This file contains the ABORT, REJECT, EVENT and ERROR */
/* Description : This file contains the ABORT, REJECT, EVENT and ERROR */
/* types and defines and the according reason codes. */
/* types and defines and the according reason codes. */
/* */
/* */
/* CHANGE_NOTES */
/* */
/* date name change */
/* ----------------------------------------------------------------------- */
/* 22.07.97 BG2-BOE set #pragma pack(2) and reset to #pragma pack() */
/* 24.09.97 BG2-BOE add additional error codes */
/* 25.09.97 BG2-NI add DP/V1 abort reason codes and DP/V1 errors */
/* 27.02.98 BG2-BOE modify add. interface error codes */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
#ifndef __PB_ERR__
#ifndef __PB_ERR__
#define __PB_ERR__
#define __PB_ERR__
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to change alignment */
#ifdef WIN32
#pragma pack(push,2)
#else
#pragma pack(2)
#endif
#pragma warning (default : 4103)
#endif
/*****************************************************************************/
/*****************************************************************************/
/************* ABORT REASON CODES *********************/
/************* ABORT REASON CODES *********************/
...
@@ -561,6 +544,8 @@
...
@@ -561,6 +544,8 @@
#define E_FMB_SERV_PARAM_INCONSIST 0x0303
#define E_FMB_SERV_PARAM_INCONSIST 0x0303
#define E_FMB_SERV_ILLEGAL_PARAM 0x0304
#define E_FMB_SERV_ILLEGAL_PARAM 0x0304
#define E_FMB_SERV_PERM_INTERN_FAULT 0x0305
#define E_FMB_SERV_PERM_INTERN_FAULT 0x0305
#define E_FMB_SERV_LOCAL_DISCONNECT 0x0306
#define E_FMB_SERV_NO_ACKNOWLEDGE 0x0307
#define E_FMB_ACCESS_OTHER 0x0500
#define E_FMB_ACCESS_OTHER 0x0500
#define E_FMB_ACCESS_OBJ_ACC_UNSUP 0x0501
#define E_FMB_ACCESS_OBJ_ACC_UNSUP 0x0501
...
@@ -571,6 +556,7 @@
...
@@ -571,6 +556,7 @@
#define E_FMB_OTHER 0x0700
#define E_FMB_OTHER 0x0700
#define E_FMB_CFG_DP_OTHER 0x0900
#define E_FMB_CFG_DP_TOO_MANY_SLAVES 0x0901
#define E_FMB_CFG_DP_TOO_MANY_SLAVES 0x0901
#define E_FMB_CFG_DP_WRONG_IO_DATA_LEN 0x0902
#define E_FMB_CFG_DP_WRONG_IO_DATA_LEN 0x0902
#define E_FMB_CFG_DP_IO_ALIGNMENT_ERROR 0x0903
#define E_FMB_CFG_DP_IO_ALIGNMENT_ERROR 0x0903
...
@@ -651,6 +637,57 @@
...
@@ -651,6 +637,57 @@
#define E_DP_ILLEGAL_EXTENSION 0x2600
#define E_DP_ILLEGAL_EXTENSION 0x2600
/****************************************************************************/
/************* DP ERROR CODE DEFINITIONS ****************************/
/****************************************************************************/
/*--- DPS SERVICE RESULTS ---------------------------------------------------*/
#define E_DPS_OK 0x0000
/* acknowledgement positive */
#define E_DPS_UE 0x0001
/* remote user error */
#define E_DPS_RR 0x0002
/* remote resource insufficient */
#define E_DPS_RS 0x0003
/* remote service/SAP deactivated */
#define E_DPS_RA 0x0004
/* access of remote SAP blocked */
#define E_DPS_NA 0x0011
/* no reaction from remote station */
#define E_DPS_DS 0x0012
/* local entity disconnected */
#define E_DPS_NO 0x0013
/* not possible in this state */
#define E_DPS_LR 0x0014
/* local resource not available */
#define E_DPS_IV 0x0015
/* invalid parameter in request */
#define E_DPS_TO 0x0016
/* timeout expired */
#define E_DPS_FE 0x00C1
/* format error in request frame */
#define E_DPS_NI 0x00C2
/* function not implemented */
#define E_DPS_AD 0x00C3
/* access denied */
#define E_DPS_EA 0x00C4
/* area too large */
#define E_DPS_LE 0x00C5
/* data block length exceeded */
#define E_DPS_RE 0x00C6
/* format error in response frame */
#define E_DPS_IP 0x00C7
/* invalid parameter */
#define E_DPS_SC 0x00C8
/* sequence conflict */
#define E_DPS_SE 0x00C9
/* sequence error */
#define E_DPS_NE 0x00CA
/* area non-existent */
#define E_DPS_DI 0x00CB
/* data incomplete */
#define E_DPS_NC 0x00CC
/* not connected */
/*--- DPS ERROR EXTENSIONS --------------------------------------------------*/
#define E_DPS_DUPLICATED_SERVICE 0x0100
#define E_DPS_WRONG_SLAVE_ADDRESS 0x0200
#define E_DPS_WRONG_CFG_LEN 0x0300
#define E_DPS_WRONG_PRM_LEN 0x0400
#define E_DPS_WRONG_DIAG_LEN 0x0500
#define E_DPS_WRONG_SSA_LEN 0x0600
#define E_DPS_WRONG_ENHANCED_INIT_LEN 0x0700
#define E_DPS_ILLEGAL_CFG_DATA 0x0800
#define E_DPS_NOT_ENOUGH_FRAME_MEMORY 0x0900
#define E_DPS_WRONG_INPUT_LEN 0x0A00
#define E_DPS_WRONG_OUTPUT_LEN 0x0B00
#define E_DPS_INVALID_DIAG_STATE 0x0C00
#define E_DPS_INVALID_EXT_DIAG_DATA 0x0D00
#define E_DPS_SSA_REQUIRED 0x0E00
#define E_DPS_SSA_NOT_SUPPORTED 0x0F00
/*****************************************************************************/
/*****************************************************************************/
/************* DP/V1 ERROR PDU CODING *********************/
/************* DP/V1 ERROR PDU CODING *********************/
/*****************************************************************************/
/*****************************************************************************/
...
@@ -745,21 +782,24 @@
...
@@ -745,21 +782,24 @@
#define E_IF_SERVICE_NOT_EXECUTABLE 25
/* service not executable */
#define E_IF_SERVICE_NOT_EXECUTABLE 25
/* service not executable */
#define E_IF_INVALID_VERSION 26
/* invalid version */
#define E_IF_INVALID_VERSION 26
/* invalid version */
#define E_IF_NO_CNTRL_PRESENT
28
#define E_IF_NO_CNTRL_PRESENT
28
/* controller not available */
#define E_IF_INVALID_PARAMETER 30
/* wrong parameter in REQ or RES */
#define E_IF_INVALID_PARAMETER 30
/* wrong parameter in REQ or RES */
#define E_IF_INIT_FAILED 31
/* init. API or Controller failed */
#define E_IF_INIT_FAILED 31
/* init. API or Controller failed */
#define E_IF_EXIT_FAILED 32
/* exit API or Controller failed */
#define E_IF_EXIT_FAILED 32
/* exit API or Controller failed */
#define E_IF_PAPI_NOT_INITIALIZED 33
/* API not initialized */
#define E_IF_PAPI_NOT_INITIALIZED 33
/* API not initialized */
#define E_IF_NO_DEVICE_CONNECTION 34
/* no PROFIBUS device connection */
/* error codes available only in Win NT --------------------------------------- */
/* error codes available only in Win NT --------------------------------------- */
#define E_IF_SLAVE_DIAG_DATA 0xF0
/* no data available */
#define E_IF_SLAVE_DIAG_DATA 0xF0
/* no data available */
/* new diagnostics data available */
/* new diagnostics data available */
#define E_IF_SLAVE_ERROR 0xF1
/* no data exchange */
#define E_IF_SLAVE_ERROR 0xF1
/* no data exchange */
#define E_IF_INVALID_DP_STATE 0xF2
/* DP is not in state operate */
#define E_IF_INVALID_DP_STATE 0xF2
/* DP is not in state clear/operate*/
#define E_IF_READING_REGISTRY 0xF3
/* error reading registry */
#define E_IF_OS_ERROR 0xFF
/* OS system (WIN,DOS) error */
#define E_IF_OS_ERROR 0xFF
/* OS system (WIN,DOS) error */
/* get detail with GetLastError */
/* get detail with GetLastError */
/* INTERFACE ERROR DETAIL CODES
----------------
------------------------------- */
/* INTERFACE ERROR DETAIL CODES
(only Win95/98)
------------------------------- */
/* for folLowing INTERFACE-ERRORS */
/* for folLowing INTERFACE-ERRORS */
/* - E_IF_NO_CNTRL_PRESENT */
/* - E_IF_NO_CNTRL_PRESENT */
/* - E_IF_INIT_FAILED */
/* - E_IF_INIT_FAILED */
...
@@ -788,11 +828,12 @@
...
@@ -788,11 +828,12 @@
#define PROFIBRD_PORT_ALREADY_USED 0x0043
/* IO port already in use */
#define PROFIBRD_PORT_ALREADY_USED 0x0043
/* IO port already in use */
/*****************************************************************************/
/*****************************************************************************/
/************* ERROR DATA STRUCTURES *****************************/
/************* ERROR DATA STRUCTURES *****************************/
/*****************************************************************************/
/*****************************************************************************/
#define MAX_ERROR_DESCR_LENGTH
ERROR_DESCR_LENGTH
#define MAX_ERROR_DESCR_LENGTH
_NAME_LENGTH(ERROR_DESCR_LENGTH)
/* --- standard error data structure --------------------------------------- */
/* --- standard error data structure --------------------------------------- */
typedef
struct
_T_ERROR
typedef
struct
_T_ERROR
...
@@ -887,5 +928,16 @@ typedef struct _T_EXCEPTION
...
@@ -887,5 +928,16 @@ typedef struct _T_EXCEPTION
USIGN16
par3
;
/* parameter 3 */
USIGN16
par3
;
/* parameter 3 */
}
T_EXCEPTION
;
}
T_EXCEPTION
;
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to reset alignment */
#ifdef WIN32
#pragma pack(pop)
#else
#pragma pack()
#endif
#pragma warning (default : 4103)
#endif
#endif
#endif
profibus/lib/rt/src/os_linux/pb_fdl.h
0 → 100644
View file @
0135e84d
/*****************************************************************************/
/* */
/* SOFTING AG */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* FDL-USER-INTERFACE DEFINES and TYPES */
/* */
/* Filename : PB_FDL.H */
/* Version : 5.21.0.00.release */
/* Date : 27-February-1998 */
/* Author : SOFTING AG */
/* */
/* Description : This file contains the types and defines of the FDL-User- */
/* Interface */
/* */
/*****************************************************************************/
#ifndef __PB_FDL__
#define __PB_FDL__
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to change alignment */
#ifdef WIN32
#pragma pack(push,2)
#else
#pragma pack(2)
#endif
#pragma warning (default : 4103)
#endif
/*****************************************************************************/
/*** FDL service identifier ***/
/*****************************************************************************/
#define FDLIF_SDA 0
#define FDLIF_SDN 1
#define FDLIF_SRD 2
#define FDLIF_REPLY_UPDATE 3
#define FDLIF_REPLY_UPDATE_MULTIPLE 4
#define FDLIF_SET_BUSPARAMETER 5
#define FDLIF_READ_BUSPARAMETER 6
#define FDLIF_SAP_ACTIVATE 7
#define FDLIF_RSAP_ACTIVATE 8
#define FDLIF_SAP_CHANGE_ACCESS 9
#define FDLIF_SAP_DEACTIVATE 10
#define FDLIF_EVENT 19
#define FDLIF_EXIT 21
/*****************************************************************************/
/*** Status of FDL confirmations, indications (error_code) ***/
/*****************************************************************************/
#define FDL_UE 0x01
/* neg. ack., remote user error */
#define FDL_RR 0x02
/* neg. ack., resource of remote FDL
entity not available or sufficient */
#define FDL_RS 0x03
/* neg. ack., service at remote SAP
or remote SAP not activated */
#define FDL_RA 0x04
/* neg. ack., access of remote SAP blocked */
#define FDL_DL 0x08
/* pos. ack. for sent data, reply data
with low priority available */
#define FDL_NR 0x09
/* pos. ack. for sent data, no reply data */
#define FDL_DH 0x0a
/* pos. ack. for sent data, reply data
with high priority available */
#define FDL_RDL 0x0c
/* neg. ack. for sent data, reply data
with low priority available */
#define FDL_RDH 0x0d
/* neg. ack. for sent data, reply data
with high priority available */
#define FDL_LS 0x10
/* service at local SAP or local SAP not
activated */
#define FDL_NA 0x11
/* no reaction from remote station */
#define FDL_DS 0x12
/* local FDL entity disconnected */
#define FDL_NO 0x13
/* not ok */
#define FDL_LR 0x14
/* resource of local FDL not available */
#define FDL_IV 0x15
/* invalid parameter in request */
#define FDL_LOW_DATA 0x20
/* low priority reply data transmitted */
#define FDL_HIGH_DATA 0x21
/* high priority reply data transmitted */
#define FDL_NO_DATA 0x22
/* no reply data transmitted */
/*****************************************************************************/
/*** SAP and address constants ***/
/*****************************************************************************/
#define BROADCAST 127
/* broadcast address */
#define FDL_DEFAULT_SAP 64
/* number of Default SAP */
/*****************************************************************************/
/*** Constants for specifying baudrate ***/
/*****************************************************************************/
#define KBAUD_9_6 0x00
#define KBAUD_19_2 0x01
#define KBAUD_45_45 0x0B
#define KBAUD_93_75 0x02
#define KBAUD_187_5 0x03
#define KBAUD_500 0x04
#define KBAUD_750 0x05
#define MBAUD_1_5 0x06
#define MBAUD_3 0x07
#define MBAUD_6 0x08
#define MBAUD_12 0x09
/*****************************************************************************/
/*** Constants for specifying redundancy ***/
/*****************************************************************************/
#define NO_REDUNDANCY 0x00
/*****************************************************************************/
/*** Data Mode for SRD and SDA indications ***/
/*****************************************************************************/
#define NORMAL_MODE 0x00
/* all faultless telegrams are indicated */
#define DATA_MODE 0x08
/* indication only if data transmitted */
/*****************************************************************************/
/*** Constants for access in SAP block ***/
/*****************************************************************************/
#define ALL 0xFF
#define SEGMENT_VALID 0x80
#define SEGMENT_INVALID 0x00
#define SEGMENT_TYP 0x40
#define INITIATOR 0x00
#define RESPONDER 0x10
#define BOTH_ROLES 0x20
#define SERVICE_NOT_ACTIVATED 0x30
/* ************************************************************************** */
/* ************** Busparameter block ********************* */
/* ************************************************************************** */
typedef
struct
_T_FDLIF_SET_BUSPARAMETER_REQ
{
USIGN8
loc_add
;
/* local station */
USIGN8
loc_segm
;
/* local segment */
USIGN8
baud_rate
;
/* baud rate */
USIGN8
medium_red
;
/* medium redundancy */
USIGN16
tsl
;
/* slot time */
USIGN16
min_tsdr
;
/* min. station delay time resp. */
USIGN16
max_tsdr
;
/* max. station delay time resp. */
USIGN8
tqui
;
/* quiet time */
USIGN8
tset
;
/* setup time */
USIGN32
ttr
;
/* target token rotation time */
USIGN8
g
;
/* gap update factor */
PB_BOOL
in_ring_desired
;
/* active or passive station */
USIGN8
hsa
;
/* highest station address */
USIGN8
max_retry_limit
;
/* max. retry limit */
USIGN16
reserved
;
/* not used */
USIGN8
ident
[
202
];
/* for internal use */
}
T_FDLIF_SET_BUSPARAMETER_REQ
;
typedef
struct
_T_FDLIF_READ_BUSPARAMETER_CNF
{
USIGN8
loc_add
;
/* local station */
USIGN8
loc_segm
;
/* local segment */
USIGN8
baud_rate
;
/* baud rate */
USIGN8
medium_red
;
/* medium redundancy */
USIGN16
tsl
;
/* slot time */
USIGN16
min_tsdr
;
/* min. station delay time resp. */
USIGN16
max_tsdr
;
/* max. station delay time resp. */
USIGN8
tqui
;
/* quiet time */
USIGN8
tset
;
/* setup time */
USIGN32
ttr
;
/* target token rotation time */
USIGN8
g
;
/* gap update factor */
PB_BOOL
in_ring_desired
;
/* active or passive station */
USIGN8
hsa
;
/* highest station address */
USIGN8
max_retry_limit
;
/* max. retry limit */
USIGN16
reserved
;
/* not used */
USIGN8
ident
[
202
];
/* FDL-Ident-String */
}
T_FDLIF_READ_BUSPARAMETER_CNF
;
/* ************************************************************************* */
/* ******************* SAP block ************************* */
/* ************************************************************************* */
typedef
struct
_T_FDLIF_SAP_ACTIVATE_REQ
{
USIGN8
sap_nr
;
/* SAP to be activated */
USIGN8
max_l_sdu_length_req
;
/* maximum length of request telegram */
USIGN8
max_l_sdu_length_con_ind
;
/* maximum length of con/ind telegram */
USIGN8
access_sap
;
/* permitted request SAPs */
USIGN8
access_station
;
/* permitted requestor */
USIGN8
sda
;
/* roles in SDA service */
USIGN8
sdn
;
/* roles in SDN service */
USIGN8
srd
;
/* roles in SRD service */
USIGN8
csrd
;
/* not supported */
USIGN8
data_mode
;
/* NORMAL_MODE, DATA_MODE */
USIGN8
credits
;
/* number of indication resources */
USIGN8
dummy
;
/* alignment byte */
}
T_FDLIF_SAP_ACTIVATE_REQ
;
typedef
struct
_T_FDLIF_RSAP_ACTIVATE_REQ
{
USIGN8
sap_nr
;
/* SAP to be activated */
USIGN8
max_l_sdu_length_req
;
/* maximum length of req telegram */
USIGN8
max_l_sdu_length_ind
;
/* maximum length of ind telegram */
USIGN8
access_sap
;
/* permitted request SAPs */
USIGN8
access_station
;
/* permitted requestor */
USIGN8
data_mode
;
/* NORMAL_MODE, DATA_MODE */
USIGN8
credits
;
/* number of indication resources */
USIGN8
dummy
;
/* alignmnet byte */
}
T_FDLIF_RSAP_ACTIVATE_REQ
;
typedef
struct
_T_FDLIF_SAP_CHANGE_REQ
{
USIGN8
sap_nr
;
/* SAP to be activated */
USIGN8
access_sap
;
/* permitted request SAPs */
USIGN8
access_station
;
/* permitted requestor */
USIGN8
dummy
;
/* alignment byte */
}
T_FDLIF_SAP_CHANGE_REQ
;
typedef
struct
_T_FDLIF_SAP_DEACTIVATE_REQ
{
USIGN8
sap_nr
;
/* SAP to be activated */
USIGN8
dummy
;
/* alignment byte */
}
T_FDLIF_SAP_DEACTIVATE_REQ
;
/* ************************************************************************* */
/* ************* Data transfer ********************* */
/* ************************************************************************* */
typedef
struct
_T_FDLIF_SDN_SDA_SRD_REQ
{
USIGN8
ssap
;
/* source SAP */
USIGN8
dsap
;
/* destination SAP */
USIGN8
rem_add
;
/* address of remote station */
USIGN8
priority
;
/* priority of request */
USIGN8
status
;
/* only used for SRD.IND */
USIGN8
length
;
/* length of request data */
/* USIGN8 req_data [length] request data */
}
T_FDLIF_SDN_SDA_SRD_REQ
;
typedef
struct
_T_FDLIF_SRD_CNF
{
USIGN8
status
;
/* status */
USIGN8
length
;
/* length of request data */
/* USIGN8 cnf_data [length]; request data */
}
T_FDLIF_SRD_CNF
;
typedef
struct
_T_FDLIF_RUP_REQ
{
USIGN8
sap_nr
;
/* number of local SAP */
USIGN8
priority
;
/* priority of request */
USIGN8
dummy
;
/* alignment byte */
USIGN8
length
;
/* length of request data */
/* USIGN8 req_data [length]; request data */
}
T_FDLIF_RUP_REQ
;
/* ************************************************************************* */
/* ************* Event ********************* */
/* ************************************************************************* */
/* the possible events are defined in the header file PB_ERR.H */
typedef
struct
_T_FDLIF_EVENT_IND
{
USIGN8
event
;
/* event */
USIGN8
dummy
;
/* alignment byte */
}
T_FDLIF_EVENT_IND
;
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to reset alignment */
#ifdef WIN32
#pragma pack(pop)
#else
#pragma pack()
#endif
#pragma warning (default : 4103)
#endif
#endif
/* __PB_FDL__ */
profibus/lib/rt/src/os_linux/pb_fm7.h
0 → 100644
View file @
0135e84d
/*****************************************************************************/
/* */
/* SOFTING AG */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* FM7-USER-INTERFACE DEFINES and TYPES */
/* */
/* Filename : PB_FM7.H */
/* Version : 5.21.0.00.release */
/* Date : 27-February-1998 */
/* Author : SOFTING AG */
/* */
/* Description : This file contains the types and defines of the FM7-User- */
/* Interface */
/* */
/*****************************************************************************/
#ifndef __PB_FM7__
#define __PB_FM7__
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to change alignment */
#ifdef WIN32
#pragma pack(push,2)
#else
#pragma pack(2)
#endif
#pragma warning (default : 4103)
#endif
/****************************************************************************/
/************* FM7-SERVICE-IDENTIFIERS ********************/
/****************************************************************************/
/*---FM7-Service-Identifiers --------------------------------------------- */
#define FM7_INITIATE 0
#define FM7_ABORT 38
#define FM7_READ_CRL_REM 1
#define FM7_INIT_LOAD_CRL_REM 2
#define FM7_LOAD_CRL_REM 3
#define FM7_TERM_LOAD_CRL_REM 4
#define FM7_SET_VALUE_REM 5
#define FM7_READ_VALUE_REM 6
#define FM7_LSAP_STATUS_REM 7
#define FM7_IDENT_REM 8
#define FM7_READ_CRL_LOC 11
#define FM7_INIT_LOAD_CRL_LOC 12
#define FM7_LOAD_CRL_LOC 13
#define FM7_TERM_LOAD_CRL_LOC 14
#define FM7_SET_VALUE_LOC 15
#define FM7_READ_VALUE_LOC 16
#define FM7_LSAP_STATUS_LOC 17
#define FM7_IDENT_LOC 18
#define FM7_EVENT 19
#define FM7_RESET 20
#define FM7_EXIT 21
#define FM7_SET_BUSPARAMETER 22
#define FM7_READ_BUSPARAMETER 24
#define FM7_GET_LIVE_LIST 26
#if (PB_VER < 500)
#define FMA7_INITIATE FM7_INITIATE
#define FMA7_READ_KBL_REM FM7_READ_CRL_REM
#define FMA7_INIT_LOAD_KBL_REM FM7_INIT_LOAD_CRL_REM
#define FMA7_LOAD_KBL_REM FM7_LOAD_CRL_REM
#define FMA7_TERM_LOAD_KBL_REM FM7_TERM_LOAD_CRL_REM
#define FMA7_SET_VALUE_REM FM7_SET_VALUE_REM
#define FMA7_READ_VALUE_REM FM7_READ_VALUE_REM
#define FMA7_LSAP_STATUS_REM FM7_LSAP_STATUS_REM
#define FMA7_IDENT_REM FM7_IDENT_REM
#define FMA7_ABORT FM7_ABORT
#define FMA7_READ_KBL_LOC FM7_READ_CRL_LOC
#define FMA7_INIT_LOAD_KBL_LOC FM7_INIT_LOAD_CRL_LOC
#define FMA7_LOAD_KBL_LOC FM7_LOAD_CRL_LOC
#define FMA7_TERM_LOAD_KBL_LOC FM7_TERM_LOAD_CRL_LOC
#define FMA7_SET_VALUE_LOC FM7_SET_VALUE_LOC
#define FMA7_READ_VALUE_LOC FM7_READ_VALUE_LOC
#define FMA7_LSAP_STATUS_LOC FM7_LSAP_STATUS_LOC
#define FMA7_IDENT_LOC FM7_IDENT_LOC
#define FMA7_EVENT FM7_EVENT
#define FMA7_RESET FM7_RESET
#define FMA7_PROFIBUS_EXIT FM7_EXIT
#define FMA7_EXIT FM7_EXIT
#define FMA7_SET_BUSPARAMETER FM7_SET_BUSPARAMETER
#define FMA7_SET_STATISTIC_CTR 23
#define FMA7_READ_BUSPARAMETER FM7_READ_BUSPARAMETER
#define FMA7_READ_STATISTIC_CTR 25
#define FMA7_GET_LIVE_LIST FM7_GET_LIVE_LIST
#define FMA7_SET_CONFIGURATION 27
#define FMA7_EXCEPTION 28
#endif
/****************************************************************************/
/************* FM7-STRING-LENGTH-CONSTANTS ********************/
/****************************************************************************/
#define MAX_CRL_EXTENSION_LENGTH _NAME_LENGTH(CRL_EXTENSION_LENGTH+1)
#define MAX_CRL_SYMBOL_LENGTH _NAME_LENGTH(CRL_SYMBOL_LENGTH)
#if (PB_VER < 500)
#define MAX_KBL_EXTENSION_LENGTH MAX_CRL_EXTENSION_LENGTH
#define MAX_KBL_SYMBOL_LENGTH MAX_CRL_SYMBOL_LENGTH
#endif
#define MAX_IDENT_STRING_LENGTH _NAME_LENGTH(IDENT_STRING_LENGTH)
/****************************************************************************/
/* FM7-Context-Management */
/****************************************************************************/
#define DETAIL_LENGTH 16
/* length of abort detail */
#define FEAT_SUPP_LEN 6
/* length of supported feature field */
/****************************************************************************/
/* Initiate Service */
/****************************************************************************/
typedef
struct
_T_FM7_INIT_REQ
{
USIGN8
snd_len_low
;
/* max FM7 PDU size to send with low priority */
USIGN8
rcv_len_low
;
/* max FM7 PDU size to receive with low priority */
USIGN8
supported_services
[
FEAT_SUPP_LEN
];
/* supported FM7 services */
}
T_FM7_INIT_REQ
;
#if (PB_VER < 500)
typedef
T_FM7_INIT_REQ
T_FMA_INIT_REQ
;
#endif
typedef
struct
_T_FM7_INIT_ERR_CNF
{
USIGN16
class_code
;
/* error code and class */
USIGN8
snd_len_low
;
/* max FM7 PDU size to send with low priority */
USIGN8
rcv_len_low
;
/* max FM7 PDU size to receive with low priority */
USIGN8
supported_services
[
FEAT_SUPP_LEN
];
/* supported FM7 services */
}
T_FM7_INIT_ERR_CNF
;
#if (PB_VER < 500)
typedef
T_FM7_INIT_ERR_CNF
T_FMA_INIT_ERR_CNF
;
#endif
/****************************************************************************/
/* Abort Service */
/****************************************************************************/
typedef
struct
_T_FM7_ABORT_REQ
{
PB_BOOL
local
;
/* local or remote detected */
USIGN8
abort_id
;
/* identifier (USR,LLI_USR,LLI,FDL) */
USIGN8
reason
;
/* abort reason code */
USIGN8
detail_length
;
/* length of detail information */
USIGN8
detail
[
DETAIL_LENGTH
];
/* detail information about the reason */
}
T_FM7_ABORT_REQ
;
#if (PB_VER < 500)
typedef
T_FM7_ABORT_REQ
T_FMA_ABORT_REQ
;
#endif
/****************************************************************************/
/* CRL-Management */
/****************************************************************************/
/* --- special values of segment address ---------------------------------- */
#define NO_SEGMENT 255
/* --- special values of station address ---------------------------------- */
#define GLOBAL_ADDRESS 127
#define ALL 0xFF
/* --- special LSAP values ------------------------------------------------ */
#define BRCT_SAP 63
#define DEFAULT_SAP 128
/* --- LLI-SAP ------------------------------------------------------------ */
#define FMS_SAP 0x00
#define FM7_SAP 0x01
#if (PB_VER < 500)
#define FMA7_SAP FM7_SAP
#endif
/* --- connection type (CR-Type/LLI-Warning/LLI-Event/Role-in-Type) ------- */
/* --- CR-Types ----------------------------------------------------------- */
#define MMAC 0x00
#define MSAC 0x01
#define MSAC_SI 0x05
#define MSCY 0x03
#define MSCY_SI 0x07
#define BRCT 0x08
#define MULT 0x0A
#define MSCY_D 0x0B
#define MSCY_DSI 0x0F
#if (PB_VER < 500)
#define MMAZ MMAC
#define MSAZ MSAC
#define MSAZ_SI MSAC_SI
#define MSZY MSCY
#define MSZY_SI MSCY_SI
#endif
/* --- LLI-Warning -------------------------------------------------------- */
#define LLI_W 0x40
/* --- LLI-Event ---------------------------------------------------------- */
#define LLI_E 0x80
/* --- Role-in-Type ------------------------------------------------------- */
#define MM_RES 0x10
#define MM_REQ 0x20
#define MM_REQ_RES 0x30
#define MS_RES 0x10
#define MS_REQ 0x20
#define CL_RCV 0x10
#define CL_REQ 0x20
/* --- connection-attribute (connection-attribute) ----------------------- */
/* --- connection-attribute ---------------------------------------------- */
#define D_CONN 0x00
#define I_CONN 0x01
#define O_CONN 0x02
/*--- CRL-Header -----------------------------------------------------------*/
typedef
struct
_T_CRL_HDR
{
INT16
nr_of_entries
;
/* number of CRL enries */
USIGN8
poll_sap
;
/* poll list SAP */
USIGN8
symbol_length
;
/* max symbol lenght in CRL */
USIGN32
ass_abt_ci
;
/* ASS / ABT controll intervall */
PB_BOOL
vfd_pointer_supported
;
/* VFD pointer supported */
USIGN8
dummy
;
/* alignment byte */
}
T_CRL_HDR
;
#if (PB_VER < 500)
typedef
T_CRL_HDR
T_KBL_HDR
;
#endif
/*--- CRL-Static-Entry -----------------------------------------------------------*/
typedef
struct
_T_CRL_STATIC
{
USIGN8
loc_lsap
;
/* local LSAP */
USIGN8
rem_add
;
/* remote address */
USIGN8
rem_segm
;
/* remote segment */
USIGN8
rem_lsap
;
/* remote LSAP */
USIGN8
conn_type
;
/* connection type */
USIGN8
lli_sap
;
/* LLI-SAP */
USIGN8
multiplier
;
/* multiplier in cyclic connections */
USIGN8
conn_attr
;
/* connection attribute */
USIGN8
max_scc
;
/* max. of send confirmed counter */
USIGN8
max_rcc
;
/* max. of receive confirmed counter */
USIGN8
max_sac
;
/* max. of send acknowledged counter */
USIGN8
max_rac
;
/* max. of receive acknowledged ctr */
USIGN32
ci
;
/* controll intervall */
USIGN8
max_pdu_snd_high
;
/* max. length of FMS-PDU send high */
USIGN8
max_pdu_snd_low
;
/* max. length of FMS-PDU send low */
USIGN8
max_pdu_rcv_high
;
/* max. length of FMS-PDU rcv high */
USIGN8
max_pdu_rcv_low
;
/* max. length of FMS-PDU rcv low */
USIGN8
feature_supp
[
FEAT_SUPP_LEN
];
/* FMS features supported */
STRINGV
symbol
[
MAX_CRL_SYMBOL_LENGTH
];
/* symbolic name */
USIGN32
vfd_pointer
;
/* vfd number */
USIGN8
extension
[
MAX_CRL_EXTENSION_LENGTH
];
/* CRL-Extension */
}
T_CRL_STATIC
;
#if (PB_VER < 500)
typedef
T_CRL_STATIC
T_KBL_STATIC
;
#endif
/*--- CRL-Dynamic-Entry ----------------------------------------------------*/
typedef
struct
_T_CRL_DYNAMIC
{
USIGN8
rem_add
;
/* current remote address */
USIGN8
rem_segm
;
/* current remote segment */
USIGN8
rem_lsap
;
/* current remote LSAP */
USIGN8
scc
;
/* send confirmed counter */
USIGN8
rcc
;
/* receive confirmed counter */
USIGN8
sac
;
/* send acknowledged counter */
USIGN8
rac
;
/* receive acknowledged counter */
PB_BOOL
poll_entry_enabled
;
/* poll entry flag */
USIGN8
master_role
;
/* current master role */
USIGN8
dummy
;
/* alignment byte */
}
T_CRL_DYNAMIC
;
#if (PB_VER < 500)
typedef
T_CRL_DYNAMIC
T_KBL_DYNAMIC
;
#endif
/****************************************************************************/
/* Load-CRL Services (Local and Remote) */
/****************************************************************************/
/*--- Load-CRL-Service -----------------------------------------------------*/
typedef
struct
_T_LOAD_CRL_REQ
{
USIGN16
desired_cr
;
/* desired communication reference */
union
{
T_CRL_HDR
crl_hdr
;
/* CRL-Header-Entry */
T_CRL_STATIC
crl_static
;
/* CRL-Static-Entry */
}
id
;
}
T_LOAD_CRL_REQ
;
#if (PB_VER < 500)
typedef
struct
_T_LOAD_KBL_REQ
{
USIGN16
desired_cr
;
/* desired communication reference */
union
{
T_KBL_HDR
kbl_hdr
;
/* CRL-Header-Entry */
T_KBL_STATIC
kbl_static
;
/* CRL-Static-Entry */
}
id
;
}
T_LOAD_KBL_REQ
;
#endif
/****************************************************************************/
/* Read-CRL Service (Local and Remote) */
/****************************************************************************/
/* --- crl-stati of the LLI state machine --------------------------------- */
#define CLOSED 0
/* --- Associate ---------------------------------------------------------- */
#define ASS_REQ_ACT_SAP 1
#define ASS_SEND_UPDATE 2
#define ASS_POLL_LIST_ON 3
#define ASS_REQ_WAIT_FOR_CON 4
#define ASS_REQ_WAIT_FOR_RES 5
#define ASS_POLL_LIST_OFF 6
#define ASS_RES_DEACT_SAP 7
#define ASS_RES_ACT_SAP 8
#define ASS_WAIT_LOC_RES 9
#define ASS_SEND_RES_PDU 10
#define ASS_REPLY_UPDATE 11
/* --- Abort -------------------------------------------------------------- */
#define ABT_UPDATE 12
#define ABT_POLL_LIST_ON 13
#define ABT_SEND_PDU 14
#define ABT_POLL_LIST_OFF 15
#define ABT_ACT_SAP 16
#define ABT_DEACT_SAP 17
/* --- Open Connection ---------------------------------------------------- */
#define OPEN 18
#define OP_POLL_LIST_ON 19
#define OP_POLL_LIST_OFF 20
/* --- DTC Requester (acyclic) -------------------------------------------- */
#define DTC_WAIT_FOR_REQ 0
#define DTC_SEND_UPDATE 1
#define DTC_WAIT_FOR_CON 2
#define DTC_WAIT_FOR_RES 3
/* --- DTC Responder (acyclic) ------------------------------------------- */
#define DTC_WAIT_FOR_REQ_PDU 0
#define DTC_WAIT_FOR_LOC_RES 1
#define DTC_REPLY_UPDATE 2
#define DTC_SEND_RES 3
/* --- DTC Requester (cyclic) --------------------------------------------- */
#define DTZ_WAIT_FOR_REQ 0
#define DTZ_SEND_UPDATE 1
#define DTZ_WAIT_FOR_CON 2
#define DTZ_WAIT_FOR_RES 3
#define DTZ_WAIT_FOR_CYC_RES 4
/* --- DTC Responder (cyclic) -------------------------------------------- */
#define DTZ_WAIT_FOR_REQ_PDU 0
#define DTZ_WAIT_FOR_FMS_RES 1
#define DTZ_REPLY_UPDATE 2
#define DTZ_SEND_RES 3
/* --- DTA Requester ------------------------------------------------------ */
#define DTA_WAIT_FOR_REQM 0
#define DTA_SEND_UPDATE 1
#define DTA_WAIT_FOR_CON 2
#define DTA_WAIT_FOR_REQS 3
#define DTA_REPLY_UPDATE 4
#define DTA_WAIT_FOR_IND 5
/* --- DTA Responder ------------------------------------------------------ */
#define DTA_WAIT_FOR_REQ_PDU 0
#define DTA_H_WAIT_FOR_BUFFER_FREE 1
#define DTA_H_REPLY_UPDATE 2
#define DTA_H_SEND_ACK 3
#define DTA_L_WAIT_FOR_BUFFER_FREE 4
#define DTA_L_UPDATE 5
#define DTA_L_SEND_ACK 6
/* --- IDLE Requester ----------------------------------------------------- */
#define IDLE_WAIT_FOR_REQM 0
#define IDLE_WAIT_FOR_CON 1
#define IDLE_SEND_UPDATE 2
#define IDLE_WAIT_FOR_REQS 3
#define IDLE_REPLY_UPDATE 4
#define IDLE_WAIT_FOR_IND 5
/* --- DTU Requester ------------------------------------------------------ */
#define CONLS_REQ 0
#define CONLS_WAIT_FOR_CON 1
/* --- DTU Receiver ------------------------------------------------------- */
#define CONLS_SERVER 0
typedef
struct
_T_READ_CRL_REQ
{
USIGN16
desired_cr
;
/* desired communication reference */
}
T_READ_CRL_REQ
;
#if (PB_VER < 500)
typedef
T_READ_CRL_REQ
T_READ_KBL_REQ
;
#endif
/*--- CRL-Entry Data-Type --------------------------------------------------*/
typedef
struct
_T_CRL_ENTRY
{
T_CRL_STATIC
crl_static
;
/* CRL-Static-Entry */
T_CRL_DYNAMIC
crl_dynamic
;
/* CRL-Dynamic-Entry */
USIGN8
dummy
;
/* alignment */
USIGN8
crl_status_len
;
/* length of CRL-Status */
/* USIGN8 crl_status[crl_status_len]; CRL-Status */
}
T_CRL_ENTRY
;
#if (PB_VER < 500)
typedef
struct
_T_KBL_ENTRY
{
T_KBL_STATIC
kbl_static
;
/* CRL-Static-Entry */
T_KBL_DYNAMIC
kbl_dynamic
;
/* CRL-Dynamic-Entry */
USIGN8
dummy
;
/* alignment */
USIGN8
kbl_status_len
;
/* length of CRL-Status */
/* USIGN8 kbl_status[crl_status_len]; CRL-Status */
}
T_KBL_ENTRY
;
#endif
typedef
struct
_T_READ_CRL_CNF
{
USIGN16
desired_cr
;
/* desired communication reference */
union
{
T_CRL_HDR
crl_hdr
;
/* CRL-header */
T_CRL_ENTRY
crl_entry
;
/* CRL-Entry */
}
id
;
}
T_READ_CRL_CNF
;
#if (PB_VER < 500)
typedef
struct
_T_READ_KBL_CNF
{
USIGN16
desired_cr
;
/* desired communication reference */
union
{
T_KBL_HDR
kbl_hdr
;
/* CRL-header */
T_KBL_ENTRY
kbl_entry
;
/* CRL-Entry */
}
id
;
}
T_READ_KBL_CNF
;
#endif
/****************************************************************************/
/* SET- and READ-BUSPARAMETER SERVICES */
/****************************************************************************/
/****************************************************************************/
/* Set-Busparameter Service (only local) */
/****************************************************************************/
/* --- Baudrate ------------------------------------------------------------ */
#define KBAUD_9_6 0x00
#define KBAUD_19_2 0x01
#define KBAUD_45_45 0x0B
#define KBAUD_93_75 0x02
#define KBAUD_187_5 0x03
#define KBAUD_500 0x04
#define KBAUD_750 0x05
#define MBAUD_1_5 0x06
#define MBAUD_3 0x07
#define MBAUD_6 0x08
#define MBAUD_12 0x09
#if (PB_VER < 500)
#define C_KBAUD_9_6 KBAUD_9_6
#define C_KBAUD_19_2 KBAUD_19_2
#define C_KBAUD_45_45 KBAUD_45_45
#define C_KBAUD_93_75 KBAUD_93_75
#define C_KBAUD_187_5 KBAUD_187_5
#define C_KBAUD_500 KBAUD_500
#define C_KBAUD_750 KBAUD_750
#define C_MBAUD_1_5 MBAUD_1_5
#define C_MBAUD_3 MBAUD_3
#define C_MBAUD_6 MBAUD_6
#define C_MBAUD_12 MBAUD_12
#endif
/* --- Medium-Redundancy -------------------------------------------------- */
#define NO_REDUNDANCY 0x00
#define BUS_A_HIGHPRIOR 0x01
#define BUS_B_HIGHPRIOR 0x02
#define REDUNDANCY 0x03
#if (PB_VER < 500)
#define C_NO_REDUNDANCY NO_REDUNDANCY
#define C_BUS_A_HIGHPRIOR BUS_A_HIGHPRIOR
#define C_BUS_B_HIGHPRIOR BUS_B_HIGHPRIOR
#define C_REDUNDANCY REDUNDANCY
#endif
/* --- In-Ring-Desired ---------------------------------------------------- */
#define IN_RING_DESIRED PB_TRUE
#define NOT_IN_RING_DESIRED PB_FALSE
#if (PB_VER < 500)
#define C_IN_RING_DESIRED IN_RING_DESIRED
#define C_NOT_IN_RING_DESIRED NOT_IN_RING_DESIRED
#endif
typedef
struct
_T_SET_BUSPARAMETER_REQ
{
USIGN8
loc_add
;
/* local station */
USIGN8
loc_segm
;
/* local segment */
USIGN8
baud_rate
;
/* baud rate */
USIGN8
medium_red
;
/* medium redundancy */
USIGN16
tsl
;
/* slot time */
USIGN16
min_tsdr
;
/* min. station delay time resp. */
USIGN16
max_tsdr
;
/* max. station delay time resp. */
USIGN8
tqui
;
/* quiet time */
USIGN8
tset
;
/* setup time */
USIGN32
ttr
;
/* target token rotation time */
USIGN8
g
;
/* gap update factor */
PB_BOOL
in_ring_desired
;
/* active or passive station */
USIGN8
hsa
;
/* highest station address */
USIGN8
max_retry_limit
;
/* max. retry limit */
USIGN16
reserved
;
/* not used */
USIGN8
ident
[
202
];
/* for internal use */
}
T_SET_BUSPARAMETER_REQ
;
/****************************************************************************/
/* Read-Busparameter Service (only local) */
/****************************************************************************/
typedef
struct
_T_READ_BUSPARAMETER_CNF
{
USIGN8
loc_add
;
/* local station */
USIGN8
loc_segm
;
/* local segment */
USIGN8
baud_rate
;
/* baud rate */
USIGN8
medium_red
;
/* medium redundancy */
USIGN16
tsl
;
/* slot time */
USIGN16
min_tsdr
;
/* min. station delay time resp. */
USIGN16
max_tsdr
;
/* max. station delay time resp. */
USIGN8
tqui
;
/* quiet time */
USIGN8
tset
;
/* setup time */
USIGN32
ttr
;
/* target token rotation time */
USIGN8
g
;
/* gap update factor */
PB_BOOL
in_ring_desired
;
/* active or passive station */
USIGN8
hsa
;
/* highest station address */
USIGN8
max_retry_limit
;
/* max. retry limit */
USIGN16
reserved
;
/* not used */
USIGN8
ident
[
202
];
/* FDL-Ident-String */
}
T_READ_BUSPARAMETER_CNF
;
/****************************************************************************/
/* SET- and READ-VALUE SERVICES */
/****************************************************************************/
/* --- FDL-Variable-Identifiers ------------------------------------------- */
#define ID_TS 1
#define ID_BAUD_RATE 2
#define ID_MEDIUM_RED 3
#define ID_HW_RELEASE 4
#define ID_SW_RELEASE 5
#define ID_TSL 6
#define ID_MIN_TSDR 7
#define ID_MAX_TSDR 8
#define ID_TQUI 9
#define ID_TSET 10
#define ID_TTR 11
#define ID_G 12
#define ID_IN_RING_DESIRED 13
#define ID_HSA 14
#define ID_MAX_RETRY_LIMIT 15
#define ID_TRR 16
#define ID_LAS 17
#define ID_GAPL 18
/* --- Statistic-Counter-Identifiers -------------------------------------- */
#define ID_FRAME_SENT_COUNT 20
#define ID_RETRY_COUNT 21
#define ID_SD_COUNT 22
#define ID_SD_ERROR_COUNT 23
/****************************************************************************/
/* Set-Value Service (Local and Remote) */
/****************************************************************************/
#if (PB_VER < 500)
typedef
struct
_T_STATISTICS_BLOCK
{
USIGN32
frame_send_count
;
/* frame sent counter */
USIGN32
sd_count
;
/* valid start delimiter counter */
USIGN16
retry_count
;
/* retry frame sent counter */
USIGN16
sd_error_count
;
/* invalid start delimiter counter */
}
T_STATISTICS_BLOCK
;
#endif
typedef
struct
_T_SET_VALUE_REQ
{
USIGN8
id
;
/* value identifier */
USIGN8
length
;
/* # of values in byte */
/* USIGN8 value[length]; list of values */
}
T_SET_VALUE_REQ
;
/****************************************************************************/
/* Read-Value Service (Local and Remote) */
/****************************************************************************/
#if (PB_VER < 500)
typedef
struct
_T_READ_STATISTIC_CTR_CNF
{
USIGN32
frame_send_count
;
/* frame sent counter */
USIGN32
sd_count
;
/* valid start delimiter counter */
USIGN16
retry_count
;
/* retry frame sent counter */
USIGN16
sd_error_count
;
/* invalid start delimiter counter */
}
T_READ_STATISTIC_CTR_CNF
;
#endif
typedef
struct
_T_READ_VALUE_REQ
{
USIGN8
id
;
/* value identifier */
USIGN8
dummy
;
/* alignment */
}
T_READ_VALUE_REQ
;
typedef
struct
_T_READ_VALUE_CNF
{
USIGN8
id
;
/* value identifier */
USIGN8
length
;
/* # of values in byte */
/* USIGN8 value[length]; list of values */
}
T_READ_VALUE_CNF
;
/****************************************************************************/
/* Ident Service (Local and Remote) */
/****************************************************************************/
/* --- instance identier ----------------------------------------------------*/
#define ID_FM7 0
#define ID_FMS 1
#define ID_LLI 2
#define ID_FDL 3
#define ID_STATION 4
#if (PB_VER < 500)
#define ID_FMA7 ID_FM7
#define ID_PHY 5
#endif
typedef
struct
_T_IDENT_REQ
{
USIGN8
instance_id
;
/* instance identifier */
USIGN8
dummy
;
/* alignment byte */
}
T_IDENT_REQ
;
#if (PB_VER >= 500)
typedef
struct
_T_CHARACTERISTICS
{
USIGN8
profile_number
[
2
];
/* profile number */
USIGN8
functions_supp
[
3
];
/* functions supported */
USIGN8
dummy1
;
/* alignment byte */
USIGN8
max_pdu_len
;
/* max. PDU length */
USIGN8
dummy2
;
/* alignment byte */
USIGN8
fms_features_supp
[
6
];
/* FMS features supported */
USIGN8
fm7_services_supp
[
6
];
/* FM7 features supported */
USIGN8
max_sap_value
;
/* max. LSAP number */
USIGN8
max_no_of_saps
;
/* max. number of LSAPs */
USIGN16
max_comref
;
/* max communication reference */
USIGN16
max_crl_len
;
/* max count of CRL-Entries */
USIGN32
total_len_of_pdu
;
/* total length of PDUs */
USIGN16
no_of_parallel_serv
;
/* number of parallel serv. */
USIGN16
max_od_index
;
/* max. OD-Index */
USIGN16
max_od_entries
;
/* max. OD-Entries */
USIGN8
max_vfd
;
/* max. VFDs */
USIGN8
max_las_entries
;
/* max. no. of LAS entries */
USIGN8
min_tsdr
;
/* min. station delay time */
USIGN8
trdy
;
/* ready time */
USIGN8
tsdi
;
/* station delay initiatior */
USIGN8
max_tsdr
;
/* station delay responder */
USIGN8
tset
;
/* setup time */
USIGN8
tqui
;
/* quiet time */
USIGN8
supported_data_types
[
4
];
/* supported data types */
USIGN8
supported_access_rights
[
3
];
/* supported access rights */
USIGN8
supported_var_types
;
/* supported variable types */
USIGN8
special_functions
[
2
];
/* special functions */
USIGN8
max_od_symbol_length
;
/* max length of symbol in OD */
USIGN8
max_crl_symbol_length
;
/* max length of symbol in CRL */
}
T_CHARACTERISTICS
;
#else
typedef
struct
_T_CHARACTERISTICS
{
USIGN8
profile_number
[
2
];
/* profile number */
USIGN8
functions_supp
[
3
];
/* functions supported */
USIGN8
dummy1
;
/* alignment byte */
USIGN8
max_pdu_len
;
/* max. PDU length */
USIGN8
dummy2
;
/* alignment byte */
USIGN8
fms_features_supp
[
6
];
/* FMS features supported */
USIGN8
fma7_services_supp
[
6
];
/* FM7 features supported */
USIGN8
max_sap_value
;
/* max. LSAP number */
USIGN8
max_no_of_saps
;
/* max. number of LSAPs */
USIGN16
max_comref
;
/* max communication reference */
USIGN16
max_kbl_len
;
/* max count of CRL-Entries */
USIGN32
total_len_of_pdu
;
/* total length of PDUs */
USIGN16
no_of_parallel_serv
;
/* number of parallel serv. */
USIGN16
max_ov_index
;
/* max. OD-Index */
USIGN16
max_ov_entries
;
/* max. OD-Entries */
USIGN8
max_vfd
;
/* max. VFDs */
USIGN8
max_las_entries
;
/* max. no. of LAS entries */
USIGN8
min_tsdr
;
/* min. station delay time */
USIGN8
trdy
;
/* ready time */
USIGN8
tsdi
;
/* station delay initiatior */
USIGN8
max_tsdr
;
/* station delay responder */
USIGN8
tset
;
/* setup time */
USIGN8
tqui
;
/* quiet time */
USIGN8
supported_data_types
[
4
];
/* supported data types */
USIGN8
supported_access_rights
[
3
];
/* supported access rights */
USIGN8
supported_var_types
;
/* supported variable types */
USIGN8
special_functions
[
2
];
/* special functions */
USIGN8
max_ov_symbol_length
;
/* max length of symbol in OD */
USIGN8
max_kbl_symbol_length
;
/* max length of symbol in CRL */
}
T_CHARACTERISTICS
;
#endif
typedef
struct
_T_IDENT_CNF
{
USIGN8
instance_id
;
/* instance ident */
USIGN8
dummy
;
/* alignment */
STRINGV
vendor_name
[
MAX_IDENT_STRING_LENGTH
];
/* vendor name */
STRINGV
controller_type
[
MAX_IDENT_STRING_LENGTH
];
/* controller type */
STRINGV
hw_release
[
MAX_IDENT_STRING_LENGTH
];
/* HW release */
STRINGV
sw_release
[
MAX_IDENT_STRING_LENGTH
];
/* SW release */
T_CHARACTERISTICS
characteristics
;
}
T_IDENT_CNF
;
/****************************************************************************/
/* LSAP-Status Service (Local and Remote) */
/****************************************************************************/
typedef
struct
_T_LSAP_STATUS_REQ
{
USIGN8
lsap
;
/* desired LSAP */
USIGN8
dummy
;
/* alignment byte */
}
T_LSAP_STATUS_REQ
;
typedef
struct
_T_LSAP_STATUS_CNF
{
USIGN8
access
;
/* station address or all */
USIGN8
addr_extension
;
/* segment number */
USIGN8
sda
;
/* SDA */
USIGN8
sdn
;
/* SDN */
USIGN8
srd
;
/* SRD */
USIGN8
csrd
;
/* CSRD */
}
T_LSAP_STATUS_CNF
;
/****************************************************************************/
/* Get-Live-List Service (Local and Remote) */
/****************************************************************************/
typedef
struct
_T_LIVE_LIST
{
USIGN8
station
;
/* station number */
USIGN8
status
;
/* current station of station */
}
T_LIVE_LIST
;
typedef
struct
_T_GET_LIVE_LIST_CNF
{
USIGN8
dummy
;
/* alignment */
USIGN8
no_of_elements
;
/* # of live list elements */
/* T_LIVE_LIST live_list[no_of_elements]; list of live list elements */
}
T_GET_LIVE_LIST_CNF
;
/****************************************************************************/
/* FM7 Fault-Management */
/****************************************************************************/
/****************************************************************************/
/* FM7-Event-Service (FM2-Event and LLI-Fault-Indications) */
/****************************************************************************/
/* NOTE: instance identifier see IDENT service ---------------------------- */
/* reason-codes and additional details are defined in PB_ERR.H --- */
typedef
struct
_T_FM7_EVENT_IND
{
USIGN16
comm_ref
;
/* communication reference */
USIGN8
instance_id
;
/* LLI, FDL, PHY */
USIGN8
reason
;
/* reason code */
USIGN8
add_detail
;
/* additional detail */
USIGN8
dummy
;
/* alignment */
}
T_FM7_EVENT_IND
;
#if (PB_VER < 500)
typedef
T_FM7_EVENT_IND
T_FMA7_EVENT_IND
;
#endif
#if (PB_VER < 500)
/****************************************************************************/
/* FMA7-Configuration-Management */
/****************************************************************************/
/*****************************************************************************/
/* Set-Configuration Service (only local) */
/*****************************************************************************/
typedef
struct
T_SET_CONFIGURATION_REQ
{
USIGN16
max_nr_of_fal_msg_buffers
;
/* max # of Layer7-Message-Buffers (all CR) */
USIGN16
max_nr_of_fdl_msg_buffers
;
/* max # of Layer2-Message-Buffers (all CR) */
USIGN16
max_nr_of_data_buffers
;
/* max # of PDU-Buffers (all CR) */
USIGN16
max_nr_of_api_data_buffers
;
/* max # of abort/poll/idle PDU-Buffers (all CR) */
USIGN16
max_nr_of_sap_buffers
;
/* max # of SAP-Buffers (all CR) */
USIGN16
max_nr_of_poll_list_entries
;
/* max # of Poll-List-Entries (all CR) */
USIGN16
max_data_buffer_size
;
/* max size of FMS-/FMA7-PDU-Buffer */
}
T_SET_CONFIGURATION_REQ
;
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to reset alignment */
#ifdef WIN32
#pragma pack(pop)
#else
#pragma pack()
#endif
#pragma warning (default : 4103)
#endif
#endif
profibus/lib/rt/src/os_linux/pb_fmb.h
View file @
0135e84d
/*
* Proview $Id: pb_fmb.h,v 1.2 2006-02-01 08:35:51 claes Exp $
* Copyright (C) SOFTING GmbH 1995-1999.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/*****************************************************************************/
/* */
/* */
/*
SOFTING GmbH
*/
/*
SOFTING AG
*/
/* Richard-Reitzner-Allee 6 */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* */
/* Copyright (C) SOFTING GmbH 1995-1999 */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/* */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
...
@@ -32,35 +16,26 @@
...
@@ -32,35 +16,26 @@
/* Filename : PB_FMB.H */
/* Filename : PB_FMB.H */
/* Version : 5.21.0.00.release */
/* Version : 5.21.0.00.release */
/* Date : 27-February-1998 */
/* Date : 27-February-1998 */
/* Author : SOFTING
-BG2
*/
/* Author : SOFTING
AG
*/
/* */
/* */
/* */
/* */
/* Description : This file contains the types and defines of the Fieldbus- */
/* Description : This file contains the types and defines of the Fieldbus- */
/* Basic Management User-Interface */
/* Basic Management User-Interface */
/* CHANGE_NOTES */
/* */
/* date name change */
/* ----------------------------------------------------------------------- */
/* 22.07.97 BG2-BOE set #pragma pack(2) and reset to #pragma pack() */
/* 24.09.97 BG2-BOE add new baudrate #defines */
/* - #define KBAUD_45_45 */
/* */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
#ifndef __PB_FMB__
#ifndef __PB_FMB__
#define __PB_FMB__
#define __PB_FMB__
/*
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
#pragma warning (disable : 4103)
/* used #pragma pack to change alignment */
#ifdef WIN32
#ifdef WIN32
#pragma pack(push,2)
#pragma pack(push,2)
#else
#else
#pragma pack(2)
#pragma pack(2)
#endif
#endif
#pragma warning (default : 4103)
#pragma warning (default : 4103)
*/
#endif
/*****************************************************************************/
/*****************************************************************************/
/*** FMB service identifier ***/
/*** FMB service identifier ***/
...
@@ -73,6 +48,7 @@
...
@@ -73,6 +48,7 @@
#define FMB_EXIT 21
#define FMB_EXIT 21
#define FMB_SET_BUSPARAMETER 22
#define FMB_SET_BUSPARAMETER 22
#define FMB_READ_BUSPARAMETER 24
#define FMB_READ_BUSPARAMETER 24
#define FMB_VALIDATE_MASTER 25
#define FMB_GET_LIVE_LIST 26
#define FMB_GET_LIVE_LIST 26
#define FMB_SET_CONFIGURATION 27
#define FMB_SET_CONFIGURATION 27
...
@@ -327,6 +303,17 @@ typedef struct _T_FMB_LSAP_STATUS_CNF
...
@@ -327,6 +303,17 @@ typedef struct _T_FMB_LSAP_STATUS_CNF
}
T_FMB_LSAP_STATUS_CNF
;
}
T_FMB_LSAP_STATUS_CNF
;
/*****************************************************************************/
/* FMB-Validate-Master Service */
/*****************************************************************************/
typedef
struct
_T_FMB_VALIDATE_MASTER_REQ
{
USIGN8
rem_add
;
/* desired remote station */
USIGN8
dummy
;
/* alignment byte */
}
T_FMB_VALIDATE_MASTER_REQ
;
/*****************************************************************************/
/*****************************************************************************/
/* FMB-Get-Live-List Service */
/* FMB-Get-Live-List Service */
/*****************************************************************************/
/*****************************************************************************/
...
@@ -370,15 +357,15 @@ typedef struct _T_FMB_FM2_EVENT_IND
...
@@ -370,15 +357,15 @@ typedef struct _T_FMB_FM2_EVENT_IND
USIGN16
reason
;
/* reason code */
USIGN16
reason
;
/* reason code */
}
T_FMB_FM2_EVENT_IND
;
}
T_FMB_FM2_EVENT_IND
;
/*
#pragma warning (disable : 4103)
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to reset alignment */
#ifdef WIN32
#ifdef WIN32
#pragma pack(pop)
#pragma pack(pop)
#else
#else
#pragma pack()
#pragma pack()
#endif
#endif
#pragma warning (default : 4103)
#pragma warning (default : 4103)
*/
#endif
#endif
/* __PB_FMB__ */
#endif
/* __PB_FMB__ */
profibus/lib/rt/src/os_linux/pb_fms.h
0 → 100644
View file @
0135e84d
/*****************************************************************************/
/* */
/* SOFTING AG */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* FMS-USER-INTERFACE DEFINES and TYPES */
/* */
/* Filename : PB_FMS.H */
/* Version : 5.21.0.00.release */
/* Date : 27-February-1998 */
/* Author : SOFTING AG */
/* */
/* Description : This file contains the types and defines of the FMS-User- */
/* Interface */
/* */
/*****************************************************************************/
#ifndef __PB_FMS__
#define __PB_FMS__
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to change alignment */
#ifdef WIN32
#pragma pack(push,2)
#else
#pragma pack(2)
#endif
#pragma warning (default : 4103)
#endif
/*****************************************************************************/
/* */
/* D E F I N E S */
/* */
/*****************************************************************************/
/*****************************************************************************/
/************* FMS STRING LENGTH CONSTANTS *********************/
/*****************************************************************************/
#define MAX_VFD_STRING_LENGTH _NAME_LENGTH(VFD_STRING_LENGTH)
#define MAX_ACCESS_NAME_LENGTH _NAME_LENGTH(ACCESS_NAME_LENGTH)
#define MAX_OBJECT_NAME_LENGTH _NAME_LENGTH(OBJECT_NAME_LENGTH)
#define MAX_EXTENSION_LENGTH _NAME_LENGTH(EXTENSION_LENGTH)
#define MAX_EXECUTION_ARGUMENT_LENGTH _NAME_LENGTH(EXECUTION_ARGUMENT_LENGTH)
/*****************************************************************************/
/************* FMS SERVICE IDENTIFIERS *********************/
/*****************************************************************************/
/* --- remote FMS services ------------------------------------------------- */
#define FMS_INITIATE 0
#define FMS_STATUS 2
#define FMS_IDENTIFY 3
#define FMS_READ 4
#define FMS_WRITE 5
#define FMS_GET_OD 6
#define FMS_READ_WITH_TYPE 7
#define FMS_WRITE_WITH_TYPE 8
#define FMS_DEF_VAR_LIST 9
#define FMS_DEL_VAR_LIST 10
#define FMS_INIT_DOWNL_SEQ 11
#define FMS_DOWNL_SEG 12
#define FMS_TERM_DOWNL_SEQ 13
#define FMS_INIT_UPL_SEQ 14
#define FMS_UPL_SEG 15
#define FMS_TERM_UPL_SEQ 16
#define FMS_REQ_DOM_DOWNL 17
#define FMS_REQ_DOM_UPL 18
#define FMS_PI_CREATE 19
#define FMS_PI_DELETE 20
#define FMS_PI_START 21
#define FMS_PI_STOP 22
#define FMS_PI_RESUME 23
#define FMS_PI_RESET 24
#define FMS_PI_KILL 25
#define FMS_ALT_EVN_CND_MNT 26
#define FMS_ACK_EVN_NOTIFY 27
#define FMS_PHYS_READ 28
#define FMS_PHYS_WRITE 29
#define FMS_INIT_PUT_OD 30
#define FMS_PUT_OD 31
#define FMS_TERM_PUT_OD 32
#define FMS_GEN_INIT_DOWNL_SEQ 61
#define FMS_GEN_DOWNL_SEG 62
#define FMS_GEN_TERM_DOWNL_SEQ 63
#define FMS_INFO_RPT 33
#define FMS_UNSOLICITEDSTATUS 34
#define FMS_EVN_NOTIFY 35
#define FMS_INFO_RPT_WITH_TYPE 36
#define FMS_EVN_NOTIFY_WITH_TYPE 37
#define FMS_ABORT 38
#define FMS_REJECT 39
/* --- FMS features -------------------------------------------------------- */
#define FMS_GET_OD_LONG 40
#define FMS_NAME_ADDRESSING 41
/* --- local FMS services -------------------------------------------------- */
#define FMS_OD_READ_LOC 42
#define FMS_INIT_LOAD_OD_LOC 43
#define FMS_LOAD_OD_LOC 44
#define FMS_TERM_LOAD_OD_LOC 45
#define FMS_CREATE_VFD_LOC 46
#define FMS_VFD_SET_PHYS_STATUS_LOC 47
#define FMS_PI_SET_STATE_LOC 48
#define FMS_VAR_DATA_EVENT_LOC 49
#if (PB_VER < 500)
#define INITIATE 0
#define STATUS 2
#define IDENTIFY 3
#define READ 4
#define WRITE 5
#define GETOV 6
#define READWITHTYPE 7
#define WRITEWITHTYPE 8
#define DEFINEVARIABLELIST 9
#define DELETEVARIABLELIST 10
#define INITIATEDOWNLOADSEQUENCE 11
#define DOWNLOADSEGMENT 12
#define TERMINATEDOWNLOADSEQUENCE 13
#define INITIATEUPLOADSEQUENCE 14
#define UPLOADSEGMENT 15
#define TERMINATEUPLOADSEQUENCE 16
#define REQUESTDOMAINDOWNLOAD 17
#define REQUESTDOMAINUPLOAD 18
#define CREATEPROGRAMINVOCATION 19
#define DELETEPROGRAMINVOCATION 20
#define START 21
#define STOP 22
#define RESUME 23
#define RESET 24
#define KILL 25
#define ALTEREVENTCONDITIONMONITORING 26
#define ACKNOWLEDGEEVENTNOTIFICATION 27
#define PHYS_READ 28
#define PHYS_WRITE 29
#define INITIATE_PUT_OV 30
#define PUT_OV 31
#define TERMINATE_PUT_OV 32
#define INFORMATIONREPORT 33
#define UNSOLICITEDSTATUS 34
#define EVENTNOTIFICATION 35
#define INFORMATIONREPORTWITHTYPE 36
#define EVENTNOTIFICATIONWITHTYPE 37
#define ABORT 38
#define REJECT 39
/* --- FMS features -------------------------------------------------------- */
#define GET_OV_LONG 40
#define NAME_ADDRESSING 41
/* --- local FMS services -------------------------------------------------- */
#define OV_READ_LOC 42
#define INITIATE_LOAD_OV_LOC 43
#define LOAD_OV_LOC 44
#define TERMINATE_LOAD_OV_LOC 45
#define CREATE_VFD_LOC 46
#define VFD_SET_PHYS_STATUS_LOC 47
#define PI_SET_STATE_LOC 48
#endif
/*****************************************************************************/
/************* ACCESS SPECIFICATION *********************/
/*****************************************************************************/
/* --- codes for object access mode, to be used as tag in T_ACC_SPEC-------- */
/* --- fixed size ---------------------------------------------------------- */
#define ACCESS_INDEX 0
/* access by index */
#define ACCESS_NAME 1
/* acess by name */
#define ACCESS_NAME_LIST 2
/* acess by name list */
/* --- codes for object access mode, to be used as tag in T_DYN_ACC_SPEC --- */
/* --- dynamic size -------------------------------------------------------- */
#define DYN_ACCESS_INDEX 3
/* access by index */
#define DYN_ACCESS_NAME 4
/* acess by name */
/* --- codes for named access specification, to be used for od services only */
/* --- fixed size ---------------------------------------------------------- */
#define INDEX_ACCESS 1
/* access by index */
#define VAR_NAME_ACCESS 2
/* access by variable name */
#define VAR_LIST_NAME_ACCESS 3
/* access by variable list name */
#define DOMAIN_NAME_ACCESS 4
/* access by domain name */
#define PI_NAME_ACCESS 5
/* access by pi name */
#define EVENT_NAME_ACCESS 6
/* access by event name */
#define START_INDEX_ACCESS 7
/* access by start index */
/*****************************************************************************/
/************* FMS CONTEXT MANAGEMENT *********************/
/*****************************************************************************/
#define DETAIL_LENGTH 16
/* length of abort detail */
#define FEAT_SUPP_LEN 6
/* length of supp. feat. field */
/*****************************************************************************/
/************* VFD SUPPORT MANAGEMENT *********************/
/*****************************************************************************/
/* --- logical status of the communcation ---------------------------------- */
#define STATE_CHANGES_ALLOWED 0
#define LIMITED_SERVICES_PERMITTED 2
/* --- physical status of the application device --------------------------- */
#define OPERATIONAL 0
#define PARTIALLY_OPERATIONAL 1
#define INOPERABLE 2
#define NEEDS_COMMISSIONING 3
/*****************************************************************************/
/************* OD-MANAGEMENT *********************/
/*****************************************************************************/
/* --- OD-states ----------------------------------------------------------- */
#define OD_LOADABLE 2
#define OD_READY 3
#define OD_LOADING_NON_INTERACTING 4
#define OD_LOADING_INTERACTING 5
#define OD_NOT_EXISTENT 6
#if (PB_VER < 500)
#define OV_LOADABLE OD_LOADABLE
#define OV_READY OD_READY
#define OV_LOADING_NON_INTERACTING OD_LOADING_NON_INTERACTING
#define OV_LOADING_INTERACTING OD_LOADING_INTERACTING
#define OV_NOT_EXISTENT OD_NOT_EXISTENT
#endif
/* --- indices in OD type description for standard data types -------------- */
#define OD_BOOL 1
#define OD_INT8 2
#define OD_INT16 3
#define OD_INT32 4
#define OD_USIGN8 5
#define OD_USIGN16 6
#define OD_USIGN32 7
#define OD_FLOAT 8
#define OD_VSTRING 9
#define OD_OSTRING 10
#define OD_DATE_TYPE 11
#define OD_TIME_OF_DAY 12
#define OD_TIME_DIFF 13
#define OD_BSTRING 14
#if defined (DOS16) || defined (WIN16)
#define BOOLEAN OD_BOOL
#define INTEGER8 OD_INT8
#define INTEGER16 OD_INT16
#define INTEGER32 OD_INT32
#define UNSIGNED8 OD_USIGN8
#define UNSIGNED16 OD_USIGN16
#define UNSIGNED32 OD_USIGN32
#define FLOATING_POINT OD_FLOAT
#define VISIBLE_STRING OD_VSTRING
#define OCTET_STRING OD_OSTRING
#define DATE_TYPE OD_DATE_TYPE
#define TIME_OF_DAY OD_TIME_OF_DAY
#define TIME_DIFFERENCE OD_TIME_DIFF
#define BIT_STRING OD_BSTRING
#endif
/* --- codes of FMS objects ------------------------------------------------ */
#define NULL_OBJECT 0
/* null object */
#define OD_OBJECT 1
/* OD object */
#define OV_OBJECT 1
/* OD object */
#define DOMAIN_OBJECT 2
/* domain object */
#define INVOCATION_OBJECT 3
/* program invocation object */
#define EVENT_OBJECT 4
/* event object */
#define TYPE_OBJECT 5
/* basic data type description */
#define TYPE_STRUCT_OBJECT 6
/* structured data type descript.*/
#define SIMPLE_VAR_OBJECT 7
/* simple variable object */
#define ARRAY_OBJECT 8
/* array object */
#define RECORD_OBJECT 9
/* record object */
#define VAR_LIST_OBJECT 10
/* variable list object */
#define VAR_OBJECT 11
/* class of all variable objects */
#define ALL_OBJECT 12
/* super class of all objects */
/* --- OD loading selection -------------------------------------------------*/
#define CONSEQUENCE_0 0
#define CONSEQUENCE_1 1
#define CONSEQUENCE_2 2
/*****************************************************************************/
/************* VARIABLE ACCESS *********************/
/*****************************************************************************/
/* --- tag values for type description (T_TYPE_DESCR)----------------------- */
#define SIMPLE_TYPE 1
#define ARRAY_TYPE 2
#define RECORD_TYPE 3
/*****************************************************************************/
/************* DOMAIN-MANAGEMENT *********************/
/*****************************************************************************/
/* --- domain states ------------------------------------------------------- */
#define DOM_EXISTENT 0x01
#define DOM_LOADING 0x02
#define DOM_INCOMPLETE 0x03
#define DOM_COMPLETE 0x04
#define DOM_READY 0x05
#define DOM_IN_USE 0x06
#if defined (DOS16) || defined (WIN16)
#define EXISTENT DOM_EXISTENT
#define LOADING DOM_LOADING
#define INCOMPLETE DOM_INCOMPLETE
#define COMPLETE DOM_COMPLETE
#define READY DOM_READY
#define IN_USE DOM_IN_USE
#endif
/* --- upload states ------------------------------------------------------- */
#define DOM_NON_EXISTENT 0x00
#define DOM_UPLOADING 0x01
#define DOM_UPLOADED 0x02
#if defined (DOS16) || defined (WIN16)
#define NON_EXISTENT 0x00
#define UPLOADING DOM_UPLOADING
#define UPLOADED DOM_UPLOADED
#endif
/*****************************************************************************/
/************* PROGRAM INVOCATION MANAGEMENT *********************/
/*****************************************************************************/
/* --- program invocation states ------------------------------------------- */
#define PI_NON_EXISTENT 0x00
#define PI_UNRUNNABLE 0x01
#define PI_IDLE 0x02
#define PI_RUNNING 0x03
#define PI_STOPPED 0x04
#define PI_STARTING 0x05
#define PI_STOPPING 0x06
#define PI_RESUMING 0x07
#define PI_RESETTING 0x08
#if defined (DOS16) || defined (WIN16)
#define NON_EXISTENT 0x00
#define UNRUNNABLE PI_UNRUNNABLE
#define IDLE PI_IDLE
#define RUNNING PI_RUNNING
#define STOPPED PI_STOPPED
#define STARTING PI_STARTING
#define STOPPING PI_STOPPING
#define RESUMING PI_RESUMING
#define RESETTING PI_RESETTING
#endif
/*****************************************************************************/
/* */
/* D A T A S T R U C T U R E S */
/* */
/*****************************************************************************/
/*****************************************************************************/
/************* ACCESS CONTROL *********************/
/*****************************************************************************/
typedef
struct
_T_ACCESS
{
USIGN8
pass_word
;
/* password */
USIGN8
acc_groups
;
/* access groups */
USIGN16
acc_right
;
/* access rights */
}
T_ACCESS
;
/*****************************************************************************/
/************* ACCESS SPECIFICATION *********************/
/*****************************************************************************/
/* --- standard access specification data structure (fixed size) ----------- */
typedef
struct
_T_ACC_SPEC
{
USIGN8
tag
;
/* id of the access specification */
USIGN8
dummy
;
/* alignment byte */
union
{
USIGN16
index
;
/* access by index */
STRINGV
name
[
MAX_ACCESS_NAME_LENGTH
];
/* access by symbolic name */
}
id
;
}
T_ACC_SPEC
;
/* --- dynamic access specification data structure (used in T_PI_CR8_REQ
and in T_VAR_DEFINE_VAR_LIST_REQ data structure (dynamic size) ----- */
typedef
struct
_T_DYN_ACC_SPEC
{
USIGN8
tag
;
/* id of the access specification */
USIGN8
length
;
/* length of access specification */
/* USIGN8 acc_spec[length] access specification (index / name) */
}
T_DYN_ACC_SPEC
;
/*****************************************************************************/
/************* FMS CONTEXT MANAGEMENT *********************/
/*****************************************************************************/
/* --- Initiate-Service -----------------------------------------------------*/
typedef
struct
_T_CTXT_INIT_REQ
{
USIGN8
profile_number
[
2
];
/* profile number */
PB_BOOL
protection
;
/* access protection */
USIGN8
password
;
/* password */
USIGN8
access_groups
;
/* access groups */
USIGN8
dummy
;
/* alignment byte */
INT16
od_version
;
/* od version */
USIGN8
snd_len_h
;
/* max pdu size to send (high prio) */
USIGN8
snd_len_l
;
/* max pdu size to send (low prio) */
USIGN8
rcv_len_h
;
/* max pdu size to receive (high) */
USIGN8
rcv_len_l
;
/* max pdu size to receive (low) */
USIGN8
supported_features
[
FEAT_SUPP_LEN
];
/* supported features */
}
T_CTXT_INIT_REQ
;
typedef
struct
_T_CTXT_INIT_CNF
{
USIGN8
profile_number
[
2
];
/* profile number */
INT16
od_version
;
/* od version */
PB_BOOL
protection
;
/* access protection */
USIGN8
password
;
/* password */
USIGN8
access_groups
;
/* access groups */
USIGN8
dummy
;
/* alignment byte */
}
T_CTXT_INIT_CNF
;
typedef
struct
_T_CTXT_INIT_ERR_CNF
{
USIGN16
class_code
;
/* error class, error code */
USIGN8
snd_len_h
;
/* max pdu size to send (high prio) */
USIGN8
snd_len_l
;
/* max pdu size to send (low prio) */
USIGN8
rcv_len_h
;
/* max pdu size to receive (high) */
USIGN8
rcv_len_l
;
/* max pdu size to receive (low) */
USIGN8
supported_features
[
FEAT_SUPP_LEN
];
/* supported features */
}
T_CTXT_INIT_ERR_CNF
;
/*--- abort service ---------------------------------------------------------*/
typedef
struct
_T_CTXT_ABORT_REQ
{
PB_BOOL
local
;
/* local or remote detected */
USIGN8
abort_id
;
/* abort identifier USR, FMS, ... */
USIGN8
reason
;
/* abort reason code */
USIGN8
detail_length
;
/* length of abort detail */
USIGN8
detail
[
DETAIL_LENGTH
];
/* detail information */
}
T_CTXT_ABORT_REQ
;
/*--- reject service --------------------------------------------------------*/
typedef
struct
_T_CTXT_REJECT_IND
{
PB_BOOL
detected_here
;
/* local or remote detected */
USIGN8
orig_invoke_id
;
/* original invoke ID */
USIGN8
pdu_type
;
/* reject PDU types */
USIGN8
reject_code
;
/* reject code */
}
T_CTXT_REJECT_IND
;
/*****************************************************************************/
/************* VARIABLE ACCESS MANAGEMENT *********************/
/*****************************************************************************/
typedef
struct
_T_SIMPLE_TYPE
{
USIGN16
data_type_index
;
/* index of data type */
USIGN8
length
;
/* size of data type */
USIGN8
dummy
;
/* alignment byte */
}
T_SIMPLE_TYPE
;
typedef
struct
_T_ARRAY_TYPE
{
USIGN16
data_type_index
;
/* index of data type */
USIGN8
length
;
/* size of data type */
USIGN8
no_of_elements
;
/* number of data types */
}
T_ARRAY_TYPE
;
typedef
struct
_T_RECORD_TYPE
{
USIGN8
no_of_elements
;
/* number of record elem. */
USIGN8
dummy
;
/* alignment byte */
T_SIMPLE_TYPE
simple
[
MAX_VAR_RECORD_ELEMENTS
];
/* list of simple types */
}
T_RECORD_TYPE
;
typedef
struct
_T_TYPE_DESCR
{
USIGN8
tag
;
/* type description identifier */
USIGN8
dummy
;
/* alignment byte */
union
{
T_SIMPLE_TYPE
simple
;
/* simple type */
T_ARRAY_TYPE
array
;
/* array type */
T_RECORD_TYPE
record
;
/* record type */
}
id
;
}
T_TYPE_DESCR
;
/*--- VARIABLE-OBJECT-DESCRIPTIONS ------------------------------------------------*/
/*--- Simple-Variable-Object-Description ------------------------------------------*/
typedef
struct
_T_SIMPLE_VAR_OBJECT
{
USIGN16
index
;
/* logical address of the object */
USIGN8
obj_code
;
/* object code */
USIGN8
length
;
/* length of object in octets */
USIGN16
index_of_type
;
/* logical address of the type */
T_ACCESS
access
;
/* access right structure */
USIGN32
local_address
;
/* local address */
STRINGV
name
[
MAX_OBJECT_NAME_LENGTH
];
/* name */
USIGN8
extension
[
MAX_EXTENSION_LENGTH
];
/* extension */
}
T_SIMPLE_VAR_OBJECT
;
/*--- Array-Variable-Object-Description -------------------------------------------*/
typedef
struct
_T_ARRAY_OBJECT
{
USIGN16
index
;
/* logical address of the object */
USIGN8
obj_code
;
/* object code */
USIGN8
length
;
/* length of an element in octets */
USIGN16
index_of_type
;
/* logical address of the type */
USIGN8
nof_elements
;
/* number of array elements */
USIGN8
dummy
;
/* alignment byte */
T_ACCESS
access
;
/* access right structure */
USIGN32
local_address
;
/* local address */
STRINGV
name
[
MAX_OBJECT_NAME_LENGTH
];
/* name */
USIGN8
extension
[
MAX_EXTENSION_LENGTH
];
/* extension */
}
T_ARRAY_OBJECT
;
/*--- Record-Variable-Object-Description ------------------------------------------*/
typedef
struct
_T_RECORD_OBJECT
{
USIGN16
index
;
/* index */
USIGN8
obj_code
;
/* object code */
USIGN8
no_of_address
;
/* number of local address */
USIGN16
index_of_type
;
/* logical address of the type */
T_ACCESS
access
;
/* access right structure */
STRINGV
name
[
MAX_OBJECT_NAME_LENGTH
];
/* name */
USIGN8
extension
[
MAX_EXTENSION_LENGTH
];
/* extension */
USIGN32
reserved
;
/* for internal use */
/* USIGN32 local_address_list[no_of_address]; local address list */
}
T_RECORD_OBJECT
;
/*--- Variable-List-Object-Description --------------------------------------------*/
typedef
struct
_T_VAR_LIST_OBJECT
{
USIGN16
index
;
/* logical address of the object */
USIGN8
obj_code
;
/* object code */
USIGN8
no_of_var
;
/* number of variables */
T_ACCESS
access
;
/* access right */
PB_BOOL
deletable
;
/* TRUE - deletable; else FALSE */
USIGN8
dummy
;
/* alignment-byte */
STRINGV
name
[
MAX_OBJECT_NAME_LENGTH
];
/* name */
USIGN8
extension
[
MAX_EXTENSION_LENGTH
];
/* extension */
USIGN32
reserved
;
/* for internal use */
/* USIGN16 var_list[no_of_var]; list of variables */
}
T_VAR_LIST_OBJECT
;
/* --- Read-Service ---------------------------------------------------------------*/
typedef
struct
_T_VAR_READ_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
USIGN8
subindex
;
/* subindex */
USIGN8
dummy
;
/* alignment byte */
}
T_VAR_READ_REQ
;
typedef
struct
_T_VAR_READ_CNF
{
USIGN8
dummy
;
/* alignment byte */
USIGN8
length
;
/* length of values in bytes */
/* USIGN8 value[lenght]; list of data */
}
T_VAR_READ_CNF
;
/*--- Read-With-Type-Service ------------------------------------------------------*/
typedef
struct
_T_VAR_READ_WITH_TYPE_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
USIGN8
subindex
;
/* subindex */
USIGN8
dummy
;
/* alignment byte */
}
T_VAR_READ_WITH_TYPE_REQ
;
typedef
struct
_T_VAR_READ_WITH_TYPE_CNF
{
USIGN8
no_of_type_descr
;
/* number of typedescription */
USIGN8
length
;
/* # of values in bytes */
/* T_TYPE_DESCR type_descr_list[no_of_type_descr]; list of type description */
/* USIGN8 value[length]; list of data */
}
T_VAR_READ_WITH_TYPE_CNF
;
/*--- Write-Service ---------------------------------------------------------------*/
typedef
struct
_T_VAR_WRITE_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
USIGN8
subindex
;
/* subindex */
USIGN8
length
;
/* # number of values in bytes */
/* USIGN8 value[length]; list of values */
}
T_VAR_WRITE_REQ
;
/*--- Write-With-Type-Service -----------------------------------------------------*/
typedef
struct
_T_VAR_WRITE_WITH_TYPE_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
USIGN8
subindex
;
/* subindex */
USIGN8
dummy
;
/* alignment byte */
USIGN8
no_of_type_descr
;
/* number of type descriptions */
USIGN8
length
;
/* # of values in bytes */
/* T_TYPE_DESCR type_descr_list[no_of_type_descr]; list of type descriptions */
/* USIGN8 value[length]; list of datas */
}
T_VAR_WRITE_WITH_TYPE_REQ
;
/*--- Information-Report-Service --------------------------------------------------*/
typedef
struct
_T_VAR_INFO_RPT_REQ
{
USIGN8
priority
;
/* priority */
USIGN8
subindex
;
/* subindex */
T_ACC_SPEC
acc_spec
;
/* access specification */
USIGN8
dummy
;
/* alignment-byte */
USIGN8
length
;
/* # of values in bytes */
/* USIGN8 value[length]; list of data */
}
T_VAR_INFO_RPT_REQ
;
/*--- Information-Report-With-Type-Service ----------------------------------------*/
typedef
struct
_T_VAR_INFO_RPT_WITH_TYPE_REQ
{
USIGN8
priority
;
/* priority */
USIGN8
subindex
;
/* subindex */
T_ACC_SPEC
acc_spec
;
/* access specification */
USIGN8
no_of_type_descr
;
/* number of typedescription */
USIGN8
length
;
/* # of values in bytes */
/* T_TYPE_DESCR type_descr_list[no_of_type_descr]; list of type description */
/* USIGN8 value[length]; list of data */
}
T_VAR_INFO_RPT_WITH_TYPE_REQ
;
/*--- Define-Variable-List-Service ------------------------------------------------*/
typedef
struct
_T_VAR_DEFINE_VAR_LIST_REQ
{
T_ACCESS
access
;
/* access rights */
STRINGV
name
[
MAX_OBJECT_NAME_LENGTH
];
/* variable list name */
USIGN8
extension
[
MAX_EXTENSION_LENGTH
];
/* extension */
USIGN16
index
;
/* index of variable list */
USIGN8
dummy
;
/* alignment byte */
USIGN8
no_of_var
;
/* number of variables */
#if (PB_VER >= 500)
/* T_DYN_ACC_SPEC var_list[no_of_var]; list of variables */
#else
/* T_ACC_SPEC var_list[no_of_var]; list of variables */
#endif
}
T_VAR_DEFINE_VAR_LIST_REQ
;
typedef
struct
_T_VAR_DEFINE_VAR_LIST_CNF
{
USIGN16
index
;
/* index of variable list */
}
T_VAR_DEFINE_VAR_LIST_CNF
;
/*--- Delete-Variable-List-Service ------------------------------------------------*/
typedef
struct
_T_VAR_DELETE_VAR_LIST_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
}
T_VAR_DELETE_VAR_LIST_REQ
;
/*--- Physical-Read-Service -------------------------------------------------------*/
typedef
struct
_T_VAR_PHYS_READ_REQ
{
USIGN32
int_addr
;
/* physical address to be read */
USIGN8
length
;
/* length in octets */
USIGN8
dummy
;
/* alignment byte */
}
T_VAR_PHYS_READ_REQ
;
typedef
struct
_T_VAR_PHYS_READ_CNF
{
USIGN8
dummy
;
/* alignment byte */
USIGN8
length
;
/* length of values in bytes */
/* USIGN8 data[length]; list of data */
}
T_VAR_PHYS_READ_CNF
;
/*--- Physical-Write-Service ------------------------------------------------------*/
typedef
struct
_T_VAR_PHYS_WRITE_REQ
{
USIGN32
int_addr
;
/* physical address to be write */
USIGN8
dummy
;
/* length in octets */
USIGN8
length
;
/* length in octets */
/* USIGN8 data[length]; list of datas */
}
T_VAR_PHYS_WRITE_REQ
;
/*--- Data-Event service ----------------------------------------------------------*/
typedef
struct
_T_VAR_DATA_EVENT_IND
{
USIGN16
index
;
/* index */
USIGN8
dummy
;
/* alignment byte */
USIGN8
length
;
/* length of values in bytes */
/* USIGN8 value[lenght]; list of data */
}
T_VAR_DATA_EVENT_IND
;
/*****************************************************************************/
/************* EVENT-MANAGEMENT *********************/
/*****************************************************************************/
/*--- Event-Object-Description ----------------------------------------------*/
typedef
struct
_T_EVENT_OBJECT
{
USIGN16
index_event
;
/* index */
USIGN8
obj_code
;
/* object code */
USIGN8
data_length
;
/* size of event data */
USIGN16
index_event_data
;
/* index of event-data */
T_ACCESS
access
;
/* access protection */
PB_BOOL
enabled
;
/* =>TRUE event is enabled */
USIGN8
dummy
;
/* alignment byte */
STRINGV
name
[
MAX_OBJECT_NAME_LENGTH
];
/* symbolic name */
USIGN8
extension
[
MAX_EXTENSION_LENGTH
];
/* extension */
}
T_EVENT_OBJECT
;
/*--- Event-Notification-Service --------------------------------------------*/
typedef
struct
_T_EVENT_NOTIFY_REQ
{
USIGN8
priority
;
/* priority */
USIGN8
event_number
;
/* event number */
T_ACC_SPEC
acc_spec
;
/* access specification */
USIGN8
dummy
;
/* alignment */
USIGN8
data_length
;
/* # of event datas in byte */
/* USIGN8 event_data[data_length]; list of event_datas */
}
T_EVENT_NOTIFY_REQ
;
/*--- Event-Notification-With-Type-Service ----------------------------------*/
typedef
struct
_T_EVENT_NOTIFY_WITH_TYPE_REQ
{
USIGN8
priority
;
/* priority */
USIGN8
event_number
;
/* event number */
T_ACC_SPEC
acc_spec
;
/* access specification */
T_TYPE_DESCR
type_descr
;
/* type description */
USIGN8
dummy
;
/* alignment */
USIGN8
data_length
;
/* length of event data */
/* USIGN8 event_data[data_length]; list of event_datas */
}
T_EVENT_NOTIFY_WITH_TYPE_REQ
;
/*--- Alter-Event-Condition-Monitoring --------------------------------------*/
typedef
struct
_T_ALT_EVN_CND_MNT_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
PB_BOOL
enabled
;
/* enable or disable the event */
USIGN8
dummy
;
/* alignment byte */
}
T_ALT_EVN_CND_MNT_REQ
;
/*--- Acknowledge-Event-Notification ----------------------------------------*/
typedef
struct
_T_ACK_EVN_NOTIFY_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
USIGN8
event_number
;
/* event count number */
USIGN8
dummy
;
/* alignment byte */
}
T_ACK_EVN_NOTIFY_REQ
;
/*****************************************************************************/
/************* DOMAIN - MANAGEMENT *********************/
/*****************************************************************************/
/*--- Domain-Object-Description ---------------------------------------------*/
typedef
struct
_T_DOM_OBJECT
{
USIGN16
index
;
/* index */
USIGN8
obj_code
;
/* object code */
USIGN8
state
;
/* domain state */
USIGN8
upload_state
;
/* upload state */
INT8
counter
;
/* in use counter */
USIGN16
max_octets
;
/* max domain length */
T_ACCESS
access
;
/* access protection */
USIGN32
local_address
;
/* local address */
STRINGV
name
[
MAX_OBJECT_NAME_LENGTH
];
/* symbolic name */
USIGN8
extension
[
MAX_EXTENSION_LENGTH
];
/* extension */
}
T_DOM_OBJECT
;
/*--- Domain-Download-Services ----------------------------------------------*/
/*--- Generic-Domain-Download-Services --------------------------------------*/
/*--- Domain-Upload-Services ----------------------------------------------*/
typedef
struct
_T_DOM_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
}
T_DOM_REQ
;
typedef
struct
_T_DNL_UPL_SEG_CNF
{
PB_BOOL
more_follows
;
/* more_follows */
USIGN8
data_len
;
/* data length */
/* USIGN8 data[data_len]; list of data */
}
T_DNL_UPL_SEG_CNF
;
typedef
struct
_T_GEN_DNL_SEG_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
PB_BOOL
more_follows
;
/* more_follows */
USIGN8
data_len
;
/* data length */
/* USIGN8 data[data_len]; list of data */
}
T_GEN_DNL_SEG_REQ
;
typedef
struct
_T_TERM_DNL_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
PB_BOOL
final_result
;
/* final result */
USIGN8
dummy
;
/* alignment */
}
T_TERM_DNL_REQ
;
typedef
struct
_T_GEN_TERM_DNL_CNF
{
PB_BOOL
final_result
;
/* final result */
USIGN8
dummy
;
/* alignment */
}
T_GEN_TERM_DNL_CNF
;
typedef
struct
_T_REQUEST_DOM_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
USIGN8
dummy
;
/* alignment */
USIGN8
add_info_length
;
/* length of add. information */
/* STRINGV add_info[add_info_length]; additional information */
}
T_REQUEST_DOM_REQ
;
/*****************************************************************************/
/************* PROGRAM-INVOCATION-MANAGEMENT *********************/
/*****************************************************************************/
/*--- Program-Invocation-Object ---------------------------------------------*/
typedef
struct
_T_PI_OBJECT
{
USIGN16
index
;
/* pi_index in OD */
USIGN8
obj_code
;
/* object code for OD */
USIGN8
cnt_dom
;
/* # domains */
T_ACCESS
access
;
/* access */
PB_BOOL
deletable
;
/* deletable */
PB_BOOL
reusable
;
/* reusable */
USIGN8
pi_state
;
/* state of pi */
USIGN8
dummy
;
/* alignment byte */
STRINGV
name
[
MAX_OBJECT_NAME_LENGTH
];
/* symbolic name of pi */
USIGN8
extension
[
MAX_EXTENSION_LENGTH
];
/* extension */
USIGN32
reserved
;
/* for internal use */
/* USIGN16 dom_list[cnt_dom]; domain index list */
}
T_PI_OBJECT
;
/*--- Create-PI-Service -----------------------------------------------------*/
typedef
struct
_T_PI_CR8_REQ
{
T_ACCESS
access
;
/* access rights */
USIGN8
cnt_dom
;
/* number of domains */
PB_BOOL
reusable
;
/* => TRUE pi is reusable */
USIGN16
index
;
/* PI-index */
STRINGV
name
[
MAX_OBJECT_NAME_LENGTH
];
/* symbolic name */
USIGN8
extension
[
MAX_EXTENSION_LENGTH
];
/* extension */
#if (PB_VER >= 500)
/* T_DYN_ACC_SPEC dom_list[cnt_dom]; list of domains */
#else
/* T_ACC_SPEC dom_list[cnt_dom]; list of domains */
#endif
}
T_PI_CR8_REQ
;
typedef
struct
_T_PI_CR8_CNF
{
USIGN16
index
;
/* index of PI */
}
T_PI_CR8_CNF
;
/*--- Delete-PI-Service -----------------------------------------------------*/
typedef
struct
_T_PI_DEL_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specification */
}
T_PI_DEL_REQ
;
/*--- Start-PI-Service ------------------------------------------------------*/
typedef
struct
_T_PI_START_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specific. */
USIGN8
exec_arg
[
MAX_EXECUTION_ARGUMENT_LENGTH
];
/* execution arg. */
}
T_PI_START_REQ
;
/*--- Stop-PI-Service -------------------------------------------------------*/
typedef
struct
_T_PI_STOP_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specific. */
}
T_PI_STOP_REQ
;
/*--- Resume-PI-Service -----------------------------------------------------*/
typedef
struct
_T_PI_RESUME_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specific. */
USIGN8
exec_arg
[
MAX_EXECUTION_ARGUMENT_LENGTH
];
/* execution arg. */
}
T_PI_RESUME_REQ
;
/*--- Reset-PI-Service ------------------------------------------------------*/
typedef
struct
_T_PI_RESET_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specific. */
}
T_PI_RESET_REQ
;
/*--- Kill-PI-Service -------------------------------------------------------*/
typedef
struct
_T_PI_KILL_REQ
{
T_ACC_SPEC
acc_spec
;
/* access specific. */
}
T_PI_KILL_REQ
;
/*--- PI-SET-STATE-Service ( only local Service ) ---------------------------*/
typedef
struct
_T_PI_SET_STATE_REQ
{
USIGN32
vfd_number
;
/* vfd number */
T_ACC_SPEC
acc_spec
;
/* access specification */
USIGN8
state
;
/* new PI state */
USIGN8
dummy
;
/* alignment byte */
}
T_PI_SET_STATE_REQ
;
typedef
struct
_T_PI_SET_STATE_CNF
{
USIGN32
vfd_number
;
/* vfd number */
}
T_PI_SET_STATE_CNF
;
/********************************************************************************/
/************* OD-MANAGEMENT ************************/
/********************************************************************************/
/* --- OD-Object-Description ---------------------------------------------------*/
typedef
struct
_T_OD_OBJ_DESCR_HDR
{
USIGN16
index
;
/* index = 0 */
USIGN8
obj_code
;
/* object-code = 1 */
PB_BOOL
flag
;
/* => TRUE write protected */
USIGN8
length
;
/* size of names (0-32) */
PB_BOOL
protection
;
/* access protection supported */
INT16
version
;
/* version */
INT16
len_st_od
;
/* length of the static type description */
USIGN16
first_index_s_od
;
/* start index of the static object description */
INT16
len_s_od
;
/* length of the static object description */
USIGN16
first_index_dv_od
;
/* start index of the dyn. var. list description */
INT16
len_dv_od
;
/* length of the dyn. variable list description */
USIGN16
first_index_dp_od
;
/* start index of the dyn. pi description */
INT16
len_dp_od
;
/* length of the dyn. pi description */
USIGN32
int_addr
;
/* internal address of OD description */
USIGN32
int_addr_st_od
;
/* internal address of the static type descr. */
USIGN32
int_addr_s_od
;
/* internal address of the static object descr. */
USIGN32
int_addr_dv_od
;
/* internal address of the dyn. var. list descr. */
USIGN32
int_addr_dp_od
;
/* internal address of the dyn. pi description */
}
T_OD_OBJ_DESCR_HDR
;
#if (PB_VER < 500)
typedef
struct
T_OV_OBJ_DESCR_HDR
{
USIGN16
index
;
/* index = 0 */
USIGN8
obj_code
;
/* object-code = 1 */
BOOL
flag
;
/* => TRUE write protected */
USIGN8
length
;
/* size of names (0-32) */
BOOL
protection
;
/* access protection supported */
INT16
version
;
/* version */
INT16
len_st_ov
;
/* length of the static type description */
USIGN16
first_index_s_ov
;
/* start index of the static object descr. */
INT16
len_s_ov
;
/* length of the static object description */
USIGN16
first_index_dv_ov
;
/* start index of the dyn. var. list descr. */
INT16
len_dv_ov
;
/* length of the dyn. variable list descr. */
USIGN16
first_index_dp_ov
;
/* start index of the dyn. pi description */
INT16
len_dp_ov
;
/* length of the dyn. pi description */
USIGN32
int_addr
;
/* internal address of ov description */
USIGN32
int_addr_st_ov
;
/* internal address of the static type descr. */
USIGN32
int_addr_s_ov
;
/* internal address of the static object descr.*/
USIGN32
int_addr_dv_ov
;
/* internal address of the dyn. var. list descr*/
USIGN32
int_addr_dp_ov
;
/* internal address of the dyn. pi description */
}
T_OV_OBJ_DESCR_HDR
;
#endif
/* --- OD-Null-Object-Description -------------------------------------------*/
typedef
struct
_T_OD_NULL_OBJECT
{
USIGN16
index
;
/* index */
USIGN8
obj_code
;
/* object code */
USIGN8
dummy
;
/* alignment reasons */
}
T_OD_NULL_OBJECT
;
#if (PB_VER < 500)
typedef
T_OD_NULL_OBJECT
T_OV_NULL_OBJECT
;
#endif
/* --- OD-Static-Type-Object-Description ------------------------------------*/
typedef
struct
_T_OD_ST_DT_DESCR
{
USIGN16
index
;
/* index */
USIGN8
obj_code
;
/* object code */
USIGN8
dummy
;
/* alignment byte */
STRINGV
meaning
[
MAX_OBJECT_NAME_LENGTH
];
/* meaning of the type */
}
T_OD_ST_DT_DESCR
;
#if (PB_VER < 500)
typedef
T_OD_ST_DT_DESCR
T_OV_ST_DT_DESCR
;
#endif
/* --- OD-Static-Structure-Object-Description -------------------------------*/
typedef
struct
_T_OD_DT_LIST
{
USIGN16
index_of_type
;
/* logical address of the type */
USIGN8
length
;
/* length of the element in octets */
USIGN8
dummy
;
/* alignment byte */
}
T_OD_DT_LIST
;
#if (PB_VER < 500)
typedef
T_OD_DT_LIST
T_OV_DT_LIST
;
#endif
typedef
struct
_T_OD_ST_DS_DESCR
{
USIGN16
index
;
/* index */
USIGN8
obj_code
;
/* object code */
USIGN8
no_of_elements
;
/* number of record elements */
USIGN32
reserved
;
/* for internal use */
/* T_OD_DT_LIST dt_list[no_of_elements]; data type list */
}
T_OD_ST_DS_DESCR
;
#if (PB_VER < 500)
typedef
struct
_T_OV_ST_DS_DESCR
{
USIGN16
index
;
/* index */
USIGN8
obj_code
;
/* object code */
USIGN8
no_of_elements
;
/* number of record elements */
USIGN32
reserved
;
/* for internal use */
/* T_OV_DT_LIST dt_list[no_of_elements]; data type list */
}
T_OV_ST_DS_DESCR
;
#endif
/* --- OD-OBJECT-DESCRIPTION ----------------------------------------------- */
#if (PB_VER >= 500)
typedef
struct
_T_OBJECT_DESCR
{
union
{
T_OD_OBJ_DESCR_HDR
od_obj_descr
;
T_OD_NULL_OBJECT
null_obj_descr
;
T_OD_ST_DT_DESCR
dt_obj_descr
;
T_OD_ST_DS_DESCR
ds_obj_descr
;
T_SIMPLE_VAR_OBJECT
s_var_obj_descr
;
T_ARRAY_OBJECT
a_var_obj_descr
;
T_RECORD_OBJECT
r_var_obj_descr
;
T_VAR_LIST_OBJECT
vlist_obj_descr
;
T_DOM_OBJECT
dom_obj_descr
;
T_EVENT_OBJECT
evn_obj_descr
;
T_PI_OBJECT
pi_obj_descr
;
}
id
;
}
T_OBJECT_DESCR
;
#else
typedef
struct
_T_OBJECT_DESCR
{
union
{
T_OV_OBJ_DESCR_HDR
ov_obj_descr
;
T_OV_NULL_OBJECT
null_obj_descr
;
T_OV_ST_DT_DESCR
dt_obj_descr
;
T_OV_ST_DS_DESCR
ds_obj_descr
;
T_SIMPLE_VAR_OBJECT
s_var_obj_descr
;
T_ARRAY_OBJECT
a_var_obj_descr
;
T_RECORD_OBJECT
r_var_obj_descr
;
T_VAR_LIST_OBJECT
vlist_obj_descr
;
T_DOM_OBJECT
dom_obj_descr
;
T_EVENT_OBJECT
evn_obj_descr
;
T_PI_OBJECT
pi_obj_descr
;
}
id
;
}
T_OBJECT_DESCR
;
#endif
/* --- OD-PACKED-OBJECT-DESCRIPTION ---------------------------------------- */
typedef
struct
_T_PACKED_OBJECT_DESCR
{
USIGN8
length
;
/* length of packed object description*/
/* USIGN8 packed_obj_descr[length]; packed object description */
}
T_PACKED_OBJECT_DESCR
;
/* --- Get-OD-Service -------------------------------------------------------*/
typedef
struct
_T_GET_OD_REQ
{
PB_BOOL
format
;
/* TRUE = long format / FALSE = short */
USIGN8
dummy
;
/* alignment byte */
T_ACC_SPEC
acc_spec
;
/* access specification */
}
T_GET_OD_REQ
;
#if (PB_VER < 500)
typedef
T_GET_OD_REQ
T_GET_OV_REQ
;
#endif
typedef
struct
_T_GET_OD_CNF
{
PB_BOOL
more_follows
;
/* further object descr. follow */
USIGN8
no_of_od_descr
;
/* # of object description */
/* T_PACKED_OBJECT_DESCR obj_descr_list[no_of_od_descr]; list of object descriptions */
}
T_GET_OD_CNF
;
#if (PB_VER < 500)
typedef
struct
_T_GET_OV_CNF
{
PB_BOOL
more_follows
;
/* further object descr. follow */
USIGN8
no_of_ov_descr
;
/* # of object description */
/* T_PACKED_OBJECT_DESCR obj_descr_list[no_of_ov_descr]; list of object descriptions */
}
T_GET_OV_CNF
;
#endif
/* --- Put-OD-Services ------------------------------------------------------*/
typedef
struct
_T_INIT_PUT_OD_REQ
{
INT8
consequence
;
/* Loading interactive/non-interactive */
USIGN8
dummy
;
/* alignment */
}
T_INIT_PUT_OD_REQ
;
#if (PB_VER < 500)
typedef
T_INIT_PUT_OD_REQ
T_INIT_PUT_OV_REQ
;
#endif
typedef
struct
_T_PUT_OD_REQ
{
USIGN8
dummy
;
/* alignment */
USIGN8
no_of_od_descr
;
/* # of object description */
/* T_PACKED_OBJECT_DESCR obj_descr_list[no_of_od_descr]; list of object descriptions */
}
T_PUT_OD_REQ
;
#if (PB_VER < 500)
typedef
struct
_T_PUT_OV_REQ
{
USIGN8
dummy
;
/* alignment */
USIGN8
no_of_ov_descr
;
/* # of object description */
/* T_PACKED_OBJECT_DESCR obj_descr_list[no_of_ov_descr]; list of object descriptions */
}
T_PUT_OV_REQ
;
#endif
/* --- Load-OD-Local-Service ------------------------------------------------*/
typedef
struct
_T_INIT_LOAD_OD_REQ
{
USIGN32
vfd_number
;
INT8
consequence
;
USIGN8
dummy
;
}
T_INIT_LOAD_OD_REQ
;
#if (PB_VER < 500)
typedef
T_INIT_LOAD_OD_REQ
T_INIT_LOAD_OV_REQ
;
#endif
typedef
struct
_T_INIT_LOAD_OD_CNF
{
USIGN32
vfd_number
;
}
T_INIT_LOAD_OD_CNF
;
#if (PB_VER < 500)
typedef
T_INIT_LOAD_OD_CNF
T_INIT_LOAD_OV_CNF
;
#endif
typedef
struct
_T_LOAD_OD_REQ
{
USIGN32
vfd_number
;
T_OBJECT_DESCR
obj_descr
;
}
T_LOAD_OD_REQ
;
#if (PB_VER < 500)
typedef
T_LOAD_OD_REQ
T_LOAD_OV_REQ
;
#endif
typedef
struct
_T_LOAD_OD_CNF
{
USIGN32
vfd_number
;
}
T_LOAD_OD_CNF
;
#if (PB_VER < 500)
typedef
T_LOAD_OD_CNF
T_LOAD_OV_CNF
;
#endif
typedef
struct
_T_TERM_LOAD_OD_REQ
{
USIGN32
vfd_number
;
}
T_TERM_LOAD_OD_REQ
;
#if (PB_VER < 500)
typedef
T_TERM_LOAD_OD_REQ
T_TERM_LOAD_OV_REQ
;
#endif
typedef
struct
_T_TERM_LOAD_OD_CNF
{
USIGN32
vfd_number
;
}
T_TERM_LOAD_OD_CNF
;
#if (PB_VER < 500)
typedef
T_TERM_LOAD_OD_CNF
T_TERM_LOAD_OV_CNF
;
#endif
/*--- Read-OD-Local-Service -------------------------------------------------*/
typedef
struct
_T_OD_READ_LOC_REQ
{
USIGN32
vfd_number
;
USIGN8
obj_code
;
USIGN8
dummy
;
T_ACC_SPEC
acc_spec
;
}
T_OD_READ_LOC_REQ
;
#if (PB_VER < 500)
typedef
T_OD_READ_LOC_REQ
T_OV_READ_LOC_REQ
;
#endif
typedef
struct
_T_OD_READ_LOC_CNF
{
USIGN32
vfd_number
;
/* vfd number */
T_OBJECT_DESCR
obj_descr
;
/* object description */
}
T_OD_READ_LOC_CNF
;
#if (PB_VER < 500)
typedef
T_OD_READ_LOC_CNF
T_OV_READ_LOC_CNF
;
#endif
/*****************************************************************************/
/************* VFD-SUPPORT-MANAGEMENT *********************/
/*****************************************************************************/
/*--- Create-VFD-Service ----------------------------------------------------*/
typedef
struct
_T_VFD_CREATE_REQ
{
USIGN32
vfd_number
;
/* vfd number */
STRINGV
vendor_name
[
MAX_VFD_STRING_LENGTH
];
/* vendor name */
STRINGV
model_name
[
MAX_VFD_STRING_LENGTH
];
/* model-name */
STRINGV
revision
[
MAX_VFD_STRING_LENGTH
];
/* revision no */
USIGN8
profile_number
[
2
];
/* profile number */
}
T_VFD_CREATE_REQ
;
typedef
struct
_T_VFD_CREATE_CNF
{
USIGN32
vfd_number
;
/* vfd number */
}
T_VFD_CREATE_CNF
;
/*--- VFD-Set-Physical-Status -----------------------------------------------*/
typedef
struct
_T_VFD_SET_PHYS_STATUS_REQ
{
USIGN32
vfd_number
;
/* vfd number */
USIGN8
physical_status
;
/* physical status */
USIGN8
dummy
;
/* alignment byte */
}
T_VFD_SET_PHYS_STATUS_REQ
;
typedef
struct
_T_VFD_SET_PHYS_STATUS_CNF
{
USIGN32
vfd_number
;
/* vfd number */
}
T_VFD_SET_PHYS_STATUS_CNF
;
/*--- Status-Service --------------------------------------------------------*/
typedef
struct
_T_VFD_STATUS_CNF
{
USIGN8
logical_status
;
/* logical status */
USIGN8
physical_status
;
/* physical status */
USIGN8
local_detail
[
3
];
/* local detail */
USIGN8
dummy
;
/* alignment byte */
}
T_VFD_STATUS_CNF
;
/*--- Unsolicited-Status-Service --------------------------------------------*/
typedef
struct
_T_VFD_UNSOL_STATUS_REQ
{
USIGN8
priority
;
/* priority */
USIGN8
logical_status
;
/* logical status */
USIGN8
physical_status
;
/* physical status */
USIGN8
dummy1
;
/* alignment byte */
USIGN8
local_detail
[
3
];
/* local detail */
USIGN8
dummy2
;
/* alignment byte */
}
T_VFD_UNSOL_STATUS_REQ
;
/*--- Identify-Service ------------------------------------------------------*/
typedef
struct
_T_VFD_IDENTIFY_CNF
{
STRINGV
vendor_name
[
MAX_VFD_STRING_LENGTH
];
/* producer of the device */
STRINGV
model_name
[
MAX_VFD_STRING_LENGTH
];
/* model-name of the device */
STRINGV
revision
[
MAX_VFD_STRING_LENGTH
];
/* revision of the device */
}
T_VFD_IDENTIFY_CNF
;
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to reset alignment */
#ifdef WIN32
#pragma pack(pop)
#else
#pragma pack()
#endif
#pragma warning (default : 4103)
#endif
#endif
profibus/lib/rt/src/os_linux/pb_if.h
View file @
0135e84d
/*
/*****************************************************************************/
* Proview $Id: pb_if.h,v 1.2 2006-02-01 08:35:51 claes Exp $
* Copyright (C) SOFTING GmbH 1995-1999.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**********************************************************************************/
/* */
/* */
/*
SOFTING GmbH
*/
/*
SOFTING AG
*/
/* Richard-Reitzner-Allee 6 */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* */
/* Copyright (C) SOFTING GmbH 1995-1999 */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/* */
/*****************************************************************************
*****
/
/*****************************************************************************/
/*****************************************************************************
*****
/
/*****************************************************************************/
/* PROFIBUS APPLICATION PROGRAM INTERFACE */
/* PROFIBUS APPLICATION PROGRAM INTERFACE */
/* */
/* */
/* Filename : PB_IF.H */
/* Filename : PB_IF.H */
/* Version : 5.2
2.0.00.release
*/
/* Version : 5.2
6.1.00.release
*/
/* Date : 2
6-February-1999
*/
/* Date : 2
7-June-2003
*/
/* Author : SOFTING
-BG2
*/
/* Author : SOFTING
AG
*/
/* */
/* */
/* Description : This file contains the
global function declarations,
*/
/* Description : This file contains the
extern function declarations,
*/
/* defines and types of the PROFIBUS Communication Interface */
/* defines and types of the PROFIBUS Communication Interface */
/* */
/* */
/* CHANGE_NOTES */
/*****************************************************************************/
/* */
/* date name change */
/* ------------------------------------------------------------------------ */
/* 18.03.97 BG2-BOE use compiler switch PB_API_FUNC_NOT_USED */
/* to switch off PAPI-functions */
/* 22.07.97 BG2-BOE remove layer identifier SM7 and SM7_USR */
/* 22.07.97 BG2-BOE set #pragma pack(2) and reset to #pragma pack() */
/* 24.09.97 BG2-BOE add new identifiers for data description interface */
/* - ID_SERIAL_DEVICE_NUMBER */
/* 24.07.97 BG2-BOE add new function prototypes */
/* - profi_get_serial_device_number() */
/* - profi_get_add_error() */
/* 10.02.99 BG2-BOE remove WIN32 function prototypes */
/**********************************************************************************/
/**********************************************************************************/
/**********************************************************************************/
#ifndef __PB_IF__
#ifndef __PB_IF__
#define __PB_IF__
#define __PB_IF__
/*
#pragma warning (disable : 4103)
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to change alignment */
#ifdef WIN32
#ifdef WIN32
#pragma pack(push,2)
#pragma pack(push,2)
#else
#else
#pragma pack(2)
#pragma pack(2)
#endif
#endif
#pragma warning (default : 4103)
#pragma warning (default : 4103)
*/
#endif
/**********************************************************************************/
/**********************************************************************************/
/* INTERFACE DEFINES */
/* INTERFACE DEFINES */
/**********************************************************************************/
/**********************************************************************************/
/* --- contants for IRQ values -(only used for 16BIT-Interface) */
/* contants for DeviceTypes -(only used for WinNT/Win2K-Interface) -------------- */
/* --- DP Devices --------------------------------------------------------------- */
#define DEVICE_DP_MANAGEMENT 1
#define DEVICE_DP_SERVICE 2
#define DEVICE_DP_SLAVE_DATA 3
#define DEVICE_DP_MSAC 9
/* --- FDL Devices -------------------------------------------------------------- */
#define DEVICE_FDL_MANAGEMENT 4
#define DEVICE_FDL_SAP 5
/* --- FMS Devices -------------------------------------------------------------- */
#define DEVICE_FMS_MANAGEMENT 6
#define DEVICE_FMS_CR 7
/* --- Basic Management Device -------------------------------------------------- */
#define DEVICE_BASIC_MANAGEMENT 8
/* --- contants for IRQ values -------------------------------- */
#define REQ_IRQ 0xF0
/* IND/CON IRQ is received */
#define REQ_IRQ 0xF0
/* IND/CON IRQ is received */
#define ACK_IRQ 0x0F
/* acknowledge REQ/RES */
#define ACK_IRQ 0x0F
/* acknowledge REQ/RES */
#define DP_SLAVE_IO_REQ_IRQ 0xE0
/* MASTER: DP-SLAVE-IO IND/REQ */
#define DP_SLAVE_IO_REQ_IRQ 0xE0
/* MASTER: DP-SLAVE-IO IND/REQ */
#define DP_SLAVE_IO_ACK_IRQ 0x0E
/* MASTER: DP-SLAVE-IO acknowldege IND/REQ */
#define DP_SLAVE_IO_ACK_IRQ 0x0E
/* MASTER: DP-SLAVE-IO acknowldege IND/REQ */
#define DP_DATA_STOP_REQ_IRQ 0xD0
/* MASTER: data transfer stop REQ received */
#define DP_DATA_STOP_REQ_IRQ 0xD0
/* MASTER: data transfer stop REQ received */
#define DP_DATA_STOP_ACK_IRQ 0x0D
/* MASTER: data transfer stop Acknowldege */
#define DP_DATA_STOP_ACK_IRQ 0x0D
/* MASTER: data transfer stop Acknowldege */
#define TRC_REQ_IRQ 0xC0
/* TRACE REQ is received */
#define TRC_ACK_IRQ 0x0C
/* TRACE acknowledge */
#define EXCEPTION_REQ_IRQ 0xB0
/* Exception Request */
#define EXCEPTION_REQ_IRQ 0xB0
/* Exception Request */
#define EXCEPTION_ACK_IRQ 0x0B
/* Exception Acknowledge */
#define EXCEPTION_ACK_IRQ 0x0B
/* Exception Acknowledge */
#define DPS_SLAVE_INP_REQ_IRQ 0xA0
/* SLAVE: DP-SLAVE-INPUT request */
#define DPS_SLAVE_INP_ACK_IRQ 0x0A
/* SLAVE: DP-SLAVE-INPUT Acknowldege */
#define DPS_SLAVE_OUTP_REQ_IRQ 0x90
/* SLAVE: DP-SLAVE-OUTPUT request */
#define DPS_SLAVE_OUTP_ACK_IRQ 0x09
/* SLAVE: DP-SLAVE-OUTPUT Acknowldege */
/* --- contants to receive an indication or confirmation ------------------------ */
/* --- contants to receive an indication or confirmation ------------------------ */
#define CON_IND_RECEIVED 0x0001
/* ind. or con. has been received */
#define CON_IND_RECEIVED 0x0001
/* ind. or con. has been received */
...
@@ -118,6 +111,8 @@
...
@@ -118,6 +111,8 @@
#define FMS_USR 0x06
/* identifier FMS-USER */
#define FMS_USR 0x06
/* identifier FMS-USER */
#define FM7_USR 0x07
/* identifier FM7-USER */
#define FM7_USR 0x07
/* identifier FM7-USER */
#define FMB_USR 0x08
/* identifier FMB-USER */
#define FMB_USR 0x08
/* identifier FMB-USER */
#define DPS 0x09
/* identifier DPS */
#define DPS_USR 0x0A
/* identifier DPS-USER */
#define DP 0x0B
/* identifier DP */
#define DP 0x0B
/* identifier DP */
#define DP_USR 0x0C
/* identifier DP-USER */
#define DP_USR 0x0C
/* identifier DP-USER */
#define FDLIF 0x0D
/* identifier FDLIF */
#define FDLIF 0x0D
/* identifier FDLIF */
...
@@ -141,6 +136,11 @@
...
@@ -141,6 +136,11 @@
/* --- DP-MASTER ---------------------------------------------------------------- */
/* --- DP-MASTER ---------------------------------------------------------------- */
#define ID_DP_SLAVE_IO_IMAGE 0x80
/* MASTER: image for slave io datas */
#define ID_DP_SLAVE_IO_IMAGE 0x80
/* MASTER: image for slave io datas */
#define ID_DP_STATUS_IMAGE 0x81
/* MASTER: image for status datas */
#define ID_DP_STATUS_IMAGE 0x81
/* MASTER: image for status datas */
#define ID_DP_SLAVE_IO_CONFIG_IMAGE 0x82
/* MASTER: DPRAM layout of slave io */
/* --- DP-SLAVE ----------------------------------------------------------------- */
#define ID_DPS_SLAVE_INPUT_IMAGE 0x90
/* SLAVE: image for slave input datas */
#define ID_DPS_SLAVE_OUTPUT_IMAGE 0x91
/* SLAVE: image for slave output datas */
/* --- 0xA0 - 0xEF reserved for future use --- (no identifiers defined) --------- */
/* --- 0xA0 - 0xEF reserved for future use --- (no identifiers defined) --------- */
...
@@ -148,12 +148,26 @@
...
@@ -148,12 +148,26 @@
#define ID_EXCEPTION_IMAGE 0xF0
/* image for exeption datas */
#define ID_EXCEPTION_IMAGE 0xF0
/* image for exeption datas */
#define ID_FW_VERS_IMAGE 0xF1
/* image for firmware version */
#define ID_FW_VERS_IMAGE 0xF1
/* image for firmware version */
#define ID_SERIAL_DEVICE_NUMBER 0xF2
/* image for serial device number */
#define ID_SERIAL_DEVICE_NUMBER 0xF2
/* image for serial device number */
#define ID_TRACE_IMAGE 0xF3
/* image for TRACE datas */
/* --- idebtifier for end of data description list ------------------------------ */
/* --- idebtifier for end of data description list ------------------------------ */
#define EOF_DATA_DESCR_LIST 0x00
/* end of data description list */
#define EOF_DATA_DESCR_LIST 0x00
/* end of data description list */
/**********************************************************************************/
/* PROFI SERVICE DESCRIPTION BLOCK */
/**********************************************************************************/
typedef
struct
_T_PROFI_DEVICE_HANDLE
{
HANDLE
hServiceReadDevice
;
// Handle for Service device
HANDLE
hServiceWriteDevice
;
// Handle for Service device
HANDLE
hDpDataDevice
;
// Handle for DP-Data device
HANDLE
hDpsInputDataDevice
;
// Handle for DP-Slave Input-Data device
HANDLE
hDpsOutputDataDevice
;
// Handle for DP-Slave Output-Data device
USIGN8
CurrentBoardNumber
;
}
T_PROFI_DEVICE_HANDLE
;
/**********************************************************************************/
/**********************************************************************************/
/* PROFI SERVICE DESCRIPTION BLOCK */
/* PROFI SERVICE DESCRIPTION BLOCK */
/**********************************************************************************/
/**********************************************************************************/
...
@@ -168,5 +182,975 @@ typedef struct _T_PROFI_SERVICE_DESCR
...
@@ -168,5 +182,975 @@ typedef struct _T_PROFI_SERVICE_DESCR
INT16
result
;
/* service result (POS or NEG) */
INT16
result
;
/* service result (POS or NEG) */
}
T_PROFI_SERVICE_DESCR
;
}
T_PROFI_SERVICE_DESCR
;
#ifdef WIN16
/**********************************************************************************/
/* PROFI INITIALIZATION DATA STRUCTURE */
/**********************************************************************************/
typedef
struct
_T_PROFI_INIT
{
USIGN32
dpr_address
;
/* DPR address */
INT16
io_port_address
;
/* IO port address */
PB_BOOL
load_firmware
;
/* PB_TRUE for PROFI-IF
PB_FALSE for PROFIboard,PROFIcard and PROFI104 */
USIGN8
time_out
;
/* time out interval in seconds */
CSTRING
*
loader_file
;
/* loader file (PROFI-IF only) */
CSTRING
*
firmware_file
;
/* firmware file (PROFI-IF only */
USIGN8
host_type
;
/* for internal use */
USIGN8
irq_vector
;
/* IRQ line to host */
USIGN8
dpr_access_mode
;
/* DPR access mode (8/16 Bit ...) */
USIGN8
address_mode
;
/* host address mode */
USIGN8
poll_int_mode
;
/* host POLL / IRQ mode */
USIGN8
cntrl_type
;
/* for internal use */
USIGN8
token_drive
;
/* indicates the token drive (only PROFI-IF)*/
USIGN8
reserved_1
;
/* reserved */
USIGN16
reserved_2
;
/* reserved */
USIGN16
reserved_3
;
/* reserved */
}
T_PROFI_INIT
;
/* --- macro to set T_PROFI_INIT data structure with default values ------------ */
#define _SET_PROFI_INIT_DEF_PARAM(init_param,a,b) \
init_param.dpr_address = a; \
init_param.load_firmware = PB_FALSE; \
init_param.io_port_address = b; \
init_param.irq_vector = (USIGN8) 0x00; \
init_param.dpr_access_mode = (USIGN8) 0x03; \
init_param.address_mode = (USIGN8) 0x0C; \
init_param.poll_int_mode = (USIGN8) 0x00; \
init_param.time_out = (USIGN8) 0x03
#endif
/************************************************************************/
/* Global function declarations using for 16/32BIT PROFIBUS API and for */
/* compatibility mode using WIN-NT PROFIBUS API */
/************************************************************************/
#ifndef PB_API_FUNC_NOT_USED
#ifdef __cplusplus
extern
"C"
{
#endif
#if defined (WIN32) || defined (_LINUX)
FUNCTION
extern
INT16
CALL_CONV
profi_set_default
(
OUT
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
USIGN8
Board
,
IN
USIGN8
Channel
,
IN
USIGN32
ReadTimeout
,
IN
USIGN32
WriteTimeout
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to initialize the WIN32 PROFIBUS-API. The function function
has to be called before any other function of PROFIBUS-API is called.
IN: Board -> number of the PROFIBUS board (0..9)
IN: Channel -> channel number (0)
IN: ReadTimeout -> receive timeout in ms (WAIT_FOREVER for infinite wait)
IN: Writetimeout -> send timeout in ms (WAIT_FOREVER for infinite wait)
Possible return values:
- E_OK -> Interface is initialized
- E_IF_NO_CNTRL_RES -> controller does not respond
- E_IF_INVALID_CNTRL_TYPE_VERSION -> invalid controller type or software version
- E_IF_INIT_INVALID_PARAMETER -> invalid initialize parameter
- E_IF_INVALID_VERSION -> invalid version
- E_IF_NO_CNTRL_PRESENT -> no controller present
- E_IF_INIT_FAILED -> initialization failed
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_init
(
OUT
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
USIGN8
Board
,
IN
USIGN32
ReadTimeout
,
IN
USIGN32
WriteTimeout
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to initialize the WIN32 PROFIBUS-API. The function function
has to be called before any other function of PROFIBUS-API is called.
IN: Board -> number of the PROFIBUS board (0..9)
IN: Channel -> channel number (0)
IN: ReadTimeout -> receive timeout in ms (WAIT_FOREVER for infinite wait)
IN: Writetimeout -> send timeout in ms (WAIT_FOREVER for infinite wait)
Possible return values:
- E_OK -> Interface is initialized
- E_IF_NO_CNTRL_RES -> controller does not respond
- E_IF_INVALID_CNTRL_TYPE_VERSION -> invalid controller type or software version
- E_IF_INIT_INVALID_PARAMETER -> invalid initialize parameter
- E_IF_INVALID_VERSION -> invalid version
- E_IF_NO_CNTRL_PRESENT -> no controller present
- E_IF_INIT_FAILED -> initialization failed
-----------------------------------------------------------------------------*/
;
#endif
FUNCTION
extern
INT16
CALL_CONV
init_profibus
(
IN
USIGN32
DprAdress
,
IN
USIGN16
IoPortAdress
,
IN
PB_BOOL
Dummy
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used initialize the PROFIBUS-API with default values and start
the PROFIBUS controller. The function function has to be called before any other
function of PROFIBUS-API is called.
IN: DprAdress -> dummy
IN: IoPortAdress -> dummy
IN: Dummy -> dummy
Possible return values:
- E_OK -> Interface is initialized
- E_IF_NO_CNTRL_RES -> controller does not respond
- E_IF_INVALID_CNTRL_TYPE_VERSION -> invalid controller type or software version
- E_IF_INIT_INVALID_PARAMETER -> invalid initialize parameter
- E_IF_INVALID_VERSION -> invalid version
- E_IF_NO_CNTRL_PRESENT -> no controller present
- E_IF_INIT_FAILED -> initialization failed
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_end
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to shutdown the PROFIBUS-API and shutdown the PROFIBUS
controller.
Possible return values:
- E_OK
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_snd_req_res
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
T_PROFI_SERVICE_DESCR
*
pSdb
,
IN
VOID
*
pData
,
IN
PB_BOOL
dummy
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to send a Service-Request or a Service-Response
to the PROFIBUS controller.
IN: pSdb -> pointer to SERVICE-DESCRIPTION-BLOCK
IN: pData -> pointer to service specific data
IN: dummy -> dummy
Possible return values:
- E_OK -> no error occured
- E_IF_INVALID_LAYER -> invalid layer
- E_IF_INVALID_SERVICE -> invalid service identifier
- E_IF_INVALID_PRIMITIVE -> invalid service primitive
- E_IF_RESOURCE_UNAVAILABLE -> no resource available
- E_IF_NO_PARALLEL_SERVICES -> no parallel services allowed
- E_IF_SERVICE_CONSTR_CONFLICT -> service temporarily not executable
- E_IF_SERVICE_NOT_SUPPORTED -> service not supported in subset
- E_IF_SERVICE_NOT_EXECUTABLE -> service not executable
- E_IF_NO_CNTRL_RES -> controller does not respond (CMI_TIMEOUT)
- E_IF_INVALID_DATA_SIZE -> not enough CMI memory available for REQ or RES
- E_IF_INVALID_VERSION -> invalid version (only PROFDI-IF)
- E_IF_INVALID_PARAMETER -> invalid parameter in REQ or RES
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_rcv_con_ind
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
OUT
T_PROFI_SERVICE_DESCR
*
pSdb
,
OUT
VOID
*
pData
,
INOUT
USIGN16
*
pDataLength
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to receive a Service-Indication or a Service-Confirmation
from the PROFIBUS controller.
OUT: pSdb -> pointer to SERVICE-DESCRIPTION-BLOCK
OUT: pData -> pointer to data buffer
INOUT: pDataLength -> IN: length of data buffer
OUT: length of received data
Possible return values:
- CON_IND_RECEIVED -> a confirmation or indication has been received
- NO_CON_IND_RECEIVED -> no confirmation or indication has been received
- E_IF_FATAL_ERROR -> unrecoverable error in PROTOCOL SW
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_set_data
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
USIGN8
DataId
,
IN
USIGN16
Offset
,
IN
USIGN16
DataLength
,
IN
VOID
*
pData
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to write data to CMI data area
IN: DataId -> data image identifier
- ID_DP_SLAVE_IO_IMAGE (DPM: image for slave io data)
- ID_DP_STATUS_IMAGE (DPM: image for status data)
IN: Offset -> write at offset in data image
IN: DataLength -> length of data to write
IN: pData -> pointer to data to write
possible return values:
- E_OK -> OK
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_SERVICE_NOT_SUPPORTED -> service not supported
- E_IF_INVALID_DATA_SIZE -> invalid user data size
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_get_data
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
USIGN8
DataId
,
IN
USIGN16
Offset
,
INOUT
USIGN16
*
pDataLength
,
OUT
VOID
*
pData
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to read data from CMI data area
IN: DataId -> data image identifier
- ID_DP_SLAVE_IO_IMAGE (DPM: image for slave io data)
- ID_DP_STATUS_IMAGE (DPM: image for status data)
IN: Offset -> read at offset in data image
INOUT: pDataLength IN: length of data buffer
OUT: length of received data
OUT: pData -> pointer to data buffer
possible return values:
- E_OK -> OK
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_SERVICE_NOT_SUPPORTED -> service not supported
- E_IF_INVALID_DATA_SIZE -> invalid user data size
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_set_dps_input_data
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
IN
USIGN8
*
pData
,
IN
USIGN8
DataLength
,
OUT
USIGN8
*
pState
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to write DP Slave input data to DPS_SLAVE_INPUT_IMAGE
IN: pData -> pointer to new input data
IN: DataLength -> number bytes of input data
OUT: pState -> pointer to a status variable for the recent input data status
possible return values:
- E_OK -> OK
- E_IF_INVALID_DATA_SIZE -> data_size does not match the expected input data size
- E_IF_NO_CNTRL_RES -> timeout controller does not response
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_get_dps_input_data
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
OUT
USIGN8
*
pData
,
INOUT
USIGN8
*
pDataLength
,
OUT
USIGN8
*
pState
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to read data CMI DPS_SLAVE_INPUT_IMAGE
OUT: pData -> destination buffer for input data
INOUT: pDataLength -> sizeof destination buffer and number of bytes read
OUT: pState -> status of input data if read successfully
possible return values:
- E_OK -> OK
- E_IF_INVALID_DATA_SIZE -> invalid user data size
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_get_dps_output_data
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
OUT
USIGN8
*
pData
,
INOUT
USIGN8
*
pDataLength
,
OUT
USIGN8
*
pState
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to read data from DPS_SLAVE_OUTPUT_IMAGE.
OUT: pData -> destination buffer for output data
INOUT: pDataLength -> sizeof destination buffer and number of bytes read
OUT: pState -> status of output data if read successfully
possible return values:
- E_OK -> OK
- E_IF_SERVICE_NOT_SUPPORTED -> service not supported
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_INVALID_DATA_SIZE -> invalid user data size
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_get_versions
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
OUT
CSTRING
*
pPapiVersion
,
OUT
CSTRING
*
pFirmwareVersion
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the vesrion strings of PAPI and firmware.
OUT: pPapiVersion -> data buffer for PAPI version string
OUT: pFirmwareVersion -> data buffer for firmware version string
NOTE: There must be at least 100 Bytes (VERSION_STRING_LENGTH) free space for
each INOUT buffer.
Possible return values:
- E_OK
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_get_serial_device_number
(
IN
T_PROFI_DEVICE_HANDLE
*
hDevice
,
OUT
USIGN32
*
pSerialDeviceNumber
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the serial device number of the PROFIBUS
controller
OUT: pSerialDeviceNumber -> serial device number
Possible return values:
- E_OK
- E_IF_PAPI_NOT_INITIALIZED -> API not initialized
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_get_last_error
(
VOID
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is returns the additional last error code for INTERFACE-ERRORs
controller
Possible return values:
- additional last error code
-----------------------------------------------------------------------------*/
;
#ifdef _LINUX
FUNCTION
PUBLIC
int
kbhit
(
VOID
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function emulates the kbhit function from dos and windows
Possible return values:
- 1, if there is something to read from stdin within 1 ms
- 0, in all other cases
-----------------------------------------------------------------------------*/
;
#endif
#ifdef WIN32
/**********************************************************************************/
/* extern function declarations using for enhanced WinNT/Win2K PROFIBUS Interface */
/**********************************************************************************/
FUNCTION
extern
HANDLE
CALL_CONV
profi_open_basic_management
(
IN
USIGN8
Board
,
IN
USIGN8
Channel
,
IN
INT32
DesiredAccess
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to initialize the enhanced mode of the PROFIBUS API.
It opens the the BASIC MANAGEMENT DEVICE and updates the PROFIBUS firmware onto
PROFIBUS controller if necessary.
IN: Board -> number of the PROFIBUS board (0..9)
IN: Channel -> channel number
IN: DesiredAccess -> GENERIC_READ specifies the read access to the device
GENERIC_WRITE specifies the write access to the device
Possible return values:
- open handle of BASIC MANAGEMENT DEVICE if function succeeds successfully
- INVALID_HANDLE_VALUE if function fails
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
HANDLE
CALL_CONV
profi_open
(
IN
HANDLE
hBasicMgmtDevice
,
IN
INT32
DeviceType
,
IN
USIGN32
Index
,
IN
INT32
DesiredAccess
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to open a PROFIBUS device specified by 'device_type'.
IN: hBasicMgmtDevice -> basic management device handle
IN: DeviceType -> type of the device to open
DEVICE_DP_MANAGEMENT -> DP management device
DEVICE_DP_SERVICE -> DP service device
DEVICE_DP_SLAVE_DATA -> DP slave data device
DEVICE_DP_MSAC -> DP master slave acyclic device
DEVICE_FDL_MANAGEMENT -> FDL management device
DEVICE_FDL_SAP -> FDL SAP device
DEVICE_FMS_MANAGEMENT -> FMS management device
DEVICE_FMS_CR -> FMS CR device
IN: Index -> index of the device to open
1..128 DP service-, DP slave data- and DP/V1 service devices
0..63,DEFAUT_SAP FDL SAP device
1..64 FMS CR device
IN: DesiredAccess -> GENERIC_READ specifies the read access to the device
GENERIC_WRITE specifies the write access to the device
Possible return values:
- open handle of the specified device if function succeeds successfuly
- INVALID_HANDLE_VALUE if function fails
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
BOOL
CALL_CONV
profi_close
(
IN
HANDLE
hDevice
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to close a device opened with 'profi_open_basic_management'
function or 'profi_open' function.
IN: hDevice -> handle of the device to close
Possible return values:
- TRUE -> device is closed
- FALSE -> device can not be closed
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_read_service
(
IN
HANDLE
hDevice
,
OUT
T_PROFI_SERVICE_DESCR
*
pSdb
,
OUT
VOID
*
pData
,
INOUT
USIGN16
*
pDataLength
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to receive a Service-Indication or a Service-Confirmation
from a PROFIBUS service device.
IN: hDevice -> device handle
OUT: pSdb -> pointer to SERVICE-DESCRIPTION-BLOCK
OUT: pData -> pointer to data buffer
INOUT: pDatalen -> IN: length of data buffer
OUT: length of received data
Possible return values:
- CON_IND_RECEIVED -> a confirmation or indication has been received
- NO_CON_IND_RECEIVED -> no confirmation or indication has been received
- E_IF_NO_CNTRL_RES -> controller does not respond
- E_IF_FATAL_ERROR -> unrecoverable error in PROTOCOL SW
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_OS_ERROR -> NT system error
- E_IF_RESOURCE_UNAVAILABLE -> no resource available
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_write_service
(
IN
HANDLE
hDevice
,
IN
T_PROFI_SERVICE_DESCR
*
pSdb
,
IN
VOID
*
pData
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to send a Service-Request or a Service-Response
to a PROFIBUS service device.
IN: hDevice -> device handle
IN: pSdp -> pointer to SERVICE-DESCRIPTION-BLOCK
IN: pData -> pointer to service specific data
Possible return values:
- E_OK -> no error occured
- E_IF_INVALID_LAYER -> invalid layer
- E_IF_INVALID_SERVICE -> invalid service identifier
- E_IF_INVALID_PRIMITIVE -> invalid service primitive
- E_IF_RESOURCE_UNAVAILABLE -> no resource available
- E_IF_NO_PARALLEL_SERVICES -> no parallel services allowed
- E_IF_SERVICE_CONSTR_CONFLICT -> service temporarily not executable
- E_IF_SERVICE_NOT_SUPPORTED -> service not supported in subset
- E_IF_SERVICE_NOT_EXECUTABLE -> service not executable
- E_IF_NO_CNTRL_RES -> controller does not respond (CMI_TIMEOUT)
- E_IF_INVALID_DATA_SIZE -> not enough CMI memory available for REQ or RES
- E_IF_INVALID_PARAMETER -> invalid wrong parameter in REQ or RES
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_CMI_CALL -> invalid CMI call
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_read_multi
(
OUT
T_PROFI_SERVICE_DESCR
*
pSdb
,
OUT
VOID
*
pData
,
INOUT
USIGN16
*
pDataLength
,
IN
USIGN16
NrOfHandles
,
IN
HANDLE
*
phDevices
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to receive a Service-Indication or a Service-Confirmation
from one ore more PROFIBUS service devices.
OUT: pSdb -> pointer to SERVICE-DESCRIPTION-BLOCK
OUT: pData -> pointer to data buffer
INOUT: pDataLength -> IN: length of data buffer
OUT: length of received data
IN: NrOfHandles -> number of device handles
IN: phDevices -> pointer to list of device handles
Possible return values:
- CON_IND_RECEIVED -> a confirmation or indication has been received
- NO_CON_IND_RECEIVED -> no confirmation or indication has been received
- E_IF_NO_CNTRL_RES -> controller does not respond
- E_IF_FATAL_ERROR -> unrecoverable error in PROTOCOL SW
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_OS_ERROR -> NT system error
- E_IF_RESOURCE_UNAVAILABLE -> no resource available
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_read_data
(
IN
HANDLE
hDevice
,
OUT
VOID
*
pData
,
OUT
USIGN16
*
pDataLength
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to read DP-Slave-I/O-Data from a DP SLAVE DATA DEVICE.
IN: hDevice -> device handle
OUT: pData -> pointer to data buffer
OUT: pDataLength -> IN: length of data buffer
OUT: length of received data
Possible return values:
- E_OK -> no error occured
- E_IF_INVALID_DP_STATE -> DP is not in operational state
- E_IF_SLAVE_ERROR -> no valid communication with DP-Slave
- E_IF_SLAVE_DIAG_DATA -> new DP diagnostics data available
- E_IF_INVALID_CMI_CALL -> invalid offset inside data image
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_write_data
(
IN
HANDLE
hDevice
,
IN
VOID
*
pData
,
IN
USIGN16
DataLength
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to write DP-Slave-I/O-Data to a DP SLAVE DATA DEVICE.
IN: hDevice -> device handle
IN: pData -> pointer to data buffer
IN: DataLength -> length of data to write
Possible return values:
- E_OK -> no error occured
- E_IF_INVALID_DP_STATE -> DP is not in operational state
- E_IF_SLAVE_ERROR -> no valid communication with DP-Slave
- E_IF_SLAVE_DIAG_DATA -> new DP diagnostics data available
- E_IF_INVALID_CMI_CALL -> invalid offset inside data image
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_read_dps_data
(
IN
HANDLE
hDevice
,
OUT
USIGN8
*
pData
,
INOUT
USIGN8
*
pDataLength
,
OUT
USIGN8
*
pState
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to read data from CMI DPS_SLAVE_INPUT_IMAGE or
DPS_SLAVE_OUTPUT_IMAGE.
IN: hDevice -> device handle
OUT: pData -> destination buffer for input data
INOUT: pDataLength -> IN: length of destination buffer
OUT: number of bytes read
OUT: pState -> status of input or output data if read or write was successfully
Possible return values:
- E_OK -> no error occured
- E_IF_INVALID_CMI_CALL -> invalid offset inside data image
- E_IF_CMI_ERROR -> serious CMI error
- E_IF_INVALID_DATA_SIZE -> size of data block provided not sufficient
- E_IF_SERVICE_CONSTR_CONFLICT -> service not executable at time
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
INT16
CALL_CONV
profi_write_dps_data
(
IN
HANDLE
hDevice
,
IN
USIGN8
*
pData
,
IN
USIGN8
DataLength
,
OUT
USIGN8
*
pState
)
/*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to write DP-Slave input data to DPS_SLAVE_INPUT_IMAGE
IN: hDevice -> device handle
IN: pData -> pointer to new input data
IN: DataLength -> number bytes of input data
OUT: pState -> pointer to a status variable for the recent input data status
possible return values:
- E_OK -> OK
- E_IF_INVALID_DATA_SIZE -> data_size does not match the expected input data size
- E_IF_OS_ERROR -> NT system error
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
BOOL
CALL_CONV
profi_get_cntrl_info
(
IN
USIGN8
Board
,
OUT
char
*
pFirmwareVersion
,
OUT
USIGN32
*
pSerialDeviceNumber
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the version of the firmware and the serial
device number of PROFIBUS controller.
IN: Board -> board number
OUT: pFirmwareVersion -> data buffer for firmware version string
OUT: pSerialDeviceNumber -> serial device number
NOTE: There must be at least 100 Bytes (VERSION_STRING_LENGTH) free space for
firmware version buffer.
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
BOOL
CALL_CONV
profi_set_timeout
(
IN
HANDLE
hBasicMgmtDevice
,
IN
USIGN32
ReadTimeout
,
IN
USIGN32
WriteTimeout
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to set send and receive TIMEOUTs for SEND/RECEIVE interface
functions
IN: hBasicMgmtDevice -> basic management device handle
IN: ReadTimeout -> receive timeout in ms (WAIT_FOREVER for infinite wait)
IN: WriteTimeout -> send timeout in ms (WAIT_FOREVER for infinite wait)
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
BOOL
CALL_CONV
profi_get_timeout
(
IN
HANDLE
hBasicMgmtDevice
,
OUT
USIGN32
*
pReadTimeout
,
OUT
USIGN32
*
pWriteTimeout
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the set send and receive TIMEOUTs for SEND/RECEIVE
interface functions
IN: hBasicMgmtDevice -> basic management device handle
OUT: pReadTimeout -> pointer to receive timeout in ms (WAIT_FOREVER for infinite wait)
OUT: pWriteTimeout -> pointer to send timeout in ms (WAIT_FOREVER for infinite wait)
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
BOOL
CALL_CONV
profi_set_queue_size
(
IN
HANDLE
hBasicMgmtDevice
,
IN
USIGN32
QueueSize
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to set the max. receive queue size for the PROFIBUS driver.
IN: hBasicMgmtDevice -> basic management device handle
IN: QueueSize -> max. receive queue size
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
BOOL
CALL_CONV
profi_get_queue_size
(
IN
HANDLE
hBasicMgmtDevice
,
OUT
USIGN32
*
pQueueSize
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the set max. receive queue size for the PROFIBUS driver.
IN: hBasicMgmtDevice -> basic management device handle
OUT: pQueueSize -> pointer to max. receive queue size
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
;
FUNCTION
extern
BOOL
CALL_CONV
profi_get_overrun_count
(
IN
HANDLE
hBasicMgmtDevice
,
OUT
USIGN32
*
pOverrunCount
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
IN: hBasicMgmtDevice -> basic management device handle
OUT: pOverrunCount -> pointer to overrun counts
Possible return values:
- TRUE -> function returns sucessfully
- FALSE -> function returns not successfully
-----------------------------------------------------------------------------*/
;
#endif
#ifdef __cplusplus
}
#endif
#endif
#if defined (WIN32) || defined (_WIN32) || defined (WIN16) || defined (_WIN16)
#pragma warning (disable : 4103)
/* used #pragma pack to reset alignment */
#ifdef WIN32
#pragma pack(pop)
#else
#pragma pack()
#endif
#pragma warning (default : 4103)
#endif
#endif
#endif
profibus/lib/rt/src/os_linux/pb_ioctl.h
0 → 100644
View file @
0135e84d
/*****************************************************************************/
/* */
/* SOFTING AG */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* PROFIBUS WINDOWS NT DRIVERS */
/* */
/* Filename : PB_IOCTL.H */
/* Version : 5.26.0.01.release */
/* Date : 30-April-2003 */
/* Author : SOFTING AG */
/* */
/* Description : This file contains the global declarations */
/* to access the PROFIBUS Drivers for Linux */
/* */
/*****************************************************************************/
#ifndef PB_IOCTL_H
#define PB_IOCTL_H
/*****************************************************************************/
/* Definitions of IO Control codes */
/*****************************************************************************/
// IOCTL-Magic for Softing-PROFIBUS is 0x69
#define IOCTL_PROFI_GET_DPRAM 0x6901
#define IOCTL_PROFI_SET_TIMEOUT 0x6902
#define IOCTL_PROFI_OPTIMIZED_MODE 0x6903
#define IOCTL_PROFI_SERIAL_NUMBER 0x6904
#define IOCTL_PROFI_STATUS_DATA 0x6905
#define IOCTL_PROFI_GET_DATA_IMAGE 0x6906
#define IOCTL_PROFI_SET_SLAVE_IN 0x6907
#define IOCTL_PROFI_DP_OPERATE 0x6908
#define IOCTL_PROFI_SET_DEBUGLEVEL 0x6909
#ifdef __KERNEL__
extern
int
pb_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
);
#endif
/*****************************************************************************/
/* Structure for data image description */
/*****************************************************************************/
typedef
struct
_StatusAndData
{
void
*
StatusImage
;
int
StatusLength
;
void
*
Data
;
int
DataLength
;
}
StatusAndData
;
typedef
struct
_NTIoctl
{
void
*
InBuf
;
int
InBufLength
;
void
*
OutBuf
;
int
OutBufLength
;
}
NTIoctl
;
typedef
struct
_DataImage
{
int
id
;
void
*
Buf
;
unsigned
short
Length
;
// sizeof( Buf )
}
DataImage
;
/*****************************************************************************/
/* Operation Mode as (FMS/DPV1-Master or DP-Slave) */
/*****************************************************************************/
#define FMS_DPV1_MASTER_MODE 0x00 // FMS/DPV1-Master
#define DPV1_MASTER_MODE 0x01 // for future use
#define DPV1_SLAVE_MODE 0x02 // DP-Slave
#endif
profibus/lib/rt/src/os_linux/pb_ntdrv.h
0 → 100644
View file @
0135e84d
/*****************************************************************************/
/* */
/* SOFTING AG */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* PROFIBUS WINDOWS NT DRIVERS */
/* */
/* Filename : PB_NTDRV.H */
/* Version : 5.26.0.01.release */
/* Date : 30-April-2003 */
/* Author : SOFTING AG */
/* */
/* Description : This file contains the global declarations */
/* to access the PROFIBUS Drivers for Windows NT */
/* */
/*****************************************************************************/
#ifndef _PB_NTDRV_H_
#define _PB_NTDRV_H_
#ifndef CTL_CODE
#include "winioctl.h"
#endif
/*****************************************************************************/
/* Definitions of IO Control codes */
/*****************************************************************************/
#define FILE_DEVICE_PROFIBOARD 0x8000
#define IOCTL_PROFI_CREATE_DP_MANAGEMENT (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_CREATE_DP_SERVICE (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_CREATE_DP_SLAVE_DATA (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_CREATE_FDL_MANAGEMENT (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_CREATE_FDL_SAP (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x804, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_CREATE_FMS_MANAGEMENT (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x805, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_CREATE_FMS_CR (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x806, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_CREATE_DP_MSAC (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x80e, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_SET_TIMEOUT (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x808, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_PROFI_GET_TIMEOUT (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x809, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_SET_QUEUE_SIZE (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x80a, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_GET_QUEUE_SIZE (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x80b, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_GET_OVERRUN_COUNT (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x80c, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_READ_MULTI (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x80d, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_GET_DATA_IMAGE (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x80f, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PROFI_SET_DPS_DATA (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x810, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define IOCTL_PROFI_SET_DP_BITS (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x811, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_PROFI_CLEAR_DP_BITS (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x812, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_PROFI_CHECK_DEV_CONN (ULONG)CTL_CODE(FILE_DEVICE_PROFIBOARD, 0x813, METHOD_BUFFERED, FILE_ANY_ACCESS)
/*****************************************************************************/
/* Macros to access for PROFIBUS specific error codes */
/*****************************************************************************/
#define PROFI_ERROR_FLAG 0xe0000000
#define CUSTOMER_OK_FLAG 0x20000000 // Bit 29 set
#define CUSTOMER_ERROR_FLAG 0xe0000000 // Bit 29..31 set
#define PROFI_ERROR(code) ((code) | PROFI_ERROR_FLAG)
#define PROFI_ERROR_FLAG_SET(code) ((BOOL) (((code) & PROFI_ERROR_FLAG) != 0) )
#define CUSTOMER_FLAG_SET(code) ((BOOL) ((code) & CUSTOMER_OK_FLAG))
/*****************************************************************************/
/* Timeout structure and define for infinitive wait */
/*****************************************************************************/
#define WAIT_FOREVER ((ULONG)-1)
typedef
struct
_PROFI_TIMEOUT
{
ULONG
TimeoutRead
;
ULONG
TimeoutWrite
;
}
PROFI_TIMEOUT
,
T_PROFI_TIMEOUT
;
/*****************************************************************************/
/* Structure for data image description */
/*****************************************************************************/
typedef
struct
_PROFI_DATA_IMAGE_DESCR
{
UCHAR
imageId
;
USHORT
offset
;
UCHAR
bus
;
}
PROFI_DATA_IMAGE_DESCR
,
T_PROFI_DATA_IMAGE_DESCR
;
/*****************************************************************************/
/* Structure for bit access in DP output data */
/*****************************************************************************/
typedef
struct
_PROFI_DP_BIT_ACCESS
{
USHORT
offset
;
UCHAR
mask
;
}
PROFI_DP_BIT_ACCESS
,
T_PROFI_DP_BIT_ACCESS
;
/*****************************************************************************/
/* Definitions for system registry access */
/*****************************************************************************/
#define REGPATH_PARAMETER_FROM_HLM "SYSTEM\\CurrentControlSet\\Services\\PROFIbrd\\Parameters"
#define MAX_SYMBOLIC_LINK_NAME_SIZE 255
/*****************************************************************************/
/* Operation Mode as (FMS/DPV1-Master or DP-Slave) */
/*****************************************************************************/
#define FMS_DPV1_MASTER_MODE 0x00 // FMS/DPV1-Master
#define DPV1_MASTER_MODE 0x01 // for future use
#define DPV1_SLAVE_MODE 0x02 // DP-Slave
#endif
profibus/lib/rt/src/os_linux/pb_tools.h
0 → 100644
View file @
0135e84d
/*****************************************************************************/
/* */
/* SOFTING AG */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* PROFIBUS-TOOLS-INTERFACE */
/* */
/* Filename : PB_TOOLS.H */
/* Version : 5.21.0.00.release */
/* Date : 27-February-1998 */
/* Author : SOFTING AG */
/* */
/* Description : This file contains the global function declarations, */
/* defines and types of the PROFIBUS-TOOLS-Interface */
/*****************************************************************************/
#ifndef __PB_TOOLS__
#define __PB_TOOLS__
/****************************************************************************/
/*** DEFINES ****************************************************************/
/****************************************************************************/
/*----- definitions to get default bus parameters --------------------------*/
#define DP_MODE 1
#define FMS_FM7_MODE 2
#define DP_FMS_FM7_MODE 3
/*****************************************************************************/
/* global function declarations */
/*****************************************************************************/
#ifdef __cplusplus
extern
"C"
{
#endif
/*----- function prototypes to get default busparameters -------------------*/
#ifdef __PB_DP__
FUNCTION
extern
PB_BOOL
CALL_CONV
pbt_get_dp_def_bus_param
(
IN
USIGN8
BaudRate
,
IN
USIGN8
StationAddr
,
IN
USIGN16
Mode
,
OUT
T_DP_BUS_PARA_SET
FAR
*
pBusParameters
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for DP operation
using ASPC2. (use this function only to version 5.02)
IN: BaudRate -> desired baudrate (see valid baudrates)
IN: StationAddr -> desired station address (0..126)
IN: Mode: -> DP_MODE standalone DP operation
DP_FMS_FM7_MODE simultaneous DP/FMS/FM7 operation
OUT: pBusParameters -> pointer to DP bus parameter structure
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
;
#endif
#ifdef __PB_FM7__
FUNCTION
extern
PB_BOOL
CALL_CONV
pbt_get_fms_fm7_def_bus_param
(
IN
USIGN8
BaudRate
,
IN
USIGN8
StationAddr
,
IN
PB_BOOL
InRingDesired
,
IN
USIGN16
Mode
,
OUT
T_SET_BUSPARAMETER_REQ
FAR
*
pBusParameters
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for FMS/FM7 operation
using ASPC2. (use this function only to version 5.02)
IN: BaudRate -> desired baudrate (see valid baudrates)
IN: StationAddr -> desired station address (0..126)
IN: InRingDesired -> PB_TRUE active station (master)
PB_FALSE passive station (slave)
IN: Mode -> FMS_FM7_MODE standalone FMS/FM7 operation
DP_FMS_FM7_MODE simultaneous DP/FMS/FM7 operation
OUT: bus_param_ptr -> pointer to FM7 bus parameter structure
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
;
#endif
#ifdef __PB_FDL__
FUNCTION
extern
PB_BOOL
CALL_CONV
pbt_get_fdlif_def_bus_param
(
IN
USIGN8
BaudRate
,
IN
USIGN8
StationAddr
,
IN
PB_BOOL
InRingDesired
,
IN
USIGN16
Mode
,
OUT
T_FDLIF_SET_BUSPARAMETER_REQ
FAR
*
pBusParameters
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for FDL operation
using ASPC2. (use this function only to version 5.02)
IN: BaudRate, -> desired baudrate (see valid baudrates)
IN: StationAddr, -> desired station address (0..126)
IN: InRingDesired -> PB_TRUE active station (master)
PB_FALSE passive station (slave)
IN: Mode -> FMS_FM7_MODE standalone FMS/FM7 operation
DP_MODE standalone DP operation
DP_FMS_FM7_MODE simultaneous DP/FMS/FM7 operation
OUT: pBusParameters -> pointer to FDLIF bus parameter structure
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
;
#endif
#ifdef __PB_FMB__
FUNCTION
extern
PB_BOOL
CALL_CONV
pbt_get_fmb_def_bus_param
(
IN
USIGN8
BaudRate
,
IN
USIGN8
StationAddr
,
IN
PB_BOOL
InRingDesired
,
IN
USIGN16
Mode
,
OUT
T_FMB_SET_BUSPARAMETER_REQ
FAR
*
pBusParameters
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
This function is used to get the default busparameter for FMB operation
using ASPC2.
IN: BaudRate -> desired baudrate (see valid baudrates)
IN: StationAddr -> desired station address (0..126)
IN: InRingDesired -> PB_TRUE active station (master)
PB_FALSE passive station (slave)
IN: Mode -> DP_MODE standalone DP operation
DP_FMS_FM7_MODE simultaneous DP/FMS/FM7 operation
FMS_FM7_MODE standalone FMS/FM7 operation
OUT: pBusParameters -> pointer to FMB bus parameter structure
possible return values:
- PB_TRUE parameters correctly set
- PB_FALSE no parameter set available, no parameters set
----------------------------------------------------------------------------*/
;
#endif
#ifdef __PB_FM7__
FUNCTION
extern
VOID
CALL_CONV
ccrl_resrces_init
(
IN
T_CRL_HDR
FAR
*
pCrlHdr
)
/*----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
At first this function has to be called to initialize the internal structures
for calculating the memory requirements.
possible return values:
- NONE
----------------------------------------------------------------------------*/
;
FUNCTION
extern
USIGN16
CALL_CONV
ccrl_resrces_add_entry
(
IN
USIGN16
Cr
,
IN
T_CRL_STATIC
FAR
*
pCrlStatic
,
OUT
T_FMB_CONFIG_CRL
FAR
*
pCrlConfig
)
/*------------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION
For each CRL entry this function has to be called to evaluate the number of resources.
Two actions are performed by this function. First, it checks the CRL entry.
If the entry is incorrect it tries to correct it. If the entry cannot be corrected
it returns with a negative result. If the entry is OK, this function calculates the
resources. After function return, the output buffer holds the sum of resources that
are needed by all CRL entries that where put into ccrl_resrces_add_entry since last
call of ccrl_resrces_init. The result after the last call of ccrl_resrces_add_entry
this is the number of all needed resources for the whole CRL. This result can be used
as input for the PROFIBUS configuration service.
IN: Cr -> communication reference
IN: pCrlStatic -> pointer to static part of the CRL entry
OUT: pCrlConfig -> pointer to CRL configuraton structure
possible return values:
- E_OK -> function executed correctly
- E_FM7_CRL_INVALID_ENTRY -> invalid entry found in CRL, resources are not
calculated
----------------------------------------------------------------------------- */
;
#endif
#ifdef __cplusplus
}
#endif
#endif
profibus/lib/rt/src/os_linux/pb_type.h
View file @
0135e84d
/*
* Proview $Id: pb_type.h,v 1.2 2006-02-01 08:35:51 claes Exp $
* Copyright (C) SOFTING GmbH 1995-1999.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*****************************************************************************/
/*****************************************************************************/
/* */
/* */
/*
SOFTING GmbH
*/
/*
SOFTING AG
*/
/* Richard-Reitzner-Allee 6 */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* */
/* Copyright (C) SOFTING GmbH 1995-1999 */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/* */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
...
@@ -32,20 +16,10 @@
...
@@ -32,20 +16,10 @@
/* Filename : PB_TYPE.H */
/* Filename : PB_TYPE.H */
/* Version : 5.22.0.00.release */
/* Version : 5.22.0.00.release */
/* Date : 26-February-1999 */
/* Date : 26-February-1999 */
/* Author : SOFTING
-BG2
*/
/* Author : SOFTING
AG
*/
/* */
/* */
/* Description : This file contains the PROFIBUS basic types */
/* Description : This file contains the PROFIBUS basic types */
/* */
/* */
/* CHANGE_NOTES */
/* */
/* date name change */
/* ----------------------------------------------------------------------- */
/* 18.03.97 BG2-BOE include header file 'pb_conf.h' */
/* 18.03.97 BG2-BOE remove #define FAR and #define HUGE */
/* 02.02.99 BG2-BOE define INT32 as int using WIN32 */
/* (compatibility to MSVC60) */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
#ifndef __PB_TYPE__
#ifndef __PB_TYPE__
...
@@ -53,31 +27,52 @@
...
@@ -53,31 +27,52 @@
#include "pb_conf.h"
/* PAPI configuration parameters */
#include "pb_conf.h"
/* PAPI configuration parameters */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
/* --- global type definitions --------------------------------------------- */
/* --- global type definitions --------------------------------------------- */
#ifndef VOID
#ifndef VOID
#define VOID void
#define VOID void
#endif
#endif
#define PB_BOOL unsigned char
typedef
unsigned
char
PB_BOOL
;
#if (PB_VER < 500)
#if (PB_VER < 500)
#undef BOOL
#undef BOOL
#define BOOL PB_BOOL
#define BOOL PB_BOOL
#endif
#endif
#define OCTET unsigned char
typedef
unsigned
char
OCTET
;
#define USIGN8 unsigned char
typedef
unsigned
char
USIGN8
;
#define USIGN16 unsigned short
typedef
unsigned
short
USIGN16
;
#define USIGN32 unsigned int
typedef
unsigned
long
USIGN32
;
#define INT8 signed char
typedef
signed
char
INT8
;
#define INT16 signed short
typedef
signed
short
INT16
;
#define INT32 signed int
#define FLOAT float
#ifdef WIN32
#define DOUBLE double
typedef
int
INT32
;
#else
typedef
signed
long
INT32
;
#endif
#define STRINGV char
#ifdef _LINUX
#define CSTRING char
typedef
unsigned
int
UINT
;
#endif
typedef
float
FLOAT
;
typedef
double
DOUBLE
;
typedef
char
STRINGV
;
#ifndef PB_CSTRING_NOT_USED
typedef
char
CSTRING
;
#endif
/* --- PROFIBUS true and false definitions --------------------------------- */
/* --- PROFIBUS true and false definitions --------------------------------- */
...
@@ -98,4 +93,3 @@
...
@@ -98,4 +93,3 @@
#endif
#endif
profibus/lib/rt/src/os_linux/rt_io_m_pb_ao.c
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_m_pb_ao.c,v 1.
4 2006-09-05 11:14:34
claes Exp $
* Proview $Id: rt_io_m_pb_ao.c,v 1.
5 2007-01-12 13:28:31
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -28,10 +28,15 @@
...
@@ -28,10 +28,15 @@
#include <sys/file.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h"
#include "rt_io_pb_locals.h"
#include "pwr.h"
#include "pwr.h"
...
...
profibus/lib/rt/src/os_linux/rt_io_m_pb_di.c
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_m_pb_di.c,v 1.
4 2006-09-05 11:14:34
claes Exp $
* Proview $Id: rt_io_m_pb_di.c,v 1.
5 2007-01-12 13:28:31
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -28,10 +28,15 @@
...
@@ -28,10 +28,15 @@
#include <sys/file.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h"
#include "rt_io_pb_locals.h"
#include "pwr.h"
#include "pwr.h"
...
...
profibus/lib/rt/src/os_linux/rt_io_m_pb_do.c
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_m_pb_do.c,v 1.
4 2006-09-05 11:14:34
claes Exp $
* Proview $Id: rt_io_m_pb_do.c,v 1.
5 2007-01-12 13:28:31
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -28,10 +28,15 @@
...
@@ -28,10 +28,15 @@
#include <sys/file.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h"
#include "rt_io_pb_locals.h"
#include "pwr.h"
#include "pwr.h"
...
...
profibus/lib/rt/src/os_linux/rt_io_m_pb_dp_slave.c
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_m_pb_dp_slave.c,v 1.
5 2006-07-25 11:00:56
claes Exp $
* Proview $Id: rt_io_m_pb_dp_slave.c,v 1.
6 2007-01-12 13:28:31
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -27,10 +27,15 @@
...
@@ -27,10 +27,15 @@
#include <sys/file.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h"
#include "rt_io_pb_locals.h"
#include "pwr.h"
#include "pwr.h"
...
@@ -321,20 +326,21 @@ static pwr_tStatus IoRackRead (
...
@@ -321,20 +326,21 @@ static pwr_tStatus IoRackRead (
{
{
pwr_sClass_Pb_Profiboard
*
mp
;
pwr_sClass_Pb_Profiboard
*
mp
;
pwr_sClass_Pb_DP_Slave
*
sp
;
pwr_sClass_Pb_DP_Slave
*
sp
;
int
fp
;
T_PROFI_DEVICE_HANDLE
*
hDevice
;
unsigned
char
diag
;
pwr_tUInt16
sts
;
pwr_tUInt16
sts
;
pwr_tUInt16
data_len
;
fp
=
((
io_sAgentLocal
*
)
(
ap
->
Local
))
->
Pb_fp
;
hDevice
=
(
T_PROFI_DEVICE_HANDLE
*
)
ap
->
Local
;
sp
=
(
pwr_sClass_Pb_DP_Slave
*
)
rp
->
op
;
sp
=
(
pwr_sClass_Pb_DP_Slave
*
)
rp
->
op
;
mp
=
(
pwr_sClass_Pb_Profiboard
*
)
ap
->
op
;
mp
=
(
pwr_sClass_Pb_Profiboard
*
)
ap
->
op
;
if
((
sp
->
Status
==
PB__NORMAL
||
sp
->
Status
==
PB__NOCONN
)
&&
mp
->
Status
==
PB__NORMAL
&&
sp
->
DisableSlave
!=
1
&&
mp
->
DisableBus
!=
1
)
{
if
((
sp
->
Status
==
PB__NORMAL
||
sp
->
Status
==
PB__NOCONN
)
&&
mp
->
Status
==
PB__NORMAL
&&
sp
->
DisableSlave
!=
1
&&
mp
->
DisableBus
!=
1
)
{
sts
=
pb_cmi_get_data
(
fp
,
ID_DP_STATUS_IMAGE
,
sp
->
SlaveAddress
,
1
,
&
diag
);
data_len
=
sp
->
BytesOfInput
;
sts
=
profi_get_data
(
hDevice
,
ID_DP_SLAVE_IO_IMAGE
,
sp
->
OffsetInputs
,
&
data_len
,
&
sp
->
Inputs
);
if
((
sts
!=
PB_OK
)
||
(
diag
&
1
))
{
if
((
sts
!=
E_OK
))
{
sp
->
Status
=
PB__NOCONN
;
sp
->
Status
=
PB__NOCONN
;
sp
->
ErrorCount
++
;
sp
->
ErrorCount
++
;
}
}
...
@@ -343,20 +349,6 @@ static pwr_tStatus IoRackRead (
...
@@ -343,20 +349,6 @@ static pwr_tStatus IoRackRead (
sp
->
ErrorCount
=
0
;
sp
->
ErrorCount
=
0
;
}
}
if
((
sp
->
Status
==
PB__NORMAL
||
sp
->
Status
==
PB__NOCONN
)
&&
sp
->
BytesOfInput
>
0
)
{
sts
=
pb_cmi_get_data
(
fp
,
ID_DP_SLAVE_IO_IMAGE
,
sp
->
OffsetInputs
,
sp
->
BytesOfInput
,
&
sp
->
Inputs
);
if
(
sts
!=
PB_OK
)
sp
->
ErrorCount
++
;
// else
// sp->ErrorCount = 0;
}
// Stall handling
// Stall handling
if
(
sp
->
ErrorCount
>
sp
->
ErrorSoftLimit
&&
sp
->
StallAction
>=
pwr_ePbStallAction_ResetInputs
)
{
if
(
sp
->
ErrorCount
>
sp
->
ErrorSoftLimit
&&
sp
->
StallAction
>=
pwr_ePbStallAction_ResetInputs
)
{
...
@@ -384,27 +376,24 @@ static pwr_tStatus IoRackWrite (
...
@@ -384,27 +376,24 @@ static pwr_tStatus IoRackWrite (
{
{
pwr_sClass_Pb_Profiboard
*
mp
;
pwr_sClass_Pb_Profiboard
*
mp
;
pwr_sClass_Pb_DP_Slave
*
sp
;
pwr_sClass_Pb_DP_Slave
*
sp
;
int
fp
;
T_PROFI_DEVICE_HANDLE
*
hDevice
;
pwr_tUInt16
sts
;
pwr_tUInt16
sts
;
fp
=
((
io_sAgentLocal
*
)
(
ap
->
Local
))
->
Pb_fp
;
hDevice
=
(
T_PROFI_DEVICE_HANDLE
*
)
ap
->
Local
;
sp
=
(
pwr_sClass_Pb_DP_Slave
*
)
rp
->
op
;
sp
=
(
pwr_sClass_Pb_DP_Slave
*
)
rp
->
op
;
mp
=
(
pwr_sClass_Pb_Profiboard
*
)
ap
->
op
;
mp
=
(
pwr_sClass_Pb_Profiboard
*
)
ap
->
op
;
// Write the whole I/O output area from local area
// Write the whole I/O output area from local area
if
((
sp
->
Status
==
PB__NORMAL
||
sp
->
Status
==
PB__NOCONN
)
&&
mp
->
Status
==
PB__NORMAL
&&
sp
->
DisableSlave
!=
1
&&
mp
->
DisableBus
!=
1
)
{
if
((
sp
->
Status
==
PB__NORMAL
||
sp
->
Status
==
PB__NOCONN
)
&&
mp
->
Status
==
PB__NORMAL
&&
(
sp
->
DisableSlave
!=
1
)
&&
(
mp
->
DisableBus
!=
1
))
{
if
(
sp
->
BytesOfOutput
>
0
)
{
if
(
sp
->
BytesOfOutput
>
0
)
{
sts
=
pb_cmi_set_data
(
fp
,
sts
=
profi_set_data
(
hDevice
,
ID_DP_SLAVE_IO_IMAGE
,
sp
->
OffsetOutputs
,
sp
->
BytesOfOutput
,
&
sp
->
Outputs
);
ID_DP_SLAVE_IO_IMAGE
,
sp
->
OffsetOutputs
,
sp
->
BytesOfOutput
,
&
sp
->
Outputs
);
if
(
sts
!=
PB
_OK
)
sp
->
ErrorCount
++
;
if
(
sts
!=
E
_OK
)
sp
->
ErrorCount
++
;
}
}
}
}
...
...
profibus/lib/rt/src/os_linux/rt_io_m_pb_ii.c
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_m_pb_ii.c,v 1.
4 2006-09-05 11:14:34
claes Exp $
* Proview $Id: rt_io_m_pb_ii.c,v 1.
5 2007-01-12 13:28:31
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -27,10 +27,16 @@
...
@@ -27,10 +27,16 @@
#include <sys/file.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h"
#include "rt_io_pb_locals.h"
#include "pwr.h"
#include "pwr.h"
...
...
profibus/lib/rt/src/os_linux/rt_io_m_pb_io.c
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_m_pb_io.c,v 1.
4 2006-09-05 11:14:34
claes Exp $
* Proview $Id: rt_io_m_pb_io.c,v 1.
5 2007-01-12 13:28:31
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -25,10 +25,15 @@
...
@@ -25,10 +25,15 @@
#include <sys/file.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h"
#include "rt_io_pb_locals.h"
#include "pwr.h"
#include "pwr.h"
...
...
profibus/lib/rt/src/os_linux/rt_io_m_pb_module.c
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_m_pb_module.c,v 1.
5 2006-07-25 11:00:56
claes Exp $
* Proview $Id: rt_io_m_pb_module.c,v 1.
6 2007-01-12 13:28:31
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -27,10 +27,15 @@
...
@@ -27,10 +27,15 @@
#include <sys/file.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h"
#include "rt_io_pb_locals.h"
#include "pwr.h"
#include "pwr.h"
...
...
profibus/lib/rt/src/os_linux/rt_io_m_pb_profiboard.c
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_m_pb_profiboard.c,v 1.
4 2006-09-14 10:28:16
claes Exp $
* Proview $Id: rt_io_m_pb_profiboard.c,v 1.
5 2007-01-12 13:28:31
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -30,10 +30,15 @@
...
@@ -30,10 +30,15 @@
#include <sys/file.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "pb_dp.h"
#include "rt_io_pb_locals.h"
#include "rt_io_pb_locals.h"
#include "pwr.h"
#include "pwr.h"
...
@@ -48,8 +53,25 @@
...
@@ -48,8 +53,25 @@
#include "rt_io_profiboard.h"
#include "rt_io_profiboard.h"
#define DP_MAX_SERVICE_RETRY 10
#define PROFI_RCV_CON_IND() retry_counter = DP_MAX_SERVICE_RETRY; \
do { \
result = profi_rcv_con_ind (hDevice, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len); \
} while ((result == NO_CON_IND_RECEIVED) && (retry_counter-- > 0)); \
\
if (result == E_IF_FATAL_ERROR) return (PB_FALSE); \
static
int
count
;
static
int
count
;
USIGN8
con_ind_buffer
[
256
];
USIGN16
con_ind_buffer_len
=
256
;
T_PROFI_SERVICE_DESCR
con_ind_sdb
;
INT16
result
;
/* !!! local result variable !!! */
USIGN16
retry_counter
;
static
pwr_tStatus
IoAgentInit
(
static
pwr_tStatus
IoAgentInit
(
io_tCtx
ctx
,
io_tCtx
ctx
,
io_sAgent
*
ap
io_sAgent
*
ap
...
@@ -71,12 +93,17 @@ static pwr_tStatus IoAgentClose (
...
@@ -71,12 +93,17 @@ static pwr_tStatus IoAgentClose (
/*----------------------------------------------------------------------------*\
/*----------------------------------------------------------------------------*\
Sends request to Profiboard for setting FMB parameters
Sends request to Profiboard for setting FMB parameters
\*----------------------------------------------------------------------------*/
\*----------------------------------------------------------------------------*/
static
short
fmb_set_configuration
(
int
fp
,
static
short
fmb_set_configuration
(
T_PROFI_DEVICE_HANDLE
*
hDevice
,
pwr_sClass_Pb_Profiboard
*
op
)
pwr_sClass_Pb_Profiboard
*
op
)
{
{
T_PROFI_SERVICE_DESCR
sdb
;
T_PROFI_SERVICE_DESCR
sdb
;
T_FMB_SET_CONFIGURATION_REQ
data
;
T_FMB_SET_CONFIGURATION_REQ
data
;
pwr_tUInt16
retval
;
USIGN8
con_ind_buffer
[
256
];
USIGN16
con_ind_buffer_len
=
256
;
T_PROFI_SERVICE_DESCR
con_ind_sdb
;
INT16
result
;
/* !!! local result variable !!! */
USIGN16
retry_counter
;
sdb
.
comm_ref
=
0
;
sdb
.
comm_ref
=
0
;
sdb
.
layer
=
FMB
;
sdb
.
layer
=
FMB
;
...
@@ -100,26 +127,34 @@ static short fmb_set_configuration(int fp,
...
@@ -100,26 +127,34 @@ static short fmb_set_configuration(int fp,
data
.
dp
.
max_bus_para_len
=
1024
;
data
.
dp
.
max_bus_para_len
=
1024
;
data
.
dp
.
max_slave_para_len
=
1024
;
data
.
dp
.
max_slave_para_len
=
1024
;
retval
=
pb_cmi_flush
(
fp
);
profi_snd_req_res
(
hDevice
,
&
sdb
,
&
data
,
PB_FALSE
);
if
(
retval
!=
PB_OK
)
return
retval
;
retval
=
pb_cmi_write
(
fp
,
&
sdb
,
&
data
,
sizeof
(
T_FMB_SET_CONFIGURATION_REQ
));
PROFI_RCV_CON_IND
();
/*Macro to fetch one confirmation or indication*/
if
(
retval
!=
PB_OK
)
return
retval
;
if
((
con_ind_sdb
.
service
==
FMB_SET_CONFIGURATION
)
&&
(
con_ind_sdb
.
primitive
==
CON
)
&&
(
con_ind_sdb
.
result
==
POS
))
{
return
(
PB_TRUE
);
}
return
(
PB_FALSE
);
retval
=
pb_cmi_read
(
fp
,
NULL
,
NULL
,
NULL
);
return
retval
;
}
}
/*----------------------------------------------------------------------------*\
/*----------------------------------------------------------------------------*\
Sends request to Profiboard for setting DP master parameters
Sends request to Profiboard for setting DP master parameters
\*----------------------------------------------------------------------------*/
\*----------------------------------------------------------------------------*/
static
short
dp_init_master
(
int
fp
,
static
short
dp_init_master
(
T_PROFI_DEVICE_HANDLE
*
hDevice
)
pwr_sClass_Pb_Profiboard
*
op
)
{
{
T_PROFI_SERVICE_DESCR
sdb
;
T_PROFI_SERVICE_DESCR
sdb
;
T_DP_INIT_MASTER_REQ
data
;
T_DP_INIT_MASTER_REQ
data
;
pwr_tUInt16
retval
;
USIGN8
con_ind_buffer
[
256
];
USIGN16
con_ind_buffer_len
=
256
;
T_PROFI_SERVICE_DESCR
con_ind_sdb
;
INT16
result
;
/* !!! local result variable !!! */
USIGN16
retry_counter
;
sdb
.
comm_ref
=
0
;
sdb
.
comm_ref
=
0
;
sdb
.
layer
=
DP
;
sdb
.
layer
=
DP
;
...
@@ -131,26 +166,29 @@ static short dp_init_master(int fp,
...
@@ -131,26 +166,29 @@ static short dp_init_master(int fp,
data
.
master_default_address
=
0
;
data
.
master_default_address
=
0
;
data
.
master_class2
=
PB_FALSE
;
data
.
master_class2
=
PB_FALSE
;
data
.
lowest_slave_address
=
2
;
data
.
lowest_slave_address
=
2
;
data
.
slave_io_address_mode
=
DP_AAM_ARRAY
;
data
.
slave_io_address_mode
=
DP_AAM_
IO_BLOCKS
;
// only mode possible with Linux-driver DP_AAM_
ARRAY;
data
.
clear_outputs
=
PB_TRUE
;
data
.
clear_outputs
=
PB_TRUE
;
data
.
auto_remote_services
=
DP_AUTO_REMOTE_SERVICES
;
data
.
auto_remote_services
=
DP_AUTO_REMOTE_SERVICES
;
data
.
cyclic_data_transfer
=
PB_TRUE
;
data
.
cyclic_data_transfer
=
PB_TRUE
;
retval
=
pb_cmi_flush
(
fp
);
profi_snd_req_res
(
hDevice
,
&
sdb
,
&
data
,
PB_FALSE
);
if
(
retval
!=
PB_OK
)
return
retval
;
retval
=
pb_cmi_write
(
fp
,
&
sdb
,
&
data
,
sizeof
(
T_DP_INIT_MASTER_REQ
));
PROFI_RCV_CON_IND
();
/*Macro to fetch one confirmation or indication*/
if
(
retval
!=
PB_OK
)
return
retval
;
retval
=
pb_cmi_read
(
fp
,
NULL
,
NULL
,
NULL
);
if
((
con_ind_sdb
.
service
==
DP_INIT_MASTER
)
&&
return
retval
;
(
con_ind_sdb
.
primitive
==
CON
)
&&
(
con_ind_sdb
.
result
==
POS
))
{
return
(
PB_TRUE
);
}
return
(
PB_FALSE
);
}
}
/*----------------------------------------------------------------------------*\
/*----------------------------------------------------------------------------*\
Sends request to Profiboard for setting DP bus parameters
Sends request to Profiboard for setting DP bus parameters
\*----------------------------------------------------------------------------*/
\*----------------------------------------------------------------------------*/
static
short
dp_
init_bus
(
int
fp
,
static
short
dp_
download_bus
(
T_PROFI_DEVICE_HANDLE
*
hDevice
,
pwr_sClass_Pb_Profiboard
*
op
)
pwr_sClass_Pb_Profiboard
*
op
)
{
{
T_PROFI_SERVICE_DESCR
sdb
;
T_PROFI_SERVICE_DESCR
sdb
;
...
@@ -158,9 +196,14 @@ static short dp_init_bus(int fp,
...
@@ -158,9 +196,14 @@ static short dp_init_bus(int fp,
T_DP_DOWNLOAD_REQ
drp
;
T_DP_DOWNLOAD_REQ
drp
;
T_DP_BUS_PARA_SET
dbp
;
T_DP_BUS_PARA_SET
dbp
;
}
data
;
}
data
;
pwr_tUInt16
retval
;
int
i
;
int
i
;
USIGN8
con_ind_buffer
[
256
];
USIGN16
con_ind_buffer_len
=
256
;
T_PROFI_SERVICE_DESCR
con_ind_sdb
;
INT16
result
;
/* !!! local result variable !!! */
USIGN16
retry_counter
;
sdb
.
comm_ref
=
0
;
sdb
.
comm_ref
=
0
;
sdb
.
layer
=
DP
;
sdb
.
layer
=
DP
;
sdb
.
service
=
DP_DOWNLOAD_LOC
;
sdb
.
service
=
DP_DOWNLOAD_LOC
;
...
@@ -219,22 +262,25 @@ static short dp_init_bus(int fp,
...
@@ -219,22 +262,25 @@ static short dp_init_bus(int fp,
for
(
i
=
0
;
i
<
32
;
i
++
)
for
(
i
=
0
;
i
<
32
;
i
++
)
data
.
dbp
.
master_class2_name
[
i
]
=
0
;
data
.
dbp
.
master_class2_name
[
i
]
=
0
;
retval
=
pb_cmi_flush
(
fp
);
profi_snd_req_res
(
hDevice
,
&
sdb
,
&
data
,
PB_FALSE
);
if
(
retval
!=
PB_OK
)
return
retval
;
retval
=
pb_cmi_write
(
fp
,
&
sdb
,
&
data
,
72
);
PROFI_RCV_CON_IND
();
/*Macro to fetch one confirmation or indication*/
if
(
retval
!=
PB_OK
)
return
retval
;
if
((
con_ind_sdb
.
service
==
DP_DOWNLOAD_LOC
)
&&
(
con_ind_sdb
.
primitive
==
CON
)
&&
(
con_ind_sdb
.
result
==
POS
))
{
return
(
PB_TRUE
);
}
return
(
PB_FALSE
);
retval
=
pb_cmi_read
(
fp
,
NULL
,
NULL
,
NULL
);
return
retval
;
}
}
/*----------------------------------------------------------------------------*\
/*----------------------------------------------------------------------------*\
Sends request for selecting operation mode to the Profiboard
Sends request for selecting operation mode to the Profiboard
\*----------------------------------------------------------------------------*/
\*----------------------------------------------------------------------------*/
static
short
act_param_loc
(
int
fp
,
static
short
dp_act_param_loc
(
T_PROFI_DEVICE_HANDLE
*
hDevice
,
pwr_sClass_Pb_Profiboard
*
op
,
short
arg
)
{
short
arg
)
{
T_PROFI_SERVICE_DESCR
sdb
;
T_PROFI_SERVICE_DESCR
sdb
;
T_DP_ACT_PARAM_REQ
apr
;
T_DP_ACT_PARAM_REQ
apr
;
...
@@ -253,96 +299,223 @@ static short act_param_loc(int fp,
...
@@ -253,96 +299,223 @@ static short act_param_loc(int fp,
apr
.
activate
=
arg
;
apr
.
activate
=
arg
;
apr
.
dummy
=
0
;
apr
.
dummy
=
0
;
retval
=
pb_cmi_flush
(
fp
);
retval
=
profi_snd_req_res
(
hDevice
,
&
sdb
,
&
apr
,
PB_FALSE
);
if
(
retval
!=
PB_OK
)
return
retval
;
retval
=
pb_cmi_write
(
fp
,
&
sdb
,
&
apr
,
sizeof
(
T_DP_ACT_PARAM_REQ
));
if
(
retval
!=
PB_OK
)
return
retval
;
retval
=
pb_cmi_read
(
fp
,
NULL
,
NULL
,
NULL
);
return
retval
;
return
retval
;
}
}
/*----------------------------------------------------------------------------*\
Sends request for selecting operation mode to the Profiboard
\*----------------------------------------------------------------------------*/
static
pwr_tBoolean
dp_get_slave_diag
(
T_PROFI_DEVICE_HANDLE
*
hDevice
)
{
T_PROFI_SERVICE_DESCR
sdb
;
pwr_tUInt16
retval
;
/* Fill the service description block */
sdb
.
comm_ref
=
0
;
sdb
.
layer
=
DP
;
sdb
.
service
=
DP_GET_SLAVE_DIAG
;
sdb
.
primitive
=
REQ
;
sdb
.
invoke_id
=
0
;
sdb
.
result
=
0
;
retval
=
profi_snd_req_res
(
hDevice
,
&
sdb
,
&
sdb
,
PB_FALSE
);
return
((
pwr_tBoolean
)
(
retval
==
E_OK
));
}
/*----------------------------------------------------------------------------*\
Sends request for selecting operation mode to the Profiboard
\*----------------------------------------------------------------------------*/
static
void
dp_get_slave_diag_con
(
T_DP_GET_SLAVE_DIAG_CON
*
get_slave_diag_con_ptr
)
{
T_DP_DIAG_DATA
FAR
*
diag_data_ptr
;
char
s
[
128
];
if
(
get_slave_diag_con_ptr
->
diag_data_len
>=
DP_MIN_SLAVE_DIAG_LEN
)
{
diag_data_ptr
=
(
T_DP_DIAG_DATA
FAR
*
)
(
get_slave_diag_con_ptr
+
1
);
sprintf
(
s
,
"Slave [%3hu] [0x%04hX]: Status = 0x%02hX 0x%02hX 0x%02hX, Master = %3hu, Ext = %hu, Diags = %hu"
,
get_slave_diag_con_ptr
->
rem_add
,
swap16
(
diag_data_ptr
->
ident_number
),
diag_data_ptr
->
station_status_1
,
diag_data_ptr
->
station_status_2
,
diag_data_ptr
->
station_status_3
,
diag_data_ptr
->
master_add
,
get_slave_diag_con_ptr
->
diag_data_len
-
DP_MIN_SLAVE_DIAG_LEN
,
get_slave_diag_con_ptr
->
diag_entries
);
errh_Info
(
"Profibus DP slave diag - %s"
,
s
);
}
/* diag_data_len */
}
/*----------------------------------------------------------------------------*\
/*----------------------------------------------------------------------------*\
Initializes one DP slave in the master card
Initializes one DP slave in the master card
\*----------------------------------------------------------------------------*/
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
init_dp_slave
(
static
pwr_tStatus
dp_download_slave
(
io_sAgent
*
ap
,
T_PROFI_DEVICE_HANDLE
*
hDevice
,
pwr_tObjid
oid
,
pwr_sClass_Pb_DP_Slave
*
op
int
restart
)
)
{
{
pwr_sClass_Pb_DP_Slave
*
op
;
io_sAgentLocal
*
local_agent
;
int
i
;
int
i
;
char
name
[
196
];
T_PROFI_SERVICE_DESCR
sdb
;
pwr_tUInt16
sts
;
struct
{
pwr_tStatus
status
;
T_DP_DOWNLOAD_REQ
drp
;
struct
timespec
rqtp
,
rmtp
;
unsigned
char
param
[
512
];
}
slave_data
;
T_DP_SLAVE_PARA_SET
prm_head
;
T_DP_PRM_DATA
prm_data
;
T_DP_AAT_DATA
aat_data
;
T_DP_SLAVE_USER_DATA
user_data
;
USIGN16
download_data_size
;
USIGN16
data_len
;
USIGN8
con_ind_buffer
[
256
];
USIGN16
con_ind_buffer_len
=
256
;
T_PROFI_SERVICE_DESCR
con_ind_sdb
;
INT16
result
;
/* !!! local result variable !!! */
USIGN16
retry_counter
;
status
=
gdh_ObjidToPointer
(
oid
,
(
pwr_tAddress
*
)
&
op
);
op
->
Status
=
PB__NOTINIT
;
status
=
gdh_ObjidToName
(
oid
,
(
char
*
)
&
name
,
sizeof
(
name
),
cdh_mNName
);
local_agent
=
(
io_sAgentLocal
*
)
(
ap
->
Local
);
// Try to initialize slave, make three attempts before we give up
op
->
Status
=
PB__NOTINIT
;
errh_Info
(
"Download Profibus DP Slave config - %s"
,
name
);
download_data_size
=
sizeof
(
prm_head
)
+
sizeof
(
prm_data
)
+
op
->
PrmUserDataLen
+
op
->
ConfigDataLen
+
sizeof
(
aat_data
)
+
sizeof
(
user_data
);
// Try to initialize slave, make three attempts before we give up
data_len
=
sizeof
(
slave_data
.
drp
)
+
download_data_size
;
sts
=
PB_OK
;
sdb
.
comm_ref
=
0
;
sdb
.
layer
=
DP
;
sdb
.
service
=
DP_DOWNLOAD_LOC
;
sdb
.
primitive
=
REQ
;
sdb
.
invoke_id
=
0
;
sdb
.
result
=
0
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
slave_data
.
drp
.
data_len
=
download_data_size
;
if
(
!
restart
)
{
slave_data
.
drp
.
rem_add
=
0
;
slave_data
.
drp
.
area_code
=
op
->
SlaveAddress
;
slave_data
.
drp
.
add_offset
=
0
;
if
(
op
->
AutoConfigure
==
1
)
{
prm_head
.
slave_para_len
=
swap16
(
download_data_size
);
sts
=
pb_get_slave_cfg
(
local_agent
->
Pb_fp
,
prm_head
.
sl_flag
=
DP_SL_NEW_PRM
|
DP_SL_ACTIVE
;
op
->
SlaveAddress
,
prm_head
.
slave_type
=
DP_SLAVE_TYPE_DP
;
&
op
->
ConfigDataLen
,
for
(
i
=
0
;
i
<
12
;
i
++
)
prm_head
.
reserved
[
i
]
=
0
;
&
op
->
ConfigData
);
}
i
=
0
;
else
{
memcpy
(
&
slave_data
.
param
[
i
],
&
prm_head
,
sizeof
(
prm_head
));
sts
=
PB_OK
;
i
+=
sizeof
(
prm_head
);
}
if
(
sts
==
PB_OK
)
{
prm_data
.
prm_data_len
=
swap16
(
sizeof
(
prm_data
)
+
op
->
PrmUserDataLen
);
sts
=
pb_download_all
(
local_agent
->
Pb_fp
,
prm_data
.
station_status
=
DP_PRM_LOCK_REQ
|
DP_PRM_WD_ON
;
op
->
SlaveAddress
,
prm_data
.
wd_fact_1
=
op
->
WdFact1
;
op
->
WdFact1
,
prm_data
.
wd_fact_2
=
op
->
WdFact2
;
op
->
WdFact2
,
prm_data
.
min_tsdr
=
0
;
0
,
prm_data
.
ident_number
=
swap16
(
op
->
PNOIdent
);
op
->
PNOIdent
,
prm_data
.
group_ident
=
op
->
GroupIdent
;
op
->
GroupIdent
,
op
->
PrmUserDataLen
,
memcpy
(
&
slave_data
.
param
[
i
],
&
prm_data
,
sizeof
(
prm_data
));
&
op
->
PrmUserData
,
i
+=
sizeof
(
prm_data
);
op
->
ConfigDataLen
,
&
op
->
ConfigData
);
memcpy
(
&
slave_data
.
param
[
i
],
op
->
PrmUserData
,
op
->
PrmUserDataLen
);
}
i
+=
op
->
PrmUserDataLen
;
}
if
(
sts
==
PB_OK
)
{
memcpy
(
&
slave_data
.
param
[
i
],
op
->
ConfigData
,
op
->
ConfigDataLen
);
sts
=
pb_get_slave_info
(
local_agent
->
Pb_fp
,
i
+=
op
->
ConfigDataLen
;
op
->
SlaveAddress
,
&
op
->
OffsetInputs
,
aat_data
.
aat_data_len
=
swap16
(
4
);
// AAT data not used in array mode
&
op
->
OffsetOutputs
,
aat_data
.
number_inputs
=
0
;
&
op
->
BytesOfInput
,
aat_data
.
number_outputs
=
0
;
&
op
->
BytesOfOutput
);
// aat_data.offset_inputs = 0;
}
// aat_data.offset_outputs = 0;
if
(
sts
==
PB_OK
)
break
;
rqtp
.
tv_sec
=
1
;
memcpy
(
&
slave_data
.
param
[
i
],
&
aat_data
,
sizeof
(
aat_data
));
rqtp
.
tv_nsec
=
0
;
i
+=
sizeof
(
aat_data
);
nanosleep
(
&
rqtp
,
&
rmtp
);
user_data
.
slave_user_data_len
=
swap16
(
2
);
memcpy
(
&
slave_data
.
param
[
i
],
&
user_data
,
sizeof
(
user_data
));
i
+=
sizeof
(
user_data
);
profi_snd_req_res
(
hDevice
,
&
sdb
,
&
slave_data
,
PB_FALSE
);
PROFI_RCV_CON_IND
();
/*Macro to fetch one confirmation or indication*/
if
((
con_ind_sdb
.
service
==
DP_DOWNLOAD_LOC
)
&&
(
con_ind_sdb
.
primitive
==
CON
)
&&
(
con_ind_sdb
.
result
==
POS
))
{
op
->
Status
=
PB__NOCONN
;
return
(
PB_TRUE
);
}
}
if
(
sts
!=
PB_OK
)
{
op
->
Status
=
PB__INITFAIL
;
op
->
Status
=
PB__INITFAIL
;
errh_Info
(
"ERROR Init Profibus DP slave %s"
,
name
);
return
IO__ERRINIDEVICE
;
}
op
->
Status
=
PB__NOCONN
;
return
(
PB_FALSE
)
;
return
IO__SUCCESS
;
}
}
/*----------------------------------------------------------------------------*\
Calculate offsets of inputs and outputs for a slave
\*----------------------------------------------------------------------------*/
static
pwr_tStatus
dp_io_offsets
(
T_PROFI_DEVICE_HANDLE
*
hDevice
,
pwr_sClass_Pb_DP_Slave
*
op
)
{
T_PROFI_SERVICE_DESCR
sdb
;
T_DP_GET_SLAVE_PARAM_REQ
get_slave_param_req
;
T_DP_GET_SLAVE_PARAM_CON
FAR
*
get_slave_param_con_ptr
;
T_DP_SLAVE_PARAM_SLAVE_INFO
FAR
*
slave_info_ptr
;
USIGN8
con_ind_buffer
[
256
];
USIGN16
con_ind_buffer_len
=
256
;
T_PROFI_SERVICE_DESCR
con_ind_sdb
;
INT16
result
;
/* !!! local result variable !!! */
USIGN16
retry_counter
;
sdb
.
comm_ref
=
0
;
sdb
.
layer
=
DP
;
sdb
.
service
=
DP_GET_SLAVE_PARAM
;
sdb
.
primitive
=
REQ
;
sdb
.
invoke_id
=
0
;
sdb
.
result
=
0
;
get_slave_param_req
.
identifier
=
DP_SLAVE_PARAM_SLAVE_INFO
;
get_slave_param_req
.
rem_add
=
op
->
SlaveAddress
;
result
=
profi_snd_req_res
(
hDevice
,
&
sdb
,
&
get_slave_param_req
,
PB_FALSE
);
if
(
result
!=
E_OK
)
return
(
result
);
PROFI_RCV_CON_IND
();
get_slave_param_con_ptr
=
(
T_DP_GET_SLAVE_PARAM_CON
FAR
*
)
con_ind_buffer
;
if
(
(
con_ind_sdb
.
service
==
DP_GET_SLAVE_PARAM
)
&&
(
con_ind_sdb
.
primitive
==
CON
)
&&
(
con_ind_sdb
.
result
==
POS
)
)
{
slave_info_ptr
=
(
T_DP_SLAVE_PARAM_SLAVE_INFO
FAR
*
)
(
get_slave_param_con_ptr
+
1
);
op
->
BytesOfInput
=
slave_info_ptr
->
number_inputs
;
op
->
BytesOfOutput
=
slave_info_ptr
->
number_outputs
;
op
->
OffsetInputs
=
slave_info_ptr
->
offset_inputs
;
op
->
OffsetOutputs
=
slave_info_ptr
->
offset_outputs
;
return
(
PB_TRUE
);
}
return
(
PB_FALSE
);
}
/*----------------------------------------------------------------------------*\
/*----------------------------------------------------------------------------*\
Init method for the Pb_profiboard agent
Init method for the Pb_profiboard agent
...
@@ -355,15 +528,20 @@ static pwr_tStatus IoAgentInit (
...
@@ -355,15 +528,20 @@ static pwr_tStatus IoAgentInit (
pwr_sClass_Pb_Profiboard
*
op
;
pwr_sClass_Pb_Profiboard
*
op
;
pwr_tUInt16
sts
;
pwr_tUInt16
sts
;
pwr_tStatus
status
;
pwr_tStatus
status
;
io_sAgentLocal
*
local
;
T_PROFI_DEVICE_HANDLE
*
hDevice
;
char
devname
[
25
];
struct
timespec
rqtp
,
rmtp
;
int
i
;
char
ok
;
char
ok
;
pwr_tObjid
slave_objid
;
pwr_tObjid
slave_objid
;
pwr_tClassId
slave_class
;
pwr_tClassId
slave_class
;
pwr_sClass_Pb_DP_Slave
*
sop
;
char
name
[
196
];
USIGN8
con_ind_buffer
[
256
];
USIGN16
con_ind_buffer_len
=
256
;
T_PROFI_SERVICE_DESCR
con_ind_sdb
;
count
=
0
;
count
=
0
;
/* Allocate area for local data structure */
/* Allocate area for local data structure */
...
@@ -373,16 +551,16 @@ static pwr_tStatus IoAgentInit (
...
@@ -373,16 +551,16 @@ static pwr_tStatus IoAgentInit (
return
IO__ERRINIDEVICE
;
return
IO__ERRINIDEVICE
;
}
}
local
=
(
io_sAgentLocal
*
)
ap
->
Local
;
hDevice
=
(
T_PROFI_DEVICE_HANDLE
*
)
ap
->
Local
;
op
=
(
pwr_sClass_Pb_Profiboard
*
)
ap
->
op
;
op
=
(
pwr_sClass_Pb_Profiboard
*
)
ap
->
op
;
op
->
Status
=
PB__NOTINIT
;
op
->
Status
=
PB__NOTINIT
;
/* Open Pb driver */
/* Initialize interface */
sprintf
(
devname
,
"/dev/pbus%1d"
,
(
int
)
op
->
BusNumber
);
local
->
Pb_fp
=
open
(
devname
,
O_RDWR
);
if
(
local
->
Pb_fp
==
-
1
)
sts
=
profi_init
(
hDevice
,
(
unsigned
char
)
op
->
BusNumber
-
1
,
0
,
0
);
if
(
sts
!=
E_OK
)
{
{
/* Can't open driver */
/* Can't open driver */
op
->
Status
=
PB__INITFAIL
;
op
->
Status
=
PB__INITFAIL
;
...
@@ -411,24 +589,16 @@ static pwr_tStatus IoAgentInit (
...
@@ -411,24 +589,16 @@ static pwr_tStatus IoAgentInit (
ok
=
FALSE
;
ok
=
FALSE
;
if
(
ctx
->
Node
->
Restarts
==
0
)
{
while
(
!
ok
)
{
while
(
!
ok
)
{
if
(
ctx
->
Node
->
Restarts
==
0
)
{
op
->
Status
=
PB__NOTINIT
;
op
->
Status
=
PB__NOTINIT
;
/* Initialize CMI */
sts
=
pb_cmi_init
(
local
->
Pb_fp
);
if
(
sts
!=
PB_OK
)
{
op
->
Status
=
PB__INITFAIL
;
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"cmi init"
);
return
IO__ERRINIDEVICE
;
}
/* Set FMB configuration */
/* Set FMB configuration */
sts
=
fmb_set_configuration
(
local
->
Pb_fp
,
op
);
sts
=
fmb_set_configuration
(
hDevice
,
op
);
if
(
sts
!=
PB_OK
)
{
if
(
!
sts
)
{
op
->
Status
=
PB__INITFAIL
;
op
->
Status
=
PB__INITFAIL
;
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"fmb set configuration"
);
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"fmb set configuration"
);
return
IO__ERRINIDEVICE
;
return
IO__ERRINIDEVICE
;
...
@@ -436,91 +606,136 @@ if (ctx->Node->Restarts == 0) {
...
@@ -436,91 +606,136 @@ if (ctx->Node->Restarts == 0) {
/* Set DP master parameters */
/* Set DP master parameters */
sts
=
dp_init_master
(
local
->
Pb_fp
,
op
);
sts
=
dp_init_master
(
hDevice
);
if
(
sts
!=
PB_OK
)
{
if
(
!
sts
)
{
op
->
Status
=
PB__INITFAIL
;
op
->
Status
=
PB__INITFAIL
;
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"dp init master"
);
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"dp init master"
);
return
IO__ERRINIDEVICE
;
return
IO__ERRINIDEVICE
;
}
}
/* Set DP bus parameters */
/* Download DP bus parameters */
sts
=
dp_init_bus
(
local
->
Pb_fp
,
op
);
sts
=
dp_download_bus
(
hDevice
,
op
);
if
(
sts
!=
PB_OK
)
{
if
(
sts
!=
PB_OK
)
{
op
->
Status
=
PB__INITFAIL
;
op
->
Status
=
PB__INITFAIL
;
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"dp init
bus"
);
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"dp download
bus"
);
return
IO__ERRINIDEVICE
;
return
IO__ERRINIDEVICE
;
}
}
/* Set stalltime
*/
/* Loop through all slaves (traverse agent's children) and initialize them
*/
sts
=
pb_set_stalltime
(
local
->
Pb_fp
,
op
->
StallTime
);
op
->
NumberSlaves
=
0
;
if
(
sts
!=
PB_OK
)
{
status
=
gdh_GetChild
(
ap
->
Objid
,
&
slave_objid
);
while
(
ODD
(
status
))
{
status
=
gdh_GetObjectClass
(
slave_objid
,
&
slave_class
);
status
=
gdh_ObjidToPointer
(
slave_objid
,
(
pwr_tAddress
*
)
&
sop
);
status
=
gdh_ObjidToName
(
slave_objid
,
(
char
*
)
&
name
,
sizeof
(
name
),
cdh_mNName
);
errh_Info
(
"Download Profibus DP Slave config - %s"
,
name
);
status
=
dp_download_slave
(
hDevice
,
sop
);
if
(
!
status
)
{
errh_Info
(
"ERROR Init Profibus DP slave %s"
,
name
);
}
op
->
NumberSlaves
++
;
status
=
gdh_GetNextSibling
(
slave_objid
,
&
slave_objid
);
}
/* Move to STOP mode, this will fix the DPRAM layout */
sts
=
dp_act_param_loc
(
hDevice
,
DP_OP_MODE_STOP
);
if
(
sts
!=
E_OK
)
{
op
->
Status
=
PB__INITFAIL
;
op
->
Status
=
PB__INITFAIL
;
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"set stalltime
"
);
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"act param loc to STOPPED
"
);
return
IO__ERRINIDEVICE
;
return
IO__ERRINIDEVICE
;
}
}
/* Move to STOP mode */
PROFI_RCV_CON_IND
();
sts
=
act_param_loc
(
local
->
Pb_fp
,
op
,
DP_OP_MODE_STOP
);
if
(
sts
!=
PB_OK
)
{
if
(
(
con_ind_sdb
.
service
==
DP_ACT_PARAM_LOC
)
&&
(
con_ind_sdb
.
primitive
==
CON
)
&&
(
con_ind_sdb
.
result
==
POS
)
)
{
op
->
Status
=
PB__STOPPED
;
}
else
{
op
->
Status
=
PB__INITFAIL
;
op
->
Status
=
PB__INITFAIL
;
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"act param loc to STOPPED"
);
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"act param loc to STOPPED"
);
return
IO__ERRINIDEVICE
;
return
IO__ERRINIDEVICE
;
}
}
op
->
Status
=
PB__STOPPED
;
/* Calculate offsets of inputs and outputs for a slave */
}
/* Loop through all slaves (traverse agent's children) and initialize them */
op
->
NumberSlaves
=
0
;
status
=
gdh_GetChild
(
ap
->
Objid
,
&
slave_objid
);
status
=
gdh_GetChild
(
ap
->
Objid
,
&
slave_objid
);
while
(
ODD
(
status
))
{
while
(
ODD
(
status
))
{
status
=
gdh_GetObjectClass
(
slave_objid
,
&
slave_class
);
status
=
gdh_GetObjectClass
(
slave_objid
,
&
slave_class
);
// printf("Found slave, class %d\n", slave_class);
status
=
gdh_ObjidToPointer
(
slave_objid
,
(
pwr_tAddress
*
)
&
sop
);
status
=
init_dp_slave
(
ap
,
slave_objid
,
ctx
->
Node
->
Restarts
);
op
->
NumberSlaves
++
;
status
=
dp_io_offsets
(
hDevice
,
sop
);
status
=
gdh_GetNextSibling
(
slave_objid
,
&
slave_objid
);
status
=
gdh_GetNextSibling
(
slave_objid
,
&
slave_objid
);
}
}
/* Move to CLEAR and OPERATE mode */
/* Move to CLEAR and OPERATE mode */
if
(
ctx
->
Node
->
Restarts
==
0
)
{
sts
=
act_param_loc
(
local
->
Pb_fp
,
op
,
DP_OP_MODE_CLEAR
);
sts
=
dp_act_param_loc
(
hDevice
,
DP_OP_MODE_CLEAR
);
if
(
sts
==
PB_OK
)
{
if
(
sts
==
E_OK
)
{
PROFI_RCV_CON_IND
();
if
(
(
con_ind_sdb
.
service
==
DP_ACT_PARAM_LOC
)
&&
(
con_ind_sdb
.
primitive
==
CON
)
&&
(
con_ind_sdb
.
result
==
POS
)
)
{
op
->
Status
=
PB__CLEARED
;
op
->
Status
=
PB__CLEARED
;
sts
=
act_param_loc
(
local
->
Pb_fp
,
op
,
DP_OP_MODE_OPERATE
);
}
else
{
if
(
sts
==
PB_OK
)
{
op
->
Status
=
PB__INITFAIL
;
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"act param loc to CLEARED"
);
return
IO__ERRINIDEVICE
;
}
sts
=
dp_act_param_loc
(
hDevice
,
DP_OP_MODE_OPERATE
);
if
(
sts
==
E_OK
)
{
if
(
(
con_ind_sdb
.
service
==
DP_ACT_PARAM_LOC
)
&&
(
con_ind_sdb
.
primitive
==
CON
)
&&
(
con_ind_sdb
.
result
==
POS
)
)
{
op
->
Status
=
PB__NORMAL
;
op
->
Status
=
PB__NORMAL
;
errh_Info
(
"Profibus DP Master %s to state OPERATE"
,
ap
->
Name
);
errh_Info
(
"Profibus DP Master %s to state OPERATE"
,
ap
->
Name
);
}
else
{
op
->
Status
=
PB__INITFAIL
;
errh_Info
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"act param loc to OPERATE"
);
return
IO__ERRINIDEVICE
;
}
}
else
{
}
else
{
op
->
Status
=
PB__INITFAIL
;
errh_Error
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"act param loc to OPERATE"
);
errh_Error
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"act param loc to OPERATE"
);
return
IO__ERRINIDEVICE
;
return
IO__ERRINIDEVICE
;
}
}
}
}
else
{
else
{
op
->
Status
=
PB__INITFAIL
;
errh_Error
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"act param loc to CLEAR"
);
errh_Error
(
"ERROR config Profibus DP Master %s - %s"
,
ap
->
Name
,
"act param loc to CLEAR"
);
return
IO__ERRINIDEVICE
;
return
IO__ERRINIDEVICE
;
}
}
ok
=
TRUE
;
ok
=
TRUE
;
for
(
i
=
0
;
i
<
4
;
i
++
)
{
/* for (i=0; i<4; i++) {
if (ok) {
if (ok) {
sts
=
pb_cmi_poll
(
local
->
Pb_fp
,
NULL
,
NULL
,
NULL
);
sts = profi_rcv_con_ind (local, &con_ind_sdb, con_ind_buffer, &con_ind_buffer_len
);
if
(
sts
==
PB_DEVICE_ERROR
)
{
if (sts !=
PB_DEVICE_ERROR) {
errh_Info("Init problems, Reconfig - %d", i);
errh_Info("Init problems, Reconfig - %d", i);
ok = FALSE;
ok = FALSE;
}
}
rqtp.tv_sec = 0;
rqtp.tv_sec = 0;
rqtp.tv_nsec = 200000000;
rqtp.tv_nsec = 200000000;
nanosleep
(
&
rqtp
,
&
rmtp
);
nanosleep(&rqtp, &rmtp); */
}
}
/* End - While !ok */
}
}
/* End - Initialization only if not restart */
}
}
}
}
else
else
op
->
Status
=
PB__DISABLED
;
op
->
Status
=
PB__DISABLED
;
...
@@ -538,10 +753,18 @@ static pwr_tStatus IoAgentRead (
...
@@ -538,10 +753,18 @@ static pwr_tStatus IoAgentRead (
)
)
{
{
io_sAgentLocal
*
local
;
io_sAgentLocal
*
local
;
T_PROFI_DEVICE_HANDLE
*
hDevice
;
pwr_sClass_Pb_Profiboard
*
op
;
pwr_sClass_Pb_Profiboard
*
op
;
pwr_tUInt16
sts
;
pwr_tUInt16
sts
;
static
int
count
;
static
int
count
;
char
s
[
128
];
USIGN8
con_ind_buffer
[
256
];
USIGN16
con_ind_buffer_len
=
256
;
T_PROFI_SERVICE_DESCR
con_ind_sdb
;
T_DP_GET_SLAVE_DIAG_CON
FAR
*
get_slave_diag_con_ptr
;
hDevice
=
(
T_PROFI_DEVICE_HANDLE
*
)
ap
->
Local
;
local
=
(
io_sAgentLocal
*
)
ap
->
Local
;
local
=
(
io_sAgentLocal
*
)
ap
->
Local
;
op
=
(
pwr_sClass_Pb_Profiboard
*
)
ap
->
op
;
op
=
(
pwr_sClass_Pb_Profiboard
*
)
ap
->
op
;
...
@@ -559,17 +782,159 @@ static pwr_tStatus IoAgentRead (
...
@@ -559,17 +782,159 @@ static pwr_tStatus IoAgentRead (
switch
(
op
->
Status
)
{
switch
(
op
->
Status
)
{
case
PB__NORMAL
:
case
PB__NORMAL
:
sts
=
pb_cmi_poll
(
local
->
Pb_fp
,
NULL
,
NULL
,
NULL
);
case
PB__STOPPED
:
case
PB__CLEARED
:
sts
=
profi_rcv_con_ind
(
hDevice
,
&
con_ind_sdb
,
con_ind_buffer
,
&
con_ind_buffer_len
);
if
(
sts
==
CON_IND_RECEIVED
)
{
if
(
con_ind_sdb
.
primitive
==
CON
)
{
if
(
con_ind_sdb
.
result
==
POS
)
{
switch
(
con_ind_sdb
.
service
)
{
/*--------------------------------------------------------------*/
case
DP_ACT_PARAM_LOC
:
{
if
(
op
->
Status
==
PB__NOTINIT
)
{
op
->
Status
=
PB__STOPPED
;
dp_act_param_loc
(
hDevice
,
DP_OP_MODE_CLEAR
);
}
else
if
(
op
->
Status
==
PB__STOPPED
)
{
op
->
Status
=
PB__CLEARED
;
dp_act_param_loc
(
hDevice
,
DP_OP_MODE_OPERATE
);
}
else
if
(
op
->
Status
==
PB__CLEARED
)
{
op
->
Status
=
PB__NORMAL
;
}
break
;
}
/* case DP_ACT_PARAM_LOC */
/*--------------------------------------------------------------*/
case
DP_GET_SLAVE_DIAG
:
{
get_slave_diag_con_ptr
=
(
T_DP_GET_SLAVE_DIAG_CON
FAR
*
)
con_ind_buffer
;
/* In case of device error, move to state NOTINIT */
dp_get_slave_diag_con
(
get_slave_diag_con_ptr
);
if
(
sts
==
PB_DEVICE_ERROR
)
{
local
->
slave_diag_requested
=
PB_FALSE
;
if
(
get_slave_diag_con_ptr
->
diag_entries
)
{
local
->
slave_diag_requested
=
PB_TRUE
;
dp_get_slave_diag
(
hDevice
);
}
break
;
}
/* case DP_GET_SLAVE_DIAG */
/*--------------------------------------------------------------*/
default:
{
break
;
}
/* deafult service */
}
/* switch */
}
/* if POS */
else
{
op
->
Status
=
PB__NOTINIT
;
op
->
Status
=
PB__NOTINIT
;
errh_Info
(
"Profibus DP Master %s - %d neg con rec"
,
ap
->
Name
,
count
);
}
/* else POS */
}
/* if CON */
else
if
(
con_ind_sdb
.
primitive
==
IND
)
{
if
(
con_ind_sdb
.
result
==
POS
)
{
switch
(
con_ind_sdb
.
service
)
{
case
FMB_FM2_EVENT
:
{
switch
(((
T_FMB_FM2_EVENT_IND
FAR
*
)
con_ind_buffer
)
->
reason
)
{
case
FM2_FAULT_ADDRESS
:
sprintf
(
s
,
"Duplicate address recognized"
);
break
;
case
FM2_FAULT_PHY
:
sprintf
(
s
,
"Phys.layer is malfunctioning"
);
break
;
case
FM2_FAULT_TTO
:
sprintf
(
s
,
"Time out on bus detected "
);
break
;
case
FM2_FAULT_SYN
:
sprintf
(
s
,
"No receiver synchronization "
);
break
;
case
FM2_FAULT_OUT_OF_RING
:
sprintf
(
s
,
"Station out of ring "
);
break
;
case
FM2_GAP_EVENT
:
sprintf
(
s
,
"New station in ring "
);
break
;
default
:
sprintf
(
s
,
"Unknown reason code received"
);
}
/* switch reason */
errh_Info
(
"Profibus DP Master %s - %s"
,
ap
->
Name
,
s
);
break
;
}
/* case FMB_FM2_EVENT */
/*--------------------------------------------------------------*/
case
DP_ACT_PARAM_LOC
:
{
USIGN8
usif_state
;
usif_state
=
((
T_DP_ACT_PARAM_IND
FAR
*
)
con_ind_buffer
)
->
activate
;
switch
(
usif_state
)
{
case
DP_OP_MODE_STOP
:
{
op
->
Status
=
PB__STOPPED
;
sprintf
(
s
,
"Mode changed to STOP"
);
break
;
}
case
DP_OP_MODE_CLEAR
:
{
op
->
Status
=
PB__CLEARED
;
sprintf
(
s
,
"Mode changed to CLEAR"
);
break
;
}
case
DP_OP_MODE_OPERATE
:
{
op
->
Status
=
PB__NORMAL
;
sprintf
(
s
,
"Mode changed to OPERATE"
);
break
;
}
}
/* In case of diagnostic message, just mark it.
}
in the future, take care of it */
else
if
(
sts
!=
PB_NO_CON_IND_RECEIVED
)
{
errh_Info
(
"Profibus DP Master %s - %s"
,
ap
->
Name
,
s
);
if
(
usif_state
==
DP_OP_MODE_STOP
)
{
usif_state
=
DP_OP_MODE_CLEAR
;
dp_act_param_loc
(
hDevice
,
DP_OP_MODE_CLEAR
);
}
else
if
(
usif_state
==
DP_OP_MODE_CLEAR
)
{
usif_state
=
DP_OP_MODE_OPERATE
;
dp_act_param_loc
(
hDevice
,
DP_OP_MODE_OPERATE
);
}
break
;
}
/* case DP_ACT_PARAM_LOC */
/*--------------------------------------------------------------*/
case
DP_GET_SLAVE_DIAG
:
{
get_slave_diag_con_ptr
=
(
T_DP_GET_SLAVE_DIAG_CON
FAR
*
)
con_ind_buffer
;
dp_get_slave_diag_con
(
get_slave_diag_con_ptr
);
op
->
Diag
[
0
]
++
;
op
->
Diag
[
0
]
++
;
if
(
(
get_slave_diag_con_ptr
->
diag_entries
)
&&
(
!
local
->
slave_diag_requested
)
)
{
if
(
dp_get_slave_diag
(
hDevice
))
{
local
->
slave_diag_requested
=
PB_TRUE
;
}
}
}
break
;
}
/* case DP_GET_SLAVE_DIAG */
/*--------------------------------------------------------------*/
default:
{
break
;
}
/* deafult service */
}
/* switch */
}
/* if POS */
else
{
op
->
Status
=
PB__NOTINIT
;
errh_Info
(
"Profibus DP Master %s - %d neg ind rec"
,
ap
->
Name
,
count
);
}
/* else POS */
}
/* if IND */
}
else
if
(
sts
!=
NO_CON_IND_RECEIVED
)
{
op
->
Status
=
PB__NOTINIT
;
}
break
;
break
;
default:
default:
...
@@ -579,7 +944,6 @@ static pwr_tStatus IoAgentRead (
...
@@ -579,7 +944,6 @@ static pwr_tStatus IoAgentRead (
IoAgentInit
(
ctx
,
ap
);
IoAgentInit
(
ctx
,
ap
);
break
;
break
;
}
}
}
}
return
IO__SUCCESS
;
return
IO__SUCCESS
;
...
@@ -607,14 +971,45 @@ static pwr_tStatus IoAgentClose (
...
@@ -607,14 +971,45 @@ static pwr_tStatus IoAgentClose (
)
)
{
{
io_sAgentLocal
*
local
;
io_sAgentLocal
*
local
;
T_PROFI_DEVICE_HANDLE
*
hDevice
;
pwr_tStatus
sts
=
PB_FALSE
;
T_PROFI_SERVICE_DESCR
sdb
;
USIGN8
con_ind_buffer
[
256
];
USIGN16
con_ind_buffer_len
=
256
;
T_PROFI_SERVICE_DESCR
con_ind_sdb
;
INT16
result
;
/* !!! local result variable !!! */
USIGN16
retry_counter
;
local
=
(
io_sAgentLocal
*
)
ap
->
Local
;
hDevice
=
(
T_PROFI_DEVICE_HANDLE
*
)
ap
->
Local
;
sdb
.
comm_ref
=
0
;
sdb
.
layer
=
DP
;
sdb
.
service
=
DP_EXIT_MASTER
;
sdb
.
primitive
=
REQ
;
sdb
.
invoke_id
=
0
;
sdb
.
result
=
0
;
profi_snd_req_res
(
hDevice
,
&
sdb
,
&
sdb
,
PB_FALSE
);
/* Close Pb driver */
PROFI_RCV_CON_IND
();
/*Macro to fetch one confirmation or indication*/
local
=
ap
->
Local
;
if
((
con_ind_sdb
.
service
==
DP_EXIT_MASTER
)
&&
(
con_ind_sdb
.
primitive
==
CON
)
&&
(
con_ind_sdb
.
result
==
POS
))
{
sts
=
PB_TRUE
;
}
close
(
local
->
hServiceReadDevice
);
close
(
local
->
hServiceWriteDevice
);
close
(
local
->
hDpDataDevice
);
close
(
local
->
hDpsInputDataDevice
);
close
(
local
->
hDpsOutputDataDevice
);
close
(
local
->
Pb_fp
);
free
(
(
char
*
)
local
);
free
(
(
char
*
)
local
);
return
IO__SUCCESS
;
return
sts
;
}
}
...
...
profibus/lib/rt/src/os_linux/rt_io_pb_locals.h
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_pb_locals.h,v 1.
3 2006-07-03 06:20:03
claes Exp $
* Proview $Id: rt_io_pb_locals.h,v 1.
4 2007-01-12 13:28:32
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -52,7 +52,13 @@
...
@@ -52,7 +52,13 @@
#define PB_ORIENTATION_DWORD 32
#define PB_ORIENTATION_DWORD 32
typedef
struct
{
typedef
struct
{
int
Pb_fp
;
int
hServiceReadDevice
;
// Handle for Service device
int
hServiceWriteDevice
;
// Handle for Service device
int
hDpDataDevice
;
// Handle for DP-Data device
int
hDpsInputDataDevice
;
// Handle for DP-Slave Input-Data device
int
hDpsOutputDataDevice
;
// Handle for DP-Slave Output-Data device
unsigned
char
CurrentBoardNumber
;
int
slave_diag_requested
;
}
io_sAgentLocal
;
}
io_sAgentLocal
;
typedef
struct
{
typedef
struct
{
...
...
profibus/lib/rt/src/os_linux/rt_io_profiboard.c
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_profiboard.c,v 1.
1 2006-01-16 13:56:5
2 claes Exp $
* Proview $Id: rt_io_profiboard.c,v 1.
2 2007-01-12 13:28:3
2 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
* Copyright (C) 2005 SSAB Oxelösund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -26,12 +26,14 @@
...
@@ -26,12 +26,14 @@
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <unistd.h>
#include "keywords.h"
#include "pb_type.h"
#include "pb_type.h"
#include "pb_conf.h"
#include "pb_if.h"
#include "pb_if.h"
#include "pb_err.h"
#include "pb_fmb.h"
#include "pb_fmb.h"
#include "pb_dp.h"
#include "pb_dp.h"
#include "pb_err.h"
#include "pbus.h"
#include "pwr.h"
#include "pwr.h"
#include "rt_io_profiboard.h"
#include "rt_io_profiboard.h"
...
@@ -54,429 +56,3 @@ unsigned int swap32(unsigned int in)
...
@@ -54,429 +56,3 @@ unsigned int swap32(unsigned int in)
return
(
result
);
return
(
result
);
}
}
pwr_tUInt16
pb_cmi_init
(
int
fp
)
{
int
sts
;
sts
=
ioctl
(
fp
,
PB_IOCTL_CMI_INIT
,
0
);
if
(
sts
==
0
)
return
PB_OK
;
else
return
PB_DEVICE_ERROR
;
}
pwr_tUInt16
pb_cmi_write
(
int
fp
,
T_PROFI_SERVICE_DESCR
*
sdb_ptr
,
void
*
data_ptr
,
pwr_tUInt16
data_len
)
{
cmi_request_access_struct
cws
;
USIGN16
retval
;
int
sts
;
cws
.
sdb_ptr
=
sdb_ptr
;
cws
.
data_ptr
=
(
unsigned
char
*
)
data_ptr
;
cws
.
data_len_ptr
=
&
data_len
;
cws
.
retval_ptr
=
&
retval
;
sts
=
ioctl
(
fp
,
PB_IOCTL_CMI_WRITE
,
(
char
*
)
&
cws
);
if
(
sts
==
0
)
return
PB_OK
;
else
return
PB_DEVICE_ERROR
;
}
pwr_tUInt16
pb_set_stalltime
(
int
fp
,
unsigned
short
t
)
{
int
sts
;
sts
=
ioctl
(
fp
,
PB_IOCTL_SET_STALLTIME
,
(
char
*
)
&
t
);
if
(
sts
==
0
)
return
PB_OK
;
else
return
PB_DEVICE_ERROR
;
}
pwr_tUInt16
pb_cmi_read
(
int
fp
,
T_PROFI_SERVICE_DESCR
*
sdb_ptr
,
void
*
data_ptr
,
pwr_tUInt16
*
data_len_ptr
)
{
cmi_request_access_struct
crs
;
T_PROFI_SERVICE_DESCR
sdb
;
USIGN8
data
[
256
];
USIGN16
data_len
;
USIGN16
retval
;
int
sts
;
int
retry
;
struct
timespec
rqtp
,
rmtp
;
crs
.
sdb_ptr
=
&
sdb
;
crs
.
data_ptr
=
(
USIGN8
*
)
&
data
;
crs
.
data_len_ptr
=
&
data_len
;
crs
.
retval_ptr
=
&
retval
;
rqtp
.
tv_sec
=
0
;
rqtp
.
tv_nsec
=
100000000
;
// One tenth
sts
=
ioctl
(
fp
,
PB_IOCTL_CMI_READ
,
(
char
*
)
&
crs
);
retry
=
10
;
do
{
sts
=
ioctl
(
fp
,
PB_IOCTL_CMI_READ
,
(
char
*
)
&
crs
);
if
(
sts
!=
0
)
return
PB_DEVICE_ERROR
;
if
(
retval
!=
CON_IND_RECEIVED
)
nanosleep
(
&
rqtp
,
&
rmtp
);
}
while
(
retval
!=
CON_IND_RECEIVED
&&
retry
--
>
0
);
if
(
retval
==
CON_IND_RECEIVED
)
{
if
(
sdb_ptr
)
{
memcpy
(
sdb_ptr
,
&
sdb
,
sizeof
(
T_PROFI_SERVICE_DESCR
));
}
if
(
data_ptr
)
{
memcpy
(
data_ptr
,
data
,
data_len
);
}
if
(
data_len_ptr
)
{
*
data_len_ptr
=
data_len
;
}
if
(
sdb
.
result
==
POS
)
return
PB_OK
;
else
return
PB_NEG_CONF
;
}
else
return
PB_NO_CON_IND_RECEIVED
;
}
pwr_tUInt16
pb_cmi_poll
(
int
fp
,
T_PROFI_SERVICE_DESCR
*
sdb_ptr
,
void
*
data_ptr
,
pwr_tUInt16
*
data_len_ptr
)
{
cmi_request_access_struct
crs
;
T_PROFI_SERVICE_DESCR
sdb
;
USIGN8
data
[
256
];
USIGN16
data_len
;
USIGN16
retval
;
int
sts
;
crs
.
sdb_ptr
=
&
sdb
;
crs
.
data_ptr
=
(
USIGN8
*
)
&
data
;
crs
.
data_len_ptr
=
&
data_len
;
crs
.
retval_ptr
=
&
retval
;
sts
=
ioctl
(
fp
,
PB_IOCTL_CMI_READ
,
(
char
*
)
&
crs
);
if
(
sts
!=
0
)
return
PB_DEVICE_ERROR
;
if
(
retval
==
CON_IND_RECEIVED
)
{
if
(
sdb_ptr
)
{
memcpy
(
sdb_ptr
,
&
sdb
,
sizeof
(
T_PROFI_SERVICE_DESCR
));
}
if
(
data_ptr
)
{
memcpy
(
data_ptr
,
data
,
data_len
);
}
if
(
data_len_ptr
)
{
*
data_len_ptr
=
data_len
;
}
if
(
sdb
.
result
==
POS
)
return
PB_OK
;
else
return
PB_NEG_CONF
;
}
else
return
PB_NO_CON_IND_RECEIVED
;
}
pwr_tUInt16
pb_cmi_flush
(
int
fp
)
{
cmi_request_access_struct
crs
;
T_PROFI_SERVICE_DESCR
sdb
;
USIGN8
data
[
256
];
USIGN16
data_len
;
USIGN16
retval
;
int
sts
;
int
retry
;
struct
timespec
rqtp
,
rmtp
;
crs
.
sdb_ptr
=
&
sdb
;
crs
.
data_ptr
=
(
USIGN8
*
)
&
data
;
crs
.
data_len_ptr
=
&
data_len
;
crs
.
retval_ptr
=
&
retval
;
rqtp
.
tv_sec
=
0
;
rqtp
.
tv_nsec
=
100000000
;
// One tenth
nanosleep
(
&
rqtp
,
&
rmtp
);
sts
=
ioctl
(
fp
,
PB_IOCTL_CMI_READ
,
(
char
*
)
&
crs
);
retry
=
100
;
do
{
sts
=
ioctl
(
fp
,
PB_IOCTL_CMI_READ
,
(
char
*
)
&
crs
);
if
(
sts
!=
0
)
return
E_IF_OS_ERROR
;
if
(
retval
==
CON_IND_RECEIVED
)
nanosleep
(
&
rqtp
,
&
rmtp
);
}
while
(
retval
==
CON_IND_RECEIVED
&&
retry
--
>
0
);
return
PB_OK
;
}
pwr_tUInt16
pb_cmi_get_data
(
int
fp
,
pwr_tUInt8
data_id
,
pwr_tUInt16
offset
,
pwr_tUInt16
data_size
,
void
*
data_ptr
)
{
USIGN16
retval
;
cmi_data_access_struct
user_arg
;
int
retry_counter
;
user_arg
.
data_id
=
data_id
;
user_arg
.
offset
=
offset
;
user_arg
.
data_ptr
=
(
USIGN8
*
)
data_ptr
;
user_arg
.
retval_ptr
=
&
retval
;
retry_counter
=
10
;
do
{
read
(
fp
,
(
char
*
)
&
user_arg
,
data_size
);
if
(
retval
==
E_IF_FATAL_ERROR
)
break
;
}
while
(
retval
!=
E_OK
&&
retry_counter
--
>
0
);
if
(
retval
==
E_OK
)
return
PB_OK
;
else
return
PB_READ_ERROR
;
}
pwr_tUInt16
pb_cmi_set_data
(
int
fp
,
pwr_tUInt8
data_id
,
pwr_tUInt16
offset
,
pwr_tUInt16
data_size
,
void
*
data_ptr
)
{
USIGN16
retval
;
cmi_data_access_struct
user_arg
;
int
retry_counter
;
user_arg
.
data_id
=
data_id
;
user_arg
.
offset
=
offset
;
user_arg
.
data_ptr
=
(
USIGN8
*
)
data_ptr
;
user_arg
.
retval_ptr
=
&
retval
;
retry_counter
=
10
;
do
{
write
(
fp
,
(
char
*
)
&
user_arg
,
data_size
);
if
(
retval
==
E_IF_FATAL_ERROR
)
break
;
}
while
(
retval
!=
E_OK
&&
retry_counter
--
>
0
);
if
(
retval
==
E_OK
)
return
PB_OK
;
else
return
PB_WRITE_ERROR
;
}
pwr_tUInt16
pb_get_slave_info
(
int
fp
,
pwr_tUInt16
slave_address
,
pwr_tUInt16
*
offset_inputs
,
pwr_tUInt16
*
offset_outputs
,
pwr_tUInt16
*
bytes_of_input
,
pwr_tUInt16
*
bytes_of_output
)
{
pwr_tUInt16
data_len
;
pwr_tUInt16
sts
;
T_PROFI_SERVICE_DESCR
sdb
;
T_DP_GET_SLAVE_PARAM_REQ
gpr
;
USIGN8
data
[
256
];
T_DP_SLAVE_PARAM_SLAVE_INFO
*
spi
;
sdb
.
comm_ref
=
0
;
sdb
.
layer
=
DP
;
sdb
.
service
=
DP_GET_SLAVE_PARAM
;
sdb
.
primitive
=
REQ
;
sdb
.
invoke_id
=
0
;
sdb
.
result
=
0
;
gpr
.
identifier
=
DP_SLAVE_PARAM_SLAVE_INFO
;
gpr
.
rem_add
=
slave_address
;
sts
=
pb_cmi_flush
(
fp
);
if
(
sts
!=
PB_OK
)
return
sts
;
sts
=
pb_cmi_write
(
fp
,
&
sdb
,
&
gpr
,
sizeof
(
T_DP_GET_SLAVE_PARAM_REQ
));
if
(
sts
!=
PB_OK
)
return
sts
;
sts
=
pb_cmi_read
(
fp
,
&
sdb
,
&
data
,
&
data_len
);
if
(
sts
==
E_OK
)
{
if
(
sdb
.
result
==
POS
)
{
spi
=
(
T_DP_SLAVE_PARAM_SLAVE_INFO
*
)
&
(
data
[
4
]);
*
offset_inputs
=
spi
->
offset_inputs
;
*
offset_outputs
=
spi
->
offset_outputs
;
*
bytes_of_input
=
spi
->
number_inputs
;
*
bytes_of_output
=
spi
->
number_outputs
;
return
PB_OK
;
}
else
return
PB_NEG_CONF
;
}
else
return
NO_CON_IND_RECEIVED
;
}
pwr_tUInt16
pb_get_slave_cfg
(
int
fp
,
pwr_tUInt16
slave_address
,
pwr_tUInt16
*
cfg_data_len
,
void
*
cfg_data
)
{
T_PROFI_SERVICE_DESCR
sdb
;
T_DP_GET_CFG_REQ
gcr
;
USIGN8
data
[
256
];
unsigned
short
data_len
;
pwr_tUInt16
sts
;
sdb
.
comm_ref
=
0
;
sdb
.
layer
=
DP
;
sdb
.
service
=
DP_GET_CFG
;
sdb
.
primitive
=
REQ
;
sdb
.
invoke_id
=
0
;
sdb
.
result
=
0
;
gcr
.
rem_add
=
slave_address
;
sts
=
pb_cmi_flush
(
fp
);
if
(
sts
!=
PB_OK
)
return
sts
;
sts
=
pb_cmi_write
(
fp
,
&
sdb
,
&
gcr
,
sizeof
(
T_DP_GET_CFG_REQ
));
if
(
sts
!=
PB_OK
)
return
sts
;
sts
=
pb_cmi_read
(
fp
,
NULL
,
&
data
,
&
data_len
);
if
(
sts
!=
PB_OK
)
return
sts
;
*
cfg_data_len
=
data_len
-
4
;
// Minus header
memcpy
(
cfg_data
,
&
(
data
[
4
]),
*
cfg_data_len
);
return
sts
;
}
pwr_tUInt16
pb_download_all
(
int
fp
,
pwr_tUInt16
slave_address
,
pwr_tUInt8
wd_fact1
,
pwr_tUInt8
wd_fact2
,
pwr_tUInt8
min_tsdr
,
pwr_tUInt16
ident_number
,
pwr_tUInt8
group_ident
,
pwr_tUInt16
prm_user_data_len
,
void
*
prm_user_data
,
pwr_tUInt16
cfg_data_len
,
void
*
cfg_data
)
{
T_PROFI_SERVICE_DESCR
sdb
;
pwr_tUInt16
sts
;
int
i
;
struct
{
T_DP_DOWNLOAD_REQ
drp
;
unsigned
char
param
[
512
];
}
slave_data
;
T_DP_SLAVE_PARA_SET
prm_head
;
T_DP_PRM_DATA
prm_data
;
T_DP_AAT_DATA
aat_data
;
T_DP_SLAVE_USER_DATA
user_data
;
USIGN16
download_data_size
;
USIGN16
data_len
;
download_data_size
=
sizeof
(
prm_head
)
+
sizeof
(
prm_data
)
+
prm_user_data_len
+
cfg_data_len
+
sizeof
(
aat_data
)
+
sizeof
(
user_data
);
data_len
=
sizeof
(
slave_data
.
drp
)
+
download_data_size
;
sdb
.
comm_ref
=
0
;
sdb
.
layer
=
DP
;
sdb
.
service
=
DP_DOWNLOAD_LOC
;
sdb
.
primitive
=
REQ
;
sdb
.
invoke_id
=
0
;
sdb
.
result
=
0
;
slave_data
.
drp
.
data_len
=
download_data_size
;
slave_data
.
drp
.
rem_add
=
0
;
slave_data
.
drp
.
area_code
=
slave_address
;
slave_data
.
drp
.
add_offset
=
0
;
prm_head
.
slave_para_len
=
swap16
(
download_data_size
);
prm_head
.
sl_flag
=
DP_SL_NEW_PRM
|
DP_SL_ACTIVE
;
prm_head
.
slave_type
=
DP_SLAVE_TYPE_DP
;
for
(
i
=
0
;
i
<
12
;
i
++
)
prm_head
.
reserved
[
i
]
=
0
;
i
=
0
;
memcpy
(
&
slave_data
.
param
[
i
],
&
prm_head
,
sizeof
(
prm_head
));
i
+=
sizeof
(
prm_head
);
prm_data
.
prm_data_len
=
swap16
(
sizeof
(
prm_data
)
+
prm_user_data_len
);
prm_data
.
station_status
=
DP_PRM_LOCK_REQ
|
DP_PRM_WD_ON
;
prm_data
.
wd_fact_1
=
wd_fact1
;
prm_data
.
wd_fact_2
=
wd_fact2
;
prm_data
.
min_tsdr
=
min_tsdr
;
prm_data
.
ident_number
=
swap16
(
ident_number
);
prm_data
.
group_ident
=
group_ident
;
memcpy
(
&
slave_data
.
param
[
i
],
&
prm_data
,
sizeof
(
prm_data
));
i
+=
sizeof
(
prm_data
);
memcpy
(
&
slave_data
.
param
[
i
],
prm_user_data
,
prm_user_data_len
);
i
+=
prm_user_data_len
;
memcpy
(
&
slave_data
.
param
[
i
],
cfg_data
,
cfg_data_len
);
i
+=
cfg_data_len
;
aat_data
.
aat_data_len
=
swap16
(
4
);
// AAT data not used in array mode
aat_data
.
number_inputs
=
0
;
aat_data
.
number_outputs
=
0
;
memcpy
(
&
slave_data
.
param
[
i
],
&
aat_data
,
sizeof
(
aat_data
));
i
+=
sizeof
(
aat_data
);
user_data
.
slave_user_data_len
=
swap16
(
2
);
memcpy
(
&
slave_data
.
param
[
i
],
&
user_data
,
sizeof
(
user_data
));
i
+=
sizeof
(
user_data
);
sts
=
pb_cmi_flush
(
fp
);
if
(
sts
!=
PB_OK
)
return
sts
;
sts
=
pb_cmi_write
(
fp
,
&
sdb
,
&
slave_data
,
data_len
);
if
(
sts
!=
PB_OK
)
return
sts
;
sts
=
pb_cmi_read
(
fp
,
NULL
,
NULL
,
NULL
);
return
sts
;
}
profibus/lib/rt/src/os_linux/rt_io_profiboard.h
View file @
0135e84d
/*
/*
* Proview $Id: rt_io_profiboard.h,v 1.
1 2006-01-16 13:56:5
2 claes Exp $
* Proview $Id: rt_io_profiboard.h,v 1.
2 2007-01-12 13:28:3
2 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
* Copyright (C) 2005 SSAB Oxelösund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -33,73 +33,5 @@ unsigned short swap16(unsigned short in);
...
@@ -33,73 +33,5 @@ unsigned short swap16(unsigned short in);
extern
extern
unsigned
int
swap32
(
unsigned
int
in
);
unsigned
int
swap32
(
unsigned
int
in
);
extern
pwr_tUInt16
pb_cmi_init
(
int
fp
);
extern
pwr_tUInt16
pb_cmi_write
(
int
fp
,
T_PROFI_SERVICE_DESCR
*
sdb_ptr
,
void
*
data_ptr
,
pwr_tUInt16
data_len
);
extern
pwr_tUInt16
pb_set_stalltime
(
int
fp
,
unsigned
short
t
);
extern
pwr_tUInt16
pb_cmi_read
(
int
fp
,
T_PROFI_SERVICE_DESCR
*
sdb_ptr
,
void
*
data_ptr
,
pwr_tUInt16
*
data_len_ptr
);
extern
pwr_tUInt16
pb_cmi_poll
(
int
fp
,
T_PROFI_SERVICE_DESCR
*
sdb_ptr
,
void
*
data_ptr
,
pwr_tUInt16
*
data_len_ptr
);
extern
pwr_tUInt16
pb_cmi_flush
(
int
fp
);
extern
pwr_tUInt16
pb_cmi_get_data
(
int
fp
,
pwr_tUInt8
data_id
,
pwr_tUInt16
offset
,
pwr_tUInt16
data_size
,
void
*
data_ptr
);
extern
pwr_tUInt16
pb_cmi_set_data
(
int
fp
,
pwr_tUInt8
data_id
,
pwr_tUInt16
offset
,
pwr_tUInt16
data_size
,
void
*
data_ptr
);
extern
pwr_tUInt16
pb_get_slave_info
(
int
fp
,
pwr_tUInt16
slave_address
,
pwr_tUInt16
*
offset_inputs
,
pwr_tUInt16
*
offset_outputs
,
pwr_tUInt16
*
bytes_of_input
,
pwr_tUInt16
*
bytes_of_output
);
extern
pwr_tUInt16
pb_get_slave_cfg
(
int
fp
,
pwr_tUInt16
slave_address
,
pwr_tUInt16
*
cfg_data_len
,
void
*
cfg_data
);
extern
pwr_tUInt16
pb_download_all
(
int
fp
,
pwr_tUInt16
slave_address
,
pwr_tUInt8
wd_fact1
,
pwr_tUInt8
wd_fact2
,
pwr_tUInt8
min_tsdr
,
pwr_tUInt16
ident_number
,
pwr_tUInt8
group_ident
,
pwr_tUInt16
prm_user_data_len
,
void
*
prm_user_data
,
pwr_tUInt16
cfg_data_len
,
void
*
cfg_data
);
#endif
#endif
profibus/lib/rt/src/os_linux/version.h
0 → 100644
View file @
0135e84d
/*****************************************************************************/
/* */
/* SOFTING AG */
/* Richard-Reitzner-Allee 6 */
/* D-85540 Haar */
/* Phone: (++49)-(0)89-45656-0 */
/* Fax: (++49)-(0)89-45656-399 */
/* */
/* Copyright (C) SOFTING AG 1995-2003 */
/* All Rights Reserved */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* PROFIBUS PAPI VERSION */
/* Filename : VERSION.H */
/* Version : 5.26.1.00.release */
/* Date : 27-Jume-2003 */
/* Author : SOFTING GmbH */
/* */
/* Description : This file contains the PROFIBUS VERSION STRINGS */
/* defines */
/* */
/* CHANGE_NOTES */
/* */
/* date name change */
/* ----------------------------------------------------------------------- */
/* */
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
#ifndef __VERSION_H__
#define __VERSION_H__
#include "buildnr.papi.h"
#define SW_VERSION "5.26.1.00.release " "(Build " BUILD_NUMBER_STR ") "
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment