0% found this document useful (0 votes)
54 views

SAMDECProg Int

Uploaded by

Moazzam Niazi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

SAMDECProg Int

Uploaded by

Moazzam Niazi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

This is the 9 October, 2007 release of the SAM/DEC programming

interface, QD/SW/BK/0011. Please see the “Revision Histories”


section of the SAM/DEC programming interface for any revisions
to controlled documents since last release.
2007
SAM/DEC programming interface

©ACRA CONTROL, 2007


All Rights Reserved

The information in this publication is provided for reference only. All information contained in this publication is
believed to be correct and complete. ACRA CONTROL shall not be liable for errors contained herein nor for
incidental or consequential damages in connection with the furnishing, performance, or the use of this
material. All product specifications, as well as the information contained in this publication are subject to
change without notice.

This publication may contain or reference information and products protected by copyrights or patents and
does not convey any license under the patent rights of ACRA CONTROL, nor the rights of others. ACRA
CONTROL does not assume any liability arising out of any infringements of patents or other rights of third
parties.

ACRA CONTROL makes no warranty of any kind with regard to this material, including but not limited to, the
implied warranties or merchantability and fitness for a particular purpose.

All world rights reserved. No part of this publication may be stored in a retrieval system, transmitted, or
reproduced in any way, including but not limited to, photocopy, photograph, magnetic or other record, without
the prior written permission of ACRA CONTROL.

CONTACT DETAILS
ACRA CONTROL INC ACRA CONTROL LTD
44145 Airport View Drive Landscape House
Hollywood, MD 20636 Landscape Road, Dublin 14
USA Ireland
Phone: (301) 373-9220 Phone: +353-1-2951264
Fax: (301) 373-9223 Fax: +353-1-2951265
Email: [email protected] Email: [email protected]
Website: www.acracontrol.com Website: www.acracontrol.com

ii
ABOUT THIS BOOK
This book describes the API interface supplied by ACRA CONTROL for setting up and acquiring data from
• SAM/DEC/005 PCM decoders
• SAM/DEC/006 PCM decoders
• SAM/DEC/007 PCM decoders
• SAM/DEC/007/UT PCM decoders
The appendices describes how to Install the ACRA CONTROL PCMCIA decoders in Linux Red Hat 7.3.,
MandrakeLinux 10.1. and Windows CE.

iii
SUGGESTED READING PATHS

Engineers wanting to use the ACRA CONTROL PC card “Using Installation utility”
PCM decoder installation utility

Engineers wanting information on the API interface with “Programming Interface for ACRA
PCM decoder cards CONTROL PCMCIA PCM Decoders”

Engineers wanting to know how to Install the ACRA “Installing ACRA CONTROL PCMCIA
CONTROL PCMCIA decoders in Linux Red Hat 7.3 decoders in Linux Red Hat 7.3”

Engineers wanting to know how to Install the ACRA “Installing ACRA CONTROL PCMCIA
CONTROL PCMCIA decoders in MandrakeLinux 10.1 decoders in MandrakeLinux 10.1”

Engineers wanting to know how to Install the ACRA “Installing PCM decoders in Windows CE”
CONTROL PCMCIA decoders in Windows CE

Engineers wanting to know the revision history of the “Revision history”


Programming Interface for ACRA CONTROL PCMCIA
PCM Decoders Manual

iv
Contents
Contact details . . . . . . . . . . . . . . . . ii
About this book . . . . . . . . . . . . . . . . iii
Suggested Reading Paths . . . . . . . . . . . . . . . . . iv

CHAPTER 1: USING INSTALLATION UTILITY . . . . . . . . . . . . . 1


1.1 Introducing PC Card PCM Decoder Installation Utility . . . . . . . . . . . 2
Using the Installation utility . . . . . . . . . . . . . . . . 2
Using Install Options . . . . . . . . . . . . . . . . . . 2

CHAPTER 2: PROGRAMMING INTERFACE FOR ACRA CONTROL PCMCIA PCM DECODERS 9


2.1 Introducing Decoder cards . . . . . . . . . . . . . . . . . . 10
Windows driver files . . . . . . . . . . . . . . . . . . 10
Linux Red Hat 7.3 driver files . . . . . . . . . . . . . . . . 11
Card information structure . . . . . . . . . . . . . . . . . 11
2.2 Interfacing issues . . . . . . . . . . . . . . . . . . . . 12
Using the DLL in Windows 95/98/ME . . . . . . . . . . . . . . 12
Windows NT4 and Windows 2000 device driver setup . . . . . . . . . 13
Linux . . . . . . . . . . . . . . . . . . . . . . 13
Using the DLL with LabVIEW . . . . . . . . . . . . . . . . 14
Using the DLL with Visual Basic . . . . . . . . . . . . . . . 14
2.3 Library interface . . . . . . . . . . . . . . . . . . . . 15
Overview . . . . . . . . . . . . . . . . . . . . . 15
PCMCIA interface functions . . . . . . . . . . . . . . . . 15
Status checking . . . . . . . . . . . . . . . . . . . 18
Data acquisition functions . . . . . . . . . . . . . . . . . 20
Decoder setup functions . . . . . . . . . . . . . . . . . 25
Error messages . . . . . . . . . . . . . . . . . . . 32
2.4 Pseudo code example . . . . . . . . . . . . . . . . . . . 34
2.5 GETERROR() string values . . . . . . . . . . . . . . . . . 35
2.6 Hardware interface. . . . . . . . . . . . . . . . . . . . 36
Data acquisition . . . . . . . . . . . . . . . . . . . 36
Setting up the decoder . . . . . . . . . . . . . . . . . 37
Mapping the decoder to PC address space . . . . . . . . . . . . 37

APPENDIX A: INSTALLING DECODERS IN LINUX . . . . . . . . . . . . 39


A.1. Installing ACRA CONTROL PCMCIA decoders in Linux Red Hat 7.3 . . . . . . 40
Installing PCMCIA support . . . . . . . . . . . . . . . . 40
Installing the device driver MEMORY_CS . . . . . . . . . . . . . 40
Updating the PCMCIA database . . . . . . . . . . . . . . . 41
Device access rights . . . . . . . . . . . . . . . . . . 41

v
Verifying device installation . . . . . . . . . . . . . . . . 42
Installing the shared library libasdx32l.so.1.1 . . . . . . . . . . . . 42
Compatibility issues . . . . . . . . . . . . . . . . . . 43
Using the shared library libasdx32l.so.1.1 . . . . . . . . . . . . 43
Making the test utility . . . . . . . . . . . . . . . . . . 43
PCMCIA debug utilities . . . . . . . . . . . . . . . . . 44
A.2. Installing ACRA CONTROL PCMCIA Decoders in MandrakeLinux 10.1 . . . . . 46
Configuring the MTD subsystem . . . . . . . . . . . . . . . 46
Configuring the PCMCIA subsystem . . . . . . . . . . . . . . 47
Creating MTD device . . . . . . . . . . . . . . . . . . 48
Final steps . . . . . . . . . . . . . . . . . . . . 48

APPENDIX B: INSTALLING PCM DECODERS IN WINDOWS CE . . . . . . . . 49


B.1. Installing decoder drivers in Windows CE . . . . . . . . . . . . . 50
Installing drivers . . . . . . . . . . . . . . . . . . . 50
Testing the drivers . . . . . . . . . . . . . . . . . . 51
REVISION HISTORY . . . . . . . . . . . . . . . . . . . . 55

vi
USING INSTALLATION UTILITY
1

1
1.1 INTRODUCING PC CARD PCM
DECODER INSTALLATION UTILITY
The ACRA CONTROL PC Card PCM decoder installation utility simplifies and verifies
the installation of the device drivers for the ACRA CONTROL PC Card PCM decoder
and KAM-500 programming cards. The device drivers are not installed automatically; the
Hardware Wizard will run as normal.
The following operating systems support this utility,
1
• Windows XP
• Windows 2000
1 • Windows ME
• Windows 98
• Windows 95
The installation process for Windows 95, 98 and ME are similar and these operating
systems are referred to as Windows 9x in this document.

Note: For the Windows 9x operating systems this utility does not support
the non-Care Information Structure (CIS) versions of the SAM/DEC/005
card. CIS is the structure that PC Cards require for resource allocation in
plug and play operating systems.

1.1.1 USING THE INSTALLATION UTILITY


The installation utility interface is a dialog box with two tabbed screens, one screen
includes installation functions and the other includes driver test and verification
functions. There are common report and device information panels.

1.1.1.1 Viewing information


The information panel lists the operating system and the cards inserted in the PC at start
up of the utility, or after the List Card(s) button was pressed in the Test Tab. If the Test
Tab is active then there is a check box associated with each device. This check box
allows the SRAM test to be turned off or on for each inserted ACRA CONTROL device.
The SRAM test is turned on by default.
If the installation utility is running successfully, the information panel will show that the
drivers are installed, and a card inserted.

1.1.2 USING INSTALL OPTIONS


To copy and remove the correct operating system device drivers from the hard disk,
• select the Install tab

2 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
1

1.1.2.1 Copying driver files


When you copy driver files, only the driver files for your operating system are copied to
the hard disk.
To copy driver files,
• select Copy
The destination directory is read from the registry key,
HKEY_LOCAL_MACHINE\Software\ACRA CONTROL\Decoders\Driver Path

Setting an installation directory


If there is no registry entry, a dialog box is displayed allowing you to select a directory.

To select the default installation directory ‘ACRA_DRIVERS’,


• select Default

Introducing PC Card PCM decoder installation utility 3


Copying driver files using Windows XP
If you use Windows XP, the utility to copy files also pre-installs the installation file
SDX_2K_XP.INF
The SDX_2K_XP.INF file is copied and renamed in the Windows inf directory to
OEMxx.INF where xx is a number. This pre-installation step means when you run the ‘Add
New Hardware Wizard’, it will launch with the correct installation directory path.
The default driver directory for Windows XP is:
\ACRA_DRIVERS\WIN_2K_XP

1 Copying driver files using Windows 2000


Enter the installation path at the Hardware Wizard interface.

1 The default driver directory for Windows 2000 is:


\ACRA_DRIVERS\WIN_2K_XP

Copying driver files using Windows 9x


Enter the installation path at the Hardware Wizard interface.
The default driver directory for Windows 9x is
\ACRA_DRIVERS\WIN_9X

1.1.2.2 Removing installation files


Before reinstalling installation files, they must be removed first.
For all operating systems the Remove function removes installation files and drivers
from the directory they have been copied to. It will not uninstall device drivers. If you
wish to remove drivers, uninstall them manually using the device manager before
removing installation files.

Removing installation files in Windows XP and Windows 2000


To remove installation files,
• select Remove
The OEMxx.INF file corresponding to the installation file SDX_2K_XP.INF is deleted from
the hard disk.
If you uninstall the drivers, remove and then re-insert the SAM/DEC/00x card, then the
Add new hardware Wizard will launch.

Removing installation files in Windows 9x


All installation files are removed in one step.
To remove installation files,
1. select Remove, you are prompted to remove all driver files
2. select Yes
This removes:
• ACRA CONTROL installation files. (At installation the installation file is copied to the
sub directory INF\OTHER in the Windows directory and renamed. The name is based
on the identification string contained in the CIS.)
• device driver file ASDXW95.VXD from the device driver directory
• ACRA CONTROL device entries from the PCMCIA registry key

4 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
Displaying driver details
To display details of the driver,
• select Driver Details
A message box is launched which displays the device driver name, time, date and size.

1.1.2.3 Using test options


To test the SAM/DEC card and verify the device driver installation process, 1
• select the Test tab

Testing installed cards

To perform an SRAM test,


• select Test Card(s)
The SRAM test is performed on selected cards. If this test fails then there may be a
memory resource problem. If a card fails then contact ACRA CONTROL.

Listing installed cards


List Card(s) searches for inserted ACRA CONTROL PC Card devices and updates the
information panel. You must use this button to update the information panel if devices
are removed or inserted while the utility is running.
To list inserted ACRA CONTROL PC Cards,
• select List Card(s)

Introducing PC Card PCM decoder installation utility 5


Viewing card history
To view inserted card types,
• select Card History
Every card type inserted is recorded in the registry. Card History searches the registry
for all ACRA CONTROL PC Cards. There should be between one and six card types
found. If there are more found it may indicate a problem with the PC Card adapter.

Verifying driver installation


1 To check if the device driver is correctly installed,
• select Verify Driver
This verifies that the correct device driver for the operating system is installed.
1
1.1.2.4 Changing the report log file
The Report shows information from the install and test functions. It also allows you to
specify a report file and whether one is generated or not.
To change the Report log files,
1. select the Generate Report File dialog box

2. select
3. navigate to the directory to save the report file

1.1.2.5 Closing the installation utility


To quit the installation utility,
• select Close

6 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
1.1.2.6 Troubleshooting the installation utility
Faults detected are listed in Table 1.1.

Problem Detected by Error Solution


Fails SRAM test Test Card(s) function Invalid memory Contact Support at
window ACRA CONTROL
Fails SRAM test Test Card(s) function Physical device Contact Support at
memory fault ACRA CONTROL
No PCMCIA key in Start up of utility PC Card adapter Check PCMCIA 1
registry device drivers not installation
installed
No PCMCIA key or Start up of utility or PC Card adapter Check PCMCIA
more than 6 Card History function fault installation
different card types
found in the
registry. See
“Viewing card
history” on page 6
Installation file is Start up of utility or Wrong installation file Uninstall and reinstall
incorrect for the Verify Driver function
operating system
Driver file is Start up of utility or Wrong device driver Uninstall and reinstall
incorrect for the Verify Driver function
operating system
No device driver Start up of utility, Device Driver not Install driver
found on the hard Verify Driver or installed
disk Driver Details
function
Device driver Start up of utility or Non CIS device PCMCIA does not
ASD5W95.VXD is Verify Driver active (only for support the utility
statically loaded Windows 9x)
in the SYSTEM.INI
file

Table 1.1

Introducing PC Card PCM decoder installation utility 7


1

THIS PAGE IS INTENTIONALLY BLANK

8 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
2: PROGRAMMING INTERFACE
FOR ACRA CONTROL PCMCIA
PCM DECODERS
2

9
2.1 INTRODUCING DECODER CARDS
The SAM/DEC/005, SAM/DEC/006 and SAM/DEC/007 from ACRA CONTROL are
compact PCM decoders in a class II PCMCIA package. This document describes the
API interface supplied by ACRA CONTROL for setting up and acquiring data from these
decoders.
This interface is provided through a Windows dynamic link library (DLL) or a shared
library in Linux. Section 2.6 describes the basic decoder hardware and the PC interface.
This information is provided for background only, it is not necessary to understand this
interface in detail to use the functions in the drivers.
The basic decommutation capabilities of decoders are listed in Table 2.1.
2
1 Feature SAM/DEC/005 SAM/DEC/007 SAM/DEC/006
Syncword 32 bits 34 bits 48 bits
Syncmask 32 bits 34 bits 48 bits
Max baudrate (with clock) 4Mbps 10Mbps 20Mbps
Max baudrate (without clock) 2Mbps 5Mbps 8Mbps
Parity on syncword No No No
Bit order, word by word Yes Yes Yes
Bit length, word by word Yes Yes Yes
Parity, word by word Yes Yes Yes
Parity for words >16 bits No No Yes
PCM codes NRZ-L and BI∅-L NRZ-L and BI∅-L 15 codes
PCM output No No Yes
TTL Yes Yes Yes
RS422 Yes Yes Yes
Clock invert Yes Yes Yes
PCM invert Yes Yes Yes
Lock on inverse of syncword Yes Yes Yes
Lock on syncword only No Yes Yes
Table 2.1
Table 2.2 lists the operating systems that ACRA CONTROL provides decoder drivers
for.

Operating DOS Windows NT4 Windows Linux Mandrake Windows Windows


System 95/98/ME 2000 Red Hat Linux XP CE
7.3 10.1
Driver Yes Yes Yes Yes Yes Yes Yes Yes

Table 2.2

2.1.1 WINDOWS DRIVER FILES

ASDX32W.DLL 32-bit programming interface for Windows 95/98/ME, NT4 and Windows
2000.

10 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
ASDX16V.DLL 16-bit programming interface for Windows 95/98/ME and Windows
3.11/DOS.
ASD5W95.VXD Device driver for Windows 95/98/ME.
ASD5NT.SYS Hardware device driver for Windows NT4. Native PCMCIA drivers must be
replaced by Cardware Version 6 for Windows NT from drivers from
AWARD Software.
ASD5NT2.SYS Hardware device driver for Windows 2000.
ASD5CE.DLL Hardware device driver for Windows CE.

2.1.2 LINUX RED HAT 7.3 DRIVER FILES 2

memory_cs.o Hardware device driver. The generic memory card driver included in the
PCMCIA support package.
libasdx32l.so.1.1 Shared library providing the decoders programming interface.

2.1.3 CARD INFORMATION STRUCTURE


Depending on the operating system used the decoder may require a card information
structure (CIS). This structure is stored in the decoders EEPROM and may be required
by "plug and play" operating systems to identify and configure the card. Multiple
decoders can be supported if they all have CIS. Table 2.3 identifies which operating
systems require CIS.

Operating DOS Windows NT4 Windows Linux Mandrake Windows


system 95/98/ME 2000 Red Hat Linux 10.1 XP
7.3
CIS No N/A1 Yes Yes Yes Yes Yes
required
Table 2.3
1.Windows 95/98/ME only supports one type at a time. To change to a different
type, the appropriate driver must be installed and the system rebooted.
DOS and Windows 95/98/ME only support a single non-CIS card at a time. Non-CIS and
CIS decoders cannot be used in the same system.

Note: All decoders now supplied by ACRA CONTROL are programmed with
CIS. Only older SAM/DEC/005 decoders may not have CIS.

Introducing decoder cards 11


2.2 INTERFACING ISSUES
2.2.1 USING THE DLL IN WINDOWS 95/98/ME

2.2.1.1 Windows 95/98/ME 16-bit programs


ASDX16V.DLL can be used by any 16-bit program running on Windows 95/98/ME.
However, the standard Windows 95/98/ME PCMCIA drivers must be enabled and the
decoder device drivers installed. See Section 2.2.1.2 for instructions on installing these
2 drivers.

1
2.2.1.2 Windows 95/98/ME 32-bit device driver setup
If a CIS card is being used for the first time then the Add new hardware wizard will start
automatically.
To install the drivers for a non-CIS card perform the following steps:
1. select Control Panel − Install New Hardware
2. select Do not let windows detect new hardware
3. from category list, select Other Device (question mark icon)
4. select Have Disk...
5. insert disk in drive A:\ and point dialog box to drive A:\
6. from the option list, select the PC Card PCM Decoder (non-plug-and-play)
installation script and install it

Warning: The driver with a non-CIS card is not plug-and-play compatible. It


assumes the decoder is permanently available. Accordingly please ensure
that the decoder is inserted before Windows starts up and do not remove
the decoder while the PC is running.

Warning: The CIS card is "plug and play" compatible but the card should
not be removed while an application is accessing it. The card does not
need to be present at boot up and it can be removed and inserted multiple
times.

Warning: The VXD generates a log file to assist post-mortem examinations


in the event of problems. This file is called ASD5VXD.LOG and will be
created in the root directory.

Note: An application can make multiple calls to ASDxOpen() and


ASDxClose().

12 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
2.2.2 WINDOWS NT4 AND WINDOWS 2000 DEVICE DRIVER
SETUP
For Windows NT4 and Windows 2000 operating systems the decoder must be
programmed with CIS. All SAM/DEC/005 MkIII, SAM/DEC/006 and SAM/DEC/007 cards
can be programmed with CIS. Only some earlier SAM/DEC/005 MkIII cards may not
have CIS programmed.

2.2.2.1 Windows NT4


Before the DLL can be used the third-party PCMCIA drivers Cardware v6.0 from
UNICORE must be installed. These drivers can be purchased online at the web site 2
www.unicore.com. These third party drivers are required because the native drivers do
not support 16-bit memory cards.
The device driver is installed with the installation program NT4INST.EXE. This copies
the driver file asd5nt.sys to the windows subdirectory system32\drivers and sets up the
PCMCIA registry entry for the specified device.
• run nt4inst 5 to set up a SAM/DEC/005
• run nt4inst 7 to set up a SAM/DEC/007
If no device type number is specified on the command line then a SAM/DEC/005 driver
is installed. Administrator privileges are required to install the drivers. If a desktop PC is
being used refer to the Cardware documentation for the list of supported PCMCIA
adapters. A PCI PCMCIA adapter is required for bit rates greater than 100kbps. The
driver DLLs (CC3260.dll and STLP45.dll) may have to be installed manually and should
be copied to the same directory as the SAM/DEC DLL.

2.2.2.2 Windows 2000/XP


No third-party drivers are required and installation of the Windows 2000 driver is similar
to the Windows 95/98/ME driver, see section 2.2.1.1 “Windows 95/98/ME 16-bit
programs” If the drivers have not been installed prior to the decoder being inserted,
Windows 2000 recognizes the card through the CIS and starts the Add new hardware
wizard to install the drivers. Administrator privileges may be required for driver
installation. If the decoder is to be used in a desktop PC then the following PCMCIA
adapters are recommended.

PCMCIA adapter Ratoc CBS51 SCM SwapBox SBP-D2


Bus type PCI ISA
Maximum bit rate 10Mbps 1Mbps
Table 2.4

2.2.3 LINUX
There is no automatic installation procedure for the decoders in Linux. The installation
process involves modifying PCMCIA configuration files and may involve installing
PCMCIA support, kernel source code and building and installing the memory card driver.
PCMCIA support is generally installed if a PCMCIA adapter was found at installation
time. This installation process is not trivial. Please see “Appendix A: Installing decoders
in Linux” for full installation details.

Interfacing issues 13
2.2.4 USING THE DLL WITH LABVIEW
The DLL can be used with LabVIEW like any other DLL. Please refer to LabVIEW
documentation for information on how to interface with LabVIEW. Note that the calling
convention used is WINAPI.

2.2.5 USING THE DLL WITH VISUAL BASIC


The DLL can be used with 16-bit or 32-bit Visual Basic (VB) programs. The normal rules
of interfacing with DLLs apply. Please refer to VB documentation.

2 All DLL functions must be declared globally in the VB application. The following list of
examples shows how this is done:
1
Declare Function ASDxCreate Lib "asdx32w" () As Long
Declare Function ASDxOpen Lib "asdx32w" (ByVal hInst As Long, ByVal A As
Integer, ByVal b As Integer) As Long
Declare Function ASDxClose Lib "asdx32w" (ByVal hInst As Long) As Long
Declare Function ASDxDestroy Lib "asdx32w" (ByVal hInst As Long) As Long
Declare Function ASDxInitFormat Lib "asdx32w" (ByVal hInst As Long) As Integer
Declare Function ASDxReadFrameEx Lib "asdx32w" (ByVal hInst As Long, ByVal
theStart As Long, ByRef theBuffer As Integer, ByVal theFrameLength As Long,
byRef theTail As Integer) As Integer
Declare Sub ASDxHaltPCM Lib "asdx32w" (ByVal hInst As Long)
Declare Sub ASDxEnablePCM Lib "asdx32w" (ByVal hInst As Long)
Declare Function ASDxTestSync Lib "asdx32w" (ByVal hInst As Long) As Byte
Declare Sub ASDxSetBaud Lib "asdx32w" (ByVal hInst As Long, ByVal baudrate As
Double)
Declare Sub ASDxSetWordDefinition Lib "asdx32w" (ByVal hInst As Long, ByVal
theWord As Integer, ByVal theBits As Integer, ByVal theOrder As Integer, ByVal
theParity As Integer)
Declare Sub ASDxSetCode Lib "asdx32w" (ByVal hInst As Long, ByVal theWord As
Long)
Declare Sub ASDxSetEndOfFrame Lib "asdx32w" (ByVal hInst As Long, ByVal
theWord As Long)
Declare Sub ASDxSetSyncWordEx Lib "asdx32w" (ByVal hInst As Long, ByRef as
char, ByVal theWord As Long)
Declare Sub ASDxSetSyncMaskEx Lib "asdx32w" (ByVal hInst As Long, ByRef as
char, ByVal theWord As Long)

Note: With 32-bit VB the filename declarations for DLL functions are case
sensitive. Use all lower-case characters for the file.

14 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
2.3 LIBRARY INTERFACE
2.3.1 OVERVIEW

2.3.1.1 Header files


The drivers are normally supplied as a DLL. The interface functions are compiled with a
PASCAL interface and are accessible from C, C++, PASCAL, DELPHI and Visual
BASIC.
The C++ header files SDX.H, SDXUTIL.H, AWINDOWS.H, SD5HNDL.H and 2
SD5_VER.H are supplied for the guidance of C++ users.

2.3.1.2 Syntax
The functions in the drivers are described below. These functions are in many cases
sensitive to the length of the parameters in bits. To provide compiler and platform
independence the following syntax is used for C declarations:

Type Size (bytes) 16-Bit C equivalent 32-bit C equivalent


WORD 2 unsigned int unsigned short
BOOL 2 unsigned int unsigned int
CHAR 1 char char
BYTE 1 unsigned char unsigned char
DWORD 4 unsigned long unsigned int
HDECODER 4 void * void *
Table 2.5

2.3.2 PCMCIA INTERFACE FUNCTIONS

2.3.2.1 ASDxCreate()

HDECODER ASDxCreate(void)

This function creates a memory structure to manage access to the decoder. Up to four
decoder objects can exist simultaneously.
The return value is a handle to the created object and must be used in all subsequent
calls to driver functions. A return value of 0 indicates that the system was unable to
create the object. More than four calls to ASDxCreate() will always return 0 unless an
ASDxClose() has been called.

Inputs:
None.

Outputs:
Returns the decoder handle, or NULL if all four exist already.

Library interface 15
2.3.2.2 ASDxDestroy()

WORD ASDxDestroy( HDECODER theDecoder )

This function destroys an instance of the decoder management structure attached to


theDecoder and frees the memory used.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().

2 Outputs:
The return value is 0 if no error occurs. If theDecoder is not valid it returns 2116 (33
1 decimal).

2.3.2.3 ASDxSetInitialTimeout()

VOID ASDxSetInitialTimeout( HDECODER theDecoder, DWORD theDelay )

This function only has meaning under Windows 95/98/ME for non-CIS cards. On some
systems there is a significant delay between inserting the card (or starting up an
application which uses the card) and the card being recognized by Windows. Attempting
to use the card before it is recognized results in an error value 20 ("No Card In Slot")
from ASDxOpen. The initial time-out instructs the DLL to wait for theDelay microseconds
before attempting to access the card. This function must be called after ASDxCreate and
before ASDxOpen. The default value for theDelay is 10000.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theDelay – the time to wait in ms.

Outputs:
No return value.

2.3.2.4 ASDxOpen()

WORD ASDxOpen( HDECODER theDecoder, WORD theAccess, WORD theMode )

Initializes PCMCIA Hardware and opens the Memory window to the first decoder. This
must be called before anything else can be done. The software will check each PC Card
socket in turn for a decoder and create a handle for the first one it finds. To open
handles to more than one decoder use ASDxOpenEx().

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theAccess – variable to control PCMCIA interface access timing for debug purposes.
Normally this value is 210 decimal.
theMode – verbose mode. If this value is 1 the DLL prints out progress messages for
debug purposes.

16 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
Outputs:
The return value is 0 if initialization completes successfully. Otherwise an error code is
returned. This code can be converted to text by passing it to ASDxGetError(). If your
platform is unable to interpret the C format character strings returned by
ASDxGetError(), see Section 2.5 for a list of the return values and their meanings.

2.3.2.5 ASDxOpenPlus()

WORD ASDxOpenPlus(HDECODER theDecoder, WORD theDeviceNo, WORD theSpeed,


WORD Vcc, WORD Vpp1, WORD Vpp2, WORD SetPower, WORD Verbose)

Use this function to open a specific decoder. For Windows 2000, XP and Linux Red Hat 2
7.3 this is the device instance while for NT4 and Windows 95/98/ME it is the socket
number. Initializes PCMCIA hardware and opens a memory window to the requested
decoder. This must be called before anything else can be done.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()
theDeviceNo – The decoder to open. This refers to the socket number in all operating
systems except Windows 2000, XP and Linux Red Hat 7.3, where it refers to the device
instance.
theSpeed – variable to control PCMCIA interface access timing for debug purposes.
Normally this value is 210 decimal.
Vcc, Vpp1, Vpp2, SetPower – these parameter are reserved and must be set to zero.
Verbose – verbose mode. If this value is 1 the DLL prints out progress messages for
debug purposes.

Outputs:
The return value is 0 if initialization completes successfully. Otherwise an error code is
returned. This code can be converted to text by passing it to ASDxGetError(). If your
platform is unable to interpret the C format character strings returned by
ASDxGetError(), see Section 2.5 for a list of the return values and their meanings.

2.3.2.6 ASDxClose()

WORD ASDxClose( HDECODER theDecoder )

Ends software interaction with the decoder attached to theHandle. Frees all system
resources used to access the PCMCIA drivers.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()

Outputs:
The return value is 0 if initialization completes successfully. Otherwise an error code is
returned. This code can be converted to text by passing it to ASDxGetError(). If your
platform is unable to interpret the C format character strings returned by
ASDxGetError(), see Section 2.5 for a list of the return values and their meanings.

Library interface 17
2.3.3 STATUS CHECKING

2.3.3.1 ASDxTestSync()

struct ASD5SyncState ASDxSyncState ( HDECODER theDecoder )

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()

2 Outputs:
1 Returns a ASD5SyncState structure. This is a 16 bit field, listed in Table 2.6.

Bit Meaning
0 System is in sync, data is being received
1 ASDxInitFormat() has not been called, decoder is not initialized
2 No syncword in data stream
4 Number of bits between syncwords is incorrect
5 Parity error in data
6 Clock error in data
Table 2.6

Note: These errors are not mutually exclusive. A return value of 20 (16+4)
indicates that there is a parity error and that no syncword is in the data
stream.

2.3.3.2 ASDxGetFrameCount()

int ASDxGetFrameCount( HDECODER theDecoder)

Returns the current frame that is being filled by the hardware. The hardware acts as a
circular buffer of frames. The frame count runs from 0 to the maximum number of frames
which can be stored in the buffer, wrapping around if the buffer fills. This function is only
supported by the SAM/DEC/005 decoders.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()

Outputs:
Returns the buffer element currently being written.

2.3.3.3 ASDxGetStatus()

struct ASD5StatusReg ASDxGetStatus( HDECODER theDecoder )

Returns the value of the Status register.

18 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()

Outputs:
The status register is returned as a ASD5StatusReg structure. This is a 16-bit field
defined in Table 2.7:

Bit Meaning
15 Set if system is in lock
14 Set if bit error since last read
13 Set if parity error since last read 2
12 Set if no syncword received since last read
11 - 0 Reserved
Table 2.7
Calling GetStatus() resets all error bits.

2.3.3.4 Version functions


The following functions are used to identify and provide a character string describing the
card.

2.3.3.5 ASDxGetVersion()

int ASDxGetVersion( HDECODER theDecoder)

Returns the version number of the decoder.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()

Outputs:
Returns one of the version numbers listed in Table 2.8.

Decoder type Version number


SAM/DEC/005 MkI 0
SAM/DEC/005 MkII 1
SAM/DEC/005 MkIII 2
SAM/DEC/006 MkI 16
SAM/DEC/007 MkI 32
SAM/DEC/007/B MkI 33
SAM/DEC/007/B/UT MkI 34
SAM/DEC/007/C MkI 35
Table 2.8

Library interface 19
2.3.3.6 ASDxGetVersionString()

const char* ASDxGetVersionString( HDECODER theDecoder )

Returns a constant char string describing the decoder version.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()

Outputs:
2 Returns one of the version descriptions listed in Table 2.9.
1
Decoder type Version string
SAM/DEC/005 MkI SAM/DEC/005 Mark I
SAM/DEC/005 MkII SAM/DEC/005 Mark II
SAM/DEC/005 MkIII SAM/DEC/005 Mark III
SAM/DEC/006 MkI SAM/DEC/006 Mark I
SAM/DEC/007 MkI SAM/DEC/007 Mark I
SAM/DEC/007/B MkI SAM/DEC/007/B Mark I
SAM/DEC/007/B/UT MkI SAM/DEC/007/B/UT Mark I
SAM/DEC/007/C MkI SAM/DEC/007/C Mark I
Table 2.9

2.3.3.7 ASDxGetVersionStringEx()

const char* ASDxGetVersionString( WORD version )

Returns a constant char string describing the version number passed in. If the version
number is not a valid decoder then the string "Undefined device" is returned.

Inputs:
version – device number

Outputs:
Returns one of the version descriptions listed in the table above in the
ASDxGetVersionString().

2.3.4 DATA ACQUISITION FUNCTIONS

2.3.4.1 ASDxEnablePCM()

void ASDxEnablePCM( HDECODER theDecoder )

Restarts PCM decoding.

20 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()

Outputs:
None.

2.3.4.2 ASDxHaltPCM()

void ASDxHaltPCM( HDECODER theDecoder )

Suspends PCM decoding. Decoding must be suspended before any of the setup 2
functions listed below are called.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()

Outputs:
None.

2.3.4.3 ASDxInitFormat()

int ASDxInitFormat( HDECODER theDecoder )

Initializes decoder after programming, sets up a range of internal variables. This function
must be called after the decoder is programmed and before data acquisition begins.
The hardware must contain a valid format before this function is called. This code
examines the format and sets up various control values of the driver to synchronize the
software with the hardware.

Inputs:
theDecoder - pointer to valid decoder structure returned by ASDxCreate()

Outputs:
Returns the number of words (16 bit or less) in a minor frame.

2.3.4.4 ASDxFlush()

void ASDxFlush( HDECODER theDecoder )

Empties the decoder buffer, discarding any data currently in it.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()

Outputs:
None.

Library interface 21
2.3.4.5 Read frame functions
These functions are the main interface functions used to acquire data for logging or
display. They are designed to move the data out of the (volatile) buffer in the decoder
into another part of system RAM for later processing. All functions read all or part of a
minor frame from the decoder and append a system word to the data.
ASDxReadFrameEx() reads the oldest frame in the internal buffer and appends the frame
number to the data. If there are no new frames in the buffer it waits up to a frame interval
for one to arrive. If one does not arrive it returns 0, indicating out of lock.
ASDxReadCurrentFrameEx() reads the freshest frame in the internal buffer and appends
the frame number to the data. If there are no new frames in the buffer it waits up to a
frame interval for one to arrive. If one does not arrive it returns 0, indicating out of lock. In
2 all functions the buffer information is appended after the last data item. The use of this
function is not recommended for the SAM/DEC/006 and SAM/DEC/007 decoders.
1
ASDxReadFrameWithTime() reads the oldest frame in the internal buffer without any
processing or waiting for a new frame.The frame header is always returned by
ASDxReadFrameWithTime() and the calling application is responsible for determining the
lock state of the decode and if this frame is stale. This function is not supported by the
SAM/DEC/005. The following tables describe the frame header:

SAM/DEC/007 frame header

Header word Description


0 Status Word
1 Bits 7 to 0 are bits 23 to 16 of the µs counter. Bits 15 to 8 are reserved
2 Bits 15 to 0 of µs counter
3 Frame pointer, position where frame is stored
4 Newest frame pointer, position where latest frame is being stored
Table 2.10

SAM/DEC/006 frame header

Header word Description


0 Status word
1 Status word when frame was received
2 Bits 7 to 0 are bits 23 to 16 of the µs counter. Bits 15 to 8 are reserved
3 Bits 15 to 0 of µs counter
4 Frame pointer, position where frame is stored
5 Newest frame pointer, position where latest frame is being stored
Table 2.11

Status word definition

Bits Description
[15:8] Reserved
(7) Error
(6) Syncword received since last read
[5:4] Error type: 00 - Bit Error, 01 - Parity, 10 - Syncword, 11 - No error
Table 2.12

22 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
Bits Description
[2:0] Reserved
Table 2.12
The µs time counter is the decoder time that the frame was received. This time value will
change slightly due to the jitter of the decoders crystal. The longer the frame, the larger
this jitter will be. The decoders crystal is rated at 300ppm. For a frame of 128 words with
16 bits at 512bps, the frame rate is 4,000,000, but due to jitter we need to allow for a
±150 difference.
The SAM/DEC/006 can decommutate a data stream of 20Mbps or less. It is
recommended that the data read rate be limited to 10Mbps or less using the store
capability described in ASDxReadCurrentFrameEx(). If data is read above this rate then
frames are more likely to be missed due to the PC performing its own housekeeping 2
tasks.

ASDxReadFrameEx() and ASDxReadCurrentFrameEx()

int ASDxReadFrameEx(HDECODER theDecoder,


SD5_ADDRESS theStart,
WORD *theBuffer,
WORD theFrameLength,
WORD *theTail )
int ASDxReadCurrnetFrameEx(HDECODER theDecoder,
SD5_ADDRESS theStart,
WORD *theBuffer,
WORD theFrameLength,
WORD *theTail )

Inputs:
theDecoder – Pointer to valid decoder structure returned by ASDxCreate().
theStart – The first word of the minor frame to read.
theBuffer – The buffer to store the frame. This must be ((theFrameLength+1) x 2) bytes
long.
theFrameLength – The number of words to read.
theTail – The number of frames remaining in the decoder will be returned in this value.
This can be used to monitor performance of the logging system to ensure no frames are
lost. This value can be NULL.

Outputs:
Returns 0 if the decoder is not in lock, 1 otherwise.

Example 1:
In this example it is assumed that the frame is 10 channels long, and all the data is to be
logged to memory. (Error and overflow checking have been left out for clarity.)

Library interface 23
WORD theData[1100];
WORD *dPtr = theData;
extern HDECODER hDecoder; /* must have been previously set up */
int i;
for(i=0; i < 100; i++)
{
ASDxReadFrameEx(hDecoder, 0, dPtr, 10, NULL);
dPtr = dPtr + 11;
}

Example 2:
2 In this example it is assumed that the frame is 10 channels long. Words 3 and 5 are to
be displayed using a function called show(). (Error checking has been left out for clarity).
1
WORD data[4];
int i;
extern HDECODER hDecoder; /* must have been previously set up */

WORD limit = ASDxGetBufferDepth()*4/3; /* limit is 3/4 full*/


WORD tail;
while(1)
{
ASDxReadFrameEx(hDecoder, 3, data, 3, &tail);
show(data[3])/* show channel 3 */
show(data[5]) /* show channel 5 */
if(tail >= limit)
{
/* Buffer is getting full so need to take actions to avoid losing
data... */
}
}

2.3.4.6 ASDxReadFrameWithTime()

int ASDxReadFrameWithTime(HDECODER theDecoder, WORD *theBuffer, WORD


theFrameLength )

This function returns the frame buffer without processing the frame header or removing
it. This function does not wait for a new frame if the present frame has been read before.

Inputs:
theDecoder – Pointer to valid decoder structure returned by ASDxCreate().
theBuffer – The buffer to store frame. This must be (((theFrameLength) + (number of
words in header))x 2) bytes long.
theFrameLength – The number of words to read. This includes the frame header.

Outputs:
Returns 0 if the decoder is not in lock, 1 otherwise.

24 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
2.3.5 DECODER SETUP FUNCTIONS

2.3.5.1 ASDxSetBaud()

void ASDxSetBaud( HDECODER theDecoder, double theWord )

Sets the baudrate for the decoder. The maximum bit rate is different for each decoder.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()
2
theWord – the baudrate to set

Outputs:
None.
Table 2.13 lists the value baudrate ranges for the decoders.

Decoder baudrate range


SAM/DEC/005 350bps to 4Mbps for NRZ-L with a separate clock
SAM/DEC/005 350bps to 2Mbps for BI∅-L
SAM/DEC/007 350bps to 10Mbps for NRZ-L with a separate clock
SAM/DEC/007 350bps to 5Mbps for BI∅-L
SAM/DEC/006 350bps to 20Mbps for codes with a separate clock
SAM/DEC/006 350bps to 10Mbps for codes without a separate clock
Table 2.13

2.3.5.2 SAM/DEC/006 PCM output baudrate functions


The SAM/DEC/006 can retransmit data from the input stream through a NRZ-L PCM
output data stream. Please see the SAM/DEC/006 data sheet for valid baud-rates for the
output stream. See Section 2.3.5.11 for details on generating this output data stream.

ASDxSetOutputBaud()
void ASDxSetOutputBaud( HDECODER theDecoder, double theBaudRate )

This function sets the output baudrate.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()
theBaudRate – the baudrate to set

Outputs:
None.

Library interface 25
ASDxGetOutputBaud()

double ASDxGetOutputBaud( HDECODER theDecoder )

This function returns the output baudrate.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()

Outputs:
2 Returns the output baudrate.

1
2.3.5.3 Syncword and syncmask functions
This section describes the functions to set and get the syncword and syncmask. The
maximum number of syncword and syncmask bits is different for each decoder as
shown in Table 2.14.

Decoder type Syncword and syncmask bits


SAM/DEC/005 MkI, MkII and MKIII 32
SAM/DEC/006 MkI 48
SAM/DEC/007 MkI 34
SAM/DEC/007/B MkI 34
SAM/DEC/007/C MkI 34
Table 2.14
The SAM/DEC/005 will always lock on the syncword and its inverse. The SAM/DEC/006
and SAM/DEC/007 can be configured to lock only on the syncword through the
ASDxSetProperty() function described later.

ASDxSetSyncWordEx()

BOOL ASDxSetSyncWordEx( HDECODER theDecoder, char* theSyncword, int theBits)

Sets the syncword for the decoder.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theSyncword – syncword in a character string format. Note that the string should be
hexadecimal with a leading "0x", for example "0xFE6B2840".
theBits – number of bits in the syncword.

Outputs:
Returns zero if the number of bits in syncword is not supported by the device.

ASDxGetSyncWordEx()

BOOL ASDxGetSyncWordEx( HDECODER theDecoder, char* theSyncword, WORD*


theBits )

26 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
Returns the present syncword of the decoder.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()
theSyncword – pointer to a character buffer to hold the syncword.
theBits – word pointer that is set to the number of bits in the syncword.

Outputs:
Returns zero if syncword was not read from the device.

ASDxSetSyncMaskEx() 2

BOOL ASDxSetSyncMaskEx( HDECODER theDecoder, char* theSyncmask, int theBits)

Sets the syncmask for the decoder.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theSyncmask – syncmask in a character string format.
theBits – number of bits in the syncmask.

Outputs:
Returns zero if the number of bits in syncword mask is not supported by the device.

ASDxGetSyncMaskEx()

BOOL ASDxGetSyncMaskEx(HDECODER theDecoder, char* theSyncmask, WORD* theBits)

Gets the syncmask of the decoder.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theSyncmask – pointer to a character buffer to hold the syncmask.
theBits – word pointer that is set to the number of bits in the syncmask.

Outputs:
Returns zero if syncword mask is not supported by the device.

2.3.5.4 ASDxSetCode()

void ASDxSetCode( SD5HANDLE theDecoder, WORD theWord )

This function sets up the global PCM properties, PCM code, data and clock polarity and
input type (RS422 or TTL). All decoders support BI∅−L and NRZ-L, please see the
SAM/DEC/006 data sheet for a full list of the codes it supports.
The other properties that are set in this function are:

Library interface 27
• RS422 - inputs are RS-422
• TTL - inputs are TTL
• INVERT_PCM - PCM input is inverted
• INVERT_CLK - PCM clock is inverted
All of the constants mentioned above are defined in SDXUTIL.H.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theWord – the code setup word as an ORed combination of the above flags. All other bits
must be set to 0.
2
1 Outputs:
None.

2.3.5.5 ASDxGetCode()

WORD ASDxGetCode( HDECODER theDecoder )

This function is used to return the setup code word. See the above function
ASDxSetCode() for details on interpreting this word.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().

Outputs:
Returns the code set up word. Refer to the ASDxSetCode() function for a description of
this code.

2.3.5.6 ASDxSetBufferDepth()

void ASDxSetBufferDepth( HDECODER theDecoder, WORD theWord )

This functions sets the number of words in a frame. It should not be used as the
ASDxInitFormat() function automatically calls it. The theWord parameter passed in
depends on the type of decoder.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theWord – size of frame as defined by the decoder.

Outputs:
None.

28 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
SAM/DEC/005 frame size
For the SAM/DEC/005 its number of minor frames is 2theWord. For example setting
theWord to 10 will set the number of minor frames stored in the decoder to 1024,
resulting in a frame size of 64 words (65536 / 1024). The decoders data buffers are
divided evenly into 64k of decoder words. The minor frame must fit into these buffers.
Only the four least significant bits of theWord are used to select the buffer depth.

SAM/DEC/007 frame size


This decoder provides more control over the frame size. The rules for selecting the
frame size are:
• include the five-word frame header
• must be a multiple of 32
2
For example with a frame of 120 words, we must add five words for the frame header
and then choose the next multiple of 32, which is 128. The value passed to the function
is the frame size multiple of 32, 4 in this case. For more information on the frame header
please see Section 2.3.5.14

SAM/DEC/006 frame Size


This decoder provides further control over the frame size. The only restriction is that a
six word header must be added.

2.3.5.7 ASDxGetBufferDepth()

WORD ASDxSetBufferDepth( HDECODER theDecoder )

This function returns the number of frames in the decoder.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().

Outputs:
Returns the number of frames in the decoder.

2.3.5.8 ASDxSetRS422()

void ASDxSetRS422( HDECODER theDecoder, WORD theSet )

Switches the decoder between RS-422 and TTL mode depending on the input
parameter, without affecting anything else in the setup.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theSet – if non-zero, RS-422 is turned off. If zero, TTL is turned on.

Outputs:
None.

Library interface 29
2.3.5.9 Word definition functions
There are two word definition functions. A generic function ASDxSetWordDefinition() for
basic parameter decom setup and a special function ASDxSetWordDefinitionEx() for the
advanced features of the SAM/DEC/007 and SAM/DEC/006. The SAM/DEC/006 and
SAM/DEC/007 both support non-storing of words. This feature reduces the read data
rate from the decoder and allows more time for data display and processing. Only the
SAM/DEC/006 can transmit a NRZ-L data stream from the received data. This
transmitting of embedded data is designed for voice and video applications.

2.3.5.10 ASDxSetWordDefinition()
2
void ASDxSetWordDefinition(HDECODER theDecoder,
1 WORD theWord,
WORD theBits,
WORD theOrder,
WORD theParity )

Each word in a minor frame has to have a corresponding word definition programmed
(including the syncword). This function performs that programming.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theWord – the location in the frame of the word to be defined (starting from 0).
theBits – the number of bits in this word. For words greater than 16 bits they must be
setup as two or more words.
theOrder – the bit order. This can be MSBFIRST or MSBLAST, defined in SDXUTIL.H.
theParity – the parity on this word. This can be NONE, ODD, EVEN or CARRY, defined
in SDXUTIL.H. The CARRY parameter allows parity to be calculated over more than 16
bits and is only supported by the SAM/DEC/006.

Outputs:
None.

2.3.5.11 ASDxSetWordDefinitionEx()

void ASDxSetWordDefinitionEx( HDECODER theDecoder,


WORD theWord,
WORD theBits,
WORD theOrder,
WORD theParity,
BOOL theStoreFlag,
BOOL theOutputFlag )

This function performs the same programming as ASDxSetWordDefinition() but with the
addition of the special features of the SAM/DEC/006 and SAM/DEC/007.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theWord – the location in the frame of the word to be defined (starting from 0).

30 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
theBits – the number of bits in this word. For words greater than 16 bits they must be
set up as two or more minor frame words.
theOrder – the bit order. This can be MSBFIRST or MSBLAST, defined in SDXUTIL.H.
theParity – the parity on this word. This can be NONE, ODD, EVEN or CARRY, defined
in SDX.H. The CARRY parameter allows parity to be calculated over more than 16 bits
and is only supported by the SAM/DEC/006.
theStoreFlag – determines if the word is stored in the decoder. The syncword must
always be stored. This feature is used to reduce the data read rate from the decoder.
The SAM/DEC/005 does not support this feature; all words must be stored.
theOutputFlag – determines if the word is transmitted in the output PCM data. This
feature is only supported by the SAM/DEC/006.
2
Outputs:
None.

2.3.5.12 ASDxSetEndOfFrame()

void ASDxSetEndOfFrame( HDECODER theDecoder, WORD theWord )

This function marks a specified minor frame word as the last word in the frame. The
word must previously have been defined using ASDxSetWordDefinition() or
ASDxSetWordDefinitionEx().

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theWord – the location in the frame of the last word (starting from 0).

Outputs:
None.

2.3.5.13 ASDxSetProperty()

BOOL ASDxSetProperty (HDECODER theDecoder, WORD theProperty, BOOL


theState)

This function is only supported by the SAM/DEC/006 and SAM/DEC/007. It sets decoder
specific properties to true or false values.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theProperty – the property to set, DECOM_LOCK_ON_INVERSE or
DECOM_LOG_FRAME_HEADER defined in the file SD5_VER.H.
theState – the value to assign to the property, TRUE or FALSE.

Outputs:
Returns 1 if property was set to requested state, and 0 if property was not set.

Library interface 31
Table 2.15 describes the properties supported by the SAM/DEC/006 and the
SAM/DEC/007.

Property State Description


DECOM_LOG_FRAME_HEADER TRUE Frame header is not removed
FALSE Frame header is removed
DECOM_LOCK_ON_INVERSE TRUE Decoder locks on syncword and its inverse
FALSE Decoder only locks on syncword
Table 2.15
By default the DECOM_LOCK_ON_INVERSE is set to TRUE while
2 DECOM_LOG_FRAME_HEADER is FALSE.
The SAM/DEC/006 and SAM/DEC/007 decoders generate a frame header containing
1 debug information for every new frame received. This header is stored in the buffer
before the frame data and is five words long for the SAM/DEC/007 and six words long
for the SAM/DEC/006. See Section 2.3.4.5, for more details. By default this property is
not set, therefore the read frame functions only return the frame data. If this property is
enabled then the read frame functions frame size must be increased by the header size.

2.3.5.14 ASDxGetProperty()

BOOL ASDxGetProperty( HDECODER theDecoder, WORD theProperty )

This function is only supported by the SAM/DEC/006 and SAM/DEC/007, it returns the
state of decoder specific properties.

Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
theProperty – the property to get, DECOM_LOCK_ON_INVERSE or
DECOM_LOG_FRAME_HEADER defined in the file SD5_VER.H.

Outputs:
Returns the property state, TRUE or FALSE.

2.3.6 ERROR MESSAGES

2.3.6.1 ASDxGetError

const char *ASDxGetError( HDECODER theHandle, WORD theError )

Returns a pointer to a string indicating the cause of theError. The string is in standard
'C' format, that is an array of characters with a terminating value of 0.

Inputs:
theHandle may have been returned from a previous call to ASD5Create() or can be 0.
theError should have been returned from ASD5Open() or ASD5Close().

32 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
Outputs:
Returns a pointer to an error string.

Library interface 33
2.4 PSEUDO CODE EXAMPLE
Example 3:
The following 'C' pseudo code example shows how to use the driver functions to read
and store data. Error checking has been left out for clarity.

#include "sdx.h"

void initialise(HDECODER theDecoder)


{
/* create an instance of the decoder managment structure */
2 hDecoder = ASDxCreate();
/* map decoder into PC address space */
1 ASDxOpen(hDecoder, 210, 0);
/* program decoder */
program(hDecoder);
/* Finish internal setup of managment structure */
ASDxInitFormat(hDecoder);
}
void cleanup(HDECODER theDecoder)
{
/* free up PCMCIA resource */
ASDxClose(hDecoder);
/* free up memory */
ASDxDestroy(hDecoder);
}
void program(HDECODER theDecoder)
{
/* Set up frame: 1MBaud, BIO-L, Sync on FAF320,
minor frame is 10 x 12bit words long, no parity */
int i;
ASDxHaltPCM(theDecoder);
ASDxSetSyncWord(theDecoder, "0xFAF32000", 24);
ASDxSetSyncMask(theDecoder, "0x00000000", 24);
ASDxSetBaud(theDecoder, 1000000.0);
ASDxSetCode(theDecoder, BIOL | RS422);
for(i=0; i < 12; i++)/* 10 words + 2 for syncword */
{
ASDxSetWordDefinition(theDecoder, i, 12, MSBFIRST, NONE);
}
ASDxSetEndOfFrame(theDecoder, 11);
ASDxEnablePCM(theDecoder);
}
void go( void )
{
DECODER hDecoder;
unsigned int buffer[11];
initialise(hDecoder);
while(ASDxReadFrameEx(hDecoder, 0, buffer, 10, NULL))
{
doSomethingWithBuffer(buffer);
}
cleanup(hDecoder);
}

34 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
2.5 GETERROR() STRING VALUES
Table 2.16 shows the strings returned by ASD5GetError() in response to the various
error codes:

HexValue DecimalValue Error Text


016 0 "No error"
116 1 "PCMCIA adapter not found or not functioning"
216 2 "Invalid attributes passed to Card Services"
316 3 "Invalid base memory address passed to Card Services"
416 4 "Invalid EDC parameter passed to Card Services"
2
616 6 "No free IRQ"
716 7 "Cannot map client to requested offset address"
816 8 "Invalid page value passed to Card Services"
916 9 "Unable to read PCMCIA device"
A16 10 "Unable to create memory window"
B16 11 "Socket does not exist"
D16 13 "Invalid window type passed to Card Services"
E16 14 "Invalid Vcc passed to Card Services"
F16 15 "Invalid Vpp passed to Card Services"
1116 17 "Invalid window handle passed to Card Services"
1216 18 "Unable to write to PCMCIA device"
1416 20 "No card in socket"
1516 21 "Invalid Card Services call"
1616 22 "Unsupported mode"
1716 23 "Incompatible memory access speed"
1816 24 "Card busy"
1916 25 "Unable to assign memory resources (CS returns general
failure)"
1A16 26 "PCMCIA device is write protected"
1B16 27 "Invalid argument list passed to Card Services"
1C16 28 "Invalid arguments passed to Card Services"
1D16 29 "Configuration locked"
1E16 30 "Resource in use"
1F16 31 "No more items"
2016 32 "Out of system resource"
2116 33 "Invalid handle passed to Card Services"
XX XX "Unexpected error. Device drivers may not be installed
correctly."
Table 2.16

GETERROR() string values 35


2.6 HARDWARE INTERFACE
2.6.1 DATA ACQUISITION
Data arrives on the PCM link as a serial stream of samples from the remote equipment.
The samples are in the form of frames. Each frame contains at least one sample from
every channel being measured in the system (please see Figure 2.1). The order of the
samples in the frame, and the physical channel they represent is determined by the
remote encoder.

2
1

Figure 2.1: PCM frames

The decoder is programmed to decode this serial stream and store the samples in its
memory. The decoder can be viewed as an external RAM. The upper section of this
RAM is reserved for system information. The lower section is reserved for PCM data.
Data in each address is stored as a 16-bit unsigned value. The data in this section is
updated continuously as data is received from the PCM stream. Each sample in the
frame occupies one address in memory.
Incoming frames are stored in a circular buffer. The details of handling this buffer are
hidden by the drivers. The only information required to access a particular parameter is
its position in the frame. A frame which contains 16 samples will occupy 16 addresses in
the decoder. A call to ASD5xxxFrame() (see Section 2.6.2) will return all or a subset of
this frame.
The words in the PCM stream may be less than 16 bits long. In this case the data is
returned MSB justified. For example, the 12-bit sample 12316 is stored as 123016 and
the 13-bit sample 123416 is stored as 91A016.
It is useful to think of each address as a channel location. Thus, in the following
description, the term channel and address can be used interchangeably.

36 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
2

Figure 2.2: Packing a frame into memory

For example, to display channel 0, a software program would have to read address 0 of
the frame continuously.
The decoder performs minor frame decommutation only. Major frame decommutation
must be performed by the calling software.

2.6.2 SETTING UP THE DECODER


To enable PCM decommutation the following parameters must be programmed in the
decoder:
• PCM code (BIØ-L, NRZ-L, inversion)
• Decoder interface (RS-422 or TTL)
• Syncword
• Syncmask
• Baudrate
For each word in a minor frame the following must be defined:
• Bits
• Parity
• Transmission order
Finally, the last word of the frame must be marked.
C functions exist to perform all of these functions without exposing the user to the
internal details of the decoder.

2.6.3 MAPPING THE DECODER TO A PC ADDRESS SPACE


The decoder interfaces to the PC via a PCMCIA adapter.
Note the following limitations in this version of the drivers, hot-swapping
(removing/inserting the decoder while the DLL is trying to access it) is not supported.
The detailed procedure for accessing the decoders is not described here. It is
recommended that the driver functions are used for all accesses.

Hardware interface 37
2
1

THIS PAGE IS INTENTIONALLY BLANK

38 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual 9 October, 2007
APPENDIX A: INSTALLING DECODERS
IN LINUX
A

39
A.2 INSTALLING ACRA CONTROL PCMCIA
DECODERS IN LINUX RED HAT 7.3
Enabling the ACRA CONTROL PCMCIA decoders in Linux Red Hat 7.3 can be split into
the following parts,
• installing PCMCIA support and the memory_cs device driver
• identification and configuration of decoder cards
• installing the shared library libasdx32l.so.1.1 that provides the programming interface
to the decoders
PCMCIA support must be installed if there is no /etc./pcmcia directory. If there is no
1 memory_cs.o driver in the /lib/modules/2.4.18-3/pcmcia then it must be installed as
described in “Installing the device driver MEMORY_CS” on page 40.
To enable the ACRA CONTROL PCMCIA decoders in Linux Red Hat 7.3, the PCMCIA
database must be updated through the config file. Also the access rights of the decoders
memory device must be changed through the installation script file: “memory”.
The shared library libasdx32l.so.1.1.that provides the decoder interface is installed
through the script file load.sh. Please see Section 1.1.7 Installing the shared library
libasdx32l.so.1.1 for more details.
Super-user privileges are required for most of these steps.

A.2.1 INSTALLING PCMCIA SUPPORT


The PCMCIA source can be found at http//pcmcia-cs.sourceforge.net. The kernel
source code is needed to build the PCMCIA modules and for Red Hat 7.3 installations
the kernel source RPM file kernel-source-2.4.18-3.i386.rpm can be found in the Red
Hat/RPMS directory on the second CD-ROM. The kernel source is usually kept in the
/usr/src/linux-2.4.18-3 directory.
To install PCMCIA support do the following:
1. install the kernel RPM source code described above
2. download the PCMCIA code version 3.2.4 from http//pcmcia-cs.sourceforge.net
3. unpack the archive in the /usr/src directory file
4. from the directory /usr/src/pcmcia-cs-3.2.4 run: make all
5. specify the kernel source path when prompted
This makefile will set up the build environment, build the utilities and install PCMCIA
support.

A.2.2 INSTALLING THE DEVICE DRIVER MEMORY_CS


There are two PCMCIA versions available; kernel and stand alone. If the kernel is
installed then the generic memory_cs.o driver may not be installed. Search for this driver
in the directory /lib/modules/2.4.18-3/pcmcia (note that 2.4.18-3 refers to the kernel
version which will change between kernel versions). If the memory_cs.o driver is not
found then it can be installed as follows:
• Install the kernel RPM source code described above
• Download the PCMCIA code version 3.2.4 from http//pcmcia-cs.sourceforge.net
• Run make all in the client directory to build the client drivers

40 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
• Run make install to Install the client drivers. Check that there is now a memory_cs.o
file in the /lib/modules/2.4.18-3/pcmcia directory

A.2.3 UPDATING THE PCMCIA DATABASE


The database is generated from the file text /etc/pcmcia/config. This file states the
device driver to load when a card is inserted into a PCMCIA slot. The device driver
required by the decoders is the generic PCMCIA memory device driver memory_cs.
Open the config file and add the following lines to the memory card section.

card "PCM Decoder"


version "ACRA CONTROL Ltd." , "PCM Decoder"
bind "memory_cs"

card "SAM/DEC/007/C"
version "ACRA CONTROL Ltd." , "SAM/DEC/007/C"
bind "memory_cs"

card "SAM/DEC/007/B"
version "ACRA CONTROL Ltd." , "SAM/DEC/007/B"
bind "memory_cs"

card "SAM/DEC/007"
version "ACRA CONTROL Ltd." , "SAM/DEC/007"
bind "memory_cs"

card "SAM/DEC/006"
version "ACRA CONTROL Ltd." , "SAM/DEC/006"
bind "memory_cs"

Note that these entries are case-sensitive. They instruct the Linux PCMCIA manager
cardmgr to load the driver memory_cs.o when a SAM/DEC/005(/006 or /007) from
ACRA CONTROL is found. After changing this file, Linux must be restarted for these
changes to take effect.
The card and version fields refer to the Manufacturer Name String and Product Name
String fields of the card identification tuple found in the CIS structure. PCMCIA cards
possess one of these CIS structures to identify the card and the resources it needs from
the operating system. Only if the information in the cards CIS structure matches an entry
in the config file will the PCMCIA manager cardmgr load the requested driver. The
cardctl utility described in “CARDCTL utility” on page 44 can be used to read the card
identification strings.

A.2.4 DEVICE ACCESS RIGHTS


By default the devices created by the memory_cs driver have only write access in root or
super-user mode. To change this we need to modify the file /etc/pcmcia/memory. The
following mknod commands must be modified with the -m666 switch to enable read and
write access for all users.

log mknod -m666 /dev/${DEVICE}c c $MAJOR `expr $MINOR + 8`


log mknod -m666 /dev/${DEVICE}a c $MAJOR `expr $MINOR + 8 + 4`

41
A.2.5 VERIFYING DEVICE INSTALLATION
After the three installation steps described above have been completed and the PC
restarted, the following devices will appear in the /dev directory whenever a decoder is
inserted into a PCMCIA slot. If there are two decoders in a system there will be another
set of devices with a 1 instead of a 0. These numbers denote device instances and the
socket the card is in.

crw-r----- 1 root kmem 1, 1 Aug 24 2000 /dev/mem


crw-rw-rw- 1 root root 253, 12 Mar 20 14:48 /dev/mem0a
crw-r--r-- 1 root root 253, 4 Mar 20 14:48 /dev/mem0a0c
crw-rw-rw- 1 root root 253, 8 Mar 20 14:48 /dev/mem0c
brw-r--r-- 1 root root 253, 0 Mar 20 14:48 /dev/mem0c0b
crw-r--r-- 1 root root 253, 0 Mar 20 14:48 /dev/mem0c0c
1

Note: /dev/mem0a and /dev/mem0c have read and write access for all users.

A.2.6 INSTALLING THE SHARED LIBRARY LIBASDX32L.SO.1.1


The shared library libasdx32l.so.1.1 can be installed into several standard directories but
the /usr/lib directory is used here. Extract the zipped tar archive libasdx32l.tar.gz.
The header files are required by the compiler when linking to the shared library.

libasdx32l.tar.gz
File Description
sdx.h Header file
Sdxutil.h Header file
sd5write.h Header file
sd5_ver.h Header file
sd5hndl.h Header file
awindows.h Header file
lwindows.h Header file
load.sh Installation script for shared library
libasdx32l.so.1.1 Shared library
Table A.1
Move to the libasdx32l directory and enter super-user mode. Make the script load.sh
executable with the command chmod +x load.sh and run the script. This script copies
the shared library to /usr/lib and generates its symbolic links. The headers files are
copied to the /usr/include/acracontrol directory. The three libraries listed should be
displayed when the script has finished.

libasdx32l.so Linker name for the library


libasdx32l.so.1 Symbolic link to the real library
libasdx32l.so.1.1 The real library

42 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
Refer to the program library HOWTO for more information on the shared library naming
conventions. The ASDxGetVersion and ASDxGetVersionString functions in
libasdx32l.so.1.1 will report the SAM/DEC/007/C as a SAM/DEC/007.

A.2.7 COMPATIBILITY ISSUES


The shared library libasdx32l.so.1.1 was built using gcc 2.9620000731 (Red Hat Linux
7.3 2.96 - 110) and the 2.4.18-3 kernel on an Intel platform. This shared library is not
guaranteed to work on any other Linux versions.

A.2.8 USING THE SHARED LIBRARY LIBASDX32L.SO.1.1


The archive file lock_test.tar.gz contains a simple test utility that uses the shared
library to open a decoder, program it and check for lock.

lock_test.tar.gz

File Description
lock_test.cpp Source file to lock onto a fixed format
Makefile makefile to generate the executable lock_test.exe
Table A.2

A.2.9 MAKING THE TEST UTILITY


After installing the shared library the test_lock.exe utility can be made by running make.
This utility will test for a frame with the following properties.

Property Value
Bitrate 1,000,000
PCM Code NRZ-L
Transmission Code RS-422
Parity None
Words 128
Syncword FE6B2840
Syncword Bits 32
Bits per Word 16
Bit Order MSB
Table A.3
This following screen was generated by a SAM/DEC/007 decoder in lock with the PCM
stream.

43
Found a SAM/DEC/007 Mark I device
Format Details
SyncWord = fe6b2840
Syncmask = 0
Code = 004A
Frame length = 128
Bit rate = 1000000.000000
In lock
Lock = 1 ; Frame = fe6b 2840 0001 eeee dddd cccc

A.2.10 PCMCIA DEBUG UTILITIES


1 The following utilities are useful when debugging PCMCIA decoder installation
problems.

A.2.10.1 CARDCTL utility


The cardctl utility is useful to determine if PCMCIA cards have been identified and
configured correctly. Depending on the Linux version it may only run in super-user
mode.
The following examples are for a SAM/DEC/007 in socket 0 and no card in socket 1.
The config command line option determines the socket voltage levels as shown below.

Example 1

Socket 0:
Vcc 5.0V Vpp1 5.0V Vpp2 5.0V
Socket 1:
not configured

The ident command line option reads the card and displays its identification information
as follows.

Example 2

Socket 0:
product info: "ACRA CONTROL Ltd.", "SAM/DEC/007", "SAM/DEC/007", "Rev 1.0"
manfid: 0x3412, 0x0010
function: 254 ((null))
Socket 1:
no product info available

Note: These product info strings must be the same as those in the
/etc/pcmcia/config file otherwise the card will not be configured by
cardmgr.

44 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
A.2.10.2 LSMOD utility
This utility displays information on all loaded drivers. If a PCMCIA decoder is in a
PCMCIA slot and has been configured correctly then the memory_cs drivers should be
displayed as shown below:
.

Module Size Used by Not tainted


nls_cp850 3580 1 (autoclean)
nls_iso8859-15 3356 5 (autoclean)
memory_cs 9416 0
sram_mtd 3396 0 (unused)
msdos 5364 0 (autoclean)
vfat 9588 1 (autoclean)
fat 31864 0 (autoclean) [msdos vfat]
isofs 25652 0 (autoclean)
inflate_fs 17892 0 (autoclean) [isofs]
udf 85472 0 (autoclean)
sg 31276 0 (autoclean) (unused)
st 26740 0 (autoclean) (unused)
sr_mod 15096 0 (autoclean) (unused)
sd_mod 11788 0 (autoclean) (unused)
scsi_mod 90372 4 (autoclean) [sg st sr_mod sd_mod]
ide-cd 28712 0 (autoclean)
cdrom 26848 0 (autoclean) [sr_mod ide-cd]
floppy 49340 2 (autoclean)
nfsd 66576 8 (autoclean)
lockd 46480 1 (autoclean) [nfsd]
sunrpc 60188 1 (autoclean) [nfsd lockd]
ds 6828 2 [memory_cs sram_mtd]
yenta_socket 9728 2
pcmcia_core 42272 0 [memory_cs sram_mtd ds yenta_socket]
af_packet 13000 0 (autoclean)
tulip 40800 0 (autoclean)
supermount 14340 2 (autoclean)
usb-uhci 21676 0 (unused)
usbcore 58304 1 [usb-uhci]
rtc 6560 0 (autoclean)
ext3 74004 2
jbd 38452 2 [ext3]

If PCMCIA support is enabled then the modules pcmcia_core and ds will be loaded.

Note: There is another PCMCIA module that is adapter dependant. In the


above example this module is yenta_socket. This will change with different
adapter types.

45
A.3 INSTALLING ACRA CONTROL PCMCIA
DECODERS IN MANDRAKELINUX 10.1
Enabling the ACRA CONTROL PCMCIA decoders in Mandrakelinux 10.1 can be split
into the following parts:
• configuring the MTD and PCMCIA subsystems
• identification and configuration of decoder cards
• installing the shared library libasdx32l.so.1.1 that provides the programming
interface to the decoders
Super-user privileges are required for most of these steps.
1 Mandrakelinux 10.1 features 2.6 kernel version. Unlike earlier kernel versions like 2.4,
PCMCIA support in 2.6 is built into the kernel and does not need to be installed
separately.
Also, the memory_cs driver is not available in Linux 2.6, and therefore the pcmciamtd
driver is used instead. This involves using the Memory Technology Device (MTD)
Subsystem.
In order for the decoders to operate, the MTD Subsystem needs to be properly
configured, and the PCMCIA MTD driver needs to be compiled and installed. The
ASDxGetVersion and ASDxGetVersionString functions in libasdx32l.so.1.1 will report
the SAM/DEC/007/C as a SAM/DEC/007.

A.3.1 CONFIGURING THE MTD SUBSYSTEM


The kernel source code is needed to build the MTD modules and the PCMCIA MTD
driver. For Mandrakelinux 10.1 the kernel source RPM file (e.g.,
kernel-source-2.6-2.6.8.1-12mdk.i586.rpm) can be found on the installation
CD-ROMs.
To install the PCMCIA MTD driver
1. install the kernel source code from the RPM file described above
2. go to the kernel source directory (e.g., /usr/src/linux-2.6.8.1-12mdk) and run
one of the kernel configuration utilities (e.g., make menuconfig)
3. set kernel configuration options
• Under Code maturity level options, select Prompt for development and/or
incomplete code/drivers
• Under Device Drivers - Memory Technology Devices (MTD), select only the
following (all as modules):
•Memory Technology Device (MTD) support
•Debugging (turn it off for the best performance, or set the required debugging
verbosity)
•Direct char device access to MTD devices
•RAM/ROM/Flash chip drivers
•Detect flash chips by Common Flash Interface (CFI) probe
•Support for RAM chips in bus mapping
•Mapping drivers for chip access
•Support non-linear mappings of flash chips

46 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
•PCMCIA MTD driver
4. Compile the kernel and the modules and install them (please see Mandrakelinux
10.1 documentation for details).
Upon completion of this step the PCMCIA MTD driver and all required MTD modules will
be installed and available to the kernel.

A.3.2 CONFIGURING THE PCMCIA SUBSYSTEM


The PCMCIA configuration is stored in /etc/pcmcia/config. This text file states the
device driver to load when a card is inserted into a PCMCIA slot. The device driver
required by the decoders is the PCMCIA MTD driver.
Open the /etc/pcmcia/config file and add following device driver definition:

device "pcmciamtd"
class "memory" module "pcmciamtd"

Add the following bindings:

card "PCM Decoder"


version "ACRA CONTROL Ltd." , "PCM Decoder"
bind "pcmciamtd"

card "SAM/DEC/007/C"
version "ACRA CONTROL Ltd." , "SAM/DEC/007/C"
bind "pcmciamtd"

card "SAM/DEC/007/B"
version "ACRA CONTROL Ltd." , "SAM/DEC/007/B"
bind "pcmciamtd"

card "SAM/DEC/007"
version "ACRA CONTROL Ltd." , "SAM/DEC/007"
bind "pcmciamtd"

card "SAM/DEC/006"
version "ACRA CONTROL Ltd." , "SAM/DEC/006"
bind "pcmciamtd"

Open the /etc/pcmcia/config opts file and add following line:

module "pcmciamtd" opts "mem_type=1"

Note that these entries are case-sensitive. They instruct the Linux PCMCIA manager
cardmgr to load the pcmciamtd driver when a SAM/DEC/005(/006 or /007) from ACRA
CONTROL is found. After changing this file Linux must be restarted for these changes to
take effect.
The card and version fields refer to the Manufacturer Name String and Product Name
String fields of the card identification tuple found in the CIS structure. PCMCIA cards
possess one of these CIS structures to identify the card and the resources it needs from
the operating system. Only if the information in the cards CIS structure matches an entry
in the config file will the PCMCIA manager cardmgr load the requested driver. The
cardctl utility described in “CARDCTL utility” on page 44 can be used to read the cards
identification strings.

47
A.3.3 CREATING MTD DEVICE
In order to make use of the pcmciamtd driver, a device named /dev/mtdX is required.
You can create this device manually every time a SAM/DEC card is inserted:
mknod –m666 /dev/mtd0 c 90 0
Alternatively, you can modify the /etc/pcmcia/memory file, which is run every time a
SAM/DEC card is inserted or removed. The following changes (in bold) need to be
applied:

'start')

rm -f /dev/${DEVICE}*
if [ "$DRIVER" = "pcmciamtd" ] ; then
1 log mknod -m666 /dev/${DEVICE} c 90 0
exit 0;
fi

'check')

if [ "$DRIVER" != "memory_cb" -a "$DRIVER" != "pcmciamtd" ] ; then

'stop')

if [ "$DRIVER" != "memory_cb" -a "$DRIVER" != "pcmciamtd" ] ; then

After applying these changes /dev/mtd0 will be automatically created by the cardmgr
every time a SAM/DEC/00x card is inserted.
You can verify the results with the following command:
ls –la /dev/mtd*
You should see your mtd device there:
crw-rw-rw- 1 root root 90, 0 May 6 17:48 /dev/mtd0
If there are two decoders in the system there will be another device named /dev/mtd1.
The numbers denote device instances and the socket the card is in.
You should also be able to see the ACRA CONTROL device in /proc/mtd:
dev: size erasesize name
mtd0: 00040000 00001000 "ACRA CONTROL Ltd. SAM/DEC/007/B SAM/DEC/007/B Rev 1.0"

A.3.4 FINAL STEPS


The steps for installing the shared library libasdx32l.so.1.3, making the LOCK_TEST
utility and for using PCMCIA debug utilities to identify the decoders are the same as for
Linux Red Hat 7.3. See “Installing the shared library libasdx32l.so.1.1” on page 42 to
“PCMCIA debug utilities” on page 44 for details.
The differences for Mandrakelinux are as follows:
• compatibility issues: the shared library libasdx32l.so.1.3 was built on
Mandrakelinux 10.1 Kernel 2.6.8.1-12mdk on an Intel platform. This shared library is
not guaranteed to work on any other Linux versions.
• for Mandrakelinux, lsmod utility should report pcmciamtd driver instead of memory_cs
driver.

48 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
APPENDIX B: INSTALLING PCM
DECODERS IN WINDOWS CE
B

49
B.1 INSTALLING DECODER DRIVERS IN
WINDOWS CE
ACRA CONTROL has developed SAM/DEC/00x decoder drivers for iPAQ. For a full
description of characteristics, see B.1.2 “Testing the drivers” on page 51.
The performance of the drivers depends on the following factors:
• Size of the frame used.
Due to overheads associated with the reading of each frame, it is important to use as
large a frame as possible to maximize performance. For example, small user frames can
be grouped in one large frame for this purpose.
1 • The way incoming data stream is handled by the application.
If you are going to do a lot of real-time screen updates (or other resource consuming
processing of incoming data), driver performance will not be as efficient.
The driver characteristics are listed in Table 2.1.

Supported SAM/DECs: SAM/DEC/005


SAM/DEC/007
SAM/DEC/007/B
SAM/DEC/007/B/UT

Supported processor ARM, 0x86


architecture:

Supported OS: Windows CE 3.0

Scalability: Only 1 SAM/DEC per iPAQ

Performance In PCM decom mode:


(measured for 8 Mbit/s for 16K word minor frames
SAM/DEC/007/B on an iPAQ 7.5 Mbit/s for 4K word minor frame
with 266Mhz CPU without any
screen updates or data 1.5 Mbit/s - for 256 word minor frame less than 1 Mbit/s for 16
processing): word minor frame
In "raw" read mode:
up to 11.3 - 11.5 Mbit/s for minor frames of 256 - 2048 words.

Table 2.1

B.1.1 INSTALLING DRIVERS


Installing the drivers requires:
• iPAQ with a free PCMCIA slot and a cradle
• desktop PC with a free USB port and a PCMCIA adapter
• Microsoft Active Sync installed on both iPAQ and desktop PC

B.1.1.1 Updating the registry


Add four entries to the Windows registry on the iPAQ. These entries are used by
Windows CE to detect SAM/DEC card and load the driver. They can be added to the
registry by using Tascal Registry Editor or any similar tool.

50 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
The registry entries are as follows:

[HKEY_LOCAL_MACHINE\Drivers\PCMCIA\ACRA_CONTROL_LTD.-PCM_DECODER-C4D3]
"Dll"="asdxce.dll"
"Prefix"="PCM"
[HKEY_LOCAL_MACHINE\Drivers\PCMCIA\ACRA_CONTROL_LTD.-PCM_Decoder_SAM/DEC/007-85AC]
"Dll"="asdxce.dll"
"Prefix"="PCM"
[HKEY_LOCAL_MACHINE\Drivers\PCMCIA\ACRA_CONTROL_LTD.-SAM/DEC/007/B-F3E6]
"Dll"="asdxce.dll"
"Prefix"="PCM"
[HKEY_LOCAL_MACHINE\Drivers\PCMCIA\ACRA_CONTROL_LTD.-SAM/DEC/007/B/UT-7e30]
"Dll"="asdxce.dll"
"Prefix"="PCM"

B.1.1.2 Installing driver DLLs


Copy asdxce.dll and asdx32ce.dll to the \Windows folder on the iPAQ. The first DLL is
the hardware driver, second is the software driver.

B.1.1.3 Installing test applications


Copy test applications iLook and iTest to a corresponding location on iPAQ,
e.g. \Program Files. Create shortcuts to these programs to make them appear in the
Start Menu or Programs Menu.

B.1.2 TESTING THE DRIVERS

B.1.2.1 Detecting drivers


Insert the SAM/DEC/00x card into the PCMCIA slot in the iPAQ. You should see an icon
appearing on the taskbar with the message ”ACRA CONTROL PCM Decoder detected”.
When you remove the card, the icon should disappear.

B.1.2.2 Basic functionality test with iTest


Start the iTest program on iPAQ. It will take a minute or so to run and it will test basic
functionality like Read, Write, BlockRead, and BlockWrite. It will also do a bitwalk test
and a simple performance test.
The test is not interactive; results can be found in the sdx_sram.log file on iPAQ. All tests
should be marked as PASSED. In case of problems look at the sdx.log file. The
sdx.log file is the log file of the hardware driver which contains details of errors
encountered by the driver.

B.1.2.3 PCM decommutation test with iLook


iLook is an interactive application that allows you to perform five predefined PCM decom
tests. The generic test procedure is described below. Each test is listed in Table 2.1.
To perform a PCM decommutation test, you will require the following,
• KAM-500 system with ENC/003 and/or ENC/004
• KSMv2
• SAM/DEC/00x

51
Performing PCM decommutation test with iLook

1. Take an appropriate XID file from the test suite (see Table 2.2 “i” on page 53 for
details)
2. Compile it using kc:
Example: kc -f <file name> –V
3. Program the system using hound:
Example: hound or hound -P0
4. Insert the SAM/DEC card into iPAQ and start iLook
5. Pick a test that corresponds to the selected XID file
6. Click Start to run the test in silent mode or Start&Display to run it interactively
7. Evaluate test results on the screen. Following indicators are provided:
•Lock / No Lock – Lock indicates if the SAM/DEC can accept PCM data
stream.
•Miss – indicates that frames are missing. This may indicate that the baudrate
is too high.

Note: You may start to skip frames or skip many more frames if you start
another task on iPAQ or in any other way use iPAQ resources at the time of
PCM decommutation.

Note: Missed frames are only detected when the selected channel is 2
(which is SFID – frame ID).

• Total frames / Missed frames – shows how many frames were read/missed since the
beginning of the test.
• Data windows – allows you to view incoming data.
- Big data window displays first 16 words (gets updated every 1000 frames)
- Small data window allows you to view any word in the frame (gets updated every 10
frames). Use the scroller to pick the word to display.

52 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
B.1.2.4 Describing iLook tests

Name: Parity/ Bit order Consistency Test 256 words 4096 words @ 16300 words @
Test @ 1.5M 8M baudrate 8M baudrate
baudrate

XID File: parity.xid consistency.xid 256.xid 4096.xid 16300.xid

Test To test words of To verify that PCM Performan Performance Performance


different length, decom returns ce test: test: testing test: testing
Description: different parity consistent values testing minor frames of minor frames of
and with different over the extended minor 4096 words size 16300 words
bit order period of time frames of size
256 words
size

Test Procedure Run the test in - Run the test in Run the Run the test in Run the test in
interactive mode. silent mode for an test in silent mode silent mode
(if different extended period of silent
Compare results
from generic): on the screen time (1-2 hours). mode
with the expected - Evaluate
results (see "Inconsistencies"
parity.res file) parameter at the
bottom of the
screen after the
test.

Expected Data displayed No inconsistencies Expected Expected result: Expected result:


on the screen are occurred result: appr. 1 missed no missed
Results: as expected ("Inconsistencies = no missed frames in 600 frames
0") frames

Table 2.2i

53
1

THIS PAGE IS INTENTIONALLY BLANK

54 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
REVISION HISTORY

QD/SW/BK/0011 Programming Interface for ACRA CONTROL PCMCIA PCM


Decoders Manual
Date Action Reason
9 Oct. 2007 Added SAM/DEC/007/C and updated the Documentation error
ASDxSetSyncWordEx code example.
1 Jul. 2005 Added section on installing PCM decoders in Specification change
Windows CE.
12 May 2005 Added section on installing ACRA CONTROL Specification change
PCMCIA decoders in MandrakeLinux 10.1
3 Aug. 2004 Added chapter on ACRA CONTROL PC Card PCM Specification change
decoder installation utility
1 Mar. 2004 Updated 1.3.5.3, change of Function specifications, Specification change
which now return a BOOL value
Updated sections 1.1, 1.3.2.1, 1.3.2.4, 1.3.3, 1.3.1.2, Documentation error
1.3.3.1, 1.3.3.2, 1.3.3.3, 1.3.3.5, 1.3.3.6, 1.3.3.7,
1.3.4.1, 1.3.4.5, 1.3.5.1, 1.3.5.6, 1.3.5.13, 1.3.6.1,
A.1.4
Updated from libasdx32l.so.1.0 to libasdx32l.so.1.1 Specification change
2 Jan. 2003. Updated 1.3.5.6. ASDxSetBufferDepth() Specification change
Updated SAM/DEC/007 frame size Style consistency
Added Index, and updated templates
Added decoder types to ASDxGetVersion String() Specification change
1 Dec. 2003 1.3.4.5. Read frame functions: Corrected text Documentation error
Applied Task based template Consistency
4 Nov. 2003 Function ASDxInitFrame in code example changed Documentation error
to ASDxInitFormat
Added function definition box for function
ASDxOpenPlus
3 Jul. 2003 1.2.5. Using the DLL with Visual Basic: corrected Documentation error
example
15 Apr. 2003 Issued first release of document

55
1

THIS PAGE IS INTENTIONALLY BLANK

56 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual


Index
C Mandrakelinux 10.1 46
Linux Red Hat 7.3 13
C++ header files 15
driver files 11
Card information structure 11
installing device driver memory 40
CIS 11
installing PCMCIA decoders 40
compatibility issues 43
opening a decoder 17
D PCMCIA support 40
updating PCMCIA database 40
decoders
baudrate 25 M
compact PCM 10
memory_cs device driver
crystal 23
Linux Red Hat 7.3 40
data buffers 29
memory_cs.o 11
decommutation capabilities 10
Microsoft Active Sync 50
EEPROM 11
MTD 46
Linux 13
NRZ-L 27 O
device
operating systems 10
access rights 41
output baud rate functions 25
verifying installation 42
device driver setup P
32-bit 95/98/ME 12
Windows NT4 and Windows 2000 13 PC Card
DLL 10 listing 5
driver details testing 5
displaying 5 viewing history 6
driver files PC Card PCM decoder 2
copying 3 PCM decoders 10
copying using Windows 2000 4 PCM decommutation 37
copying using Windows 9x 4 PCM link 36
copying using Windows XP 4 PCMCIA 40
Linux Red Hat 7.3 11 adapters 13
viewing 6 database 41
Windows 10 debug utilities 44
decoders in Linux Red Hat 7.3 40
E installing support 40
interface function 15
error messages 32
kernel 40
F Linux manager 41
MandrakeLinux 10.1 46
frame size
MTD driver 46
SAM/DEC/005 29
registry key 4
SAM/DEC/006 29
stand alone 40
SAM/DEC/007 29
subsystem 47
I third-party drivers 13
pseudo code example
information C 34
viewing 2
installation files R
removing 4
reading paths iv
removing in Windows 9x 4
registry
removing in Windows XP and Windows 2000 4
updating for windows CE 50
installation utility 2
reports
closing 6
viewing 6
troubleshooting 7
RPM file 46
using 2
iPAQ 50 S
installing drivers 50
SAM/DEC/006 frame header 22
iTest 51
SAM/DEC/007 frame header 22
L shared library 10
installing 42
LabVIEW 14
using 43
library 15
status checking 18
Linux

57
Index
status word definition 22 V
syntax
Visual Basic 14
C declarations 15

T W
WINAPI 14
test options
Windows 2000 13
using 5
Windows 95/98/ME 12
test utility
Windows CE 50
making 43
Windows driver files 10
U Windows dynamic link library 10
Windows NT4 13
UNICORE 13
Word definition functions 30
utility
write access
cardctl 44
root mode 41
lsmod 45
super-user mode 41

58

You might also like