EasyManuals Logo

LabJack U3 User Manual

LabJack U3
120 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #46 background imageLoading...
Page #46 background image
In the sample code, alternate functions (S or SS versions) can generally be substituted as
desired, changing the parameter types accordingly. All samples here are written in pseudo-C
Functions with an “S” or “SS” appended are provided for programming languages that can’t
include the LabJackUD.h file and therefore can’t u
.
se the constants included. It is generally poor
rogramming form to hardcode numbers into function calls, if for no other reason than it is hard
Type parameter with a const char * which is a
of the desired constant. Functions with a
penLabJackS replaces both
eviceType and ConnectionType with strings since both take constants.
C, where the LabJackUD.h file can be included and the constants used directly:
ddRequest(Handle, LJ_ioGET_CONFIG, LJ_ioHARDWARE_VERSION,0,0,0);
ET_CONFIG”, “LJ_ioHARDWARE_VERSION”,0,0,0);
s, or
h do not take strings. The StringToConstant() function
kes a string and returns the numeric constant. So, for example:
LJ_ERROR err;
err = AddRequestSS(Handle, “LJ_ioGETCONFIG”, “LJ_ioHARDWARE_VERSION”,0,0,0);
if (err == t
do some r
Once agai h
if (err == 2)
4.1.2 Mu -
This driver is c these functions can
be called f
Because of thi
requests/resul
multiple thread
into another. I are added, and then results return LJE_NO_DATA_AVAILABLE or a
imilar error, chances are the requests and results are in different threads.
equest is made in by the thread ID. If a thread is killed and
ly a
m
he
s are created and destroyed
ontinuously. This will result in the slow consumption of memory as requests on old threads are
p
to read. Functions with a single “S” replace the IO
string. A string can then be passed with the name
double “SS” replace both the IOType and Channel with strings. O
D
For example:
In
A
The bad way (hard to read) when LabJackUD.h cannot be included:
AddRequest(Handle, 1001, 10, 0, 0, 0);
The better way when LabJackUD.h cannot be included, is to pass strings:
AddRequestSS(Handle, “LJ_ioG
Continuing on this vein, the function StringToConstant() is useful for error handling routine
with the GetFirst/Next functions whic
ta
S ringToConstant(“LJE_INVALID_DEVICE_TYPE”))
er or handling..
n, t is is much clearer than:
lti Threaded Operation
ompletely thread safe. With some very minor exceptions, all
rom multiple threads at the same time and the driver will keep everything straight.
s Add, Go, and Get must be called from the same thread for a particular set of
ts. Internally the list of requests and results are split by thread. This allows
s to be used to make requests without accidentally getting data from one thread
f requests
s
The driver tracks which thread a r
then a new one is created, it is possible for the new thread to have the same ID. Its not real
problem if Add is called first, but if Get is called on a new thread results could be returned fro
the thread that already ended.
As mentioned, the list of requests and results is kept on a thread-by-thread basis. Since t
driver cannot tell when a thread has ended, the results are kept in memory for that thread
regardless. This is not a problem in general as the driver will clean it all up when unloaded.
hen it can be a problem is in situations where thread
W
c
46

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the LabJack U3 and is the answer not in the manual?

LabJack U3 Specifications

General IconGeneral
Analog Outputs2
Analog Output Resolution10 bits
Digital I/O20
Counter/Timers2
InterfaceUSB
Operating Voltage5 V
ManufacturerLabJack Corporation
Analog Inputs16
Analog Input Resolution12-bit
Max Sample Rate50 kHz