SAMDECProg Int
SAMDECProg Int
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
iv
Contents
Contact details . . . . . . . . . . . . . . . . ii
About this book . . . . . . . . . . . . . . . . iii
Suggested Reading Paths . . . . . . . . . . . . . . . . . iv
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
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.
2 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
1
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.
2. select
3. navigate to the directory to save the report file
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.
Table 1.1
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.
Table 2.2
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.
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.
Note: All decoders now supplied by ACRA CONTROL are programmed with
CIS. Only older SAM/DEC/005 decoders may not have CIS.
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 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.
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.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 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.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:
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()
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()
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()
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()
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()
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()
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()
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()
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.5 ASDxGetVersion()
Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()
Outputs:
Returns one of the version numbers listed in Table 2.8.
Library interface 19
2.3.3.6 ASDxGetVersionString()
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()
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.1 ASDxEnablePCM()
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()
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()
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()
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:
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.
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 */
2.3.4.6 ASDxReadFrameWithTime()
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()
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.
ASDxSetOutputBaud()
void ASDxSetOutputBaud( HDECODER theDecoder, double theBaudRate )
Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate()
theBaudRate – the baudrate to set
Outputs:
None.
Library interface 25
ASDxGetOutputBaud()
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.
ASDxSetSyncWordEx()
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()
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
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()
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()
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()
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()
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.
2.3.5.7 ASDxGetBufferDepth()
Inputs:
theDecoder – pointer to valid decoder structure returned by ASDxCreate().
Outputs:
Returns the number of frames in the decoder.
2.3.5.8 ASDxSetRS422()
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()
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()
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()
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.
2.3.5.14 ASDxGetProperty()
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.1 ASDxGetError
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"
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:
2
1
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
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.
Hardware interface 37
2
1
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.
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
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.
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.
Note: /dev/mem0a and /dev/mem0c have read and write access for all users.
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.
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.
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
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
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:
.
If PCMCIA support is enabled then the modules pcmcia_core and ds will be loaded.
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.
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.
device "pcmciamtd"
class "memory" module "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"
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"
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.
Table 2.1
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"
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
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.
Table 2.2i
53
1
54 Programming Interface for ACRA CONTROL PCMCIA PCM Decoders Manual, 9 October, 2007
REVISION HISTORY
55
1
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