You are on page 1of 247

Library/DLL

applicom®

a product of Woodhead Software & Electronics

Library/DLL 1 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Library/DLL 2 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Table of contents

1. General ...........................................................................................6

2. Using the DLL with your programming language .......................7

3. Maximum number of variables ...................................................10

4. Initialization ..................................................................................12
Product initialization => INITBUS .............................................................. 12
Set the maximum number of variable => AuSetApplicationMaxSize............... 13
Get the maximum number of variable => AuGetApplicomMaxSize................. 15
Program end => EXITBUS ........................................................................ 17

5. Wait mode functions....................................................................18


Reading .................................................................................................................18
Bit reading => READPACKBIT ................................................................... 18
Input bit reading => READPACKIBIT.......................................................... 20
Output bit reading => READPACKQBIT ...................................................... 22
Quick reading of 8 bits => READQUICKBIT................................................. 24
Byte reading => READBYTE...................................................................... 26
Input byte reading => READIBYTE ............................................................ 28
Output byte reading => READQBYTE ......................................................... 30
Packed byte reading => READPACKBYTE.................................................... 32
Packed input byte reading => READPACKIBYTE .......................................... 34
Packed output byte reading => READPACKQBYTE ....................................... 36
Word reading => READWORD................................................................... 38
Input word reading => READIWORD ......................................................... 40
Output word reading => READQWORD ...................................................... 42
BCD word reading => READWORDBCD ...................................................... 44
Double word reading => READDWORD ...................................................... 46
Floating word reading => READFWORD ..................................................... 48
Timer reading => READTIMER .................................................................. 50
Counter reading => READCOUNTER .......................................................... 52
Bit writing => WRITEPACKBIT .................................................................. 54
Output bit writing => WRITEPACKQBIT...................................................... 56
Byte writing => WRITEBYTE ..................................................................... 58
Output byte writing => WRITEQBYTE ........................................................ 60
Packed byte writing => WRITEPACKBYTE ................................................... 62
Packed output byte writing => WRITEPACKQBYTE....................................... 64
Word writing => WRITEWORD .................................................................. 66
Output word writing => WRITEQWORD...................................................... 68
BCD word writing => WRITEWORDBCD ..................................................... 70
Double word writing => WRITEDWORD...................................................... 72
Floating word writing => WRITEFWORD ..................................................... 74
Timer writing => WRITETIMER ................................................................. 76
Counter writing => WRITECOUNTER.......................................................... 78
Diagnostic counter reading => READDIAG.................................................. 80
Event counter reading => READEVEN ........................................................ 81
Change to STOP => MANUAL.................................................................... 82
Change to RUN => AUTOMATIC ................................................................ 83
Connection or reservation => AppConnect ................................................. 84
Disconnection or dereservation => AppUnconnect ....................................... 86
Slave status => STATJBUS ...................................................................... 87
Master counter reading => IOCOUNTER..................................................... 88
Master counter reset => RESETIOCOUNTER ............................................... 90
Error counter reset => RESETCOUNTERUTE ............................................... 91
Trace buffer reading => READTRACE ......................................................... 92
Error counter reading => READDIAGUTE.................................................... 94

Library/DLL 3 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Device identification => READIDENT ......................................................... 96
Open function ........................................................................................................98
Uni-Te text block function => TXTUTE ....................................................... 98
Free access to messaging => AuWriteReadMsg......................................... 100
“Ports without protocol” functions........................................................................101
Message reception => READMES............................................................. 101
Message transmission => WRITEMES ...................................................... 103
Message reception transmission => WRITEREADMES................................. 105
Profibus FMS specific functions ..........................................................................107
Reading of FMS object dictionnary => AppFmsGetOd................................. 107
FMS Device status => AppFmsStatus....................................................... 108

6. Deferred mode functions .......................................................... 110


Conditions of use.................................................................................................110
Reading ...............................................................................................................110
Bit reading => READDIFBIT.................................................................... 110
Input bit reading => READDIFIBIT .......................................................... 112
Output bit reading => READDIFQBIT ....................................................... 113
Byte reading => READDIFBYTE............................................................... 114
Input byte reading => READDIFIBYTE ..................................................... 115
Output byte reading => READDIFQBYTE .................................................. 116
Word reading => READDIFWORD............................................................ 117
Input word reading => READDIFIWORD................................................... 118
Output word reading => READDIFQWORD ............................................... 119
Double word reading => READDIFDWORD ............................................... 120
Floating word reading => READDIFFWORD............................................... 121
Quick reading of 8 bits => READDIFQUICKBIT .......................................... 122
Writing .................................................................................................................123
Bit writing => WRITEDIFPACKBIT ........................................................... 123
Output bit writing => WRITEDIFPACKQBIT ............................................... 125
Byte writing => WRITEDIFPACKBYTE....................................................... 127
Output byte writing => WRITEDIFPACKQBYTE .......................................... 129
Word writing => WRITEDIFWORD ........................................................... 131
Output word writing => WRITEDIFQWORD............................................... 133
Double word writing => WRITEDIFDWORD............................................... 135
Floating word writing => WRITEDIFFWORD .............................................. 137
“Ports without protocol” functions........................................................................139
Message reception => READDIFMES........................................................ 139
Message transmission => WRITEDIFMES ................................................. 141
Message transmission and reception => WRITEREADDIFMES...................... 143
Open function ......................................................................................................145
Free access to messaging => AuWriteReadDifMsg ..................................... 145
Differed request transfer......................................................................................146
Differed transfer in unpacked format => TRANSDIF................................... 146
Differed transfer in packed format => TRANSDIFPACK............................... 148
Deferred request test => TESTTRANSDIF................................................. 150

7. Cyclic mode functions............................................................... 151


Cyclic function creation => CREATECYC ................................................... 151
Cyclic function start => STARTCYC.......................................................... 154
Cyclic function stop => STOPCYC ............................................................ 155
One-off activation => ACTCYC ................................................................ 156
Cyclic request transfer.........................................................................................157
Cyclic transfer in unpacked format => TRANSCYC ..................................... 157
Cyclic transfer in packed format => TRANSCYCPACK ................................. 159
Request for information on cyclic functions.........................................................161
List of cyclic functions executed => CYCEXECUTED ................................... 161
Parameters of a cyclic function => APPGETCYCPARAM ............................... 163

8. Data-Base functions .................................................................. 165


Reading ...............................................................................................................165
Contiguous packed bit reading => GETPACKBIT ........................................ 165
Contiguous unpacked bit reading => GETBIT............................................ 167
Contiguous byte reading => GETPACKBYTE .............................................. 169
Contiguous word reading => GETWORD................................................... 171

Library/DLL 4 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous double word reading => GETDWORD ...................................... 173
Contiguous floating word reading => GETFWORD...................................... 175
Non contiguous bit reading => GETDISPBIT ............................................. 177
Non contiguous word reading => GETDISPWORD...................................... 179
Non contiguous double word reading => GETDISPDWORD ......................... 181
Non contiguous floating word reading => GETDISPFWORD......................... 183
Writing .................................................................................................................185
Contiguous packed bit writing => SETPACKBIT ......................................... 185
Contiguous unpacked bit writing => SETBIT ............................................. 187
Contiguous byte writing => SETPACKBYTE ............................................... 189
Contiguous word writing => SETWORD .................................................... 191
Contiguous double word writing => SETDWORD ....................................... 193
Contiguous floating word writing => SETFWORD ....................................... 195
Non contiguous bit writing => SETDISPBIT .............................................. 197
Non contiguous word writing => SETDISPWORD ....................................... 199
Non contiguous double word writing => SETDISPDWORD .......................... 201
Non contiguous floating word writing => SETDISPFWORD .......................... 203
Incrementation.....................................................................................................205
Non contiguous word increment => INCDISPWORD................................... 205
Non contiguous double word increment => INCDISPDWORD ...................... 207
Decrementation ...................................................................................................209
Non contiguous word decrement => DECDISPWORD ................................. 209
Non contiguous double word decrement => DECDISPDWORD..................... 211
Event FIFO ..........................................................................................................213
Logged variable configuration => CONFDB ............................................... 213
Logging FIFO reading => GETEVENT ....................................................... 215
Copy of events into the FIFO => SETEVENT ............................................. 218

9. Functions for Redundancy of Equipment................................ 219


Functionality ........................................................................................................219
Read active definition function => AppGetEquipmentSwap ...............................221
Select active definition function => AppSetEquipmentSwap ..............................222

10. Local functions .......................................................................... 224


Bit unpacking => TRANSWORDBIT ...................................................................224
Bit grouping => TRANSBITWORD ............................................................ 226
Integer table comparison => COMPWORD ................................................ 227
Word bit inversion => INVBIT................................................................. 229
applicom® date unpacking => UNPACKDATE............................................ 230
applicom® time unpacking => UNPACKTIME ............................................ 232
BCD-binary transcoding => BCDBIN ........................................................ 234
Binary BCD transcoding => BINBCD ........................................................ 236

11. Modem functions ....................................................................... 238


Modem signal reading => GETMODEM ..................................................... 238
Modem signal setting => SETMODEM ...................................................... 240

12. Annex functions......................................................................... 241


Watchdog contact activation => WATCHDOG............................................ 241
Reading discrete input/output => AppGetWatchDog .................................. 242
Access to the software protection key => ACCESSKEY ............................... 244
Date and time Initialization => AppIniTime .............................................. 245

13. General applicom® statuses...................................................... 246

Library/DLL 5 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


1. General

This manual describes the different functions of the applicom® library.


In the description of each function, you will find its class, either:

¾ “applicom® standard” function.


¾ Function “Specific to a protocol”.

Functions called “applicom® standards” are valid for any protocol (Profibus, Modbus, Uni-Te, ...)
and will also be supported for future protocols proposed on the applicom® product. These standard
functions are (or will be) available provided that the protocol supports the object type (bits, words, ...) or
the functionality affected by the function. You will find the list of functions supported in the “Protocol
manual” used.

Remarks:
The read and write functions of bytes in pack mode (ex: readpackbyte, writepackbyte, ...) use array
of bytes. This variable type can not be declared by all “BASIC” compiler.

Library/DLL 6 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


2. Using the DLL with your programming language

The APPLICOM DLL is common for all Windows 32 bits platforms (Windows 2003 Server, Windows
XP and Windows Vista). Applications developed can therefore run on either of the Windows 32 bits
systems.

Caution: the applicom® DLL is installed in the Windows system directory and must
be unique on the computer hard disk.

Using the applicom® DLL

Use of the DLL “APPLICOM.DLL” is direct. An application uses the defined entry points like any
applicom® function, taking care, of course, to respect the number of parameters and their type, given that
“Pascal” call conditions tolerate no error.

Visual Basic Language

The procedure declarations can be found in APPLICOM.BAS. This file is stored in the sub-directory
Visual Studio\VB\VB 6.0. It should be inserted in your project using the option “Add a file”.
The first function to be called is CALL INITBUS(status%). If the “status” is not 0, you cannot use the
other applicom® functions.
Comment:
To avoid seeing the message “cannot find APPLICOM.DLL” while working in the VISUAL BASIC
directory, define your VISUAL BASIC working directory as the directory where “APPLICOM.DLL” is
present by using the option “File/Properties” in the Program Manager.

.Net language

An assembly is provided to help development under .Net language. You just have to add a
reference on the assembly that is called “applicomWra.dll” using the option “Add reference…” in project
menu.
With this assembly, you can access all applicom functions with the static class “AppliCom”
contained in the namespace “ApplicomWra”.
As every other language, the first function to call is “ApplicomWra.AppliCom.Initbus(out status)”. If
the “status” is not 0, you cannot use the other applicom® functions.

A simple sample is provided to simply access read and write applicom® functions, written in
VB.NET and C#. These samples are in directory “Samples/VS2005/VB.NET” and “Samples/VS2005/C#”.

C Microsoft Language

Add the file “APPLICOM.LIB” (import library) to your project (.MAK). This file is stored in the sub-
directory Visual Studio\C.
Add to your program the file containing the prototypes for the applicom® DLL functions.
# include "APPLICOM.H"

All arguments are placed by address (&). The first procedure to call is initbus(&status). If the
“status” is not 0, you cannot use the other applicom® functions.

C++ Microsoft Language

Add the file “APPLICOM.LIB” (import library) to your project (.MAK). This file is stored in the sub-
directory Visual Studio\C++.

Library/DLL 7 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


There is no applicom® class library; applicom® functions are seen as C functions, and you must
therefore include in your program the file containing the prototypes for the applicom® DLL functions,
adding before it the “C” keyword EXTERN.
extern “C”
{
#include "APPLICOM.H"
}

All arguments are placed by address (&). The first procedure to call is initbus(&status). If the
“status” is not 0, you cannot use the other applicom® functions.

Borland Delphi language

The procedure declarations can be found in “APPLICOM.PAS”. This file is stored in the sub-
directory DELPHI.
Insert it in your project with the following line:
implementation
{$R *.DFM}
{$I c:\applicom\delphi\APPLICOM.PAS}

The first function to be called is initbus(status). If the “status” is not 0, you cannot use the other
applicom® functions.
Comment:
The procedures do not verify array dimensions. Declare your arrays with correct dimensions.
The 16 bits integer type with 32 bits DELPHI is SmallInt and not Integer.

C Borland Language

To have the proper version of the applicom.lib file corresponding to the version of the applicom.dll
file that you have installed on the machine, use the Borland Tool IMPLIB.
Additional help information can be find in the Borland help Files.
Add to your program the file containing the prototypes for the applicom® DLL.
# include "APPLICOM.H"

All arguments are placed by address (&). The first procedure to call is initbus(&status). If the
“status” is not 0, you cannot use the other applicom® functions.

C++ Borland 32 bits Language


To have the proper version of the applicom.lib file corresponding to the version of the applicom.dll
file that you have installed on the machine, use the Borland Tool IMPLIB.
Additional help information can be find in the Borland help Files.

There is no applicom® class library; applicom® functions are seen as C functions, and you must
therefore include in your program the file containing the prototypes for the applicom® DLL functions,
adding before it the “C” keyword EXTERN.
extern “C”
{
#include "APPLICOM.H"
}

All arguments are placed by address (&). The first procedure to call is initbus(&status). If the
“status” is not 0, you cannot use the other applicom® functions.

Language G with LabVIEW by National Instrument

applicom® provides a library compatible with this environment: “applicom.llb”. This applicom®
library contains subVIs, each subVI allows you to access to an applicom® function.

applicom® provide two different libraries depending of the version of labview you are using. You will
find in “Sample/labview/4.0” directory the library compatible with labview version is lower than 8.2. Since
the 8.2 version, you need to use the library provided in “Sample/labview/8.2” directory.

Library/DLL 8 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Like every program which use the applicom® DLL, a LabVIEW program must call “initbus” to
initialize the communication before call other applicom® functions. The communication must be finished
by “exitbus”.

In LabVIEW, you insert a subVI in your diagram with “functions” palette, “select a VI”.
Then, the wiring of the subVI is easier if you display the connector terminals by the “show”,
“terminals” menu. By selecting the wiring tool in “Tools” palette, the terminal titles appear when you
approach the wiring tool to the terminal.
These files are stored in the sub-directory LabView.
There is a help for each applicom® function in “Help” window.
Online help more complete is available if the installation directory is the default directory.

PCSoft Windev language

To use the applicom® procedures, we advise to load, at the beginning of the project (when creating
the main window), APPLICOM.DLL with the following command in W-Language:

inst is a long integer


inst = chargeDLL(“APPLICOM.DLL”)

When the program is finishing, we advise to unload APPLICOM.DLL with the following command in
W-Language:

dechargeDLL(inst)

The first procedure to be called is appelDLL(“APPLICOM”,”initbus”,&status). If the “status” is not 0,


you cannot use the other applicom® functions.

Comment:
The procedures do not verify array dimensions. Declare your arrays with correct dimensions.

The utilization of chargeDLL is not obligatory because appelDLL loads and unloads
APPLICOM.DLL in the memory. To improve the performance, we advise to load APPLICOM.DLL with
chargeDLL and to unload it at the end of the program with DechargeDLL.
These files are stored in the sub-directory WINDEV.

Library/DLL 9 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


3. Maximum number of variables

The various functions of the applicom® V3.0 (or higher) library henceforth make it possible to
handle a higher number of variables compared to the preceding versions. To be able to reach these new
limits, the following conditions must be observed:
¾ use the applicom® V3.0 (or higher) product for Windows 32-bit with applicom® cards to the
PCI format,
¾ carry out the requests towards a protocol supporting the new limits (Industrial Ethernet...), or
towards the applicom® DATABASE,
¾ call the AuSetApplicationMaxSize function (after initbus) with the
APP_1584BYTES_BASED_LIMITS parameter.
The application has the possibility of consulting the limits supported on the various applicom®
interfaces by using the AuGetApplicomMaxSize function.
This number of maximum variable is defined as follows:

Type of variable Maximum number of variables(*) Maximum number of variables(*)


version < 3.0 version 3.0 or higher
APP_256BYTES_BASED_LIMITS APP_1584BYTES_BASED_LIMITS
Not packed bits (getbit) 128 792
Bits in deferred mode 2048 12672
(readdifpackbit,...)
Packed bits (readpackbit, 2048 12672
getpackbit,...)
Non contiguous bit writing 64 396
(setdispbit)
Non contiguous bit reading 128 792
(getdispbit)
Bytes (readbyte,...) 128 792
Packed bytes (readpackbyte, 256 1584
setpackbyte,...)
Words (readword, getword,...) 128 792
Non contiguous word writing 64 396
(setdispword)
Non contiguous word reading 128 792
(getdispword)
32 bit double and floating words 64 396
(readdword, readfword,...)
Non contiguous 32 bit double and 32 198
floating words writing (setdispdword,
setdispfword)
Non contiguous 32 bit double and 64 396
floating words reading
(getdispdword, getdispfword)
Timer, Counter (readtimer, 128 792
readcounter)
Logging FIFO reading (getevent) 20 144
readident, readmes, writemes, 256 1584
writereadmes, readdifmes,
writedifmes, writereaddifmes
(*)
these values represent the maximum and can be lower depending on the protocol and the
targetted Device.

Library/DLL 10 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


If the AuSetApplicationMaxSize function is not called, the applicom® software ensures you to
accept only requests compatible with the old limits (thus avoiding any problem of compatibility of the
existing applications using applicom®).
In all cases, the application must be ensured to have returned buffers sufficiently dimensioned at
the time of the calls to the applicom® functions.
In the following functions, the number of variables “Nb” varies from 1 to MAX. MAX represents one
of the limits above defined in table.

Library/DLL 11 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


4. Initialization

Product initialization => INITBUS

Prototypes

Language Prototype
C void initbus(short* wStatus)
MS pascal initbus(var wStatus: integer)
C# void initbus(out short wStatus)
VB.NET initbus(ByRef wStatus As short)

Parameters

Parameter Type
wStatus Error status

Description

This instruction must only be executed once in your application program before any access to the
applicom® functions.
By executing this function, you can:
¾ Check the interface presence.
¾ Initialize the communication with the applicom® library.

See also:
¾ In this manual:
9 General applicom® statuses

Example in Microsoft C language

#include "applicom.h"
short int status;
short int end_loop;

main()
{
initbus(&status);
if (!status)
{
do
{
/* your application */
}
while(end_loop == 0);
exitbus(&status);
exit(0);
}
else
{
printf(" non-resident applicom® communication software ");
exit(1);
}
}

Library/DLL 12 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Set the maximum number of variable => AuSetApplicationMaxSize

Prototypes:

Language Prototype
C BOOL AuSetApplicationMaxSize(short wBuffSize, unsigned long* dwStatus)
MS pascal function AuSetApplicationMaxSize(wBuffSize: SmallInt, var dwStatus: LongInt)
: boolean
C# bool AuSetApplicationMaxSize(ushort wBuffSize, out int dwStatus)
VB.NET Sub AuSetApplicationMaxSize(ByVal wBuffSize As UShort, ByRef dwStatus As
Integer)

Parameters

Parameter Type
wbuffersize Indicate if the application wishes to use the new limits of the applicom®library
• APP_1584BYTES_BASED_LIMITS Utilization of the news limits.
• APP_256BYTES_BASED_LIMITS Utilization of the old limits.
dwStatus Error status.

Return Value
TRUE if the function succeeds.

Description
Function only available under Windows operating system.
This function enables the application to declare the maximum size of it handles during calls to
applicom® functions.

To indicate that your application is designed to support the new limits, call this function with the
APP_1584BYTES_BASED_LIMITS parameter.
If the AuSetApplicationMaxSize function is not called, the applicom® software ensures you to
accept only requests compatible with the old limits (thus avoiding any problem of compatibility of the
existing applications using applicom®)
The applicom® product calculates the number of acceptable variables in a request in function:
¾ of the limits which you have just fixed,
¾ of the maximum supported by the protocol concerned
Caution: AuSetApplicationMaxSize must be called after the initbus function. The application must
have returned buffers sufficiently dimensioned at the time of the calls to the applicom®
functions.

See also:
¾ In this manual:
9 General applicom® statuses
9 Maximum number of variables

Library/DLL 13 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


example in Microsoft language C

#include "applicom.h"
short int status;
unsigned long dwStatus;
short int end_loop;

main()
{
initbus(&status);
if (!status)
{
if(!AuSetApplicationMaxSize(APP_1584BYTES_BASED_LIMITS, &dwStatus))
{
exitbus(&status);
exit(1);
}
do
{
/* votre application */
}
while(end_loop == 0);
exitbus(&status);
exit(0);
}
else
{
printf("applicom® dialog software not resident ");
exit(1);
}
}

Library/DLL 14 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Get the maximum number of variable => AuGetApplicomMaxSize

Prototypes

Language Prototype
C BOOL AuGetApplicomMaxSize(short TablSizeDB[8],short
TablSizeChannel[32],unsigned long* dwStatus);
MS pascal fonction AuGetApplicomMaxSize(var TablSizeDB:SmallInt;var
TablSizeChannel:SmallInt;var dwStatus:LongInt) : boolean
C# bool AuGetApplicomMaxSize(ushort[] TablSizeDB, ushort TablSizeChannel, out
int dwStatus)
VB.NET Sub AuGetApplicomMaxSize(ByVal TablSizeDB() As UShort, ByVal TablSizeChannel
As UShort, ByRef dwStatus As Integer)

Parameters

Parameter Type
TablSizeDB Table of 8 16 bits Integer. Each element contains a value indicating the limits of
corresponding database. The value can be:
¾ APP_1584BYTES_BASED_LIMITS Support the new limits of the
applicom® V3.0 (or higher) software,
¾ APP_256BYTES_BASED_LIMITS Support the limits of the applicom®
software before the version 3.0.
TablSizeChannel Table of 32 Integer 16 bits Each element contains a value indicating the limits of
corresponding channel. The value can be:
¾ APP_1584BYTES_BASED_LIMITS Support the new limits of the
applicom® V3.0 (or higher) software,
¾ APP_256BYTES_BASED_LIMITS Support the limits of the
applicom® software before the version 3.0.
dwStatus Error status.

Return Value
TRUE if the function succeeds.

Description
Function only available under Windows operating system.
This function allows to know the limits supported by date-bases or the master protocols of the
applicom® interfaces.

See also:
¾ In this manual:
9 General applicom® statuses
9 Maximum number of variables

Library/DLL 15 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft language C

#include "applicom.h"
short int status;
unsigned long dwStatus;
short dwStatus;
short int end_loop;
short sizeDB[8], sizeChannel[32];

main()
{
initbus(&status);
if (!status)
{
if(!AuGetApplicomMaxSize(sizeDB,sizeChannel, &dwStatus))
{
exitbus(&status);
exit(1);
}
do
{
/* your application */
}
while(end_loop == 0);
exitbus(&status);
exit(0);
}
else
{
printf("applicom® dialog software not resident ");
exit(1);
}
}

Library/DLL 16 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Program end => EXITBUS

Prototypes:

Language Prototype
C void exitbus(short * wStatus)
MS pascal procedure exitbus(var wStatus: integer)
C# void exitbus(out short wStatus)
VB.NET Sub exitbus(ByRef wStatus As Short)

Parameters

Parameter Type
wStatus Not used (always 0)

Description

This instruction must be executed at the exit of all the tasks that executed an INITBUS (with or
without success). Status is always equal to 0 upon exit from this function.

See also:
¾ In this manual:
9 Product initialization => INITBUS

Library/DLL 17 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


5. Wait mode functions

Reading
Bit reading => READPACKBIT

Prototypes:

Language Prototype
C void readpackbit(short * wChan, short * wNes, short * wNb, long* dwAdr, short
* lpwTabl, short * wStatus)
MS pascal procedure readpackbit(var wChan, wNes, wNb: integer; var: dwAdr integer4; var
lpwTabl, wStatus: integer)
C# void readpackbit(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[]lpwTabl, out short wStatus)
VB.NET Sub readpackbit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255)
wNb Number of bits to be read (1-2048).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be read in the device.
lpwTabl Table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read bits in a device in packed format. The
different values are stored in the integer table called “lpwTabl”. A table item therefore contains a 16-bit
chain maximum. The bits which are not read in the last word that receives the data are in an
undetermined state.
The applicom® “transwordbit” function allows you to unpack bit chains

See also:
¾ In this manual:
9 General applicom® statuses
9 Bit unpacking => TRANSWORDBIT
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 18 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft language C

Reading of bits 0 to 7 of Device number 6, channel number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short nb = 8; /* Number of variables */
short status; /* Status */
long adr = 0; /* First variable address */
short tabl[1]; /* Table receiving the data */
short tablbit[8]; /* Table containing the unpacked values */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readpackbit(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
transwordbit(&nb, tabl, tablbit, &status);
for (i=0; i < nb ; i++)
printf(" %hd",tablbit[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 19 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Input bit reading => READPACKIBIT

Prototypes:

Language Prototype
C void readpackibit(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * lpwTabl, short * wStatus)
MS pascal procedure readpackibit(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var lpwTabl, wStatus:integer)
C# void readpackibit(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[]lpwTabl, out short wStatus)
VB.NET Sub readpackibit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31)
wNes Device number (0-255)
wNb Number of bits to be read (1-2048)
The maximum number depends on the protocol and target device
dwAdr Address of the first bit to be read in the device.
lpwTabl Table receiving read data
wStatus Error status.

Description:

This applicom® standard function can be used to read input bits in a device in packed format. The
different values are stored in the integer table called lpwTabl. A table item therefore contains a 16-bit
chain maximum. The bits which are not read in the last word that receives the data are in an
undetermined state.
The applicom® “transwordbit” function allows you to unpack bit chains.

See also:
¾ In this manual:
9 General applicom® statuses
9 Bit unpacking => TRANSWORDBIT
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 20 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of bits 0 to 33 of Device number 6, from the applicom® interface channel number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short nb = 34; /* Number of variables */
short status; /* Status */
long adr = 0; /* First variable address */
short tabl[3]; /* Table receiving the data */
short tablbit[34]; /* Table containing the unpacked values */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readpackibit(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
transwordbit(&nb, tabl, tablbit, &status);
for (i=0; i < nb; i++)
printf(" %hd",tablbit[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 21 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output bit reading => READPACKQBIT

Prototypes:

Language Prototype
C void readpackqbit(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * lpwTabl, short * wStatus)
MS pascal procedure readpackqbit(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var lpwTabl, wStatus:integer)
C# void readpackqbit(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[]lpwTabl, out short wStatus)
VB.NET Sub readpackqbit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters:

Parameter Type
wChan Channel number (0-31)
wNes Device number (0-255)
wNb Number of bits to be read (1-2048)
The maximum number depends on the protocol and target device
dwAdr Address of the first bit to be read in the device
lpwTabl Table receiving read data
wStatus Error status.

Description:

This applicom® standard function can be used to read output bits in a device in packed format. The
different values are stored in the integer table called lpwTabl. A table item therefore contains a 16-bit
chain maximum. The bits which are not read in the last word that receives the data are in an
undetermined state.
The applicom® “transwordbit” function allows you to unpack bit chains.

See also:
¾ In this manual:
9 General applicom® statuses
9 Bit unpacking => TRANSWORDBIT
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 22 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of output bits 0 to 33 in Device number 6, from the applicom® interface channel number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short nb = 34; /* Number of variables */
short status; /* Status */
long adr = 0; /* First variable address */
short tabl[3]; /* Table receiving the data */
short tablbit[34]; /* Table containing the unpacked values */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readpackqbit(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
transwordbit(&nb, tabl, tablbit, &status);
for (i=0; i < nb; i++)
printf(" %hd",tablbit[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 23 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Quick reading of 8 bits => READQUICKBIT

Prototypes:

Language Prototype
C void readquickbit(short * wChan, short * wNes, short * lpwTabl, short *
wStatus)
MS pascal procedure readquickbit(var wChan, wNes, lpwTabl, wStatus:integer)
C# void readquickbit(ref ushort wChan, ref ushort wNes, short[]lpwTabl, out
short wStatus)
VB.NET Sub readquickbit(ByRef wChan As UShort, ByRef wNes As UShort, ByVal lpwTabl()
As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (1-255).
lpwTabl Table receiving read data.
wStatus Error status.

Description:

This function specific to Jbus protocol allows the quick reading of 8 bits. The bit addresses are:
¾ A504 to A511 for devices from the SMC range
¾ 0A00 to 0A07 for devices from the PB range
¾ 0000 to 0007 for applicom® PC100 devices
¾ Configurable between 0 and 32000 for applicom® PC1000/PC4000/GT4000/VME4000
devices

Data are received in the least significant byte of a first lpwTabl table item. The applicom®
“transwordbit” function allows you to unpack bit chains.

See also:
¾ In this manual:
9 General applicom® statuses
9 Bit unpacking => TRANSWORDBIT
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 24 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


example in Microsoft C language

Quick reading of the 8 bits of Device number 6, from the applicom® interface channel number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short status; /* Status */
short tabl[1]; /* Table receiving the data */
short tablbit[8]; /* Table containing the unpacked values */
short nb = 8; /* Number of variables */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readquickbit(&nchan, &neq, tabl, &status);
if (!status)
{
transwordbit(&nb, tabl, tablbit, &status);
for (i=0; i<nb ; i++)
printf(" %hd",tablbit[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
.
.
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 25 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Byte reading => READBYTE

Prototypes:

Language Prototype
C void readbyte(short * wChan, short * wNes, short * wNb, long * dwAdr, short *
lpwTabl, short * wStatus)
MS pascal procedure readbyte(var wChan, wNes, wNb: integer; var dwAdr: integer4; var
lpwTabl, wStatus: integer)
C# void readbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[]lpwTabl, out short wStatus)
VB.NET Sub readbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As Short,
ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be read (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first byte to be read in the device.
lpwTabl Table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read bytes in a device. The different values are
stored in the least significant bytes of the integer table called lpwTabl. The most significant byte of each
table item is set to 0.

Notes:

Uni-Te protocol:
¾ The dwAdr address argument is coded on 32 bits. The coding of the 16 most significant bits
allows the access to specific segments and object types.
¾ This function is not supported by the TSX PLC.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 26 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of bytes 0 to 33 of device number 6, from channel number 1 of the applicom® interface.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short nb = 34; /* Number of variables */
short status; /* Interchange status */
long adr = 0; /* First variable address */
short tabl[34]; /* Table receiving data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readbyte(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i < nb; i++)
printf(" %hd", tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 27 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Input byte reading => READIBYTE

Prototypes:

Language Prototype
C void readibyte(short * wChan, short * wNes, short * wNb, long * dwAdr, short
* lpwTabl, short * wStatus)
MS pascal procedure readibyte(var wChan, wNes, wNb: integer; var dwAdr: integer4; var
lpwTabl, wStatus: integer)
C# void readibyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[]lpwTabl, out short wStatus)
VB.NET Sub readibyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be read (1-128).
The maximum number depends on the protocol and target device
dwAdr Address of the first byte to be read in the device.
lpwTabl Table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read input bytes in a device. The different values
will be stored in the least significant bytes of the integer table called lpwTabl. The most significant byte of
each table item is set to 0.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 28 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of input bytes 0 to 33 of Device number 6, from the applicom® interface channel number
1.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short nb = 34; /* Number of variables */
short status; /* Interchange status */
long adr = 0; /* First variable address */
short tabl[34]; /* Table receiving the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readibyte(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i < nb; i++)
printf(" %hd", tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 29 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output byte reading => READQBYTE

Prototypes:

Language Prototype
C void readqbyte(short * wChan, short * wNes, short * wNb, long * dwAdr, short
* lpwTabl, short * wStatus)
MS pascal procedure readqbyte(var wChan, wNes, wNb: integer; var dwAdr: integer4; var
lpwTabl, wStatus: integer)
C# void readqbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[]lpwTabl, out short wStatus)
VB.NET Sub readqbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be read (1-128).
The maximum number depends on the protocol and target device).
dwAdr Address of the first byte to be read in the device.
lpwTabl Table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read output bytes in a device. The different
values will be stored in the least significant bytes of the integer table called lpwTabl. The most significant
byte of each table item is set to 0.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 30 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of output bytes 0 to 33 of Device number 6, from the applicom® interface channel number
1.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short nb = 34; /* Number of variables */
short status; /* Interchange status */
long adr = 0; /* First variable address */
short tabl[34]; /* Table receiving the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readqbyte(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i < nb; i++)
printf(" %d", tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 31 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Packed byte reading => READPACKBYTE

Prototypes:

Language Prototype
C void readpackbyte(short * wChan, short * wNes, short * wNb, long * dwAdr,
char * lpcTabl, short * wStatus)
MS pascal procedure readpackbyte(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var lpcTabl: byte; var wStatus: integer)
C# void readpackbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, sbyte[]lpcTabl, out short wStatus)
VB.NET Sub readpackbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpcTabl() As SByte, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be read (1-256).
The maximum number depends on the protocol and target device.
dwAdr Address of the first byte to be read in the device.
lpcTabl Byte table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read bytes in a device. The different values are
stored in the byte table called lpcTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 32 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of bytes 0 to 33 in Device number 6, from channel number 1 of the applicom® interface.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short nb = 34; /* Number of variables */
short status; /* Interchange status */
long adr = 0; /* First variable address */
char tabl[34]; /* Table receiving the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readpackbyte(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i < nb; i++)
printf(" %d", tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 33 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Packed input byte reading => READPACKIBYTE

Prototypes:

Language Prototype
C void readpackibyte(short * wChan, short * wNes, short * wNb, long * dwAdr,
char * lpcTabl, short * wStatus)
MS pascal procedure readpackibyte(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var lpcTabl: byte; var wStatus: integer)
C# void readpackibyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, sbyte[]lpcTabl, out short wStatus)
VB.NET Sub readpackibyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpcTabl() As SByte, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be read (1-256).
The maximum number depends on the protocol and target device.
dwAdr Address of the first byte to be read in the device.
lpcTabl Byte table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read input bytes in a device. The different values
are stored in the byte table called lpcTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 34 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of packed input bytes 0 to 33 in device number 6, from the applicom® interface channel
number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short nb = 34; /* Number of variables */
short status; /* Interchange status */
long adr = 0; /* First variable address */
char tabl[34]; /* Table receiving the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readpackibyte(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i < nb; i++)
printf(" %d", tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 35 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Packed output byte reading => READPACKQBYTE

Prototypes:

Language Prototype
C void readpackqbyte(short * wChan, short * wNes, short * wNb, long * dwAdr,
char * lpcTabl, short * wStatus)
MS pascal procedure readpackqbyte(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var lpcTabl: byte; var wStatus: integer)
C# void readpackqbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, sbyte[]lpcTabl, out short wStatus)
VB.NET Sub readpackqbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpcTabl() As SByte, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be read (1-256).
The maximum number depends on the protocol and target device.
dwAdr Address of the first byte to be read in the device.
lpcTabl Byte table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read output bytes in a device. The different
values are stored in the byte table called lpcTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 36 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of output bytes 0 to 33 in device number 6, from the applicom® interface channel number
1.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short nb = 34; /* Number of variables */
short status; /* Interchange status */
long adr = 0; /* First variable address */
char tabl[34]; /* Table receiving the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readpackqbyte(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i < nb; i++)
printf(" %d", tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 37 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Word reading => READWORD

Prototypes:

Language Prototype
C void readword(short * wChan, short * wNes, short * wNb, long * dwAdr, short *
lpwTabl, short * wStatus)
MS pascal procedure readword(var wChan, wNes, wNb:integer ; var dwAdr:integer4 ; var
lpwTabl, wStatus:integer)
C# void readword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[]lpwTabl, out short wStatus)
VB.NET Sub readword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As Short,
ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be read (1-128 max).
The maximum number depends on the protocol and target device.
dwAdr Address of the first word to be read.
lpwTabl Table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read words in a device. The different values read
in the Device are returned by the function into the integer table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 38 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of words 20 to 30 of Device number 4, on channel number 2.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 2; /* Channel number */
short neq = 4; /* Device number */
short nb = 11; /* Number of variables */
short status; /* Interchange status */
long adr = 20; /* First variable address */
short tabl[11]; /* Table receiving the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readword(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i < nb; i++)
printf("word%ld = %hd \n",adr+i,tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 39 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Input word reading => READIWORD

Prototypes:

Language Prototype
C void readiword(short * wChan, short * wNes, short * wNb, long * dwAdr, short
* lpwTabl, short * wStatus)
MS pascal procedure readiword(var wChan, wNes, wNb: integer; var dwAdr: integer4 ; var
lpwTabl, wStatus:integer)
C# void readiword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[]lpwTabl, out short wStatus)
VB.NET Sub readiword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be read (1-128)
The maximum number depends on the protocol and target device.
dwAdr Address of the first word to be read.
lpwTabl Table receiving read data
wStatus Error status.

Description:

This applicom® standard function can be used to read input words in a device. The different values
read in the Device are returned by the function into the integer table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 40 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language:

Reading of words 20 to 30 of Device number 4, on channel number 2.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 2; /* Channel number */
short neq = 4; /* Device number */
short nb = 11; /* Number of variables */
short status; /* Interchange status */
long adr = 20; /* First variable address */
short tabl[11]; /* Table receiving the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readiword(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i<nb ; i++)
printf("word%ld = %hd \n",adr+i,tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 41 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output word reading => READQWORD

Prototypes:

Language Prototype
C void readqword(short * wChan, short * wNes, short * wNb, long * dwAdr, short
* lpwTabl, short * wStatus)
MS pascal procedure readqword(var wChan, wNes, wNb: integer; var dwAdr: integer4 ; var
lpwTabl, wStatus:integer)
C# void readqword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub readqword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be read (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first word to be read.
lpwTabl Table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read output words in a device. The different
values read in the Device are returned by the function into the integer table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 42 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of output words 20 to 30 in Device number 4, of the applicom® interface channel number
2.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 2; /* Channel number */
short neq = 4; /* Device number */
short nb = 11; /* Number of variables */
short status; /* Interchange status */
long adr = 20; /* First variable address */
short tabl[11]; /* Table receiving data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readqword(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i<nb ; i++)
printf("word%ld = %hd \n",adr+i,tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 43 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


BCD word reading => READWORDBCD

Prototypes:

Language Prototype
C void readwordbcd(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * lpwTabl, short * wStatus)
MS pascal procedure readwordbcd(var wChan, wNes, wNb: integer; var dwAdr: integer4 ;
var lpwTabl, wStatus:integer)
C# void readwordbcd(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub readwordbcd(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be read (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first word to be read.
lpwTabl Table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read words in BCD format.
Example:
Value read in the device h'9999' in hexadecimal.
Value returned by the function 9999 in decimal.
The different values read in the Device are returned by the function into the integer table called
lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 44 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of BCD words 20 to 30 in Device number 4 of the applicom® interface channel number 2.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 2; /* Channel number */
short neq = 4; /* Device number */
short nb = 11; /* Number of variables */
short status; /* Interchange status */
long adr = 20; /* First variable address */
short tabl[11]; /* Table receiving the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readwordbcd(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i<nb ; i++)
printf("word%ld = %d \n",adr+i,tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 45 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Double word reading => READDWORD

Prototypes:

Language Prototype
C void readdword(short * wChan, short * wNes, short * wNb, long * dwAdr, long *
lpwTabl, short * wStatus)
MS pascal procedure readdword(var wChan, wNes, wNb:integer; var dwAdr,
lpwTabl:integer4; var wStatus:integer)
C# void readdword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, int[] lpwTabl, out short wStatus)
VB.NET Sub readdword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Integer, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of double words to be read (1-64).
The maximum number depends on the protocol and target device.
dwAdr Address of the first double word to be read.
lpwTabl Table receiving read data
wStatus Error status.

Description:

This applicom® standard function can be used to read double words in a device. The different
values read in the Device are returned by the function into the Table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 46 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of double words 20 to 30 of Device number 4, on channel number 2.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 2; /* Channel number */
short neq = 4; /* Device number */
short nb = 11; /* Number of variables */
short status; /* Interchange status */
long adr = 20; /* First variable address */
long tabl[11]; /* Table receiving data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readdword(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i < nb; i++)
printf("word%ld = %ld \n",adr+i,tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
}

Library/DLL 47 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Floating word reading => READFWORD

Prototypes:

Language Prototype
C void readfword(short * wChan, short * wNes, short * wNb, long * dwAdr,float
* pfTabl, short * wStatus)
MS pascal procedure readfword(var wChan, wNes, wNb:integer; var dwAdr:integer4; var
pfTabl:real; var wStatus:integer)
C# void readfword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, float[] pfTabl, out short wStatus)
VB.NET Sub readfword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal pfTabl() As Single, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of floating words to be read (1-64).
The maximum number depends on the protocol and target device.
dwAdr Address of the first floating word to be read.
pfTabl Table receiving read data.
wStatus Error status.

Description:

This applicom® standard function can be used to read floating words in IEEE format in a device.
The different values read in the Device are returned by the function into the 32-bit real table called
pfTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 48 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of floating words 20 to 26 of Device number 1, on channel number 0.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 0; /* Channel number */
short neq = 1; /* Device number */
short nb = 7; /* Number of variables */
short status; /* Interchange status */
long adr = 20; /* First variable address */
float tabl[7]; /* Table receiving the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readfword(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i<nb ; i++)
printf("word%ld = %f \n",adr+i,tabl[i]);
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 49 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Timer reading => READTIMER

Prototypes:

Language Prototype
C void readtimer(short * wChan, short * wNeq, short * wNb, long * dwAdr,short *
wTabl, short * wStatus)
MS pascal procedure readtimer(var wChan, wNeq, wNb:integer; var dwAdr: integer4, var
wTabl, wStatus:integer);
C# void readtimer(ref ushort wChan, ref ushort wNeq, ref short wNb, ref int
dwAdr, short[] wTabl, out short wStatus)
VB.NET Sub readtimer(ByRef wChan As UShort, ByRef wNeq As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal wTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-255).
wNb Number of timers to be read (1-128).
The maximum number depends on the protocol and target device.
dwAdr First timer number.
wTabl Table receiving the current values of wNb timers.
wStatus Error status.

Description:

This applicom® standard function can be used to read preset values related to timers in a device.
The different values are stored in the Table called wTabl.

Notes:

Uni-Te protocol:
¾ 1Timer maximum.
¾ Can be used to read Ti,P objects of TSX PLCs (i = timer no.).

3964/3964R protocol, RK512 messaging:


¾ Can be used to read TB objects.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 50 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of timer no. 3 in Device number 6, from the applicom® interface channel number 1.

#include "applicom.h" /* Prototype declaration file */


short nchan = 1; /* Channel number */
short neq = 6; /* Device number */
short nb = 1; /* Number of timers */
long adr = 3; /* Timer address */
short tabl[1]; /* Table receiving the data */
short status; /* Interchange status */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readtimer(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
{
printf(" Value of timer no. %ld = %hd \n ", adr, tabl[0] );
}
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 51 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Counter reading => READCOUNTER

Prototypes:

Language Prototype
C void readcounter(short * wChan, short * wNeq,short * wNb, long * dwAdr, short
* wTabl, short * wStatus)
MS pascal procedure readcounter(var wChan, wNeq, wNb:integer; var dwAdr: integer4, var
wTabl, wStatus:integer);
C# void readcounter(ref ushort wChan, ref ushort wNeq, ref short wNb, ref int
dwAdr, short[] wTabl, out short wStatus)
VB.NET Sub readcounter(ByRef wChan As UShort, ByRef wNeq As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal wTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-255).
wNb Number of counters to be read (1-128).
The maximum number depends on the protocol and target device.
dwAdr First counter number.
wTabl Table receiving the current values of wNb counters.
wStatus Error status.

Description:

This applicom® standard function can be used to read preset values related to counters in a
device. The different values read in the Device are returned by the function into the integer table called
wTabl.

Notes:

Uni-Te protocol:
¾ 1 Counter maximum.
¾ Can be used to read Ci,P objects of TSX PLCs (i = counter no.).

3964/3964R protocol, RK512 messaging:


¾ Can be used to read ZB objects.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 52 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of counter no. 10 in Device number 4, from the applicom® interface channel number 0.

#include "applicom.h" /* Prototype declaration file */


short nchan = 0; /* Channel number */
short neq = 4; /* Device number */
short nb = 1; /* Number of counters */
long adr = 10; /* Counter address */
short tabl[1]; /* Table receiving the data */
short status; /* Interchange status */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
readcounter(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
printf(" Value of counter no. %ld = %hd \n", adr, tabl[0]);
else
printf(" problem on Device no. %hd \n", neq);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 53 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Bit writing => WRITEPACKBIT

Prototypes:

Language Prototype
C void writepackbit(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * lpwTabl, short * wStatus)
MS pascal procedure writepackbit(var wChan, wNes, wNb:integer; var dwAdr:integer4, var
lpwTabl, wStatus:integer);
C# void writepackbit(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writepackbit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bits to be written (1-2048).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be written.
lpwTabl Table containing the data.
wStatus Error status.

Description:

This applicom® standard function can be used to write bits in a device. The different values are
stored in the integer table called lpwTabl in “packed” mode (16 bits per integer).

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 54 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of bits 20 to 30 of Device number 4, from the applicom® interface channel number 2.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan = 2; /* Channel number */
short neq = 4; /* Device number */
short nb =11; /* Number of bits */
short status; /* Interchange status */
long adr = 20; /* First bit address */
short tabl[1]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
tabl[0] = 0x07FF;
writepackbit(&nchan, &neq, &nb, &adr, tabl, &status);
if (status)
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 55 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output bit writing => WRITEPACKQBIT

Prototypes:

Language Prototype
C void writepackqbit(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * lpwTabl, short * wStatus)
MS pascal procedure writepackqbit(var wChan, wNes, wNb:integer; var dwAdr:integer4, var
lpwTabl, wStatus:integer);
C# void writepackqbit(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writepackqbit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bits to be written (1-2048).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be written.
lpwTabl Table containing the data.
wStatus Error status.

Description:

This applicom® standard function can be used to write output bits in a device. The different values
are stored in the integer table called lpwTabl in “packed” mode (16 bits per integer).

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 56 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of output bits 20 à 30 of Device number 4, from the applicom® Interface channel
number 2.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short nchan = 2; /* Channel number */
short neq = 4; /* Device number */
short nb 11; /* Number of bits */
short status; /* Interchange status */
long adr = 20; /* First bit address */
short tabl[1]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
tabl[0] = 0x07FF;
writepackqbit(&nchan, &neq, &nb, &adr, tabl, &status);
if (status)
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 57 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Byte writing => WRITEBYTE

Prototypes:

Language Prototype
C void writebyte(short * wChan, short * wNes, short * wNb, long * dwAdr, short
* lpwTabl, short * wStatus)
MS pascal procedure writebyte(var wChan, wNes, wNb: integer; var dwAdr: integer4; var
lpwTabl, wStatus: integer);
C# void writebyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writebyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be written (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first byte to be write in the device.
lpwTabl Table containing the data to be written.
wStatus Error status.

Description:

This applicom® standard function can be used to write bytes in a device. The different values will
be stored in the least significant bytes of the integer table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 58 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of bytes 10 to 13 of Device number 4, from the applicom® interface channel number 2.
Values are typed from the keyboard.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of bytes */
short status; /* Interchange status */
long adr; /* First byte address */
short tabl[4]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=2; neq=4; nb=4; adr=10;
for ( i = 0; i < nb; i++)
{
printf("\n Value of byte %ld (0-255) = ", adr+i);
scanf(" %hd", &tabl[i]);
}
writebyte(&nchan, &neq, &nb, &adr, tabl, &status);
if (status)
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 59 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output byte writing => WRITEQBYTE

Prototypes:

Language Prototype
C void writeqbyte(short * wChan, short * wNes, short * wNb, long * dwAdr, short
* lpwTabl, short * wStatus)
MS pascal procedure writeqbyte(var wChan, wNes, wNb: integer; var dwAdr: integer4; var
lpwTabl, wStatus: integer);
C# void writeqbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writeqbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be written (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first byte to be read in the device.
lpwTabl Table containing the data to be written.
wStatus Error status.

Description:

This applicom® standard function can be used to write output bytes in a device. The different
values will be stored in the least significant bytes of the integer table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 60 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of output bytes 10 to 13 of Device number 4, from the applicom® interface channel number
2. Values are typed from the keyboard.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of bytes */
short status; /* Interchange status */
long adr; /* First byte address */
short tabl[4]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=2; neq=4; nb=4; adr=10;
for ( i = 0; i < nb; i++)
{
printf("\n Value of byte %ld (0-255) = ", adr+i);
scanf(" %hd", &tabl[i]);
}
writeqbyte(&nchan, &neq, &nb, &adr, tabl, &status);
if (status)
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 61 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Packed byte writing => WRITEPACKBYTE

Prototypes:

Language Prototype
C void writepackbyte(short * wChan, short * wNes, short * wNb, long * dwAdr,
char * pbyTabl, short * wStatus)
MS pascal procedure writepackbyte(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var wStatus: byte; var status : integer)
C# void writepackbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, sbyte[] pbyTabl, out short wStatus)
VB.NET Sub writepackbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal pbyTabl() As SByte, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be written (1-256).
The maximum number depends on the protocol and target device.
dwAdr address of the first byte to be written in the device.
pbyTabl Table containing the data to be written.
wStatus Error status.

Description:

This applicom® standard function can be used to write bytes in a device. The different values are
stored in the byte table called pbyTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 62 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of packed bytes 10 and 11 of Device number 4, from the applicom® interface channel
number 2. Values are positioned at 255.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of bytes */
short status; /* Interchange status */
long adr; /* First byte address */
char tabl[2]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=2; neq=4; nb=2; adr=10;
tabl[0] = 255; tabl[1] = 255;
writepackbyte(&nchan, &neq, &nb, &adr, tabl, &status);
if (status)
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 63 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Packed output byte writing => WRITEPACKQBYTE

Prototypes:

Language Prototype
C void writepackqbyte(short * wChan, short * wNes, short * wNb, long * dwAdr,
char * pbyTabl, short * wStatus)
MS pascal procedure writepackqbyte(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var pbyTabl: byte; var wStatus: integer)
C# void writepackqbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, sbyte[] pbyTabl, out short wStatus)
VB.NET Sub writepackqbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal pbyTabl() As SByte, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be written (1-256).
The maximum number depends on the protocol and target device.
dwAdr address of the first byte to be written in the device.
pbyTabl Table containing the data to be written.
wStatus Error status.

Description:

This applicom® standard function can be used to write output bytes in a device. The different
values are stored in the byte table called pbyTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 64 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of output bytes 10 to 11 of Device number 4, from the applicom® interface channel number
2. Values are positioned at 255.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of bytes */
short status; /* Interchange status */
long adr; /* First byte address */
char tabl[2]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=2; neq=4; nb=2; adr=10;
tabl[0] = 255; tabl[1] = 255;
writepackqbyte(&nchan, &neq, &nb, &adr, tabl, &status);
if (status)
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 65 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Word writing => WRITEWORD

Prototypes:

Language Prototype
C void writeword(short * wChan, short * wNes, short * wNb, long * dwAdr, short
* lpwTabl, short * wStatus)
MS pascal procedure writeword(var wChan, wNes, wNb:integer; var dwAdr:integer4; var
lpwTabl, wStatus:integer);
C# void writeword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writeword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be written (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first word to be written.
lpwTabl Table containing the data.
wStatus Error status.

Description:

This applicom® standard function can be used to write words in a device. The different values are
stored in the integer table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 66 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of words 20 to 30 in Device number 1, from the applicom® interface channel number 0.
Values are typed from the keyboard.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of words */
short status; /* Interchange status */
long adr; /* First word address */
short tabl[11]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; neq=1; nb=11; adr=20;
for ( i = 0; i < nb; i++)
{
printf("\n Value of word %ld ?", adr+i);
scanf(" %hd",&tabl[i]);
}
writeword(&nchan, &neq, &nb, &adr, tabl, &status);
if (status)
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 67 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output word writing => WRITEQWORD

Prototypes:

Language Prototype
C void writeqword(short * wChan, short * wNes, short * wNb, long * dwAdr, short
* lpwTabl, short * wStatus)
MS pascal procedure writeqword(var wChan, wNes, wNb:integer; var dwAdr:integer4; var
lpwTabl, wStatus:integer);
C# void writeqword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writeqword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be written (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first word to be written.
lpwTabl Table containing the data.
wStatus Error status.

Description:

This applicom® standard function can be used to write output words in a device. The different
values are stored in the integer table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 68 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of output words 20 to 30 in Device number 1, from the applicom® interface channel number
0. Values are typed from the keyboard.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of words */
short status; /* Interchange status */
long adr; /* First word address */
short tabl[11]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; neq=1; nb=11; adr=20;
for ( i = 0; i < nb; i++)
{
printf("\n Value of word %ld ?", adr+i);
scanf(" %hd",&tabl[i]);
}
writeqword(&nchan, &neq, &nb, &adr, tabl, &status);
if (status)
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 69 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


BCD word writing => WRITEWORDBCD

Prototypes:

Language Prototype
C void writewordbcd(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * lpwTabl, short * wStatus)
MS pascal procedure writewordbcd(var wChan, wNes, wNb:integer; var dwAdr:integer4; var
lpwTabl, wStatus:integer);
C# void writewordbcd(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writewordbcd(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be written (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first word to be written
lpwTabl Table containing the data.
wStatus Error status.

Description:

This applicom® standard function can be used to write words in BCD format in a device.
Example:
¾ Value given to the function 9999 decimal.
¾ Value written in the device h'9999' hexadecimal.
The different values are stored in the integer table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 70 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of BCD words 20 to 30 in Device number 1, from the applicom® interface channel number
0. Values are typed from the keyboard.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of words */
short status; /* Interchange status */
long adr; /* First word address */
short tabl[11]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; neq=1; nb=11; adr=20;
for ( i = 0; i < nb; i++)
{
printf("\n Value of word %ld ?", adr+i);
scanf(" %hd",&tabl[i]);
}
writewordbcd(&nchan, &neq, &nb, &adr, tabl, &status);
if (status)
printf(" Incorrect writing !!, status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 71 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Double word writing => WRITEDWORD

Prototypes:

Language Prototype
C void writedword(short * wChan, short * wNes, short * wNb, long * dwAdr, long
* lpwTabl, short * wStatus)
MS pascal procedure writedword(var wChan, wNes, wNb:integer; var dwAdr,
lpwTabl:integer4; var wStatus:integer);
C# void writedword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, int[] lpwTabl, out short wStatus)
VB.NET Sub writedword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Integer, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of double words to be written (1-64).
The maximum number depends on the protocol and target device.
dwAdr Address of the first word to be written.
lpwTabl Table receiving the data.
wStatus Error status.

Description:

This applicom® standard function can be used to write double words in a device. The
different values must be written in the table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 72 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of the 2 double words from address 20 in Device number 1, from the applicom® interface
channel number 0. Values are typed from the keyboard.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
short status; /* Interchange status */
long adr; /* First double word address */
long tabl[2]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; neq=1; nb=2; adr=20;
for ( i = 0; i < nb; i++)
{
printf("\n Value of word %ld ?", adr+i);
scanf(" %ld",&tabl[i]);
}
writedword(&nchan, &neq, &nb, &adr, tabl, &status);
if (status)
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 73 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Floating word writing => WRITEFWORD

Prototypes:

Language Prototype
C void writefword(short * wChan, short * wNes, short * wNb, long * dwAdr, float
* pfTabl, short * wStatus)
MS pascal procedure writefword(var wChan, wNes, wNb:integer; var dwAdr:integer4; var
pfTabl:real; var wStatus:integer)
C# void writefword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, float[] pfTabl, out short wStatus)
VB.NET Sub writefword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal pfTabl() As Single, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of floating words to be written (1-64).
The maximum number depends on the protocol and target device.
dwAdr Address of the first floating word to be written.
pfTabl Table receiving the data.
wStatus Error status.

Description:

This applicom® standard function can be used to write floating words in IEEE format in a device.
The different values are stored in the 32-bit real table called pfTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 74 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of 2 floating words from address 20 in Device number 1, from the applicom® interface
channel number 0. Their values are typed from the keyboard.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
short status; /* Interchange status */
long adr; /* First floating word address */
float tablf[2]; /* Table containing the data */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; neq=1; nb=2; adr=20;
for ( i = 0; i < nb; i++)
{
printf("\n Value of word %ld ?", adr+i);
scanf(" %f",&tablf[i]);
}
writefword(&nchan, &neq, &nb, &adr, tablf, &status);
if (status)
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 75 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Timer writing => WRITETIMER

Prototypes:

Language Prototype
C void writetimer(short * wChan, short * wNeq, short * wNb, long * dwAdr, short
* wTabl, short * wStatus)
MS pascal procedure writetimer(var wChan, wNeq, wNb:integer; var wStatus:integer4;
tabl, status :integer);
C# void writetimer(ref ushort wChan, ref ushort wNeq, ref short wNb, ref int
dwAdr, short[] wTabl, out short wStatus)
VB.NET Sub writetimer(ByRef wChan As UShort, ByRef wNeq As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal wTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-255).
wNb Number of timers (1-128).
The maximum number depends on the protocol and target device.
dwAdr First timer number.
wTabl Table containing the wNb preset values.
wStatus Error status.

Description:

This applicom® standard function can be used to write preset values related to timers in a device.
The different values to be written are stored in the Table called wTabl.

Notes:

Uni-Te protocol:
¾ 1 Timer maximum.
¾ Can be used to write Ti,P objects of TSX PLCs TSX (i = timer no.).

3964/3964R protocol, RK512 messaging:


¾ Can be used to write TB objects.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 76 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of the preset value corresponding to timer no.3 in server Device number 4, from the
applicom® interface channel number 2. The value is typed from the keyboard.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of timers */
long adr; /* Timer number */
short tabl[1]; /* Table containing the data */
short status; /* Interchange status */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=2; neq=4; nb=1; adr=3;
scanf("value ? %hd", tabl);
writetimer(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
exit(0)
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 77 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Counter writing => WRITECOUNTER

Prototypes:

Language Prototype
C void writecounter(short * wChan, short * wNeq, short * wNb, long * dwAdr,
short * wTabl, short * wStatus)
MS pascal procedure writecounter(var wChan, wNeq, wNb: integer; var dwAdr:integer4; var
wTabl, wStatus:integer);
C# void writecounter(ref ushort wChan, ref ushort wNeq, ref short wNb, ref int
dwAdr, short[] wTabl, out short wStatus)
VB.NET Sub writecounter(ByRef wChan As UShort, ByRef wNeq As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal wTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-255).
wNb Number of counters (1-128).
The maximum number depends on the protocol and target device.
dwAdr First counter number.
wTabl Table containing the wNb preset values.
wStatus Error status.

Description:

This applicom® standard function can be used to write preset values related to counters in a
device. The different values are stored in the Table called wTabl.

Notes:

Uni-Te protocol:
¾ 1 counter maximum.
¾ Can be used to write Ci,P objects of TSX PLCs (i = timer no.).

3964/3964R protocol, RK512 messaging:


¾ Can be used to write ZB objects

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 78 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Writing of the preset value corresponding to counter no. 3 in Device number 4, from the applicom®
interface channel number 2. The value is typed from the keyboard.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of counters */
long adr; /* Counter number */
short tabl[1]; /* Preset value */
short status; /* Interchange status */

main()
{
/* Initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=2; neq=4; nb=1; adr=3;
scanf("Value ? %hd", tabl);
writecounter(&nchan, &neq, &nb, &adr, tabl, &status);
if (!status)
exit(0);
else
printf(" problem on Device no. %hd \n",neq);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 79 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Diagnostic counter reading => READDIAG

Prototypes:

Language Prototype
C void readdiag(short * wChan, short * wNes, short * lpwTabl, short * wStatus)
MS pascal procedure readdiag(var wChan, wNes, lpwTabl, wStatus: integer);
C# void readdiag(ref ushort wChan, ref ushort wNes, short[] lpwTabl, out short
wStatus)
VB.NET Sub readdiag(ByRef wChan As UShort, ByRef wNes As UShort, ByVal lpwTabl() As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
lpwTabl Table with at least 2 items.
- lpwTabl[0] = Undercode.
- lpwTabl[1] = Data.
wStatus Error status.

Description:

This function can be used to read the Diagnostic counters (function code 8) of a Jbus / Modbus
device.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Reading of the number of frames received with a CRC error by Device 9, connected on the
applicom® interface channel 2.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short tabl[2]; /* Table containing the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=2; neq=9; tabl[0]=12;
readdiag(&nchan, &neq, tabl, &status);
printf(" Number of frames received with CRC error = %hd \n ", tabl[1] );
}
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 80 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Event counter reading => READEVEN

Prototypes:

Language Prototype
C void readeven(short * wChan, short * wNes, short * wVal, short * wStatus)
MS pascal procedure readeven(var wChan, wNes, wVal, wStatus: integer);
C# void readeven(ref ushort wChan, ref ushort wNes, out short wVal, out short
wStatus)
VB.NET Sub readeven(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wVal As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wVal Receive the data.
wStatus Error status.

Description:

This function can be used to read the event counter of a Jbus / Modbus Device (function code 11).

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Reading of the number of events of Device 9, connected on the applicom® interface channel 2.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short val; /* Integer containing the data */
short status; /* Interchange status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
nchan=2; neq=9;
readeven(&nchan, &neq, &val, &status);
printf(" Number of frames received with CRC error = %hd \n ", val[0]);
}
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 81 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Change to STOP => MANUAL

Prototypes:

Language Prototype
C void manual(short * wChan, short * wNes, short * wStatus)
MS pascal procedure manual(var wChan, wNes, wStatus: integer);
C# void manual(ref ushort wChan, ref ushort wNes, out short wStatus)
VB.NET Sub manual(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wStatus Error status.

Description:

Uni-Te protocol:
¾ This function places the Uni-Te devices in “STOP” mode. Some devices require a
preliminary reservation.

Jbus protocol:
¾ This function places the Jbus/Modbus Device central processor en “STOP” mode (function
code 13).

See also:
¾ In this manual:
9 General applicom® statuses
9 Connection or reservation => AppConnect
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Change to “STOP” of Device 1 from the applicom® interface channel 3.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short status; /* Interchange status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
nchan=3; neq=1;
manual(&nchan, &neq, &status);
.....
}
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 82 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Change to RUN => AUTOMATIC

Prototypes:

Language Prototype
C void automatic(short * wChan, short * wNes, short * wStatus)
MS pascal procedure automatic(var wChan, wNes, wStatus: integer);
C# void automatic(ref ushort wChan, ref ushort wNes, out short wStatus)
VB.NET Sub automatic(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wStatus Error status.

Description:

Uni-Te protocol:
¾ This function places the Uni-Te devices in “RUN” mode. Some devices require a
preliminary reservation.

Jbus/Modbus protocol:
¾ This function places Jbus/Modbus devices in “RUN” mode (function code 13).

See also:
¾ In this manual:
9 General applicom® statuses
9 Connection or reservation => AppConnect
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Change to “RUN” of the Uni-Te Device no. from the applicom® interface channel 3.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short status; /* Interchange status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
nchan=3; neq=1;
AppConnect(&nchan, &neq, &status); /* Server reservation */
if ( status == 0)
automatic(&nchan, &neq, &status);
.....
}
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 83 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Connection or reservation => AppConnect

Prototypes:

Language Prototype
C void AppConnect(short * wChan, short * wNes, short * wStatus)
MS pascal procedure AppConnect(var wChan, wNes, wStatus: integer);
C# void AppConnect(ref ushort wChan, ref ushort wNes, out short wStatus)
VB.NET Sub AppConnect(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wStatus Error status.

Description:

Uni-Te protocol:
¾ This function reserves the server Device which is aimed at (h'1D' request). This command
allows a client, during critical requests (downloading, Run, Stop, ...) to reserve the server
Device with which he wants to communicate. Reservation is valid for 60 seconds
maximum.

Jbus/Modbus protocol:
¾ This function can be used to connect the slave Jbus/Modbus coupler to the PLC program
memory by ensuring the mutual exclusion towards the other couplers.

3964/3964R protocol, free messaging:


¾ Can be used to allow reception.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 84 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reservation of Uni-Telway Device no. 1 from the applicom® interface channel 3.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
nchan=3; neq=1;
AppConnect(&nchan, &neq, &status);
.....
}
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 85 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Disconnection or dereservation => AppUnconnect

Prototypes:

Language Prototype
C void AppUnconnect(short * wChan, short * wNes, short * wStatus)
MS pascal procedure AppUnconnect(var wChan, wNes, wStatus: integer);
C# void AppUnconnect(ref ushort wChan, ref ushort wNes, out short wStatus)
VB.NET Sub AppUnconnect(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wStatus
As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wStatus Error status.

Description:

Uni-Te protocol:
¾ This function ensures the dereservation of the affected server device (h'1E' request).

Jbus/Modbus protocol:
¾ This function can be used to disconnect the Jbus/Modbus device coupler from the PLC
memory and release it for the other couplers.

3964/3964R protocol, free messaging:


¾ Can be used to lock reception.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Dereservation of Device 1 from the applicom® interface channel 3.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short status; /* Interchange status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
nchan=3; neq=1;
AppUnconnect(&nchan, &neq, &status);
.....
}
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 86 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Slave status => STATJBUS

Prototypes:

Language Prototype
C void statjbus(short * wChan, short * lpcTabl, short * wStatus)
MS pascal procedure statjbus(var wChan, lpcTabl, wStatus: integer);
C# void statjbus(ref ushort wChan, short[] lpcTabl, out short wStatus)
VB.NET Sub statjbus(ByRef wChan As UShort, ByVal lpcTabl() As Short, ByRef wStatus
As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
lpcTabl 256-item table made up of 16-bit integers receiving the channel device
status.
- lpcTabl[1] = Status of interchanges with device 1.
- lpcTabl[255] = Status of interchanges with device 255.
wStatus Error status.

Description:

This Jbus/Modbus specific function can be used to query the status of the last interchange with the
devices.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Reading of the status of the first 20 devices connected onto the applicom® interface master
channel no. 3.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short tabl[256]; /* Table receiving the status */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
nchan=3;
statjbus(&nchan, tabl, &status);
printf("statjbus status = %d\n ", status);
if (status == 0)
{
for ( i=1 ; i<=20 ; i++ ) printf("Slave status = %hd ", tabl[i] );
}
. }
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 87 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Master counter reading => IOCOUNTER

Prototypes:

Language Prototype
C void iocounter(short * wChan,short * wNes, short * lpcTabl, short * wStatus)
MS pascal procedure iocounter(var wChan, wNes, lpcTabl, wStatus: integer);
C# void iocounter(ref ushort wChan, ref ushort wNes, short[] lpcTabl, out short
wStatus)
VB.NET Sub iocounter(ByRef wChan As UShort, ByRef wNes As UShort, ByVal lpcTabl() As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
lpcTabl Table receiving the status and contents of the counters managed by
the master related to wNes device.
- lpcTabl[0] = Device status.
- lpcTabl[1] = Number of messages without transmission errors.
- lpcTabl[2] = Number of exception code answers
- lpcTabl[3] = Number of time-outs.
- lpcTabl[4] = Number of CRC errors.
wStatus Error status.

Description:

This function can be used to read in the master task the error counters related to a Jbus / Modbus
device.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 88 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of master counters that relate to Device no. 9 connected on the applicom® interface
channel 2.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short tabl[5]; /* Integer containing the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
nchan=2; neq=9;
iocounter(&nchan,&neq,tabl,&status);
printf("iocounter status = %d \n\t",status);
if (status == 0)
{
printf(" Device status = %hd \n ", tabl[0]);
printf(" Number of interchanges performed = %hd \n ", tabl[1]);
printf(" Number of exception code = %hd \n ", tabl[2]);
printf(" Number of time-out = %hd \n ", tabl[3]);
printf(" Number of parity or crc error = %hd \n ", tabl[4]);
}
}
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 89 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Master counter reset => RESETIOCOUNTER

Prototypes:

Language Prototype
C void resetiocounter(short * wChan, short * wNes, short * wStatus)
MS pascal procedure resetiocounter(var wChan, wNes, wStatus: integer);
C# void resetiocounter(ref ushort wChan, ref ushort wNes, out short wStatus)
VB.NET Sub resetiocounter(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wStatus
As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wStatus Error status.

Description:

This Jbus / Modbus function can be used to reset the master counters. The Device number makes
this reset selective.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Reset of error counters of Device 1 in Jbus master of channel 3.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
nchan=3; neq=1;
resetiocounter(&nchan, &neq, &status);
printf(" resetiocounter status = %d \n ",status);
}
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 90 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Error counter reset => RESETCOUNTERUTE

Prototypes:

Language Prototype
C void resetcounterute(short * wChan, short * wNeq, short * wStatus)
MS pascal procedure resetcounterute(var wChan, wNeq, wStatus: integer);
C# void resetcounterute(ref ushort wChan, ref ushort wNeq, out short wStatus)
VB.NET Sub resetcounterute(ByRef wChan As UShort, ByRef wNeq As UShort, ByRef
wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-255).
wStatus Error status.

Description:

This Uni-Te specific function can be used to reset the Device error counters. This function is
complementary to function READDIAGUTE.

See also:
¾ In this manual:
9 General applicom® statuses
9 Error counter reading => READDIAGUTE
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Reset of the diagnostic counter of Device 1 connected on the applicom® interface channel 3.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
{
nchan=3; neq=1;
resetcounterute(&nchan, &neq, &status);
if (status == 0)
printf(" Counter reset OK !!");
else
printf(" Problem with Device no. %d ", neq);
}
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 91 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Trace buffer reading => READTRACE

Prototypes:

Language Prototype
C void readtrace(short * wChan, short * wNeq, short * wTabl, short * wStatus)
MS pascal procedure readtrace(var wChan, wNeq, wTabl, wStatus: integer) ;
C# void readtrace(ref ushort wChan, ref ushort wNeq, short[] wTabl, out short
wStatus)
VB.NET Sub readtrace(ByRef wChan As UShort, ByRef wNeq As UShort, ByVal wTabl() As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-255).
wTabl 66-item table made up of 16-bit integers receiving the data.
- wTabl[0] = Event counter state.
- wTabl[1] = Message counter state.
- wTabl[2] to wTabl[65] = Buffer trace.
wStatus Error status.

Description:

This Jbus specific function can be used to query the history of the last 64 transactions in target
device.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol
¾ Other documentation:
9 Manufacturer documentation (function code 12).

Library/DLL 92 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of the “Trace buffer” of Jbus slave no. 9, connected on the applicom® interface channel 2.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short tabl[66]; /* Integer containing the data */
short status; /* Interchange status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
nchan=2; neq=9;
readtrace(&nchan, &neq, tabl, &status);
printf("readtrace status = %hd \n",status);
if (status == 0)
{
printf("\n Event counter value : %hd ", tabl[0]);
printf("\n Message counter value : %hd ", tabl[1]);
for ( i=0 ; i<4 ; i++ )
{
for ( j=0 ; j<8; j++ ) printf(" %04X",tabl[i*8+j+2]);
}
}
}
while(status == 0);
}
.
.
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 93 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Error counter reading => READDIAGUTE

Prototypes:

Language Prototype
C void readdiagute(short * wChan, short * wNeq, short * wTabl,short * wStatus)
MS pascal procedure readdiagute(var wChan, wNeq, wTabl, wStatus: integer);
C# void readdiagute(ref ushort wChan, ref ushort wNeq, short[] wTabl, out short
wStatus)
VB.NET Sub readdiagute(ByRef wChan As UShort, ByRef wNeq As UShort, ByVal wTabl() As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-255).
wTabl Table made up of 4 16-bit integers receiving the data.
- wTabl[0] = Number of non acknowledged transmitted messages.
- wTabl[1] = Number of refused transmitted messages.
- wTabl[2] = Number of non acknowledged received messages.
- wTabl[3] = Number of refused received messages.
wStatus Error status.

Description:

This Uni-Te specific function can be used to query the target device link defect history (character
error, frame error, protocol error). The applicom® RESETCOUNTERUTE function can be used to reset
the various counters.

Notes:
Uni-Te protocol
¾ The slave TSX PLCs only manage this request on the listen address (ad2).
To read the master counters, you must target its system address:
Network no. = 0
Station no. = 254
Gate no. =5
Unit no. = 254
Way no. = 100
If the applicom® interface is the Uni-Telway bus master, these counters can be queried by
using an applicom® device no. configured at link address 0 (in the default configuration, the
latter corresponds to the applicom® device no. 153).

Ethway network
¾ TSX PLC on Ethway manage this request only on network gate (Gate number = 4)

See also:
¾ In this manual:
9 General applicom® statuses
9 Error counter reset => RESETCOUNTERUTE
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 94 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of diagnostic counters of device 1, from the applicom® interface channel 2.

#include "applicom.h" /* Prototype declaration file */


short i; /* Loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short tabl[4]; /* Integer containing the data */
short status; /* Interchange status */

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
nchan=2; neq=1;
readdiagute(&nchan, &neq, tabl, &status);
for ( i = 0; i < 4; i++) printf(" counter %hd = %hd\n", i, tabl[i]);
}
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 95 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Device identification => READIDENT

Prototypes:

Language Prototype
C void readident(short * wChan, short * wNes, short * wNb, char * lpcTabl,
short * wStatus)
MS pascal procedure readident(var wChan, wNes, wNb: integer, var lpcTabl: byte, var
wStatus: integer);
C# void readident(ref ushort wChan, ref ushort wNes, ref short wNb, sbyte[]
lpcTabl, out short wStatus)
VB.NET Sub readident(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByVal lpcTabl() As SByte, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of characters in the identification message (1-256).
lpcTabl Byte table receiving the ASCII identification message.
wStatus Error status.

Description:

This applicom® standard function can be used to identify a device. The ASCII identification
message is returned in the byte table lpcTabl.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 96 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C langage

Identification of the Device number 1 of channel 3.

#include "applicom.h" /* Prototypes declaration file */


short nchan = 3; /* Channel number */
short neq = 1; /* Device number */
short nb; /* Number of returned bytes */
char tabl[256]; /* Table receiving the identification message */
short status; /* Status */
short i;

main()
{
/* initialize the communication with the applicom® product with "initbus"*/
{
do
{
readident(&nchan, &neq, &nb, tabl, &status);
if (!status)
{
for ( i=0; i < nb; i++ )
printf(" %c", tabl[i]);
}
else
printf(" problem on device no %hd \n",neq);
}
while(status == 0);
}
/* Execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 97 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Open function
Uni-Te text block function => TXTUTE

Prototypes:

Language Prototype
C void txtute(short * wChan, short * wNeq, short * wTxTic, short * wTxTil, char
* byTablTx, char * byTablRx, short * wNbRx, short * wNbTe, short * wStatus)
MS pascal procedure txtute(var wChan, wNeq, wTxTic, wTxTil: integer; var wStatus, :
byte; var txtis, txtiv, status: integer)
C# void txtute(ref ushort wChan, ref ushort wNeq, ref short wTxTic, ref short
wTxTil, sbyte[] byTablTx, sbyte[] byTablRx, out short wNbRx, out short wNbTe,
out short wStatus)
VB.NET Sub txtute(ByRef wChan As UShort, ByRef wNeq As UShort, ByRef wTxTic As
Short, ByRef wTxTil As Short, ByVal byTablTx() As SByte, ByVal byTablRx() As
SByte, ByRef wNbRx As Short, ByRef wNbTe As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-255).
wTxTic *256 class code + Uni-Te request code.
wTxTil Number of bytes in transmission table.
byTablTx Byte table making up the transmission table.
byTablRx Byte table making up the reception table.
wNbRx Number of received data bytes.
wNbTe UNI-TE report.
wStatus Error status.

Description:

This function is comparable to the text block used in the TELEMECANIQUE TSX PLCs. It therefore
allows the user to set up its own Uni-Te request. This function which is available in wait mode therefore
allows you to access all the Uni-Te functions that are not supported by applicom®.
You must enter the request code as well as the class code (wTxTic) and define the data field in the
transmission table (byTablTx) as well as the length of this table in bytes (wTxTil). The request report is
returned into the argument (wNbTe) with the number of data bytes (wNbRx). Data will be stored in the
reception table (byTablRx).
In particular, this function can be used to transmit “Unsollicited data”: h'FC' request. In that case, as
the h'FC' request does not return any report, the status argument will be positioned at -9 when
transmission is completed.

Note:
On Ethway network:
This function can also be used to transmit message from application to application. Since this
type of exchange does not use a request code, the wTxTic argument will be set arbitrarily to:
wTxTic = FFFF (h), for the transmission of 240 bytes maximum to a type “TXT” text
block.
wTxTic = FFFE (h), for the transmission of 16 bytes maximum to a type “TLG” text block
(Telegrams).
As this service does not return any report, the status argument will be positioned at -9 when
transmission is completed.

Library/DLL 98 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Reading of the list of addresses present on the Uni-Telway bus (h'A3' request). The client slave
applicom® interface on channel 0 interrogates the master of the bus configured with Device number 32
(default configuration). The master scans 8 addresses.

Transmitted request:

Request Class
h'A3' h'07'

Correct interchange answer:

CR Addr no. state of the 152 addresses (19 bytes)


h'D3' h'98'

Incorrect interchange answer:

CR
h'FD'

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short txtic; /* Request code + Class code */
short txtil; /* Number of bytes in bufemi */
char bufemi[126]; /* Transmission table */
char bufrec[126]; /* Reception table */
short txtis; /* Integer: number of received bytes */
short txtiv; /* Integer: Uni-Te report */
short status; /* Interchange status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan = 0; neq = 32; txtic = 0x07A3; txtil = 0;
txtute(&nchan, &neq, &txtic, &txtil, bufemi, bufrec, &txtis, &txtiv, &status);
if ((txtiv == 0xD3) && (status == 0))
{
printf(" TXTiV Report = %hd \n ", txtiv);
printf(" Number of addresses managed by the master = %hd \n ", bufrec[0]);
printf(" State of the first 8 addresses = %X \n ", bufrec[1]);
}
else
{
printf(" Interchange status = %hd \n ", status);
printf(" TXTiV report = %hd \n ", txtiv);
}
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 99 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Free access to messaging => AuWriteReadMsg

Prototypes:

Language Prototype
C bool AuWriteReadMsg(ref ushort wChan, ref ushort wNeq, ref int dwMsgParam,
ref short wNbTx, sbyte[] byBufTx, ref short wNbRx, sbyte[] byBufRx, out int
dwStatus)
C# bool AuWriteReadMsg(ref ushort wChan, ref ushort wNeq, ref int dwMsgParam,
ref short wNbTx, sbyte[] byBufTx, ref short wNbRx, sbyte[] byBufRx, out int
dwStatus)
VB.NET Function AuWriteReadMsg(ByRef wChan As UShort, ByRef wNeq As UShort, ByRef
dwMsgParam As Integer, ByRef wNbTx As Short, ByVal byBufTx() As SByte, ByRef
wNbRx As Short, ByVal byBufRx() As SByte, ByRef dwStatus As Integer) As
Boolean

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-255).
dwMsgParam Messaging parameter.
wNbTx Number of bytes sent.
byBufTx Byte table. Message or command to be sent.
wNbRx Caution, this is an input and output parameter:
- As input, it must contain the maximum expected number of bytes.
- As feedback, it contains the number of bytes actually received.
byBufRx Table. Message or information returned by device.
dwStatus Error status. If the byte table recovered by this function is larger than
the number indicated in the wNbRx parameter, status 74 will be
returned.

Description:
This function enables direct access to messaging for certain protocols. Therefore, prior to use,
you should consult users’ manual for your protocol to determine if this function is supported.
Commands, parameters and statuses depend on the protocol in question. When this function is
called up, the user must enter the maximum number of bytes, wNbRx, that can be returned by the
function.
For more information, refer to the manual for your communication protocol.

Value returned:
TRUE if OK. If this function returns FALSE in the event of an error, refer to the dwStatus variable
for more information.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 100 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


“Ports without protocol” functions
Message reception => READMES

Prototypes:

Language Prototype
C void readmes(short * wChan, short * wStop, short * wNbRx, short * wTimeOut,
short * wTimeOut_ic, char * byTablRx, short * wStatus)
MS pascal procedure readmes(var wChan, wStop, wNbRx, wTimeOut, wTimeOut_ic: integer;
var byTablRx: byte; var wStatus: integer);
C# void readmes(ref ushort wChan, ref short wStop, ref short wNbRx, ref short
wTimeOut, ref short wTimeOut_ic, sbyte[] byTablRx, out short wStatus)
VB.NET Sub readmes(ByRef wChan As UShort, ByRef wStop As Short, ByRef wNbRx As
Short, ByRef wTimeOut As Short, ByRef wTimeOut_ic As Short, ByVal byTablRx()
As SByte, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wStop Contain up to two ASCII characters. Message end will be detected by
one of these 2 characters.
- If wStop = -1, stop character management is inactive.
wNbRx - At calling wNbRx = Number of characters to be received (1 to 256).
- At return wNbRx = Number of received characters.
wTimeOut Time-out (0 to 65535 ms).
If wTimeOut = 0, the inter-character time-out is inactive.
wTimeOut_ic Inter-character time-out (0-4000 ms).
- If wTimeOut_ic = 0, the inter-character time-out is inactive.
byTablRx Table receiving the message.
wStatus Error status.
wStatus = 0, End of reception on byte count or end character.
wStatus = 33, End of reception on time-out (no character received).
wStatus = 34, End of reception on parity defect.
wStatus = -8, end of reception on inter-character time-out (wNbRx
indicates the number of characters received in byTablRx).

Description:

This applicom® function can be used to receive a frame on a channel of the applicom® interface.
Received bytes are stored in the byte table called byTablRx without interpretation.
When time-out is inactive (wTimeOut = 0), the channel remains locked in reception until the arrival
of at least 1 character. From that moment, the time-out is inhibited and the inter-character time-out is
activated. The exit in reception will take place either:
- on number of received characters (wNbRx).
- on stop character, if its value differs from -1.
- on wTimeOut_ic, if its value differs from 0.

Notes:

3964/3964R protocol, free messaging:


¾ This function can be used to de-store an information block from the channel buffer memory.
So that the channel can receive the information blocks and store them in its buffer memory,
you must first execute the “AppConnect” function.
¾ wStop and wTimeOut_ic parameters are non significant.

Library/DLL 101 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


See also:
¾ In this manual:
9 General applicom® statuses
9 Connection or reservation => AppConnect
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Message reception on the applicom® interface channel 0. The reception end will be detected on the
LF ASCII character (h'0A').

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short stop; /* End character */
short nb; /* Number of variables */
short tim_out /* Time-out */
short tim_ic /* Inter-character time-out */
char tabl[256]; /* Table receiving the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; stop = 0x0A0A; nb=255; tim =0; tim_ic=0;
readmes(&nchan, &stop, &nb, &tim, &tim_ic, tabl, &status);
if (!status)
for (i=0; i<nb ; i++) printf(" %c ",tabl[i]);
else
printf(" Problem on channel no. %hd \n",nchan);
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 102 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Message transmission => WRITEMES

Prototypes:

Language Prototype
C void writemes(short * wChan, short * wNb, char * pbyTabl, short * wStatus)
MS pascal procedure writemes(var wChan, wNb: integer; var pbyTabl: byte; var wStatus:
integer);
C# void writemes(ref ushort wChan, ref short wNb, sbyte[] pbyTabl, out short
wStatus)
VB.NET Sub writemes(ByRef wChan As UShort, ByRef wNb As Short, ByVal pbyTabl() As
SByte, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNb Number of characters to be transmitted (1 to 256).
pbyTabl Byte table containing the message to be transmitted.
wStatus Error status.

Description:

This applicom® function can be used to transmit a frame on a channel of the applicom® interface.
The message stored in the byte table called pbyTabl is transmitted without interpretation.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 103 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Transmission of message “DRAINING PUMP IN DEFECT !!” to the Device connected on the
applicom® interface channel 0.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short nb; /* Number of variables */
char tabl[26]; /* Table containing the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; nb=26;
strcpy(tabl,"DRAINING PUMP IN DEFECT !!");
writemes(&nchan, &nb, tabl, &status);
if (status != 0)
printf(" !! Defect, incorrect transmission \n");
else
{
printf(" correct transmission \n");
}
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 104 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Message reception transmission => WRITEREADMES

Prototypes:

Language Prototype
C void writereadmes(short * wChan, short * wNbTx, char * byTablTx, short *
wStop, short * wNbRx, short * wTimeOut, short * wTimeOut_ic, char * byTablRx,
short * wStatus)
MS pascal procedure writereadmes(var wChan, wNbTx: integer; var byTablTx: byte; var
wStop, wNbRx, wTimeOut, wTimeOut_ic: integer; var byTablRx: byte; var
wStatus: integer);
C# void writereadmes(ref ushort wChan, ref short wNbTx, sbyte[] byTablTx, ref
short wStop, ref short wNbRx, ref short wTimeOut, ref short wTimeOut_ic,
sbyte[] byTablRx, out short wStatus)
VB.NET Sub writereadmes(ByRef wChan As UShort, ByRef wNbTx As Short, ByVal
byTablTx() As SByte, ByRef wStop As Short, ByRef wNbRx As Short, ByRef
wTimeOut As Short, ByRef wTimeOut_ic As Short, ByVal byTablRx() As SByte,
ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNbTx Number of characters to be sent (1-256).
byTablTx Byte table containing the message to be sent.
wStop Contains up to two ASCII characters. The message end will be
detected on one of these 2 characters.
- If wStop = -1, stop character management is inactive.
wNbRx - At calling wNbRx = Number of characters to be received (1 to
256).
- At return wNbRx = Number of received characters.
wTimeOut Time-out (0 to 65535 ms).
- If wTimeOut = 0, the time-out is inactive.
wTimeOut_ic Inter-character time-out (0-4000 ms).
- If wTimeOut_ic = 0, the inter-character time-out is inactive.
byTablRx Table receiving the message.
wStatus Error status.
wStatus = 0, End of reception on byte count or end character.
wStatus = 33, End of reception on time-out (no character
received).
wStatus = 34, End of reception on parity defect.
wStatus = -8, End of reception on inter-character time-out (wNbRx
indicates the number of characters received in byTablRx).

Description:

This applicom® standard function can be used to transmit then receive a frame on a channel of the
applicom® interface.
When wTimeOut is inactive (wTimeOut = 0), the channel remains locked in reception until the arrival
of at least 1 character. From that moment, the time-out is inhibited and the inter-character time-out is
activated. The exit in reception will take place either:
- on number of received characters (wNbRx).
- on stop character, if its value differs from -1.
- on wTimeOut_ic, if its value differs from 0.

Notes:

3964/3964R protocol, free messaging:


¾ The “READ” part of this function can be used to de-store an information block from the
channel buffer memory. So that the channel can receive the information blocks and store
them in its buffer memory, you must first execute the “AppConnect” function.
¾ wStop and wTimeOut_ic parameters are non significant.

Library/DLL 105 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


See also:
¾ In this manual:
9 General applicom® statuses
9 Connection or reservation => AppConnect
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Transmission of message “DRAINING PUMP IN DEFECT !!” to the Device connected on the
applicom® interface channel 0. Then, reception of a character for 3 seconds.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short nbtx; /* Number of characters to be transmitted */
char tabltx[26]; /* Table containing the data to be transmitted */
short stop; /* Reception end character */
short nbrx; /* Number of characters to be received */
short tim; /* Time-out */
short tim_ic; /* Inter-character time-out */
char tablrx[1]; /* Reception table */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; nbtx=26; stop=-1; nbrx=1; tim=3000; tim_ic=0;
strcpy(tabltx,"DRAINING PUMP IN DEFECT !!");
writereadmes(&nchan, &nbtx, tabltx, &stop, &nbrx, &tim, &tim_ic, tablrx, &status);
if (status != 0)
printf(" !! Defect: transmission/reception status = %hd \n", status);
else
{
printf(" Received character = %c \n ", tablrx[0]);
.
.
}
}
while(status == 0);
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 106 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Profibus FMS specific functions
Reading of FMS object dictionnary => AppFmsGetOd

Prototypes:

Language Prototype
C void AppFmsGetOd( short * wChan, short * wNeq, short * wAttr, short *
wAccess, short * wIdx, short * wNb, void * byTabl, short * wMf, short *
wStatus)
MS pascal procedure AppFmsGetOd(var wChan, wNeq, wAttr, wAccess, wIdx, wNb: integer;
var byTabl: byte; var wMf, wStatus:integer);
C# void AppFmsGetOd(ref ushort wChan, ref ushort wNeq, ref short wAttr, ref
short wAccess, ref short wIdx, out short wNb, sbyte[] byTabl, out short wMf,
out short wStatus)
VB.NET Sub AppFmsGetOd(ByRef wChan As UShort, ByRef wNeq As UShort, ByRef wAttr As
Short, ByRef wAccess As Short, ByRef wIdx As Short, ByRef wNb As Short, ByVal
byTabl() As SByte, ByRef wMf As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-99).
wAttr 0: Short form.
1: Long form.
wAccess 0: Read by index
1: Read by start index
wIdx Index number (or first index number) to read.
wNb Number of received bytes (1-256).
byTabl Byte table receiving read data.
wMf 0 : No more index after the reading.
1 : Still one or several index exist after reading.
wStatus Error status.

Description:

This PROFIBUS FMS specific function is used to read a device item’s object dictionary. The data is
returned according to the Profibus convention (most significant first). The buffer contents are interpreted
according to standard DIN 19245 part 2.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 107 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


FMS Device status => AppFmsStatus

Prototypes:

Language Prototype
C void AppFmsStatus( short * wChan, short * wNeq, unsigned short * wLogStat,
unsigned short * wPhyStat, short * wStatus)
MS pascal procedure AppFmsStatus( var wChan, wNeq: integer ; var wLogStat, wPhyStat:
word ; var wStatus: integer );
C# void AppFmsStatus(ref ushort wChan, ref ushort wNeq, out ushort wLogStat, out
ushort wPhyStat, out short wStatus)
VB.NET Sub AppFmsStatus(ByRef wChan As UShort, ByRef wNeq As UShort, ByRef wLogStat
As UShort, ByRef wPhyStat As UShort, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-99).
wLogStat PROFIBUS logical status
Value:
0: State changes allowed. All services can be operated normally.
2: Limited services permitted. Limited number of services, at least the
following services are accessible as servers: Establishment,
Reject, Identification, Status, Request OD.
4: OD loading non interacting. Cannot load OD, this status indication
shows that the object dictionary (OD) cannot be loaded.
5: OD loading interacting. Can load OD, all connections, apart from
that used for OD transmission or request, are blocked. The
establish connection request is rejected.
wPhyStat PROFIBUS physical status
Value:
0: Operational.
1: Partialy operational.
2: Inoperable.
3: Needs commissioning.
wStatus Error status.

Description:

This PROFIBUS FMS specific function can be used to read the logical and the physical status of
Devices.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 108 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C langage

Reading of FMS status in PROFIBUS device number 1 of channel 3.

#include "applicom.h" /* Prototype declaration file */


short nchan = 3; /* Channel number */
short neq = 1; /* Device number */
unsigned short logstat; /* FMS logical Status */
unsigned short phystat; /* FMS physical Status */
short status; /* applicom® status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
AppFmsStatus( &nchan, &neq, &logstat, &phystat, &status);
if ( status == 0 )
{
printf("Logical Status : ");
switch(logstat)
{
case 0 : printf("state changes allowed\n") ; break;
case 2 : printf("limited services permitted\n") ; break;
case 4 : printf("OD loading non interacting\n") ; break;
case 5 : printf("OD loading interacting\n") ; break;
default : printf("Bad logical status value = %hd\n", logstat );
}
printf("Physical Status : ");
switch(phystat)
{
case 0 : printf("operational\n") ; break;
case 1 : printf("partially operational\n") ; break;
case 2 : printf("inoperable\n") ; break;
case 3 : printf("needs commissioning\n") ; break;
default: printf("Bad physical status value = %hd\n", phystat );
}
}
else
printf(" problem on device no %hd status %hd \n", neq , status );
}
/* execute function "exitbus" before exitting */
exit(0);
}

Library/DLL 109 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


6. Deferred mode functions

Conditions of use
The deferred request manager can accept requests in a multitasking environment. Use of deferred
mode therefore involves certain particularities depending on your operating system:

Under multitasking OS (MS-Windows XP, OS/2, UNIX,...)

The deferred request manager for each applicom® interface can accept requests from 8
different tasks (or threads). A task is referenced in the manager during its first request (if a 9th
task attempts to access deferred mode, status 40 is returned). Each task retrieves its request
results, and for a given channel in the order that the requests were made.
The tasks frees its place and the resources used (requests made but results not yet read) by
the exitbus function (must absolutely be called when closing the application).

Reading
Bit reading => READDIFBIT

Prototypes:

Language Prototype
C void readdifbit (short * wChan, short * wNes, short * wNb, long* dwAdr, short
* wStatus)
MS pascal procedure readdifbit(var wChan, wNes, wNb:integer; var dwAdr:integer4; var
wStatus:integer);
C# void readdifbit(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdifbit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bits to be read (1-2048).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be read.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of bits in a device. The different
values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred requests
being run by applicom® interface is limited to 64.

Library/DLL 110 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


See also:
¾ In this manual:
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 General applicom® statuses

Example in Microsoft C language

Deferred reading of bits 0 to 33 in Device number 6, from the applicom® interface channel number
1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6; nb=34, adr=0;
readdifbit(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 111 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Input bit reading => READDIFIBIT

Prototypes:

Language Prototype
C void readdifibit(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * wStatus)
MS pascal procedure readdifibit(var wChan, wNes, wNb: integer; var dwAdr: integer4; var
wStatus: integer);
C# void readdifibit(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdifibit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bits to be read (1-2048).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be read.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of input bits in a device. The different
values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred requests
being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 General applicom® statuses

Example in Microsoft C language

Deferred reading of input bits 0 to 33 in Device number 6, from the applicom® interface channel
number 1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6; nb=34, adr=0;
readdifibit(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 112 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output bit reading => READDIFQBIT

Prototypes:

Language Prototype
C void readdifqbit(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * wStatus)
MS pascal procedure readdifqbit(var wChan, wNes, wNb: integer; var wStatus: integer4;
status: integer);
C# void readdifqbit(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdifqbit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bits to be read (1-2048).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be read.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of output bits in a device. The
different values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred
requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 General applicom® statuses

Example in Microsoft C language

Deferred reading of output bits 0 to 7 in Device number 6, from the applicom® interface channel
number 0.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=0; neq=6; nb=8, adr=0;
readdifqbit(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 113 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Byte reading => READDIFBYTE

Prototypes:

Language Prototype
C void readdifbyte(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * wStatus)
MS pascal procedure readdifbyte(var wChan, wNes, wNb: integer; var wStatus: integer4;
status: integer);
C# void readdifbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdifbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be read (1-256).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be read.
wStatus 16-bit integer, Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of bytes in a device. The different
values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred requests
being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 General applicom® statuses

Example in Microsoft C language

Deferred reading of bytes 0 to 33 in Device number 6, from the applicom® interface channel
number 1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6; nb=34, adr=0;
readdifbyte(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 114 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Input byte reading => READDIFIBYTE

Prototypes:

Language Prototype
C void readdifibyte(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * wStatus)
MS pascal procedure readdifibyte(var wChan, wNes, wNb: integer; var wStatus: integer4;
status: integer);
C# void readdifibyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdifibyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be read (1-256).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be read.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of input bytes in a device. The
different values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred
requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 General applicom® statuses

Example in Microsoft C language

Deferred reading of input bytes 0 to 33 in Device number 6, from the applicom® interface channel
number 1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6; nb=34, adr=0;
readdifibyte(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 115 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output byte reading => READDIFQBYTE

Prototypes:

Language Prototype
C void readdifqbyte(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * wStatus)
MS pascal procedure readdifqbyte(var wChan, wNes, wNb: integer; var wStatus: integer4;
status: integer);
C# void readdifqbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdifqbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be read (1-256).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be read.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of output bytes in a device. The
different values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred
requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 General applicom® statuses

Example in Microsoft C language

Deferred reading of output bytes 0 to 33 in Device number 6, from the applicom® interface channel
number 1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6; nb=34, adr=0;
readdifqbyte(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 116 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Word reading => READDIFWORD

Prototypes:

Language Prototype
C void readdifword(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * wStatus)
MS pascal procedure readdifword(var wChan, wNes, wNb: integer ; var dwAdr: integer4;
var wStatus: integer)
C# void readdifword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdifword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be read (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first word to be read.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of words in a device. The different
values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred requests
being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 General applicom® statuses

Example in Microsoft C language

Deferred reading of words 0 to 33 in Device number 6, from the applicom® interface channel
number 1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6; nb=34, adr=0;
readdifword(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 117 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Input word reading => READDIFIWORD

Prototypes:

Language Prototype
C void readdifiword(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * wStatus)
MS pascal procedure readdifiword(var wChan, wNes, wNb: integer; var dwAdr: integer; var
wStatus, : integer)
C# void readdifiword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdifiword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of input words to be read (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first input word to be read.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of input words in a device. The
different values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred
requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 General applicom® statuses

Example in Microsoft C language

Deferred reading of input words 0 to 33 in Device number 6, from the applicom® interface channel
number 1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6; nb=34, adr=0;
readdifiword(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %d \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 118 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output word reading => READDIFQWORD

Prototypes:

Language Prototype
C void readdifqword(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * wStatus)
MS pascal procedure readdifqword(var wChan, wNes, wNb: integer; var dwAdr: integer; var
wStatus, : integer)
C# void readdifqword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdifqword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of output words to be read (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first output word to be read.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of output words in a device. The
different values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred
requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 General applicom® statuses

Example in Microsoft C language

Deferred reading of output words 0 to 33 in Device number 6, from the applicom® interface channel
number 1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6; nb=34, adr=0;
readdifqword(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 119 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Double word reading => READDIFDWORD

Prototypes:

Language Prototype
C void readdifdword(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * wStatus)
MS pascal procedure readdifdword(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var wStatus:integer);
C# void readdifdword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdifdword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be read (1-64).
The maximum number depends on the protocol and target device.
dwAdr Address of the first double word to be read.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of double words in a device. The
different values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred
requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 General applicom® statuses

Example in Microsoft C language

Deferred reading of 4 double words from address 20 in Device number 6, connected on the
applicom® interface channel number 1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6; nb=4, adr=20;
readdifdword(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 120 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Floating word reading => READDIFFWORD

Prototypes:

Language Prototype
C void readdiffword(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * wStatus)
MS pascal procedure readdiffword(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var wStatus: integer);
C# void readdiffword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, out short wStatus)
VB.NET Sub readdiffword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of floating words to be read (1-64).
The maximum number depends on the protocol and target device.
dwAdr Address of the first floating word to be read.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred reading of floating words in IEEE format in a
device. The different values will be fed back by the TRANSDIF or TRANSDIFPACK function. The number
of deferred requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Example in Microsoft C language

Deferred reading of 4 floating words from address 20 in Device number 6, connected on the
applicom® interface channel number 1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6; nb=4, adr=20;
readdiffword(&nchan, &neq, &nb, &adr, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 121 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Quick reading of 8 bits => READDIFQUICKBIT

Prototypes:

Language Prototype
C void readdifquickbit(short * wChan, short * wNes, short * wStatus)
MS pascal procedure readdifquickbit(var wChan, wNes, wStatus: integer);
C# void readdifquickbit(ref ushort wChan, ref ushort wNes, out short wStatus)
VB.NET Sub readdifquickbit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef
wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (1-255).
wStatus Status of acceptance by the deferred function manager.

Description:

This specific function allows the quick reading of 8 bits managed by Jbus protocol (Jbus function
code = 7). The different values will be fed back by the TRANSDIF or TRANSDIFPACK function. The
number of deferred requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Example in Microsoft C language

Quick reading of 8 bits in Jbus Device number 6, connected on the applicom® interface channel
number 1.

#include "applicom.h" /* Prototype declaration type */


short nchan; /* Channel number */
short neq; /* Device number */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=1; neq=6;
readdifquickbit(&nchan, &neq, &status);
printf(" Status = %hd \n", status);
}
/* execute the "exitbus" function before quitting */
exit(0);
}

Library/DLL 122 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Writing
Bit writing => WRITEDIFPACKBIT

Prototypes:

Language Prototype
C void writedifpackbit(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * lpwTabl, short * wStatus)
MS pascal procedure writedifpackbit(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var lpwTabl, wStatus: integer);
C# void writedifpackbit(ref ushort wChan, ref ushort wNes, ref short wNb, ref
int dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writedifpackbit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bits to be written (1-2048).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be written.
lpwTabl Table containing the data.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred writing of bits in a device. The different
values are stored in the integer table called lpwTabl in “packed” mode (16 bits per integer). The writing
report will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred requests
being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Library/DLL 123 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of bits 20 to 30 in Device number 4, from the applicom® interface channel number 2.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
short status; /* Status */
long adr; /* First variable address */
short tabl[1]; /* Table containing the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
{
nchan=2; neq=4; nb=11; adr=20;
tabl[0] = 0x07FF;
writedifpackbit(&nchan, &neq, &nb, &adr, tabl, &status);
if(status == 41)
printf(" !! Defect: the deferred request register is full \n");
}
.
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 124 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output bit writing => WRITEDIFPACKQBIT

Prototypes:

Language Prototype
C void writedifpackqbit(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * lpwTabl, short * wStatus)
MS pascal procedure writedifpackqbit(var wChan, wNes, wNb: integer; var dwAdr:
integer4; var lpwTabl, wStatus: integer);
C# void writedifpackqbit(ref ushort wChan, ref ushort wNes, ref short wNb, ref
int dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writedifpackqbit(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb
As Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bits to be written (1-2048).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be written.
lpwTabl Table containing the data.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred writing of bits in a device. The different
values are stored in the integer table called lpwTabl in “packed” mode (16 bits per integer). The writing
report will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of deferred requests
being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Library/DLL 125 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting ot 1 of output bits 20 to 30 in Device number 4, from the applicom® interface channel
number 2.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
short status; /* Status */
long adr; /* First variable address */
short tabl[1]; /* Table containing the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
{
nchan=2; neq=4; nb=11; adr=20;
tabl[0] = 0x07FF;
writedifpackqbit(&nchan, &neq, &nb, &adr, tabl, &status);
if(status == 41)
printf(" !! Defect: the deferred request register is full \n");
}
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 126 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Byte writing => WRITEDIFPACKBYTE

Prototypes:

Language Prototype
C void writedifpackbyte(short * wChan, short * wNes, short * wNb, long* dwAdr,
char * lpcTabl, short * wStatus)
MS pascal procedure writedifpackbyte(var wChan,wNesnwNb,dwAdrnlpcTabl:integer;var
wStatus:integer4; var tabl : byte; var status : integer)
C# void writedifpackbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref
int dwAdr, sbyte[] lpcTabl, out short wStatus)
VB.NET Sub writedifpackbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb
As Short, ByRef dwAdr As Integer, ByVal lpcTabl() As SByte, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be written (1-256).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be written.
lpcTabl Table containing the data to be written.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function can be used to write bytes in a device. The different values are
stored in the byte table called lpcTabl.
The writing report will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of
deferred requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Library/DLL 127 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 255 of bytes 20 and 21 in Device number 4, from the applicom® interface channel
number 2.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
short status; /* Status */
long adr; /* First variable address */
char tabl[2]; /* Table containing the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
{
nchan=2; neq=4; nb=2; adr=20;
tabl[0] = 255;
tabl[1] = 255;
writedifpackbyte(&nchan, &neq, &nb, &adr, tabl, &status);
if(status == 41)
printf(" !! Defect: the deferred request register is full \n");
}
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 128 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output byte writing => WRITEDIFPACKQBYTE

Prototypes:

Language Prototype
C void writedifpackqbyte(short * wChan, short * wNes, short * wNb, long* dwAdr,
char * lpcTabl, short * wStatus)
MS pascal procedure writedifpackqbyte(var wChan,wNesnwNb,dwAdrnlpcTabl:integer;var
wStatus:integer4; var tabl : byte; var status : integer)
C# void writedifpackqbyte(ref ushort wChan, ref ushort wNes, ref short wNb, ref
int dwAdr, sbyte[] lpcTabl, out short wStatus)
VB.NET Sub writedifpackqbyte(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb
As Short, ByRef dwAdr As Integer, ByVal lpcTabl() As SByte, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of bytes to be written (1-256).
The maximum number depends on the protocol and target device.
dwAdr Address of the first bit to be written.
lpcTabl Table containing the data to be written.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred writing of output bytes in a device. The
different values are stored in the byte table called lpcTabl.
The writing report will be fed back by the TRANSDIF or TRANSDIFPACK function. The number of
deferred requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Library/DLL 129 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 255 of output bytes 20 and 21 in Device number 4, from the applicom® interface channel
number 2.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
short status; /* Status */
long adr; /* First variable address */
char tabl[2]; /* Table containing the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
{
nchan=2; neq=4; nb=2; adr=20;
tabl[0] = 255;
tabl[1] = 255;
writedifpackqbyte(&nchan, &neq, &nb, &adr, tabl, &status);
if(status == 41)
printf(" !! Defect: the deferred request register is full \n");
}
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 130 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Word writing => WRITEDIFWORD

Prototypes:

Language Prototype
C void writedifword(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * lpwTabl, short * wStatus)
MS pascal procedure writedifword(var wChan, wNes, wNb: integer; var dwAdr: integer4;
var lpwTabl, wStatus: integer);
C# void writedifword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writedifword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be written (1-128).
(the maximum number depends on the protocol and target device).
dwAdr Address of the first word to be written.
lpwTabl Table containing the data
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred writing of words in a device. The different
values are stored in the integer table called lpwTabl. The writing report will be fed back by the TRANSDIF
or TRANSDIFPACK function. The number of deferred requests being run by applicom® interface is limited
to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Library/DLL 131 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Deferred writing of words 20 to 30 of Device number 1, connected on the applicom® interface


channel number 0.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short tabl[11]; /* Table containing the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; neq=1; nb=11; adr=20;
for (i=0; i<nb; i++)
{
printf("\n value of word %ld ?",adr+i);
scanf(" %hd ", &tabl[i] );
}
writedifword(&nchan, &neq, &nb, &adr, tabl, &status);
if (status != 0)
{
printf(" !! Defect: Deferred request not accepted \n");
}
else
{
}
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 132 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Output word writing => WRITEDIFQWORD

Prototypes:

Language Prototype
C void writedifqword(short * wChan, short * wNes, short * wNb, long * dwAdr,
short * lpwTabl, short * wStatus)
MS pascal procedure writedifqword(var wChan, wNes, wNb: integer; var dwAdr: integer4
;var lpwTabl, wStatus: integer);
C# void writedifqword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writedifqword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of words to be written (1-128).
The maximum number depends on the protocol and target device.
dwAdr Address of the first word to be written.
lpwTabl Table containing the data
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred writing of output words in a device. The
different values are stored in the integer table called lpwTabl. The writing report will be fed back by the
TRANSDIF or TRANSDIFPACK function. The number of deferred requests being run by applicom®
interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Library/DLL 133 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Deferred writing of output words 20 to 30 from Device number 1, connected on the applicom®
interface channel number 0.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
short tabl[11]; /* Table containing the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; neq=1; nb=11; adr=20;
for (i=0; i<nb; i++)
{
printf("\n value of word %ld ?",adr+i);
scanf(" %hd ", &tabl[i] );
}
writedifqword(&nchan, &neq, &nb, &adr, tabl, &status);
if (status != 0)
{
printf(" !! Defect: Deferred request not accepted \n");
}
else
{
}
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 134 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Double word writing => WRITEDIFDWORD

Prototypes:

Language Prototype
C void writedifdword(short * wChan, short * wNes, short * wNb, long * dwAdr,
long * lpwTabl, short * wStatus)
MS pascal procedure writedifdword(var wChan, wNes, wNb: integer; var dwAdr, lpwTabl:
integer4; var wStatus:integer);
C# void writedifdword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, short[] lpwTabl, out short wStatus)
VB.NET Sub writedifdword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of double words to be written (1-64).
The maximum number depends on the protocol and target device.
dwAdr Address of the first double word to be written.
lpwTabl Table containing the data.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred writing of double words in a device. The
different values are stored in the Table called lpwTabl. The writing report will be fed back by the
TRANSDIF or TRANSDIFPACK function. The number of deferred requests being run by applicom®
interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Library/DLL 135 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Deferred writing of 11 double words from address 20 in Device number 1, connected on the
applicom® interface channel number 0.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
long tabl[11]; /* Table containing the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; neq=1; nb=11; adr=20;
for (i=0; i<nb; i++)
{
printf("\n value of double word %ld ?",adr+i);
scanf(" %ld ", &tabl[i] );
}
writedifdword(&nchan, &neq, &nb, &adr, tabl, &status);
if (status != 0)
{
printf(" !! Defect: Deferred request not accepted \n");
}
else
{
}
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 136 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Floating word writing => WRITEDIFFWORD

Prototypes:

Language Prototype
C void writediffword(short * wChan, short * wNes, short * wNb, long * dwAdr,
float * lpwTabl, short * wStatus)
MS pascal procedure writediffword(var wChan,wNesnwNb,dwAdrnlpwTabl:integer;var wStatus:
integer4;var tabl:real; var status:integer)
C# void writediffword(ref ushort wChan, ref ushort wNes, ref short wNb, ref int
dwAdr, float[] lpwTabl, out short wStatus)
VB.NET Sub writediffword(ByRef wChan As UShort, ByRef wNes As UShort, ByRef wNb As
Short, ByRef dwAdr As Integer, ByVal lpwTabl() As Single, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNes Device number (0-255).
wNb Number of floating words to be written (1-64).
The maximum number depends on the protocol and target device.
dwAdr Address of the first floating word to be written.
lpwTabl Table containing the data.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the deferred writing of floating words in IEEE format in a
device. The different values are stored in the 32-bit real table called lpwTabl. The writing report will be fed
back by the TRANSDIF or TRANSDIFPACK function. The number of deferred requests being run by
applicom® interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Library/DLL 137 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Deferred writing of 11 floating words from address 20 in Device number 1, connected on the
applicom® interface channel number 0.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* First variable address */
float tabl[11]; /* Table containing the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; neq=1; nb=11; adr=20;
for (i=0;i<nb;i++)
{
printf("\n value of floating word %ld ?",adr+i);
scanf(" %f ", &tabl[i] );
}
writediffword(&nchan, &neq, &nb, &adr, tabl, &status);
if (status != 0)
{
printf(" !! Defect: Deferred request not accepted \n");
}
else
{
}
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 138 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


“Ports without protocol” functions
Message reception => READDIFMES

Prototypes:

Language Prototype
C void readdifmes(short * wChan, short * wStop, short * wNbRx, short *
wTimeOut, short * wTimeOut_ic, short * wStatus)
MS pascal procedure readdifmes(var wChan, wStop, wNbRx, wTimeOut, wTimeOut_ic, wStatus:
integer);
C# void readdifmes(ref ushort wChan, ref short wStop, ref short wNbRx, ref short
wTimeOut, ref short wTimeOut_ic, out short wStatus)
VB.NET Sub readdifmes(ByRef wChan As UShort, ByRef wStop As Short, ByRef wNbRx As
Short, ByRef wTimeOut As Short, ByRef wTimeOut_ic As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wStop Contains up to two ASCII characters. The message end will be
detected on one of these 2 characters.
- if wStop = -1, stop character management is inactive.
wNbRx Number of characters to be received (1 to 256).
wTimeOut Time-out (0 to 65535 ms)
- If wTimeOut = 0, time-out is inactive.
wTimeOut_ic Inter-character time-out (0 to 4000 ms).
- If wTimeOut_ic = 0, inter-character time-out is inactive.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function can be used to receive in deferred mode a frame on a channel of
the applicom® interface. The different values will be fed back by the TRANSDIF or TRANSDIFPACK
function. The number of deferred requests being run by applicom® interface is limited to 64.
When time-out is inactive (wTimeOut = 0), the channel remains locked in reception until the arrival
of at least 1 character. From that moment, time-out is inhibited and the inter-character time-out is
activated. The exit in reception will take place either:
- on number of received characters (wNbRx).
- on stop character, if its value differs from -1.
- on wTimeOut_ic, if its value differs from 0.

Notes:

3964/3964Rprotocol, free messaging:


¾ This function can be used to retrieve an information block from the channel buffer memory.
¾ So that the channel can receive the information blocks and store them in its buffer memory,
you must first execute the “AppConnect” function.
¾ wStop and wTimeOut_ic parameters are non significant.

Library/DLL 139 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 Connection or reservation => AppConnect
9 Disconnection or dereservation => AppUnconnect

Example in Microsoft C language

Deferred reception on the applicom® interface channel 0. The reception end will be detected on the
LF (h'0A') ASCII character. No time-out nor inter-character time-out management.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short stop; /* End character */
short nb; /* Number of variables */
short tim_out; /* Inter-character time-out */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; stop = 0x0A0A; nb=256; tim_out =0; tim_ic=0;
readdifmes(&nchan, &stop, &nb, &tim_out, &tim_ic, &status);
if (status != 0)
printf(" !! Defect: Deferred request not accepted \n");
else
{
}
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 140 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Message transmission => WRITEDIFMES

Prototypes:

Language Prototype
C void writedifmes(short * wChan, short * wNbTx, char * byTablRx, short *
wStatus)
MS pascal procedure writedifmes(var wChan, wNbTx: integer; var byTablRx: byte; var
wStatus:integer);
C# void writedifmes(ref ushort wChan, ref short wNbTx, sbyte[] byTablRx, out
short wStatus)
VB.NET Sub writedifmes(ByRef wChan As UShort, ByRef wNbTx As Short, ByVal byTablRx()
As SByte, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNbTx Number of characters to be sent (1-256).
byTablRx Table containing the message.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function allows the transmission in deferred mode of a frame on a
channel of the applicom® interface. The message stored in the byte table called byTablRx is transmitted
without interpretation. The transmission report will be fed back by the TRANSDIF or TRANSDIFPACK
function. The number of deferred requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Library/DLL 141 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Transmission in deferred mode of the message: “DRAINING PUMP FAULT !!” to the Device
connected on the applicom® interface channel 0.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short nb; /* Number of variables */
char tabl[26]; /* Table containing the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; nb=26;
strcpy(tabl,"DRAINING PUMP FAULT !!");
writedifmes(&nchan, &nb, tabl, &status);
if (status != 0)
printf(" !! Defect: Deferred request not accepted \n");
else
{
}
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 142 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Message transmission and reception => WRITEREADDIFMES

Prototypes:

Language Prototype
C void writereaddifmes(short * wChan, short * wNbTx, char * byTablTx, short *
wStop, short * wNbRx, short * wTimeOut, short * wTimeOut_ic, short * wStatus)
MS pascal procedure writereaddifmes(var wChan, wNbTx:integer; var byTablTx: byte; var
wStop, wNbRx, wTimeOut, wTimeOut_ic, wStatus: integer)
C# void writereaddifmes(ref ushort wChan, ref short wNbTx, sbyte[]byTablTx, ref
short wStop, ref short wNbRx, ref short wTimeOut, ref short wTimeOut_ic, out
short wStatus)
VB.NET Sub writereaddifmes(ByRef wChan As UShort, ByRef wNbTx As Short, ByVal
byTablTx() As SByte, ByRef wStop As Short, ByRef wNbRx As Short, ByRef
wTimeOut As Short, ByRef wTimeOut_ic As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNbTx Number of characters to be sent (1-256).
byTablTx Byte table containing the message to be sent.
wStop Contains up to two ASCII characters The message end will be
detected on one of these 2 characters.
- If wStop = -1, stop character management is inactive.
wNbRx Number of characters to be received (1 to 256).
wTimeOut Time-out (0 to 65535 ms).
- If wTimeOut = 0, time-out is inactive.
wTimeOut_ic Inter-character time-out (0-4000 ms).
- If wTimeOut_ic = 0, inter-character time-out is inactive.
wStatus Status of acceptance by the deferred function manager.

Description:

This applicom® standard function can be used to transmit then receive a frame in deferred mode
on a channel of the applicom® interface. The message to be sent is stored in the byte table called
byTablTx.
The transmission/reception report as well as the received data will be fed back by the TRANSDIF or
TRANSDIFPACK function. The number of deferred requests being run by applicom® interface is limited to
64.
When time-out is inactive (wTimeOut = 0), the channel remains locked in reception until the arrival
of at least 1 character. From that moment, the time-out is inhibited and the inter-character time-out is
activated. The exit in reception will take place either:
¾ on number of received characters (wNbRx).
¾ on wStop character, if its value differs from -1.
¾ on wTimeOut_ic, if its value differs from 0.

Notes:

3964/3964R protocol, free messaging:


¾ The “READ” part of this function can be used to retrieve an information block from the
channel buffer memory. So that the channel can receive the information blocks and store
them in the buffer memory, you must first execute the “AppConnect” function.
¾ wStop and wTimeOut_ic parameters are non significant.

Library/DLL 143 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK
9 Connection or reservation => AppConnect
9 Disconnection or dereservation => AppUnconnect

Example in Microsoft C language

Transmission in deferred mode of the message: “DRAINING PUMP FAULT !!” to the Device
connected on the applicom® interface channel 0. Then character reception for 3 seconds.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short nbtx; /* Number of characters to be transmitted */
char tabltx[26]; /* Table containing the data to be transmitted */
short stop; /* Reception end character */
short nbrx; /* Number of characters to be received */
short tim; /* Time-out */
short tim_ic; /* Inter-character time-out */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; nbtx=26; stop=-1; nbrx=1; tim=3000, tim_ic=0;
strcpy(tabltx,"DRAINING PUMP FAULT !!");
writereaddifmes(&nchan, &nbtx, tabltx, &stop, &nbrx, &tim, &tim_ic, &status);
if (status != 0)
printf(" !! Defect: Deferred request not accepted \n");
else
{
}
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 144 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Open function
Free access to messaging => AuWriteReadDifMsg

Prototypes:

Language Prototype
C BOOL AuWriteReadDifMsg (unsigned short wChan, unsigned short wNeq, unsigned
long dwMsgParam, unsigned short wNbTx, unsigned char* byBufTx, unsigned long
* dwStatus);
C# bool AuWriteReadDifMsg(ref ushort wChan, ref ushort wNeq, ref int dwMsgParam,
ref short wNbTx, sbyte[]byBufTx, out int dwStatus)
VB.NET Function AuWriteReadDifMsg(ByRef wChan As UShort, ByRef wNeq As UShort, ByRef
dwMsgParam As Integer, ByRef wNbTx As Short, ByVal byBufTx() As SByte, ByRef
dwStatus As Integer) As Boolean

Parameters

Parameter Type
wChan Channel number (0-31).
wNeq Device number (0-255).
dwMsgParam Messaging parameter.
wNbTx Number of bytes sent.
byBufTx Message or command to be sent.
dwStatus Recognition status from differed function manager.

Description:
This function enables direct access to messaging in differed mode for certain protocols.
Therefore, prior to use, you should consult the users' manual for your protocol to determine if this
function is supported.
The send/receive report and the data received will be returned by the TRANSDIF or
TRANSDIFPACK function. The number of differed requests being executed by the applicom®
interface is limited to 64.
Caution: Data recovery via the TRANSDIF or TRANSDIFPACK functions involves some special
features.

Value returned:
TRUE if OK. If this function returns FALSE in the event of an error, refer to the dwStatus variable
for more information.

See also:
¾ In this manual:
9 General applicom® statuses
9 Differed transfer in unpacked format => TRANSDIF
9 Differed transfer in packed format => TRANSDIFPACK

Library/DLL 145 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Differed request transfer
Differed transfer in unpacked format => TRANSDIF

Prototypes:

Language Prototype
C void transdif(short * wChan, short * pwNb, short * pwTyp, void * lpdwTabl,
short * wStatus)
MS pascal procedure transdif(var wChan, pwNb, pwTyp: integer; var lpdwTabl: integer4;
var wStatus: integer);
C# void transdif(ref ushort wChan, out short pwNb, out short pwTyp, int[]
lpdwTabl, out short wStatus)
VB.NET Sub transdif(ByRef wChan As UShort, ByRef pwNb As Short, ByRef pwTyp As
Short, ByVal lpdwTabl() As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
pwNb Number of variable transferred.
pwTyp Indicates returned variable type.
1 = Bit.
2 = Byte.
3 = 16 bit integer.
4 = 32 bit integer.
5 = 32 bit floating.
lpdwTabl Data reception table.
wStatus Error status.

Description:

This function enables you to view the result of a differed request.


Following a differed read request (or message reception), the variables will be arrayed in the
unpacked format, with one variable assigned to each 32 bit element of the lpdwTabl table.

Following a differed write request (or message transmission), no data will be transferred, and the
wStatus argument will be equal to –1 if the exchange was OK.
If TRANSDIF is used when the differed request has not yet been performed, status –5 will be
returned.
If you use TRANSDIF when there are no more differed requests underway, status 42 will be
returned.

Remark:

When using this function as part of data recovery after the AuWriteReadDifMsg function has been
called up, you must use the pwNb parameter to indicate the maximum size of the byte table that can be
returned by the function.
If the recovered byte table is larger than the pwNb parameter, status 74 will be returned.

Library/DLL 146 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


See also:
¾ In this manual:
9 Free access to messaging => AuWriteReadDifMsg
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft language C

Differed read of word 20 on device 1 and then word 30 on device 2, which are connected to channel
no. 0 of the applicom® interface. Then, results are transferred.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* Address of the first variable */
short typ; /* Type of variables */
long tablong[10]; /* Array containing the data */
short status; /* Status */

main()
{
/* initialize the dialogue with the applicom® product by "initbus" */
{
nchan=0; neq=1; nb=1; adr=20;
readdifword(&nchan, &neq, &nb, &adr, &status);
if (status != 0)
printf(" !! Default: Differed request not recognized \n");
else
{
neq=2; adr=30;
readdifword(&nchan, &neq, &nb, &adr, &status);
if (status != 0)
printf(" !! Default: Differed request not recognized \n");
else
{
do
{
do
{
transdif(&nchan, &nb, &typ, tablong, &status);
}
while(status == -5);
switch(status)
{
case 0: /* Read OK */
for(i=0; i<nb; i++) printf("%ld \n" ; tablong[i]);
break;
case -1: /* Write OK */
printf("WRITE OK \n");
break;
case 42:
printf("NO MORE DIFFERED REQUESTS \n");
break;
default: /* Exchange not OK */
printf("EXCHANGE NOT OK ON CHANNEL %hd STATUS %hd \n", nchan, status);
}
}
while(status != 42);
}
}
}
/* execute the "exitbus" function before exiting */
exit(0);
}

Library/DLL 147 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Differed transfer in packed format => TRANSDIFPACK

Prototypes:

Language Prototype
C void transdifpack(short * wChan, short * pwNb, short * pwTyp, void *
lpdwTabl, short * wStatus)
MS pascal procedure transdifpack(var wChan, pwNb, pwTyp, lpdwTabl, wStatus: integer)
C# void transdifpack(ref ushort wChan, out short pwNb, out short pwTyp, int[]
lpdwTabl, out short wStatus)
VB.NET Sub transdifpack(ByRef wChan As UShort, ByRef pwNb As Short, ByRef pwTyp As
Short, ByVal lpdwTabl() As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
pwNb Number of variable transferred.
pwTyp Indicates nature of the returned variables.
1 = Bit.
2 = Byte.
3 = 16 bit integer.
4 = 32 bit integer.
5 = 32 bit floating.
lpdwTabl Data reception table.
wStatus Error status.

Description:

This function enables you to view the result of a differed request.


Following a differed read request (or message reception), the variables will be arrayed in the
packed format in the lpdwTabl table. Data (bits, bytes, words and double words) are arrayed in memory
according to contiguous addresses without type interpretation.

Following a differed write request (or message transmission), no data will be transferred, and the
wStatus argument will be equal to –1 if the exchange was OK.
If TRANSDIFPACK is used when the differed request has not yet been performed, status –5 will be
returned.
If you use TRANSDIFPACK when there are no more differed requests underway, status 42 will be
returned.

Remark:

When using this function as part of data recovery after the AuWriteReadDifMsg function has been
called up, you must use the pwNb parameter to indicate the maximum size of the byte table that can be
returned by the function.
If the recovered byte table is larger than the pwNb parameter, status 74 will be returned.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 148 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft language C

Differed read of 10 words from address 20 on device 1 and then on device 2, which are connected
to channel no. 0 of the applicom® interface. Then, results are transferred.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short neq; /* Device number */
short nb; /* Number of variables */
long adr; /* Address of the first variable */
short typ; /* Type of variables */
short tabl[10]; /* Array containing the data */
short status; /* Status */

main()
{
/* initialize the dialogue with the applicom® product by "initbus" */
{
nchan=0; neq=1; nb=10; adr=20;
readdifword(&nchan, &neq, &nb, &adr, &status);
if (status != 0)
printf(" !! Default: Differed request not recognized \n");
else
{
neq=2;
readdifword(&nchan, &neq, &nb, &adr, &status);
if (status != 0)
printf(" !! Default: Differed request not recognized \n");
else
{
do
{
do
{
transdifpack(&nchan, &nb, &typ, tabl, &status);
}
while(status == -5);
switch(status)
{
case 0: /* Read OK */
for(i=0; i<nb; i++) printf("%hd \n" ; tabl[i]);
break;
case -1: /* Write OK */
printf("WRITE OK \n");
break;
case 42:
printf("NO MORE DIFFERED REQUESTS \n");
break;
default: /* Exchange not OK */
printf("EXCHANGE NOT OK ON CHANNEL %hd STATUS %hd \n", nchan, status);
}
}
while(status != 42);
}
}
}
/* execute the "exitbus" function before exiting */
exit(0);
}

Library/DLL 149 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Deferred request test => TESTTRANSDIF

Prototypes:

Language Prototype
C void testtransdif(short * wChan, short * wNb1, short * wNb2, short * wStatus)
MS pascal procedure testtransdif(var wChan, wNb1, wNb2, wStatus: integer)
C# void testtransdif(ref ushort wChan, out short wNb1, out short wNb2, out short
wStatus)
VB.NET Sub testtransdif(ByRef wChan As UShort, ByRef wNb1 As Short, ByRef wNb2 As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNb1 Number of deferred requests in progress
wNb2 Number of deferred requests performed.
wStatus Error status

Description:

This function can be used to know the number of deferred request in progress and the number of
deferred requests performed.
The number of deferred requests being run by applicom® interface is limited to 64.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Displays the state of the deferred requests of the applicom® interface channel 0.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short nb1; /* Number of requests */
short nb2; /* Number of requests performed */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=0;
testtransdif(&nchan, &nb1, &nb2, &status);
if (status == 0)
{
printf("Requested deferred function(s) : %hd \n ", nb1);
printf("Performed deferred function(s) : %hd \n ", nb2);
}
else
{
}
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 150 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


7. Cyclic mode functions

Cyclic function creation => CREATECYC

Prototypes:

Language Prototype
C void createcyc(short * wChan, short * wFonc, short * wPer, short * wAct,short
* wTypf, short * wCodedb, short * wNes, short * wNb, long * dwAdrl, short *
wAdrdb, short * wAdrstat,short * wStatus)
MS pascal procedure createcyc(var wChan, wFonc, wPer, wAct, wTypf, wCodedb, wNes, wNb :
integer; var dwAdrl : integer4; var wAdrdb, wAdrstat, wStatus :integer);
C# void createcyc(ref ushort wChan, ref short wFonc, ref short wPer, ref short
wAct, ref short wTypf, ref short wCodedb, ref ushort wNes, ref short wNb, ref
int dwAdrl, ref short wAdrdb, ref short wAdrstat, out short wStatus)
VB.NET Sub createcyc(ByRef wChan As UShort, ByRef wFonc As Short, ByRef wPer As
Short, ByRef wAct As Short, ByRef wTypf As Short, ByRef wCodedb As Short,
ByRef wNes As UShort, ByRef wNb As Short, ByRef dwAdrl As Integer, ByRef
wAdrdb As Short, ByRef wAdrstat As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wFonc Cyclic function number (1-255)
(1-100 for GT4000 box).
wPer Desired activation period expressed as a multiple of 100 milliseconds (0-65535).
- If wPer = 0 : Functions are chained without rotational delay time.
wAct Indicates the function state after CREATECYC
wAct = 0, Non active function (will require STARTCYC to be activated).
wAct = 1, Active function after CREATECYC execution.
wTypf Interchange type selection code.
Type of variable in Function type (wTypf)
the device Reading Writing
Decimal Hex Decimal Hex
Bits 4099 1003 4105 1009
Input bits 4100 1004
Output bits 4186 105A 4187 105B
Quick rdg/wtg of 8 bits 4109 100D

Packed bytes 4190 105E 4192 1060


Bytes 4191 105F 4193 1061
Packed input bytes 4200 1068
Input bytes 4201 1069
Packed output bytes 4202 106A 4204 106C
Output bytes 4203 106B 4205 106D

Words 4101 1005 4106 100A


BCD words 4194 1062 4195 1063
Input words 4102 1006
Output words 4197 1065 4198 1066

32-bit double words 4103 1007 4107 100B


IEEE floating words 4104 1008 4108 100C
wCodedb Type of read or forced DATA BASE variables.
1 - Bit
2 - Byte
3 - 16-bit integer
4 - 32-bit integer
5 - 32-bit IEEE floating
wNes Device number (0-255).
wNb Number of accessed variables in the Device.

Library/DLL 151 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


dwAdrl First variable address in the Device.
wAdrdb First variable address in DATA-BASE.
The areas whose addresses are greater than 31999 have special assignments.
wAdrstat Storage address of the cyclic function status word in DATABASE.
- If wAdrstat = -1, the status is not copied into DATABASE.
wStatus Cyclic function creation status.

Description:

When the applicom® communication product is initialized, PCINIT.EXE activates command


LOADCYC which transfers the cyclic function configuration of files called CONFCYC.AP1 to
CONFCYC.AP8 into the applicom® interfaces (1 to 8). These functions can be modified or created
dynamically by the user program.
If the wTypf interchange type is not correct, the status will equal 1 and the function will not be
modified.
If wTypf is equal to 0, the cyclic function will be destroyed.

Notes:

Jbus / Modbus protocol:


¾ A master counter reading function can be created if wTypf = 4123 (101B H). In that case,
the dwAdrl parameter is ignored and wNb is limited to 10 (5 words per slave and therefore 2
slaves maximum).
¾ When the 8-bit quick reading function is created, the dwAdrl parameter is ignored.

Uni-Te protocol:
¾ The dwAdrl address argument is coded on 32 bits. The coding of the 16 most significant
bits allows the access to specific segments and objects types (NUM).

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 152 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Creation of cyclic function no. 52 on channel 2 to read 10 words from address 24 in Device no. 12.
The interchange rate is one second and variables will be stored in the applicom® interface “word” data
base from address 100. The function must be activated as soon as the subroutine is executed and the
cyclic interchange status will be stored at address 110.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short nfonc; /* cyclic function number */
short per; /* refreshing period */
short act; /* cyclic function activation or not */
short typf; /* . */
short vardb; /* type of variable in data-base */
short neq; /* slave number */
short nb; /* number of variables to be interchanged */
long adreq; /* address in the slave */
short adrdb; /* address in data-base */
short adrstat; /* status address in data-base */
short status; /* status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan = 2; /* Channel number */
nfonc = 52; /* Function number */
per = 10; /* 1-second period */
act = 1; /* function activation */
typf = 0x1005; /* Word reading function */
vardb = 3; /* DATA BASE word area */
neq = 12; /* Slave number 12 */
nb = 10; /* 10 variables */
adreq = 24; /* Reading at address 24 of the slave */
adrdb = 100; /* Result of DATA-BASE address 100 */
adrstat = 110; /* No status copy into DATA BASE */
createcyc( &nchan, &nfonc, &per, &act, &typf, &vardb, &neq, &nb, &adreq,
&adrbd, &adrstat, &status );
swicth(status)
{
case 0 :
printf(" function creation: OK !!");
break;
case 4 :
printf(" Function creation NOK, First stop the function ");
break;
default :
printf(" Function creation NOK, Status = %hd", status);
}
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 153 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Cyclic function start => STARTCYC

Prototypes:

Language Prototype
C void startcyc(short * wChan, short * wFonc, short * wStatus)
MS pascal procedure startcyc(var wChan, wFonc, wStatus: integer);
C# void startcyc(ref ushort wChan, ref short wFonc, out short wStatus)
VB.NET Sub startcyc(ByRef wChan As UShort, ByRef wFonc As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wFonc Cyclic function number (1-255).
wStatus Error Status

Description:

This function starts a cyclic function

See also:
¾ In this manual:
9 General applicom® statuses

Example in Microsoft C language

Initiation of cyclic function no. 1 of the applicom® interface channel 0.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short fonc; /* Function number */
short status; /* status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=0; fonc=1;
startcyc( &nchan, &fonc, &status );
if(status == 0)
printf(" Function %hd of channel %hd active \n ", fonc, nchan);
else
{
}
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 154 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Cyclic function stop => STOPCYC

Prototypes:

Language Prototype
C void stopcyc(short * wChan, short * wFonc, short * wStatus)
MS pascal procedure stopcyc(var wChan, wFonc, wStatus: integer);
C# void stopcyc(ref ushort wChan, ref short wFonc, out short wStatus)
VB.NET Sub stopcyc(ByRef wChan As UShort, ByRef wFonc As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wFonc Cyclic function number (1-255).
wStatus Error Status.

Description:

This function stops a cyclic function.

See also:
¾ In this manual:
9 General applicom® statuses

Example in Microsoft C language

Stop of cyclic function no. 1 of the applicom® interface channel 0.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short fonc; /* Function number */
short status; /* status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nchan=0; fonc=1;
stopcyc( &nchan, &fonc, &status );
if(status == 0)
printf(" Stopped function %hd of channel %hd active \n ", fonc, nchan);
else
{
}
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 155 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


One-off activation => ACTCYC

Prototypes:

Language Prototype
C void actcyc(short * wChan, short * wFonc, short * wStatus)
MS pascal procedure actcyc(var wChan, wFonc, wStatus: integer);
C# void actcyc(ref ushort wChan, ref short wFonc, out short wStatus)
VB.NET Sub actcyc(ByRef wChan As UShort, ByRef wFonc As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wFonc Cyclic function number (1-255).
wStatus Error status

Description:

This function starts a cyclic function in a one-off way. A single interchange is performed by
executing function ACTCYC.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

Activation of cyclic function no. 1 of the applicom® interface channel 0.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short fonc; /* Function number */
short status; /* status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=0; fonc=1;
actcyc( &nchan, &fonc, &status );
if(status == 0)
printf(" Function %hd of channel %hd activated once \n ", fonc, nchan);
else
{
}
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 156 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Cyclic request transfer
Cyclic transfer in unpacked format => TRANSCYC

Prototypes:

Language Prototype
C void transcyc(short * wChan, short * wFonc, short * wNb, short * wTyp, void *
lpdwTabl, short * wStatus)
MS pascal procedure transcyc(var wChan, wFonc, wNb, wTyp: integer; var lpdwTabl:
integer4; var wStatus:integer)
C# void transcyc(ref ushort wChan, ref short wFonc, out short wNb, out short
wTyp, int[] lpdwTabl, out short wStatus)
VB.NET Sub transcyc(ByRef wChan As UShort, ByRef wFonc As Short, ByRef wNb As Short,
ByRef wTyp As Short, ByVal lpdwTabl() As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wFonc Cyclic function number (1-255).
wNb Returned by the function. Number of transferred variables.
wTyp Returned by the function. Indicates the type of returned variables.
1 = Bit.
2 = Byte.
3 = 16-bit integer.
4 = 32-bit integer.
5 = 32-bit floating.
lpdwTabl Table receiving the data.
wStatus Error status.

Description:

This function can be used to query the result of a cyclic function.


When TRANSCYC is called, data are retrieved in the applicom® interface data base. This implies
that if a cyclic function stores variables in the data base, an external master or the PC program can also
modify these variables. TRANSCYC will then return the last set values.
If TRANSCYC is used for a function that has never been activated, status 35 will be returned and
no data will be transfered.
If TRANSCYC is used for a function that is no longer activated, status -6 will be returned and the
data will be transfered.
After the result of a reading cyclic function has been transfered, variables will be stored in unpacked
format in the table called lpdwTabl (one variable per table 32-bit item). The returned value interpretation
depends on wTyp (bit, byte, word, double word or floating word). The variable format must be taken into
account by the application program.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 157 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Cyclic function result transfer. The channel number, as well as the function number are keyed in.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nchan; /* Channel number */
short fonc; /* Function number */
short nb; /* Number of variables */
short typ; /* Type of variables */
long tablong[2048]; /* Table which contains the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
printf("Cyclic function TRANSFER \n ");
printf("Channel number : \n"); scanf(" %hd", &nchan);
printf("Function number : \n"); scanf(" %hd", &fonc);
transcyc(&nchan, &fonc, &nb, &typ, tablong, &status);
printf("transcyc status = %d\n",status);
if ( status <= 0 )
{
printf(" %d ",nb);
switch (typ)
{
case 1 :
printf("bit(s)\n");
for (i=0 ; i<nb ; i++) printf("%ld ",tablong[i]);
break;
case 2 :
printf("byte(s)\n");
for (i=0 ; i<nb ; i++) printf("%ld ",tablong[i]);
break;
case 3 :
printf("word(s)\n");
for (i=0 ; i<nb ; i++) printf("%ld ",tablong[i]);
break;
case 4 :
printf("double word(s)\n");
for (i=0 ;i<nb ; i++) printf ("%ld ",tablong[i]);
break;
case 5 :
printf("floating word(s)\n");
for ( i=0 ; i<nb ; i++ )printf("%f ",*(float *)&tablong[i]);
break;
default : break;
}
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 158 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Cyclic transfer in packed format => TRANSCYCPACK

Prototypes:

Language Prototype
C void transcycpack(short * wChan, short * wFonc, short * wNb, short * pwTyp,
void * lpdwTabl, short * wStatus)
MS pascal procedure transcycpack(var wChan, wFonc, wNb, pwTyp: integer; var lpdwTabl:
byte; wStatus: integer)
C# void transcycpack(ref ushort wChan, ref short wFonc, out short wNb, out short
pwTyp, int[] lpdwTabl, out short wStatus)
VB.NET Sub transcycpack(ByRef wChan As UShort, ByRef wFonc As Short, ByRef wNb As
Short, ByRef pwTyp As Short, ByVal lpdwTabl() As Integer, ByRef wStatus As
Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wFonc Cyclic function number (1-255).
wNb Returned by the function. Number of transferred variables.
pwTyp Returned by the function. Indicates the type of returned variables.
1 = Bit.
2 = Byte.
3 = 16-bit integer.
4 = 32-bit integer.
5 = 32-bit floating.
lpdwTabl Table receiving the data.
wStatus Error status.

Description:

This function can be used to query the result of a cyclic function.


When TRANSCYCPACK is called, data are retrieved in the applicom® interface data base. This
implies that if a cyclic function stores variables in the data base, an external master or the PC program
can also modify these variables. TRANSCYCPACK will then return the last set values.
If TRANSCYCPACK if used for a function that has never been activated, status 35 will be returned
to you and no data will be transferred.
If TRANSCYCPACK is used for a function that is no longer activated, status -6 will be returned to
you and data will be transferred.
After the result of a reading cyclic function has been transferred, variables will be stored in packed
format in the item table called lpdwTabl. Data (bit, byte, word, double word) will be stored in memory
according to contiguous addresses without type interpretation.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 159 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Transfer of a cyclic function result in packed format. The channel number, as well as the function
number are keyed in.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short fonc; /* Function number */
short nb; /* Number of variables */
short typ; /* Type of variables */
short tabl[128]; /* Table which contains the data */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
printf("Cyclic function TRANSFER \n ");
printf("Channel number : \n"); scanf(" %hd", &nchan);
printf("Function number : \n"); scanf(" %hd", &fonc);
transcycpack(&nchan, &fonc, &nb, &typ, tabl, &status);
printf("transcyc status = %hd\n",status);
if ( status == 0 )
{
/* Data interpretation */
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 160 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Request for information on cyclic functions
List of cyclic functions executed => CYCEXECUTED

Prototypes:

Language Prototype
C void CycExecuted(short * wChan, short * wNb, short * lpwTabl, short *
wStatus)
MS pascal procedure CycExecuted(var wChan, wNb, lpwTabl, wStatus:integer)
C# void CycExecuted(ref ushort wChan, out short wNb, short[] lpwTabl, out short
wStatus)
VB.NET Sub CycExecuted(ByRef wChan As UShort, ByRef wNb As Short, ByVal lpwTabl() As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wNb Returned by the function. (value 1280 on return)
lpwTabl Array storing the flags. This array must be dimensioned to at least 80
short.
wStatus Error status.

Description:

This function is used to obtain in the first 16 short in the array lpwTabl flags (16 * 16 =256 flags).
Each flag corresponds to a cyclic function (from number 0 to number 255). If the flag corresponding to a
cyclic function is 1, this means that the data have been refreshed by the cyclic function since the last call
to function “transcyc” on this function.
On return:
¾ the first element (short) in the array contains the flags for cyclic functions 0 to 15 (the least
significant bit of the short corresponds to function 0, and the most significant to function 15).
¾ the next element contains the flags for cyclic functions 16 to 31.
¾ etc.

See also:
¾ In this manual:
9 General applicom® statuses
9 Cyclic transfer in unpacked format => TRANSCYC
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 161 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft language C

This example tests whether the new values have been deposited by cyclic function No. 110 and if
so reads the values:

#include "applicom.h" /* Prototype declaration file */


short nchan =0; /* Channel number */
short nb; /* Number of variables */
short tabl[81]; /* Array storing the flags before unpacking */
short tablbit[256]; /* Array storing the flags after unpacking */
short status; /* Status */
short nfonc; /* Number of the cyclic function to be tested */

main()
{
/* call "CycExecuted" */
CycExecuted(&nchan, &nb, tabl, &status);
if ( status == 0 )
{
nb=256;
transwordbit(&nb, tabl, tablbit, &status);
if( status == 0 )
{
nfonc=110 ;
if ( tablbit[nfonc]==1 )
{
/*the cyclic function has refreshed its data */
transcyc(....);
)
}
}
}

Library/DLL 162 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Parameters of a cyclic function => APPGETCYCPARAM

Prototypes:

Language Prototype
C void AppGetCycParam(short * wChan, short * wFonc, long * lpdwTabl, short *
wStatus)
MS pascal procedure AppGetCycParam(var lpdwTabl, wStatus:integer, tabl :integer4,
status:integer)
C# void AppGetCycParam(ref ushort wChan, ref short wFonc, int[] lpdwTabl, out
short wStatus)
VB.NET Sub AppGetCycParam(ByRef wChan As UShort, ByRef wFonc As Short, ByVal
lpdwTabl() As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wFonc Number of the cyclic function (0 to 255).
lpdwTabl Array storing the parameters. This array must be dimensioned to 64
long.
wStatus Error status.

Description:

This function places all the current parameters of a cyclic function in an array.

On return:
lpdwTabl[0] Cyclic function activation period expressed in multiples of 100 ms (0-65535).

lpdwTabl[1] Exchange type selection code. According to the following principle:

Type of variable in Function type (wTypf)


the device Reading Writing
Decimal Hex Decimal Hex
Bits 4099 1003 4105 1009
Input bits 4100 1004
Output bits 4186 105A 4187 105B
Quick rdg/wtg of 8 bits 4109 100D

Packed bytes 4190 105E 4192 1060


Bytes 4191 105F 4193 1061
Packed input bytes 4200 1068
Input bytes 4201 1069
Packed output bytes 4202 106A 4204 106C
Output bytes 4203 106B 4205 106D

Words 4101 1005 4106 100A


BCD words 4194 1062 4195 1063
Input words 4102 1006
Output words 4197 1065 4198 1066

32-bit double words 4103 1007 4107 100B


IEEE floating words 4104 1008 4108 100C

Library/DLL 163 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


lpdwTabl[2] Type of variables in the DATA BASE read or forced.
1 - Bit
2 - Byte
3 - 16 bit integer
4 - 32 bit integer
5 - 32 bit IEEE floating

lpdwTabl[3] Number of target device (0-255).

lpdwTabl[4] Number of variables accessed in the Device.

lpdwTabl[5] Address of the first variable in the Device.

lpdwTabl[6] Address of the first variable in the DATA-BASE.

lpdwTabl[7] Storage address of the cyclic function status word in DATA-BASE. If adrstat = -1,
the status is not copied in DATA BASE.

lpdwTabl[8] Cyclic function status.

lpdwTabl[9] Not used.

lpdwTabl[10] Function status: 0 = inactive; 1 = active.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 164 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


8. Data-Base functions

Reading
Contiguous packed bit reading => GETPACKBIT

Prototypes:

Language Prototype
C void getpackbit(short * wCard, short * wNb, short * wAdr, short * lpwTabl,
short * wStatus)
MS pascal procedure getpackbit(var wCard, wNb, wAdr, lpwTabl, wStatus: integer);
C# void getpackbit(ref ushort wCard, ref short wNb, ref short wAdr, short[]
lpwTabl, out short wStatus)
VB.NET Sub getpackbit(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As
Short, ByVal lpwTabl() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of bits to be read (1-2048).
wAdr Address of the first bit to be read (0-32767).
lpwTabl Table receiving the data.
wStatus Error status.

Description:

This applicom® standard function can be used to read bits in the applicom® interface data base in
packed format. The different values are stored in the integer table called lpwTabl. An item of this table
therefore contains a 16-bit chain maximum. The bits not read in the last word which receives the data are
in an undetermined state.
The applicom® “transwordbit” function allows you to unpack the bit chains.

See also:
¾ In this manual:
9 General applicom® statuses
9 Bit unpacking => TRANSWORDBIT

Library/DLL 165 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of bits 0 to 7 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 8; /* Number of bits */
short status; /* Status */
short adr = 0; /* First bit address */
short tabl[1]; /* Table receiving the data */
short tablbit[8]; /* Table containing unpacked values */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
getpackbit(&ncard, &nb, &adr, tabl, &status);
if (!status)
{
transwordbit(&nb, tabl, tablbit, &status);
for (i=0; i < nb ; i++)
printf(" %hd",tablbit[i]);
}
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 166 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous unpacked bit reading => GETBIT

Prototypes:

Language Prototype
C void getbit(short * wCard, short * wNb, short * wAdr, short * lpwTabl, short
* wStatus)
MS pascal procedure getbit(var wCard, wNb, wAdr, lpwTabl, wStatus: integer);
C# void getbit(ref ushort wCard, ref short wNb, ref short wAdr, short[] lpwTabl,
out short wStatus)
VB.NET Sub getbit(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As Short,
ByVal lpwTabl() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8)
wNb Number of bits to be read (1-128).
wAdr Address of the first bit to be read (0 à 32767).
lpwTabl Table receiving the data.
wStatus Error status.

Description:

This applicom® standard function can be used to read bits in the applicom® interface data base in
unpacked format. Bits are stored in unpacked format in the table called lpwTabl (one bit per table 16-bit
integer).

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 167 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of bits 0 to 7 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 8; /* Number of bits */
short status; /* Status */
short adr = 0; /* First bit address */
short tabl[8]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
getbit(&ncard, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" %hd",tabl[i]);
}
else
printf(" problem!! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 168 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous byte reading => GETPACKBYTE

Prototypes:

Language Prototype
C void getpackbyte(short * wCard, short * wNb, short * wAdr, char * lpcTabl,
short * wStatus)
MS pascal procedure getpackbyte(var wCard, wNb, wAdr: integer; var lpcTabl:byte; var
wStatus:integer);
C# void getpackbyte(ref ushort wCard, ref short wNb, ref short wAdr, sbyte[]
lpcTabl, out short wStatus)
VB.NET Sub getpackbyte(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As
Short, ByVal lpcTabl() As SByte, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of bytes to be read (1-256).
wAdr Address of the first byte to be read (0-13 999).
lpcTabl Byte table receiving the data.
wStatus Error status.

Description:

This applicom® standard function can be used to read bytes in the applicom® interface database.
The different values are returned by the function into the byte table called lpcTabl.

Notes:

The byte area is common to the word area with an offset of 25 000 on word addressing.

Word address Byte address


Most signif. byte Least signif. byte
24 999
25 000 1 0
25 001 3 2
. . .
. . .
31 998 13 997 13 996
31 999 13 999 13 998

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 169 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of bytes 0 to 7 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 8; /* Number of bytes */
short status; /* Status */
short adr = 0; /* First byte address */
char tablbyte[8]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
getpackbyte(&ncard, &nb, &adr, tablbyte, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" %X",tablbyte[i]);
}
else
printf(" problem !! status = %hd \n", status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 170 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous word reading => GETWORD

Prototypes:

Language Prototype
C void getword(short * wCard, short * wNb, short * wAdr, short * lpwTabl, short
* wStatus)
MS pascal procedure getword(var wCard, wNb, wAdr, lpwTabl, wStatus:integer);
C# void getword(ref ushort wCard, ref short wNb, ref short wAdr, short[]
lpwTabl, out short wStatus)
VB.NET Sub getword(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As Short,
ByVal lpwTabl() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of words to be read (1-128).
wAdr Address of the first word to be read (0-32767).
lpwTabl Table receiving the data.
wStatus Error status.

Description:

This applicom® standard function can be used to read words in the applicom® interface data base.
The different values are stored in the integer table called lpwTabl.

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 171 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of words 0 to 7 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 8; /* Number of words */
short status; /* Status */
short adr = 0; /* First word address */
short tabl[8]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
getword(&ncard, &nb, &adr, tabl, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" %hd",tabl[i]);
}
else
printf(" problem !! status = %hd \n", status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 172 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous double word reading => GETDWORD

Prototypes:

Language Prototype
C void getdword(short * wCard, short * wNb, short * wAdr, long * lpdwTabl,short
* wStatus)
MS pascal procedure getdword(var wCard, wNb, wAdr:integer; var lpdwTabl:integer4; var
wStatus:integer);
C# void getdword(ref ushort wCard, ref short wNb, ref short wAdr, int[]
lpdwTabl, out short wStatus)
VB.NET Sub getdword(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As Short,
ByVal lpdwTabl() As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of double words to be read (1-64).
wAdr Address of the first double word to be read (0-32766).
lpdwTabl Table receiving the data.
wStatus Error status.

Description:

This applicom® standard function can be used to read double words in the applicom® interface
data base. The different values are stored in the Table called lpdwTabl.

Notes:

The double word area is common to the word area.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 173 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of 8 double words from address 0 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 8; /* Number of double words */
short status; /* Status */
short adr = 0; /* First double word address */
long tablong[8]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
getdword(&ncard, &nb, &adr, tablong, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" %ld",tablong[i]);
}
else
printf(" problem !! status = %hd \n", status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 174 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous floating word reading => GETFWORD

Prototypes:

Language Prototype
C void getfword(short * wCard, short * wNb, short * wAdr, float * lpfTabl,
short * wStatus)
MS pascal procedure getfword(var wCard, wNb, wAdr: integer; var lpfTabl: real; var
wStatus: integer);
C# void getfword(ref ushort wCard, ref short wNb, ref short wAdr, float[]
lpfTabl, out short wStatus)
VB.NET Sub getfword(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As Short,
ByVal lpfTabl() As Single, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of floating words to be read (1-64).
wAdr Address of the first floating word to be read (0-32766).
lpfTabl Table receiving the data.
wStatus Error status.

Description:

This applicom® standard function can be used to read floating words in IEEE format in the
applicom® interface data base. The different values are stored in the 32-bit real table called lpfTabl.

Notes:

The floating word area is common to the word area.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal datat area

Library/DLL 175 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of 8 floating words from address 0 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 8; /* Number of floating words */
short status; /* Status */
short adr = 0; /* First floating word address */
float tablfloat[8]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
getfword(&ncard, &nb, &adr, tablfloat, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" %f",tablfloat[i]);
}
else
printf(" problem !! status = %hd \n", status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 176 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Non contiguous bit reading => GETDISPBIT

Prototypes:

Language Prototype
C void getdispbit(short * wCard, short * wNb, short * pwTablAdr, short *
lpwTablVal, short * wStatus)
MS pascal procedure getdispbit(var wCard, wNb, pwTablAdr, lpwTablVal, wStatus:integer);
C# void getdispbit(ref ushort wCard, ref short wNb, ref short pwTablAdr, short[]
lpwTablVal, out short wStatus)
VB.NET Sub getdispbit(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr As
Short, ByVal lpwTablVal() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of bits to be read (1 à 128).
pwTablAdr Table containing the addresses of the bits to be read (0 to 32767).
lpwTablVal Table receiving the condition (0 or 1) of the bits whose addresses
correspond to pwTablAdr.
wStatus Error status

Description:

This applicom® standard function can be used to read non contiguous bits in the applicom®
interface data base. The bits are stored in unpacked format in the table called lpwTablVal (one bit per
table 16-bit integer).

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 177 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of the 4 bits whose addresses are 0, 5, 10, and 15 in the data base of the applicom®
board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of bits */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
short tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 5; tabladr[2] = 10; tabladr[3] = 15;
do
{
getdispbit(&ncard, &nb, tabladr, tablval, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" Address bit condition %hd = %hd", tabladr[i], tablval[i]);
}
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 178 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Non contiguous word reading => GETDISPWORD

Prototypes:

Language Prototype
C void getdispword(short * wCard, short * wNb, short * pwTablAdr, short *
lpwTablVal, short * wStatus)
MS pascal procedure getdispword(var wCard, wNb, pwTablAdr, lpwTablVal, wStatus:
integer);
C# void getdispword(ref ushort wCard, ref short wNb, ref short pwTablAdr,
short[]lpwTablVal, out short wStatus)
VB.NET Sub getdispword(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr As
Short, ByVal lpwTablVal() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of words to be read (1 to 128).
pwTablAdr Table containing the addresses of the words to be read (0 to 32767).
lpwTablVal Table receiving the values of the words whose addresses
correspond to lpwTablVal.
wStatus Error status.

Description:

This applicom® standard function can be used to read non contiguous words in the applicom®
interface data base. The words are stored in the table called lpwTablVal.

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 179 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of the 4 words whose addresses are 0, 5, 10, and 15 in the data base of the applicom®
board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of words */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
short tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 5; tabladr[2] = 10; tabladr[3] = 15;
do
{
getdispword(&ncard, &nb, tabladr, tablval, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" State of address word %hd = %hd", tabladr[i], tablval[i]);
}
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 180 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Non contiguous double word reading => GETDISPDWORD

Prototypes:

Language Prototype
C void getdispdword(short * wCard, short * wNb, short * pwTablAdr, long *
lpwTablVal, short * wStatus)
MS pascal procedure getdispdword(var wCard, wNb, pwTablAdr:integer; var lpwTablVal :
integer4,var wStatus: integer);
C# void getdispdword(ref ushort wCard, ref short wNb, ref short pwTablAdr,
short[]lpwTablVal, out short wStatus)
VB.NET Sub getdispdword(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr
As Short, ByVal lpwTablVal() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of double words to be read (1-64).
pwTablAdr Table containing the addresses of the double words to be read (0 to
32766).
lpwTablVal Table receiving the values of the double words whose addresses
correspond to pwTablAdr.
wStatus Error status.

Description:

This applicom® standard function can be used to read non contiguous double words in the
applicom® interface data base. The double words are stored in the Table called lpwTablVal.

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 181 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of the 4 double words whose addresses are 0, 10, 20 and 30 in the data base of the
applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of words */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
long tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 10; tabladr[2] = 20; tabladr[3] = 30;
do
{
getdispdword(&ncard, &nb, tabladr, tablval, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" Status of the double word at address %hd = %ld", tabladr[i],
tablval[i]);
}
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 182 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Non contiguous floating word reading => GETDISPFWORD

Prototypes:

Language Prototype
C void getdispfword(short * wCard, short * wNb, short * pwTablAdr, float *
lpfablVal,short * wStatus)
MS pascal procedure getdispfword(var wCard, wNb, pwTablAdr:integer; var lpfablVal:real;
var wStatus:integer);
C# void getdispfword(ref ushort wCard, ref short wNb, ref short pwTablAdr,
float[] lpfablVal, out short wStatus)
VB.NET Sub getdispfword(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr
As Short, ByVal lpfablVal() As Single, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of floating words to be read (1-64).
pwTablAdr Table containing the addresses of the floating words to be read (0 to
32766).
lpfablVal Table receiving the value of the floating words whose addresses
correspond to pwTablAdr.
wStatus Error status.

Description:

This applicom® standard function can be used to read non contiguous floating words in the
applicom® interface data base. The floating words are stored in the 32-bit real table called lpfablVal.

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 183 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of the 4 floating words whose addresses are 0, 10, 20 and 30 in the data base of the
applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of words */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
float tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 10; tabladr[2] = 20; tabladr[3] = 30;
do
{
getdispfword(&ncard, &nb, tabladr, tablval, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" State of floating word at address %hd = %f", tabladr[i], tablval[i]);
}
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 184 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Writing
Contiguous packed bit writing => SETPACKBIT

Prototypes:

Language Prototype
C void setpackbit(short * wCard, short * wNb, short * wAdr, short * lpwTabl,
short * wStatus)
MS pascal procedure setpackbit(var wCard, wNb, wAdr, lpwTabl, wStatus: integer);
C# void setpackbit(ref ushort wCard, ref short wNb, ref short wAdr, short[]
lpwTabl, out short wStatus)
VB.NET Sub setpackbit(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As
Short, ByVal lpwTabl() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of bits to be written (1-2048).
wAdr Address of the first bit to be written (0-32767).
lpwTabl Table receiving the bits to be written.
wStatus Error status.

Description:

This applicom® standard function can be used to write bits in the applicom® interface data base in
packed format. The different values are stored in the integer table called lpwTabl. An item of this table
therefore contains a 16-bit chain maximum.
The applicom® “transbitword” function allows you to group bit chains.

Notes:

The bit area beyond 31999 has specific assignments. Report to see aslo section.

See also:
¾ In this manual:
9 General applicom® statuses
9 Bit unpacking => TRANSWORDBIT
¾ In the documentation:
9 Operation modes: Database: Internal datat area

Library/DLL 185 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of bits 0 to 7 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short ncard = 1; /* Board number */
short nb = 8; /* Number of bits */
short status; /* Status */
short adr = 0; /* First bit address */
short tabl[1]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabl[0] = 0x00FF;
do
{
setpackbit(&ncard, &nb, &adr, tabl, &status);
if (!status)
printf(" Writing OK \n ");
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 186 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous unpacked bit writing => SETBIT

Prototypes:

Language Prototype
C void setbit(short * wCard, short * wNb, short * wAdr, short * lpwTabl, short
* wStatus)
MS pascal procedure setbit(var wCard, wNb, wAdr, lpwTabl, wStatus: integer);
C# void setbit(ref ushort wCard, ref short wNb, ref short wAdr, short[] lpwTabl,
out short wStatus)
VB.NET Sub setbit(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As Short,
ByVal lpwTabl() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of bits to be written (1-128).
wAdr Address of the first bit to be written (0-32767).
lpwTabl Table receiving the bits to be written.
wStatus Error status.

Description:

This applicom® standard function can be used to write bits in the applicom® interface data base in
unpacked format. The different values are stored in the integer table called lpwTabl. An item of this table
therefore contains one bit maximum.

Notes:

The bit area beyond 31999 has specific assignments.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal datat area

Library/DLL 187 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of bits 0 to 7 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* */
short ncard = 1; /* Board number */
short nb = 8; /* Number of bits */
short status; /* Status */
short adr = 0; /* First bit address */
short tabl[8]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
for (i=0; i<nb; i++)
tabl[i] = 1;
do
{
setbit(&ncard, &nb, &adr, tabl, &status);
if (!status)
printf(" Writing OK \n ");
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 188 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous byte writing => SETPACKBYTE

Prototypes:

Language Prototype
C void setpackbyte(short * wCard, short * wNb, short * wAdr, char * lpcTabl,
short * wStatus)
MS pascal procedure setpackbyte(var wCard, wNb, wAdr: integer; var lpcTabl:byte; var
wStatus:integer);
C# void setpackbyte(ref ushort wCard, ref short wNb, ref short wAdr, sbyte[]
lpcTabl, out short wStatus)
VB.NET Sub setpackbyte(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As
Short, ByVal lpcTabl() As SByte, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of bytes to be written (1-256).
wAdr Address of the first byte to be written (0-13 999).
lpcTabl Byte table receiving the data to be written.
wStatus Error status.

Description:

This applicom® standard function can be used to write bytes in the applicom® interface data base.
The different values are stored in the byte table called lpcTabl.

Notes:

The byte area is common to the word area with an offset of 25 000 on word addressing.

Word address Byte address


Most signif. byte Least signif. byte
24 999
25 000 1 0
25 001 3 2
. . .
. . .
31 998 13 997 13 996
31 999 13 999 13 998

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal datat area

Library/DLL 189 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of bytes 0 to 7 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 8; /* Number of bytes */
short status; /* Status */
short adr = 0; /* First byte address */
char tabl[8]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
for (i=0; i<nb; i++)
tabl[i] = 1;
do
{
setpackbyte(&ncard, &nb, &adr, tabl, &status);
if (!status)
printf(" Writing OK \n ");
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
.
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 190 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous word writing => SETWORD

Prototypes:

Language Prototype
C void setword(short * wCard, short * wNb, short * wAdr, short * lpwTabl, short
* wStatus)
MS pascal procedure setword(var wCard, wNb, wAdr, lpwTabl, wStatus: integer);
C# void setword(ref ushort wCard, ref short wNb, ref short wAdr, short[]
lpwTabl, out short wStatus)
VB.NET Sub setword(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As Short,
ByVal lpwTabl() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of words to be written (1-128).
wAdr Address of the first word to be written (0-32767).
lpwTabl Table receiving the data to be written.
wStatus Error status.

Description:

This applicom® standard function can be used to write words in the applicom® interface data base.
The different values are stored in the Table called lpwTabl.

Notes:

The word area beyond 31999 has specific assignments.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 191 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of words 0 to 7 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 8; /* Number of words */
short status; /* Status */
short adr = 0; /* First word address */
short tabl[8]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
for (i=0; i<nb; i++)
tabl[i] = 1;
do
{
setword(&ncard, &nb, &adr, tabl, &status);
if (!status)
printf(" Writing OK \n ");
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 192 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous double word writing => SETDWORD

Prototypes:

Language Prototype
C void setdword(short * wCard, short * wNb, short * wAdr, long * lpdwTabl,
short * wStatus)
MS pascal procedure setdword(var wCard, wNb, wAdr:integer; var lpdwTabl: integer4; var
wStatus: integer);
C# void setdword(ref ushort wCard, ref short wNb, ref short wAdr, int[]
lpdwTabl, out short wStatus)
VB.NET Sub setdword(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As Short,
ByVal lpdwTabl() As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of double words to be written (1-64).
wAdr Address of the first double word to be written (0-32766).
lpdwTabl Table receiving the data to be written.
wStatus Error status

Description:

This applicom® standard function can be used to write double words in the applicom® interface
data base. The different values are stored in the Table called lpdwTabl.

Notes:

The double word area beyond 31999 has specific assignments.


The double word area is common to the word area.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 193 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of 3 double words from address 0 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 3; /* Number of double words */
short status; /* Status */
short adr = 0; /* First double word address */
long tabl[3]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
for (i=0; i<nb; i++)
tabl[i] = 1;
do
{
setdword(&ncard, &nb, &adr, tabl, &status);
if (!status)
printf(" Writing OK \n ");
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 194 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Contiguous floating word writing => SETFWORD

Prototypes:

Language Prototype
C void setfword(short * wCard, short * wNb, short * wAdr, float * lpdwTabl,
short * wStatus)
MS pascal procedure setfword(var wCard, wNb, wAdr:integer; var lpdwTabl: real4; var
wStatus: integer);
C# void setfword(ref ushort wCard, ref short wNb, ref short wAdr, float[]
lpdwTabl, out short wStatus)
VB.NET Sub setfword(ByRef wCard As UShort, ByRef wNb As Short, ByRef wAdr As Short,
ByVal lpdwTabl() As Single, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of floating words to be written (1-64).
wAdr Address of the first floating word to be written (0-32766).
lpdwTabl Table receiving the data to be written.
wStatus Error status.

Description:

This applicom® standard function can be used to write floating words in IEEE format in the
applicom® interface data base. The different values are stored in the 32-bit real table called lpdwTabl.

Notes:

The floating word area beyond 31999 has specific assignments.


This floating word area is common to the word area.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 195 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of 3 floating words from address 0 in the data base of the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 3; /* Number of floating words */
short status; /* Status */
short adr = 0; /* Address of the first floating word */
float tabl[3]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
for (i=0; i<nb; i++)
tabl[i] = 1;
do
{
setfword(&ncard, &nb, &adr, tabl, &status);
if (!status)
printf(" Writing OK \n ");
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 196 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Non contiguous bit writing => SETDISPBIT

Prototypes:

Language Prototype
C void setdispbit(short * wCard, short * wNb, short * pwTablAdr, short *
lpwTablVal, short * wStatus)
MS pascal procedure setdispbit(var wCard, wNb, pwTablAdr, lpwTablVal, wStatus:
integer);
C# void setdispbit(ref ushort wCard, ref short wNb, ref short pwTablAdr, short[]
lpwTablVal, out short wStatus)
VB.NET Sub setdispbit(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr As
Short, ByVal lpwTablVal() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of bits to be written (1 to 64).
pwTablAdr Table containing the addresses of the bits to be written (0 to 32767).
lpwTablVal Table receiving the condition (0 or 1) of the bits whose addresses
correspond to pwTablAdr.
wStatus Error status.

Description:

This applicom® standard function can be used to write non contiguous bits in the applicom®
interface data base. The bits are stored in unpacked format in the table called lpwTablVal (one bit per
table 16-bit integer).

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 197 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of the 4 bits whose addresses are 0, 5, 10, and 15 in the data base of the applicom®
board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of bits */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
short tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 5; tabladr[2] = 10; tabladr[3] = 15;
for (i=0; i<nb; i++)
tablval[i] = 1;
do
{
setdispbit(&ncard, &nb, tabladr, tablval, &status);
if (!status)
printf(" Writing OK \n ");
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 198 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Non contiguous word writing => SETDISPWORD

Prototypes:

Language Prototype
C void setdispword(short * wCard, short * wNb, short * pwTablAdr, short *
lpwTablVal, short * wStatus)
MS pascal procedure setdispword(var wCard, wNb, pwTablAdr, lpwTablVal, wStatus:
integer);
C# void setdispword(ref ushort wCard, ref short wNb, ref short pwTablAdr,
short[] lpwTablVal, out short wStatus)
VB.NET Sub setdispword(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr As
Short, ByVal lpwTablVal() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of words to be written (1-64).
pwTablAdr Table containing the addresses to the words to be written (0 to
32767).
lpwTablVal Table receiving the values of the words whose addresses
correspond to lpwTablVal.
wStatus Error status.

Description:

This applicom® standard function can be used to write non contiguous words in the applicom®
interface data base. The words are stored in the table called lpwTablVal.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 199 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of the 4 words whose addresses are 0, 5, 10, and 15 in the data base of the applicom®
board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of words */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
short tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 5; tabladr[2] = 10; tabladr[3] = 15;
for (i=0; i<nb; i++)
tablval[i] = 1;
do
{

setdispword(&ncard, &nb, tabladr, tablval, &status);


if (!status)
printf(" Writing OK \n ");
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 200 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Non contiguous double word writing => SETDISPDWORD

Prototypes:

Language Prototype
C void setdispdword(short * wCard, short * wNb, short * pwTablAdr, long *
lpwTablVal, short * wStatus)
MS pascal procedure setdispdword(var wCard, wNb, pwTablAdr:integer; var
lpwTablVal:integer4; var wStatus:integer);
C# void setdispdword(ref ushort wCard, ref short wNb, ref short pwTablAdr, int[]
lpwTablVal, out short wStatus)
VB.NET Sub setdispdword(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr
As Short, ByVal lpwTablVal() As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of double words to be written (1-32).
pwTablAdr Table containing the addresses of the double words to be written (0
to 32766).
lpwTablVal Table receiving the values of the double words whose addresses
correspond to lpwTablVal.
wStatus Error status.

Description:

This applicom® standard function can be used to write non contiguous double words in the
applicom® interface data base. The double words are stored in the table called lpwTablVal.
The double word area is common to the word area.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 201 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of the 4 double words whose addresses are 0, 10, 20, and 30 in the data base of the
applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of words */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
long tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 10; tabladr[2] = 20; tabladr[3] = 30;
for (i=0; i<nb; i++)
tablval[i] = 1;
do
{
setdispdword(&ncard, &nb, tabladr, tablval, &status);
if (!status)
printf(" Writing OK \n ");
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 202 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Non contiguous floating word writing => SETDISPFWORD

Prototypes:

Language Prototype
C void setdispfword(short * wCard, short * wNb, short * pwTablAdr, float *
lpfTablVal, short * wStatus)
MS pascal procedure setdispfword(var wCard, wNb, pwTablAdr:integer; var
lpfTablVal:real4; var wStatus:integer);
C# void setdispfword(ref ushort wCard, ref short wNb, ref short pwTablAdr,
float[] lpfTablVal, out short wStatus)
VB.NET Sub setdispfword(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr
As Short, ByVal lpfTablVal() As Single, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of floating words to be written (1-32).
pwTablAdr Table containing the addresses of the floating words to be written (0
to 32766).
lpfTablVal Table receiving the values of the floating words whose addresses
correspond to pwTablAdr.
wStatus Error status.

Description:

This applicom® standard function can be used to write non contiguous floating words in IEEE
format in the applicom® interface data base. The floating words are stored in the table called lpfTablVal.
The floating word area is common to the word area.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 203 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Setting to 1 of the 4 floating words whose addresses are 0, 10, 20, and 30 in the data base of the
applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of floating words */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
float tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 10; tabladr[2] = 20; tabladr[3] = 30;
for (i=0; i<nb; i++)
tablval[i] = 1.0;
do
{
setdispfword(&ncard, &nb, tabladr, tablval, &status);
if (!status)
printf(" Writing OK \n ");
else
printf(" problem !! status = %hd \n",status);
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 204 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Incrementation
Non contiguous word increment => INCDISPWORD

Prototypes:

Language Prototype
C void incdispword(short * wCard, short * wNb, short * pwTablAdr, short *
lpwTablVal, short * wStatus)
MS pascal procedure incdispword(var wCard, wNb, pwTablAdr, lpwTablVal, wStatus:
integer);
C# void incdispword(ref ushort wCard, ref short wNb, ref short pwTablAdr,
short[] lpwTablVal, out short wStatus)
VB.NET Sub incdispword(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr As
Short, ByVal lpwTablVal() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of words to be incremented (1-128).
pwTablAdr Table which contains the addresses of the words to be incremented
(0 to 32767).
lpwTablVal Table returned by the function. Contains the values of the
incremented words whose addresses correspond to pwTablAdr.
wStatus Error status

Description:

This applicom® function can be used to increment non contiguous words in the applicom®
interface database.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 205 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Incrementation of the 4 words whose addresses are 0, 10, 20, and 30 in the data base of the
applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of words */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
short tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 10; tabladr[2] = 20; tabladr[3] = 30;
incdispword(&ncard, &nb, tabladr, tablval, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" Value of word at address %hd after increment = %hd \n", tabladr[i],
tablval[i]);
}
else
printf(" problem !! status = %hd \n",status);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 206 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Non contiguous double word increment => INCDISPDWORD

Prototypes:

Language Prototype
C void incdispdword(short * wCard, short * wNb, short * pwTablAdr, long *
lpdwTablVal, short * wStatus)
MS pascal procedure incdispdword(var wCard, wNb, pwTablAdr: integer; var lpdwTablVal:
integer4; var wStatus: integer);
C# void incdispdword(ref ushort wCard, ref short wNb, ref short pwTablAdr, int[]
lpdwTablVal, out short wStatus)
VB.NET Sub incdispdword(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr
As Short, ByVal lpdwTablVal() As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of double words to be incremented (1-64).
pwTablAdr Table which contains the addresses of the double words to be
incremented (0 to 32766).
lpdwTablVal Table returned by the function. Contains the value of the
incremented double words whose addresses correspond to
lpdwTablVal.
wStatus Error status.

Description:

This applicom® function can be used to increment non contiguous double words in the applicom®
interface database.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 207 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Incrementation of the 4 double words whose addresses are 0, 10, 20, and 30 in the data base of
the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of double words */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
long tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 10; tabladr[2] = 20; tabladr[3] = 30;
incdispdword(&ncard, &nb, tabladr, tablval, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" Value of double word at address %hd after increment = %ld \n",
tabladr[i], tablval[i]);
}
else
printf(" problem !! status = %hd \n",status);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 208 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Decrementation
Non contiguous word decrement => DECDISPWORD

Prototypes:

Language Prototype
C void decdispword(short * wCard, short * wNb, short * pwTablAdr, short *
lpwTablVal, short * wStatus)
MS pascal procedure decdispword(var wCard, wNb, pwTablAdr, lpwTablVal,
wStatus:integer);
C# void decdispword(ref ushort wCard, ref short wNb, ref short pwTablAdr,
short[] lpwTablVal, out short wStatus)
VB.NET Sub decdispword(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr As
Short, ByVal lpwTablVal() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of words to be decremented (1-128).
pwTablAdr Table which contains the addresses of the words to be decremented
(0 to 32767).
lpwTablVal Table returned by the function. Contains the values of the
decremented words whose addresses correspond to pwTablAdr.
wStatus Error status.

Description:

This applicom® function can be used to decrement non contiguous words in the applicom®
interface database.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 209 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Decrementation of the 4 words whose addresses are 0, 10, 20, and 30 in the data base of the
applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of words */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
short tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 10; tabladr[2] = 20; tabladr[3] = 30;
decdispword(&ncard, &nb, tabladr, tablval, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" Value of word at address %hd after decrement = %hd \n", tabladr[i],
tablval[i]);
}
else
printf(" problem !! status = %hd \n",status);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 210 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Non contiguous double word decrement => DECDISPDWORD

Prototypes:

Language Prototype
C void decdispdword(short * wCard, short * wNb, short * pwTablAdr, long *
lpdwTablVal, short * wStatus)
MS pascal procedure decdispdword(var wCard, wNb, pwTablAdr: integer; var lpdwTablVal:
integer4; var wStatus: integer);
C# void decdispdword(ref ushort wCard, ref short wNb, ref short pwTablAdr, int[]
lpdwTablVal, out short wStatus)
VB.NET Sub decdispdword(ByRef wCard As UShort, ByRef wNb As Short, ByRef pwTablAdr
As Short, ByVal lpdwTablVal() As Integer, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of double words to be decremented (1-64).
pwTablAdr Table which contains the addresses of the double words to be
decremented (0 to 32766).
lpdwTablVal Table returned by the function. Contains the values of the
decremented double words whose addresses correspond to
pwTablAdr.
wStatus Error status.

Description:

This applicom® function can be used to decrement non contiguous double words in the applicom®
interface database.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 211 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Decrementation of the 4 double words whose addresses are 0, 10, 20, and 30 in the data base of
the applicom® board number 1.

#include "applicom.h" /* Prototype declaration file */


short i; /* for loop counter */
short ncard = 1; /* Board number */
short nb = 4; /* Number of double words */
short status; /* Status */
short tabladr[4]; /* Table receiving the addresses */
long tablval[4]; /* Table receiving the data */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
tabladr[0] = 0; tabladr[1] = 10; tabladr[2] = 20; tabladr[3] = 30;
decdispdword(&ncard, &nb, tabladr, tablval, &status);
if (!status)
{
for (i=0; i < nb ; i++)
printf(" Value of double word at address %hd after decrement = %ld", tabladr[i],
tablval[i]);
}
else
printf(" problem !! status = %hd \n",status);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 212 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Event FIFO
Caution:
All the event fifo functions must be used only in one active application (process and thread).

Logged variable configuration => CONFDB

Prototypes:

Language Prototype
C void confdb(short * wCard,short * wTyp, short * wNb, short * wAdr,short *
wCond, short * wStatus)
MS pascal procedure confdb(var wCard, wTyp, wNb, wAdr, wCond, wStatus: integer);
C# void confdb(ref ushort wCard, ref short wTyp, ref short wNb, ref short wAdr,
ref short wCond, out short wStatus)
VB.NET Sub confdb(ByRef wCard As UShort, ByRef wTyp As Short, ByRef wNb As Short,
ByRef wAdr As Short, ByRef wCond As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wTyp Type of variable to be logged.
1 = bit
2 = byte
3 = 16-bit word
4 = 32-bit double word
5 = 32-bit IEEE double word
wNb Number of logged variables.
wAdr Address of the first variable logged in DATA-BASE.
wCond Logging type.
0 = Unlogging.
1 = On state change.
2 = Unconditional.
wStatus Error status.

Description:

The variable evolution in the applicom® interface data base can be automatically logged and time
stamped in a 4096-position FIFO. Function CONFDB can be used to define the different variable areas to
be monitored in the data base.
The applicom® GETEVENT function can be used to query the events listed in the FIFO.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 213 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

#include "applicom.h" /* Prototype declaration file */


short ncard; /* Board number */
short typ; /* Type of variables */
short nb; /* Number of variables */
short adr; /* Address in data-base */
short cond; /* Logging condition */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
printf("LOGGING in the event FIFO \n");
printf("Logging type \n");
scanf(" 1=Bit, 2=Byte, 3=Word, 4=DWord, 5=FWord : %hd \n ",&typ);
scanf("Number of variables to be logged : %hd \n ",&nb);
scanf("Logging start address : %hd \n ",&adr);
printf("Logging condition \n");
printf(" 0 : unlogging \n ");
printf(" 1 : conditional logging \n ");
scanf(" 2 : unconditional logging \n %hd",&cond);
confdb (&ncard,&typ,&nb,&adr,&cond,&status);
printf ("status = %d\n",status);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 214 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Logging FIFO reading => GETEVENT

Prototypes:

Language Prototype
C void getevent(short * wCard,short * wNb, short * lpwtabltyp, short *
lpwtabladr, long * lpdwTablVal, short * lpwTablDat, short * lpwTablTime,
short * wStatus)
MS pascal procedure getevent(var wCard, wNb, lpwtabltyp, lpwtabladr: integer; var
lpdwTablVal: integer4; var lpwTablDat, lpwTablTime, wStatus: integer);
C# void getevent(ref ushort wCard, ref short wNb, short[] lpwtabltyp, short[]
lpwtabladr, int[] lpdwTablVal, short[] lpwTablDat, short[] lpwTablTime, out
short wStatus)
VB.NET Sub getevent(ByRef wCard As UShort, ByRef wNb As Short, ByVal lpwtabltyp() As
Short, ByVal lpwtabladr() As Short, ByVal lpdwTablVal() As Integer, ByVal
lpwTablDat() As Short, ByVal lpwTablTime() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wNb Number of events to be read in the FIFO (1-20).
If the number of lower than wNb, DATA-BASE returns into wNb the
number of returned events.
lpwtabltyp Table, Types of logged variables.
1 = Bit.
2 = Byte.
3 = 16-bit integer.
4 = 32-bit integer.
5 = 32-bit IEEE floating.
lpwtabladr Table, Logged variable address.
lpdwTablVal Table, Set value.
lpwTablDat Table, Event date in packed format.
lpwTablTime Table, Event time in packed format.
wStatus Error status.

Description:

GETEVENT returns wNb loggings. If the number of events logged in the FIFO is lower than wNb,
wNb will be modified by GETEVENT. lpdwTablVal is a table made up of 32-bit items. The returned
value interpretation depends on lpwtabltyp (bit, byte, word, double or floating word). The variable
format must be taken into account by the application program.
The applicom® UNPACKDATE and UNPACKTIME functions can be used to unpack the date and
time format.
The bit at address 32767 (7FFF H) in DATA-BASE indicates if the event FIFO is full. It must be
reset by the user program or by the PLCs.
The bit at address 32766 (7FFE H) in DATA-BASE can be used to reset the event FIFO. This bit is
monostable.
The word whose address is 32766 (7FFE H) in DATA-BASE indicates the number of available
spaces in the event FIFO.

Library/DLL 215 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


See also:
¾ In this manual:
9 General applicom® statuses
9 applicom® date unpacking => UNPACKDATE
9 applicom® time unpacking => UNPACKTIME
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 216 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Display of events logged in the FIFO.

#include "applicom.h" /* Prototype declaration file */


short ncard; /* Board number */
short nb; /* Number of events */
short tabltyp[20]; /* Type of variables */
short tabladr[20]; /* Address in data-base */
long tablval[20]; /* Type of variables */
short tabldate[20]; /* Event date */
short tabltime[20]; /* Event time */
short status; /* Status */
short i, day, month, year;
short hour, minute, second;

main()
{
/* initialize the communication with the applicom® product with "initbus" */
.
printf("Event FIFO READING \n");
scanf("Board number : %hd \n",&ncard);
scanf("Number of events to be read : %hd \n",&nb);
getevent(&ncard, &nb, tabltyp, tabladr, tablval, tabldate, tabltime, &status);
printf("status getevent = %d \n",status);
if ( status == 0 )
{
if ( nb == 0 )
printf("empty FIFO \n");
else
{
printf("Number of logged events : %d \n",nb);
for ( i=0 ; i<nb ; i++ )
{
unpackdate (&tabldate[i],&day,&month,&year,&status);
unpacktime (&tabltime[i],&second,&minute,&hour,&status);
printf("%2d / %2d / %2d %2d: %2d: %2d ",day,month,year,hour,minute,second);
switch (tabltyp[i])
{
case 1 :
printf (" Bit address : %6d Value : %12d \n",tabladr[i],tablval[i]);
break;
case 2 :
printf (" Byte address : %6d Value : %12d \n",tabladr[i],tablval[i]);
break;
case 3 :
printf (" Word address : %6d Value : %12d
H%8lX\n",tabladr[i],tablval[i],tablval[i]);
break;
case 4 :
printf (" DWord address : %6d Value : %12ld
H%8lX\n",tabladr[i],tablval[i],tablval[i]);
break;
case 5 :
printf (" FWord address : %6d Value : %12.3f\n",tabladr[i],*(float
*)&tablval[i]);
break;
default : break;
}
}
}
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 217 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Copy of events into the FIFO => SETEVENT

Prototypes:

Language Prototype
C void setevent(short * wCard,short * wTyp, short * wNb, short * wAdr, short *
wStatus)
MS pascal procedure setevent(var wCard,wTyptwNb, wAdr, wStatus, : integer);
C# void setevent(ref ushort wCard, ref short wTyp, ref short wNb, ref short
wAdr, out short wStatus)
VB.NET Sub setevent(ByRef wCard As UShort, ByRef wTyp As Short, ByRef wNb As Short,
ByRef wAdr As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wTyp Type of variable to be copied.
1 = Bit.
2 = Byte.
3 = 16-bit integer.
4 = 32-bit integer.
5 = 32-bit IEEE integer.
wNb Number of variables to be copied into the FIFO.
wAdr Address of the first Data-Base variable to be copied.
wStatus Error status.

Description:

This applicom® function copies the value of Data-Base variables into the applicom® interface
event logging FIFO.
These events can be queried with function GETEVENT.

See also:
¾ In this manual:
9 General applicom® statuses
9 Logging FIFO reading => GETEVENT
¾ In the documentation:
9 Operation modes: Database: Internal data area

Library/DLL 218 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


9. Functions for Redundancy of Equipment

Functionality

The redundancy of equipment functionality is available with the applicom® PCI2000ETH and
PCI2000MBP interfaces on the following electronic messaging systems:

¾ ALLEN-BRADLEY on TCP/IP
¾ CEGELEC on TCP/IP
¾ GE FANUC on TCP/IP
¾ INDUSTRIAL ETHERNET on ISO and/or TCP/IP
¾ MITSUBISHI on TCP/IP
¾ MODBUS on TCP/IP
¾ OMRON on TCP/IP
¾ UNI-TE on TCP/IP
¾ Modbus Plus

This functionality enables the application to change target equipment on the same applicom®
channel.
Generally, each applicom® function targets an equipment number. During the configuration, a protocol
address is associated with this applicom® equipment number. that is to say:

¾ IP address for Ethernet TCP/IP.


¾ MAC address for Ethernet ISO.
¾ Path of 5 bytes for Modbus Plus.

Following example is applied with a TCP/IP, but the principle stays is identical for the other
messaging.

applicom® equipment TCP/IP address


number
0 128.127.055.000
1 128.127.055.001
… …
126 128.127.055.126
127 128.127.055.127

With the equipment redundancy functionality, the range of 128 configurable devices is divided into two
parts: 64 devices for the primary definition and 64 for the secondary definition.

Example:

applicom® equipment number TCP/IP address


0 128.127.055.000
1 128.127.055.001
Primary definition … …
62 128.127.055.062
63 128.127.055.063
64 128.127.055.064
65 128.127.055.065
Secondary definition … …
126 128.127.055.126
127 128.127.055.127

Library/DLL 219 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Consequently, each device is associated with a primary definition and a secondary definition.

Associated applicom®
equipment number
0 64
1 65
… …
62 126
63 127

The application can change target PLC using a simple command via the AppSetEquipmentSwap(…)
function. All functions targeting the equipment, therefore, change from the IP address of the primary
definition to the IP address of the secondary definition (and vice versa). Inversely, to read the swap status,
the application can use the AppGetEquipementSwap(…) function.

Library/DLL 220 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Read active definition function => AppGetEquipmentSwap

Prototypes:

Language Prototype
C void AppGetEquipmentSwap(short * wChan,short * wFeq, short * wNb, char *
byTabls, short * wStatus)
C# void AppGetEquipmentSwap(ref ushort wChan, ref short wFeq, ref short wNb,
sbyte[]byTabls, out short wStatus)
VB.NET Sub AppGetEquipmentSwap (ByRef wChan As UShort, ByRef wFeq As Short, ByRef
wNb As Short, ByRef byTabls() As SByte, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wFeq First device number (0-63).
wNb Number of devices (1-64).
byTabls Table containing the equipment statuses:
0 : Primary definition active
1 : Secondary definition active
255 : Equipment not configured (primary and/or secondary).
wStatus Error status

Description :

This function is used to read a byte table. Each byte corresponds to an applicom® equipment
number, its value indicates whether the equipment number uses the primary or secondary definition.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Library/DLL 221 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Select active definition function => AppSetEquipmentSwap
Prototypes:

Language Prototype
C void AppSetEquipmentSwap(short * wChan,short * wFeq, short * wNb, char *
byTablS, short * wStatus)
C# void AppSetEquipmentSwap(ref ushort wChan, ref short wFeq, ref short wNb, ref
sbyte[] byTablS, out short wStatus)
VB.NET Sub AppSetEquipmentSwap(ByRef wChan As UShort, ByRef wFeq As Short, ByRef wNb
As Short, ByRef byTablS() As SByte, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wFeq First device number (0-63).
wNb Number of devices (1-64).
byTabls Table containing the equipment statuses:
0 : Activation of primary definition
1 : Activation of secondary definition
wStatus Error status

Description :

This function is used to write a byte table. Each byte corresponds to an applicom® equipment
number, its value specifies whether the applicom® equipment number must use the primary or secondary
definition.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In protocol manuals:
9 Statuses relating to the protocol

Example in Microsoft C language

An independent program can be used to automatically swap devices 0 to 63:


- in Windows, by using APPLICOM.DLL
- in the applicom® board, by using the applicom® development kit.
By monitoring the statuses of the cyclic functions (copied into the board database) you can define a
device swapping law.
This law will be more or less complicated depending on the supervision application, the degree of
security required, and the types of equipment used.

Whether in Windows or in the applicom® board, use of the functions AppSetEquipmentSwap and
AppGetEquipmentSwap is identical.

Library/DLL 222 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


The following examples demonstrates a typical use of these two functions.

#include "applicom.h" /* Prototype declaration file */


short wChan; /* Channel number */
short wFeq; /* First device number */
short wNb; /* Number of device */
char byTablS[64]; /* Table containing the equipment statuses */
short wStatus; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
/*-- write the 'swap' status -----------------------------------------*/
wChan = 0;
wFeq = 12;
wNb = 3;
byTablS[0] = 1; /* equipement 12 : swap */
byTablS[1] = 0; /* equipement 13 : normal */
byTablS[2] = 1; /* equipement 14 : swap */

AppSetEquipmentSwap(&wChan, &wFeq, &wNb, &byTablS[0], &wStatus);


if (wStatus != 0){
/* Error management */
}

/*-- read the 'swap' status-----------------------------------------*/


wChan = 0;
wFeq = 12;
wNb = 3;

AppGetEquipmentSwap(&wChan, &wFeq, &wNb, &byTablS[0], &wStatus);


if (wStatus != 0){
/* Error management */
}
else{
printf( "Swap state : %d %d %d", byTablS[0], byTablS[1], byTablS[2]);
}

/* execute function "exitbus" before quitting */


exit(0);
}

Library/DLL 223 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


10. Local functions

Bit unpacking => TRANSWORDBIT


Prototypes:

Language Prototype
C void transwordbit(short* wNb, short* pwTablSrc, short * pwTablDst, short *
wStatus)
MS pascal procedure transwordbit(var wNb, pwTablSrc, pwTablDst, wStatus:integer)
C# void transwordbit(ref short wNb, short[] pwTablSrc, short[] pwTablDst, out
short wStatus)
VB.NET Sub transwordbit(ByRef wNb As Short, ByVal pwTablSrc() As Short, ByVal
pwTablDst() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wNb Number of bits to be unpacked
pwTablSrc Table containing the integers to be unpacked.
pwTablDst Table receiving the result (0 or 1).
wStatus Error status.

Description:

This applicom® function allows you to unpack the integer bits in a table. An integer from table
pwTablSrc is unpacked into 16 bits in the table called pwTablDst.

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 224 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Unpack the 16 bits contained in the val integer.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nb; /* Number of bits to be unpacked */
short tabls[1]; /* Table containing the data */
short tabld[16]; /* Table receiving the result (0 or 1) */
short status; /* Status */
short val; /* Value to be unpacked */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nb =16;
tabls[0] = val;
transwordbit(&nb, tabls, tabld, &status);
if (status == 0)
{
for (i=0; i<nb; i++)
printf( "state of bit %hd = %hd \n ", i, tabld[i]);
}
else
printf("Problem !! status = %hd \n",status);
.
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 225 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Bit grouping => TRANSBITWORD

Prototypes:

Language Prototype
C void transbitword(short* wNb, short* pwTablSrc, short * pwTablDst, short *
wStatus)
MS pascal procedure transbitword(var wNb, pwTablSrc, pwTablDst, wStatus:integer)
C# void transbitword(ref short wNb, short[] pwTablSrc, short[] pwTablDst, out
short wStatus)
VB.NET Sub transbitword(ByRef wNb As Short, ByVal pwTablSrc() As Short, ByVal
pwTablDst() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wNb Number of bits to be grouped.
pwTablSrc Table containing the data to be grouped (0 or 1).
pwTablDst Table receiving the result.
wStatus Error status

Description:

This applicom® function allows you to group the bits of an integer table containing binary values (0-
1). 16 integers from table pwTablSrc are grouped in 1 integer of table pwTablDst.

See also:
¾ In this manual:
9 General applicom® statuses

Example in Microsoft C language

Group the 16 bits contained in the 16 items of the integer table tabls into the val integer.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nb; /* Number of bits to be grouped */
short tabls[16]; /* Source table */
short val; /* Destination variable */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nb =16;
transbitword(&nb, tabls, &val, status);
if (status == 0)
printf( "Grouped value = %hd \n ", val[0]);
else
printf("Problem !! status = %hd \n",status);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 226 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Integer table comparison => COMPWORD

Prototypes:

Language Prototype
C void compword(short* wNb, short* pwTabl1, short* pwTabl2, short * pwTablRes,
short * wStatus)
MS pascal procedure compword(var wNb, pwTabl1, pwTabl2, pwTablRes, wStatus:integer);
C# void compword(ref short wNb, short[] pwTabl1, short[] pwTabl2, short[]
pwTablRes, out short wStatus)
VB.NET Sub compword(ByRef wNb As Short, ByVal pwTabl1() As Short, ByVal pwTabl2() As
Short, ByVal pwTablRes() As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wNb Number of 16-bit integers to be compared.
pwTabl1 Source Table.
pwTabl2 Table intended to store the pwTabl1 previous states.
pwTablRes Result table.
0 = If no change
1 = If the corresponding integer increased.
-1 = If the corresponding integer decreased.
wStatus Error status.

Description:

This applicom® function allows you to compare two integer tables. The pwTablRes table specifies
item per item the differences between the 2 tables.

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 227 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nb; /* Number of words to be unpacked */
short tabl1[16]; /* Source data table */
short tabl2[16]; /* Previous state storage table */
short tablr[16]; /* Table containing the results */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nb = 16;
compword(&nb, tabls1, tabls2, tablr, &status);
if (status == 0)
{
for (i=0; i<nb; i++)
{
switch ( tablr[i])
{
case 0 :
printf( " items %hd are identical \n" , i );
break;
case 1 :
printf( " items %hd are increasing \n", i );
break;
case -1 :
printf( " items %hd are decreasing \n", i );
break;
default :
break;
}
}
}
else
printf("Problem !! status = %hd \n",status);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 228 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Word bit inversion => INVBIT

Prototypes:

Language Prototype
C void invbit(short* wNb, short* lpwTabls, short* lpwTabld, short * wStatus)
MS pascal procedure invbit(var wNb, lpwTabls, lpwTabld, wStatus:integer)
C# void invbit(ref short wNb, short[] lpwTabls, short[] lpwTabld, out short
wStatus)
VB.NET Sub invbit(ByRef wNb As Short, ByVal lpwTabls() As Short, ByVal lpwTabld() As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wNb Number of words to be inverted.
lpwTabls Source Table.
lpwTabld Destination Table.
wStatus Error status.

Description:

This applicom® function is particularly interesting for PB and APRIL device for the least significant
bits correspond to the word most significant bits.

See also:
¾ In this manual:
9 General applicom® statuses

Example in Microsoft C language

Bit inversion of the 16 words of tabls.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nb; /* Number of words to be inverted */
short tabls[16]; /* Source table */
short tabld[16]; /* Destination table */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nb = 16;
invbit(&nb, tabls, tabld, &status);
if (status == 0)
{
for (i=0; i<nb; i++)
{
printf( " value before inversion %hd \n", tabls[i] );
printf( " value after inversion %hd \n", tabld[i] );
}
}
else
printf("Problem !! status = %hd \n",status);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 229 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


applicom® date unpacking => UNPACKDATE

Prototypes:

Language Prototype
C void unpackdate(short* wDate, short* wDay, short* wMonth, short* wYear, short
* wStatus)
MS pascal procedure unpackdate(var wDate, wDay, wMonth, wYear, wStatus:integer)
C# void unpackdate(ref short wDate, out short wDay, out short wMonth, out short
wYear, out short wStatus)
VB.NET Sub unpackdate(ByRef wDate As Short, ByRef wDay As Short, ByRef wMonth As
Short, ByRef wYear As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wDate applicom® date in packed format.
wDay Return the day of packed wDate.
wMonth Return the month of packed wDate.
wYear Return the year of packed wDate.
wStatus Error status.

Description:

This applicom® function can be used to unpack the applicom® date in packed format sent back by
the Data-Base GETEVENT function.

See also:
¾ In this manual:
9 General applicom® statuses
9 Logging FIFO reading => GETEVENT

Library/DLL 230 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Display of time stamped events logged in the FIFO.

#include "applicom.h" /* Prototype declaration file */


short ncard; /* Board number */
short nb; /* Number of events */
short tabltyp[20]; /* Type of variables */
short tabladr[20]; /* Address in data-base */
long tablval[20]; /* Type of variables */
short tabldate[20]; /* Event date */
short tabltime[20]; /* Event time */
short status; /* Status */
short i, jour, mois, annee;
short heure, minute, seconde;

main()
{
/* initialize the communication with the applicom® product with "initbus" */
printf("event FIFO READING \n");
scanf("Board number : %hd \n",&ncard);
scanf("Number of events to be read : %hd \n",&nb);
getevent(&ncard, &nb, tabltyp, tabladr, tablval, tabldate, tabltime, &status);
printf("getevent status = %d \n",status);
if ( status == 0 )
{
if ( nb == 0 )
printf("empty FIFO \n");
else
{
printf("Number of logged events : %hd \n",nb);
for ( i=0 ; i<nb ; i++ )
{
unpackdate (&tabldate[i],&jour,&mois,&annee,&status);
unpacktime (&tabltime[i],&seconde,&minute,&heure,&status);
printf("%2d / %2d / %2d %2d: %2d: %2d ",jour,mois,annee,heure,minute,seconde);
switch (tabltyp[i])
{
case 1 :
printf (" Bit address : %6d Value : %12d \n",tabladr[i],tablval[i]);
break;
case 2 :
printf (" Byte address : %6d Value : %12d \n",tabladr[i],tablval[i]);
break;
case 3 :
printf (" Word address : %6d Value : %12d
H%8X\n",tabladr[i],tablval[i],tablval[i]);
break;
case 4 :
printf (" DWord address : %6d Value : %12ld
H%8lX\n",tabladr[i],tablval[i],tablval[i]);
break;
case 5 :
printf (" FWord address : %6d Value : %12.3f\n",tabladr[i],*(float
*)&tablval[i]);
break;
default : break;
}
}
}
}
/* execute function "exitbus" before quitting */
}

Library/DLL 231 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


applicom® time unpacking => UNPACKTIME

Prototypes:

Language Prototype
C void unpacktime(short* wTime, short* wSec, short* wMin, short* wHour, short *
wStatus)
MS pascal procedure unpacktime(var wTime, wSec, wMin, wHour, wStatus:integer)
C# void unpacktime(ref short wTime, out short wSec, out short wMin, out short
wHour, out short wStatus)
VB.NET Sub unpacktime(ByRef wTime As Short, ByRef wSec As Short, ByRef wMin As
Short, ByRef wHour As Short, ByRef wStatus As Short)

Parameters

Parameter Type
wTime applicom® time in packed format.
wSec Return seconds from packed wTime, (rounded to 2 seconds)
wMin Return minutes from packed wTime.
wHour Return hours from packed wTime.
wStatus Error status.

Description:

This applicom® function can be used to unpack the applicom® time in packed format sent back by
the Data-Base GETEVENT function.

See also:
¾ In this manual:
9 General applicom® statuses
9 Logging FIFO reading => GETEVENT

Library/DLL 232 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Display of time stamped events logged in the FIFO.

#include "applicom.h" /* Prototype declaration file */


short ncard; /* Board number */
short nb; /* Number of events */
short tabltyp[20]; /* Type of variables */
short tabladr[20]; /* Address in data-base */
long tablval[20]; /* Type of variables */
short tabldate[20]; /* Event date */
short tabltime[20]; /* Event time */
short status; /* Status */
short i, jour, mois, annee;
short heure, minute, seconde;

main()
{
/* initialize the communication with the applicom® product with "initbus" */
printf("Event FIFO READING \n");
scanf("Board number : %hd \n",&ncard);
scanf("Number of events to be read : %hd \n",&nb);
getevent(&ncard, &nb, tabltyp, tabladr, tablval, tabldate, tabltime, &status);
printf("getevent status = %d \n",status);
if ( status == 0 )
{
if ( nb == 0 )
printf("empty FIFO \n");
else
{
printf("Number of logged events : %hd \n",nb);
for ( i=0 ; i<nb ; i++ )
{
unpackdate (&tabldate[i],&jour,&mois,&annee,&status);
unpacktime (&tabltime[i],&seconde,&minute,&heure,&status);
printf("%2d / %2d / %2d %2d: %2d: %2d ",jour,mois,annee,heure,minute,seconde);
switch (tabltyp[i])
{
case 1 :
printf (" Bit address : %6d Value: %12d \n",tabladr[i],tablval[i]);
break;
case 2 :
printf (" Byte address : %6d Value : %12d \n",tabladr[i],tablval[i]);
break;
case 3 :
printf (" Word address : %6d Value : %12d
H%8X\n",tabladr[i],tablval[i],tablval[i]);
break;
case 4 :
printf (" DWord address : %6d Value : %12ld
H%8lX\n",tabladr[i],tablval[i],tablval[i]);
break;
case 5 :
printf (" FWord address : %6d Value: %12.3f\n",tabladr[i],*(float
*)&tablval[i]);
break;
default : break;
}
}
}
}
/* execute function "exitbus" before quitting */
}

Library/DLL 233 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


BCD-binary transcoding => BCDBIN

Prototypes:

Language Prototype
C void bcdbin(short* wNb, short* lpwTabls, short* lpwTabld, short * wStatus)
MS pascal procedure bcdbin(var wNb, lpwTabls, lpwTabld, wStatus:integer)
C# void bcdbin(ref short wNb, short[] lpwTabls, short[] lpwTabld, out short
wStatus)
VB.NET Sub bcdbin(ByRef wNb As Short, ByVal lpwTabls() As Short, ByVal lpwTabld() As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wNb Number of words to be converted
lpwTabls Table, BCD values to be converted
lpwTabld Table, converted binary values
wStatus Error status.

Description:

This applicom® function converts 16-bit integers expressed in BCD (Binary-coded decimal) in
binary format.

Example:

BCD value = 1234 (Hex) Value after conversion = 1234 (Decimal)

If one of the values positioned in lpwTabls is not in BCD format, status 3 will be returned and no
exchange will be performed.

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 234 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Conversion of the 16 words of tabls.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nb; /* Number of words */
short tabls[16]; /* Source table */
short tabld[16]; /* Destination table */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nb = 16;
bcdbin(&nb, tabls, tabld, &status);
if (status == 0)
{
for (i=0; i<nb; i++)
{
printf( " value before conversion %hd \n", tabls[i] );
printf( " value after conversion %hd \n", tabld[i] );
}
}
else
printf("Problem !! status = %hd \n",status);
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 235 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Binary BCD transcoding => BINBCD

Prototypes:

Language Prototype
C void binbcd(short* wNb, short* lpwTabls, short* lpwTabld, short * wStatus)
MS pascal binbcd procedure(var wNb, lpwTabls, lpwTabld, wStatus:integer)
C# void binbcd(ref short wNb, short[] lpwTabls, short[] lpwTabld, out short
wStatus)
VB.NET Sub binbcd(ByRef wNb As Short, ByVal lpwTabls() As Short, ByVal lpwTabld() As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wNb Number of words to be converted.
lpwTabls Table, Binary values to be converted.
lpwTabld Table, Converted BCD values.
wStatus Error status.

Description:

This applicom® functions converts 16-bit integers expressed in binary format in BCD format
(Binary-coded decimal.

example:
BCD value = 1234 (Decimal) Value after conversion = 1234 (Hex)

If one of the values positioned in lpwTabls is greater than 9999, status 3 will be returned to you
and no conversion will be performed.

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 236 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Conversion of the 16 words of tabls.

#include "applicom.h" /* Prototype declaration file */


short i; /* For loop counter */
short nb; /* Number of words */
short tabls[16]; /* Source table */
short tabld[16]; /* Destination table */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
nb = 16;
binbdc(&nb, tabls, tabld, &status);
if (status == 0)
{
for (i=0; i<nb; i++)
{
printf( " value before conversion %hd \n", tabls[i] );
printf( " value after conversion %hd \n", tabld[i] );
}
}
else
printf("Problem !! status = %hd \n",status);
.
}
/* execute function "exitbus" before quitting */
exit(0);
}

Library/DLL 237 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


11. Modem functions

Modem signal reading => GETMODEM

Prototypes:

Language Prototype
C void getmodem(short * wChan, short * wCts, short * wDcd, short * wStatus)
MS pascal procedure getmodem(var wChan, wCts, wDcd, wStatus: integer);
C# void getmodem(ref ushort wChan, out short wCts, out short wDcd, out short
wStatus)
VB.NET Sub getmodem(ByRef wChan As UShort, ByRef wCts As Short, ByRef wDcd As Short,
ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wCts Clear To Send.
0 = inactive.
1 = active.
wDcd Data Carrier Detect
0 = inactive
1 = active
wStatus Error status.

Description:

This applicom® function can be used to read the modem signals (CTS, DCD) of an applicom®
interface RS232 channel.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Modem link management

Library/DLL 238 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in Microsoft C language

Reading of CTS and DCD modem signals of the applicom® interface channel number 3.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short cts; /* Signal clear to send */
short dcd; /* Signal data carrier detect */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
do
{
nchan=3;
getmodem(&nchan, &cts, &dcd, &status);
if (status == 0)
{
printf (" CTS signal state = %hd \n ", cts);
printf (" DCD signal state = %hd \n ", dcd);
}
}
while(status == 0);
}
/* execute function "exitbus" before quitting */
}

Library/DLL 239 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Modem signal setting => SETMODEM

Prototypes:

Language Prototype
C void setmodem(short * wChan, short * wCts, short * wDcd, short * wStatus)
MS pascal procedure setmodem(var wChan, wCts, wDcd, wStatus: integer);
C# void setmodem(ref ushort wChan, ref short wCts, ref short wDcd, out short
wStatus)
VB.NET Sub setmodem(ByRef wChan As UShort, ByRef wCts As Short, ByRef wDcd As Short,
ByRef wStatus As Short)

Parameters

Parameter Type
wChan Channel number (0-31).
wCts Signal Request To Send.
0 = inactive.
1 = active.
wDcd Signal Data Terminal Ready.
0 = inactive.
1 = active.
wStatus Error status.

Description:

This applicom® function can be used to position the modem signals (DTR, RTS) of an applicom®
interface RS232 channel.

See also:
¾ In this manual:
9 General applicom® statuses
¾ In the documentation:
9 Operation modes: Modem link management

Example in Microsoft C language

Setting to 1 of RTS and DTR signals of the applicom® interface channel number 3.

#include "applicom.h" /* Prototype declaration file */


short nchan; /* Channel number */
short rts; /* Signal request to send */
short dtr; /* Signal data terminal ready */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
{
{
nchan=3; rts=1; dtr=1;
setmodem(&nchan, &rts, &dtr, &status);
if (status == 0)
{
printf (" Active RTS and DTR modem signals \n");
}
}
}
/* execute function "exitbus" before quitting */
}

Library/DLL 240 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


12. Annex functions

Watchdog contact activation => WATCHDOG

Prototypes:

Language Prototype
C void watchdog(short * wCard, short* wTime, short * wStatus)
MS pascal procedure watchdog(var wCard, wTime, wStatus:integer)
C# void watchdog(ref ushort wCard, ref short wTime, out short wStatus)
VB.NET Sub watchdog(ByRef wCard As UShort, ByRef wTime As Short, ByRef wStatus As
Short)

Parameters

Parameter Type
wCard Board number (1-8).
wTime Contact closing period in seconds.
wTime = 0, Contact opening without period.
wTime = -1, Contact closing without period.
wStatus Error status.

Description:

This applicom® function can be accessed on all the applicom® interfaces. A watchdog contact is at
the user's disposal. This contact can be set as closed, open or refreshed for a given period. In this last
case, the contact closes as soon as the function is called and reopens after the time entered in parameter,
unless the user program has refreshed this function again before this time has elapsed.

See also:
¾ In this manual:
9 General applicom® statuses

Example in Microsoft C language

The following subroutine refreshes the watchdog contact for a 10-second period. If this subroutine
is not run again before 10 seconds, the watchdog contact will open.

#include "applicom.h" /* Prototype declaration file */


short ncard; /* Board number */
short time; /* Closing time */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
do
{
ncard=1;time=10;
watchdog(&ncard, &time, &status);
if(status == 0)
printf(" Watchdog contact closed for %hd second \n ", time);
}
while(1);
/* execute function "exitbus" before quitting */
}

Library/DLL 241 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Reading discrete input/output => AppGetWatchDog

Prototypes:

Language Prototype
C void AppGetWatchDog(short * wCard, unsigned short * wDI, unsigned short *
wTimeContact, short * wStatus)
MS pascal procedure AppGetWatchDog(var wCard:integer ; var wDI_wTimeContactiwStatus,
_c: integer ; var status :integer)
C# void AppGetWatchDog(ref ushort wCard, out ushort wDI, out ushort
wTimeContact, out short wStatus)
VB.NET Sub AppGetWatchDog(ByRef wCard As UShort, ByRef wDI As UShort, ByRef
wTimeContact As UShort, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wDI Discrete input status. (0 or 1).
wTimeContact Watchdog. output contact status
wTimeContact = 0, Contact opens.
wTimeContact = 65535, Contact closes.
0 < wTimeContact < 65535, Contact closed during the time
expressed in seconds
wStatus Error status.

Description:

This applicom® function is used to read the status:


¾ of the discrete input.
¾ of the “watchdog” output contact.

This function is only supported on the interfaces with 3.2 or higher EPROM version.

See also:
¾ In this manual:
9 General applicom® statuses
9 Watchdog contact activation => WATCHDOG

Library/DLL 242 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Example in C Microsoft language

The following sub-routine reads the status of the discrete input and of the “watchdog” contact.

#include "applicom.h" /* Prototype declaration files */


short ncard = 1; /* Board number */
unsigned short digital_input; /* Discrete input status */
unsigned short time_contact; /* Time */
short status; /* Status */

main()
{
/* initialize the communication with the applicom® product with "initbus" */
AppGetWatchDog( &ncard, &digital_input, &time_contact, &status);
if ( status == 0 )
{
printf(" Discrete input = %hu \n ", digital_input );
printf(" Contact time = %hu secondes \n ", time_contact );
}
else
printf(" Status AppGetWatchDog = %hd \n ", status );
/* execute the "exitbus" function before quitting */
}

Library/DLL 243 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Access to the software protection key => ACCESSKEY

Prototypes:

Language Prototype
C void accesskey(short * wCard, short * wType, short* wVal, short * wStatus)
MS pascal procedure accesskey(var wCard, wType, wVal, wStatus:integer)
C# void accesskey(ref ushort wCard, ref short wType, ref short wVal, out short
wStatus)
VB.NET Sub accesskey(ByRef wCard As UShort, ByRef wType As Short, ByRef wVal As
Short, ByRef wStatus As Short)

Parameters

Parameter Type
wCard Board number (1-8).
wType Type of access to protection circuit.
0 = Circuit reading
1 = Circuit writing
wVal Value read in the circuit if wType = 0.
Value set in the circuit if wType = 1.
wStatus Error status.

Description:

An algorithm can be defined to protect your software from copies. For that purpose, the
ACCESSKEY function can be used to read or write a bytes sequence. Your program will have to check
that the read/write sequencing is consistent with the algorithm you defined.
Please contact applicom® to have more information about the way to define this algorithm.

See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 244 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Date and time Initialization => AppIniTime

Prototypes:

Language Prototype
C void AppIniTime( short * wChan, short * wStatus)
MS pascal procedure AppIniTime( var wChan, wStatus:integer );
C# void AppIniTime(ref ushort wChan, out short wStatus)
VB.NET Sub AppIniTime(ByRef wChan As UShort, ByRef wStatus As Short)

Parameters

Parameter Type
wChan Card number (1-8).
wStatus Error status.

Description :

This applicom® function allows to initialize the date and the time of the applicom® interface with
the date and the time of the PC.
See also:
¾ In this manual:
9 General applicom® statuses

Library/DLL 245 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


13. General applicom® statuses

Status description
-6 The function TRANSCYC (or TRANSCYCPACK) is used with a cyclic function number which was
activated but is no longer.
-5 The user program is attempting to make a deferred transfer TRANSDIF (or TRANSDIFPACK) although the
current deferred request is not finished.
-1 Deferred transfer request TRANSDIF (or TRANSDIFPACK) concerning a write which took place correctly.
0 No anomaly detected. The function was executed correctly.
1 Unknown function.
The function requested is not supported.
2 Bad address.
The address of the variable that you are soliciting is bad.
3 Bad data.
Additional information:
Function: BINBCD, BCDBIN.
- At least one of the values accessed is not in BCD format (0<= value <= 9999).
Function: WriteByte, WriteQByte
- The different values will be stored in the least significant bytes of the integer table. If the most significant
byte does not equal 0, the returned status will be 3
4 Inaccessible data.
32 Bad parameter passed to the function.
Bad number of variables.
35 Data not available in cyclic read.
Attempt to transfer data by TRANSCYC (or TRANSCYCPACK) before reading the data
in the device.
40 Deferred read or write attempt by a task when the maximum number of tasks which can use deferred mode
simultaneously has been reached.
Another task must release resources by performing an exitbus.
41 Deferred read or write attempt when the deferred request register is full.
Perform deferred request transfers with TRANSDIF (or TRANSDIFPACK) to release the register (64
positions).
42 Deferred request transfer attempt with TRANSDIF (or TRANSDIFPACK) when it is empty (no deferred
requests to do).
45 Communication program not resident.
Initialize the applicom® interface before using it by launching PCINIT tool.
®
46 Board number not configured, or applicom master/client function targeting a channel configured as
slave/server or vice versa.
47 No applicom® interface.
51 Driver system problem.
®
59 - Protection key missing on the applicom interface.
®
- Use of applicom functions without calling the function INITBUS beforehand.
66 Not enough applicom® interface memory.
97 Operating mode.

255 Used by the Windows server “PCDDE”. Initial value of the items “STATUS_READ” and “STATUS_WRITE”.
This value indicates that no transaction was carried out between “PCDDE” and the applicom® interface.

Remark: negative statuses are information codes.

Library/DLL 246 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.


Library/DLL 247 08/02/2008

Copyright © 2006 Woodhead Software & Electronics. All rights reserved.

You might also like