LI-7000 communication


Enumerations

enum  LiSources_t {
  CO2A_UMM = 1, CO2B_UMM = 2, CO2D_UMM = 3, H2OA_MMM = 4,
  H2OB_MMM = 5, H2OD_MMM = 6, CO2A_PA = 10, CO2B_PA = 11,
  CO2D_PA = 12, H2OA_KPA = 13, H2OB_KPA = 14, H2OD_KPA = 15,
  H2OA_DPC = 16, H2OB_DPC = 17, H2OD_DPC = 18, P_KPA = 22,
  T_C = 23, CO2A_W = 50, CO2B_W = 51, H2OA_W = 52,
  H2OB_W = 53
}
enum  LiTimestamp_t { STAMP_LONG = 0, STAMP_SHORT = 1, STAMP_NONE = 2 }
enum  LiH2OReference_t {
  ESTIMATED = 0, DRY = 1, EXACT = 2, AUX1 = 2,
  AUX2 = 3
}
enum  LiPumpRate_t { PUMP_OFF = 0, PUMP_SLOW = 1, PUMP_MEDIUM = 2, PUMP_FAST = 3 }

Functions

Li7000_t * liOpen (const char *const ttydevice)
 Open LI-7000 communication.
void liClose (Li7000_t *obj)
 Close LI-7000 communication.
int liGetFd (Li7000_t *obj)
 Return file descriptor of serial port.
int liSend (Li7000_t *obj, const char *const data)
 Send data to LI-7000.
char * liGetSavedLine (Li7000_t *obj)
 Return next saved response line.
char * liReadNextLine (Li7000_t *obj, char *buf, size_t buflen)
 Read next line from LI-7000, and return it.
int liSetDataTypes (Li7000_t *obj, LiTimestamp_t timestamp, int num,...)
 Set data sources.
int liSetDataTypesV (Li7000_t *obj, LiTimestamp_t timestamp, LiSources_t *src, int num)
 Set data sources.
int liQueryDataTypes (Li7000_t *obj, LiTimestamp_t *timestamp, LiSources_t *sources, int maxnum)
 Queries actually set DATA sources.
int liSetDataRate (Li7000_t *obj, int rate)
 Sets DATA aquire rate.
int liQueryDataRate (Li7000_t *obj)
 Queries DATA aquire rate.
int liSetH2OReference (Li7000_t *obj, LiH2OReference_t mode, float conc)
 Sets H2O reference mode.
int liParseData (char *const data, time_t *time, double *values, size_t len)
 Parses a DATA datagram sent by the LI-7000.
int liPoll (Li7000_t *obj, time_t *time, double *values, size_t len)
 Polls one data set.
int liCalibDoH2OReadA (Li7000_t *obj, float conc)
 Calibrates H2O: Make Cell A read (exact value) ($^\circ{}$ C).
int liCalibDoH2OReadAM (Li7000_t *obj, float conc)
 Calibrates H2O: Make Cell A read (exact value) (mmol/mol).
int liCalibDoH2OMatch (Li7000_t *obj)
 Calibrates H2O: Match Cell A and Cell B.
int liGetH2OCalibCoefficients (Li7000_t *obj, double *z, double *zm, double *s, double *w0)
 Returns calibration coefficients.
const char * liDataTypeString (LiSources_t type)
 Returns a string with the name of a Li_Sources_t type.
int liSetPumpRate (Li7000_t *obj, LiPumpRate_t rate)
 Sets internal pump.
double magnusFormula (double T)
 Calculates water vapour partial pressure of dew point using Magnus' formula.

Detailed Description

Types and functions for communicating with LI-7000 Gas Analyser

Note:
Not all possibilities of communication as described in the LI-7000 manual are implemented here.

Enumeration Type Documentation

enum LiSources_t

Sources that can be queried from LI-7000

Enumerator:
CO2A_UMM  CO2 cell A mol/mol
CO2B_UMM  CO2 cell B mol/mol
CO2D_UMM  CO2 differential, mol/mol
H2OA_MMM  H2O cell A mmol/mol
H2OB_MMM  H2O cell B mmol/mol
H2OD_MMM  H2O differential, mmol/mol
CO2A_PA  CO2 cell A partial pressure, Pa
CO2B_PA  CO2 cell B partial pressure, Pa
CO2D_PA  CO2 differential partial pressure, Pa
H2OA_KPA  H2O cell A partial pressure, kPa
H2OB_KPA  H2O cell B partial pressure, kPa
H2OD_KPA  H2O differential partial pressure, kPa
H2OA_DPC  H2O dew point of cell A, $^\circ{}$ C
H2OB_DPC  H2O dew point of cell B, $^\circ{}$ C
H2OD_DPC  H2O dew point differential, $^\circ{}$ C
P_KPA  Pressure messured in Cell B, kPa
T_C  Temperature messured in Cell A, $^\circ{}$ C
CO2A_W  CO2 cell A raw signal (intensity)
CO2B_W  CO2 cell B raw signal (intensity)
H2OA_W  H2O cell A raw signal (intensity)
H2OB_W  H2O cell B raw signal (intensity)

enum LiTimestamp_t

Different Timestamps which can be set for DATA queries

Enumerator:
STAMP_LONG  Long timestamp: YYYY-MM-DD hh:mm:ss
STAMP_SHORT  Short timestamp: Seconds since power on of the LI-7000 device
STAMP_NONE  No timestamp

enum LiH2OReference_t

Reference modes

Enumerator:
ESTIMATED  Reference Estimated Mode (REM)
DRY  Dry air flowing through cell A
EXACT  A known concentration is flowing through cell A
AUX1  Aux1 input (voltage)
AUX2  Aux2 input (voltage)

enum LiPumpRate_t

Pump Rate of the internal pump

Enumerator:
PUMP_OFF  off
PUMP_SLOW  slow rate
PUMP_MEDIUM  medium rate
PUMP_FAST  fast rate


Function Documentation

EXTERN Li7000_t * liOpen ( const char *const  ttydevice  ) 

Open LI-7000 communication.

This function initialises everything needed for communication with the LI-7000 device. It opens the port and does tty settings.

Parameters:
ttydevice The device name of the serial port
Returns:
A pointer to an "object" structure containing all necessary information, or NULL in case of error and errno will be set
See also:
liClose()

EXTERN void liClose ( Li7000_t *  obj  ) 

Close LI-7000 communication.

Parameters:
obj Pointer to the Li7000 "object" structure

EXTERN int liGetFd ( Li7000_t *  obj  ) 

Return file descriptor of serial port.

Parameters:
obj Pointer to the Li7000 "object" structure
Returns:
The file descriptor

EXTERN int liSend ( Li7000_t *  obj,
const char *const  data 
)

Send data to LI-7000.

Sends the data contained in data and waits for the response

Parameters:
obj Pointer to the Li7000 "object" structure
data Null-terminated string which contains data to send
Returns:
0 if the call was successful, -1 in case of error

EXTERN char * liGetSavedLine ( Li7000_t *  obj  ) 

Return next saved response line.

Returns the next saved line from the response buffer, or NULL if there is none left. The returned item is removed from the list.

Parameters:
obj Pointer to the Li7000 "object" structure
Returns:
A pointer to the string, or NULL if there is no string left.
Note:
The string returned by this function must be freed using free() if it is no longer needed.

EXTERN char * liReadNextLine ( Li7000_t *  obj,
char *  buf,
size_t  buflen 
)

Read next line from LI-7000, and return it.

If there are saved lines in the response buffer, these are returned first. If there are no more unread lines, the function reads a line from the LI-7000. It will block until new data becomes available on the serial line.

Parameters:
obj Pointer to the Li7000 "object" structure
buf The buffer into which the string will be stored, or NULL if memory should be allocated for it.
buflen The length of the buffer buf
Returns:
A pointer to the string, or NULL if a read error occured (and errno will be set).
Note:
If buf is NULL, the string returned by this function must be freed using free() if it is no longer needed.

EXTERN int liSetDataTypes ( Li7000_t *  obj,
LiTimestamp_t  timestamp,
int  num,
  ... 
)

Set data sources.

Sets data sources to be returned by the LI-7000, either by polling or by fixed-rate output.

Parameters:
obj Pointer to the Li7000 "object" structure
timestamp The timestamp to be used
num The number of data sources to be set
... num arguments of type LiSources_t, describing what is to be returned in the corresponding location.
Returns:
0 if the call was successful, -1 in case of error
Example:
 liSetDataTypes(li, SHORT, 3, CO2B_UMM, H2OB_MMM, TC); 

EXTERN int liSetDataTypesV ( Li7000_t *  obj,
LiTimestamp_t  timestamp,
LiSources_t src,
int  num 
)

Set data sources.

Sets data sources to be returned by the LI-7000, either by polling or by fixed-rate output.

This is something like an overloaded member function, doing exactly the same as liSetDataTypes(), but with other types of arguments.

Parameters:
obj Pointer to the Li7000 "object" structure
timestamp The timestamp to be used
src An array of LiSources_t
num The number of elements in the src array
Returns:
0 if the call was successful, -1 in case of error

EXTERN int liQueryDataTypes ( Li7000_t *  obj,
LiTimestamp_t timestamp,
LiSources_t sources,
int  maxnum 
)

Queries actually set DATA sources.

Parameters:
obj Pointer to the Li7000 "object" structure
timestamp Returns the timestamp to be used
sources Returns the sources set
maxnum the maximum number of elements in the array sources
Returns:
Returns the number of array elements set if successful. If an error occurs, -1 is returned (and errno is set).

EXTERN int liSetDataRate ( Li7000_t *  obj,
int  rate 
)

Sets DATA aquire rate.

Parameters:
obj Pointer to the Li7000 "object" structure
rate the data rate in seconds to be used (e.g. 2 means send every 2 seconds); 0 = polled operation
Returns:
0 if the call was successful, -1 in case of error

EXTERN int liQueryDataRate ( Li7000_t *  obj  ) 

Queries DATA aquire rate.

Parameters:
obj Pointer to the Li7000 "object" structure
Returns:
The data rate in seconds if the call was successful, -1 in case of error

EXTERN int liSetH2OReference ( Li7000_t *  obj,
LiH2OReference_t  mode,
float  conc 
)

Sets H2O reference mode.

This function sets the reference mode, i.e. the mode the LI-7000 uses to aquire data.

Parameters:
obj Pointer to the Li7000 "object" structure
mode The mode to be set
conc The known Cell A concentration in EXACT mode
Returns:
0 if the call was successful, or -1 in case of error

EXTERN int liParseData ( char *const   data,
time_t *  time,
double *  values,
size_t  len 
)

Parses a DATA datagram sent by the LI-7000.

Parameters:
data A pointer to a string containing the data sent
time This variable will be set to the time stamp of the data
values A pointer to an array of double which stores the data transfered
len The length of the values array
Returns:
If the call was successful, returns the number of items stored in values. If data contained a data header, -2 is returned. -1 indicates an error.

EXTERN int liPoll ( Li7000_t *  obj,
time_t *  time,
double *  values,
size_t  len 
)

Polls one data set.

This function is only to be called if the LI-7000 is in poll mode. See liSetDataRate() function.

Parameters:
obj Pointer to the Li7000 "object" structure
time This variable will be set to the time stamp of the data
values A pointer to an array of double which stores the data transfered
len The length of the values array
Returns:
0 if the call was successful, -1 in case of error

EXTERN int liCalibDoH2OReadA ( Li7000_t *  obj,
float  conc 
)

Calibrates H2O: Make Cell A read (exact value) ($^\circ{}$ C).

This function does H2O calibration. It assumes that a constant and known H2O concentration is actually flowing through cell A of the LI-7000 and it already has stabilised; if you are not sure whether values have stabilised yet, consider liCalibrateH2O().

The known concentration has to be given with the conc parameter.

Parameters:
obj Pointer to the Li7000 "object" structure
conc The H2O concentration, given as dew point ($^\circ{}$ C)
Returns:
0 if the call was successful, -1 if a communication error occured

EXTERN int liCalibDoH2OReadAM ( Li7000_t *  obj,
float  conc 
)

Calibrates H2O: Make Cell A read (exact value) (mmol/mol).

This function is analogous to liCalibDoH2OReadA(), but the concentration is given in mmol/mol.

Parameters:
obj Pointer to the Li7000 "object" structure
conc The H2O concentration, given as dew point (mmol/mol)
Returns:
0 if the call was successful, -1 if a communication error occured

EXTERN int liCalibDoH2OMatch ( Li7000_t *  obj  ) 

Calibrates H2O: Match Cell A and Cell B.

This function does H2O calibration. It assumes that the same H2O concentration is actually flowing through both cells of the LI-7000 and it already has stabilised; if you are not sure whether values have stabilised yet, consider liCalibrateH2O().

Parameters:
obj Pointer to the Li7000 "object" structure
Returns:
0 if the call was successful, -1 if a communication error occured

EXTERN int liGetH2OCalibCoefficients ( Li7000_t *  obj,
double *  z,
double *  zm,
double *  s,
double *  w0 
)

Returns calibration coefficients.

This function returns the H2O calibration coefficients Z, Zm, S, and W0

Parameters:
obj Pointer to the Li7000 "object" structure
z Returns Z
zm Returns Zm
s Returns S
w0 Returns W0
Returns:
0 if the call was successful, -1 if a communication error occured

EXTERN const char * liDataTypeString ( LiSources_t  type  ) 

Returns a string with the name of a Li_Sources_t type.

Parameters:
type The type
Returns:
A string, or NULL if type has not a valid value.

EXTERN int liSetPumpRate ( Li7000_t *  obj,
LiPumpRate_t  rate 
)

Sets internal pump.

Sets the speed of the internal pump of the LI-7000.

Parameters:
obj Pointer to the Li7000 "object" structure
rate The flow rate to be set
Returns:
0 if the call was successful, -1 in case of error

EXTERN double magnusFormula ( double  T  ) 

Calculates water vapour partial pressure of dew point using Magnus' formula.

Parameters:
T Temperature (K)
Returns:
The H2O partial pressure (kPa)


Generated by
doxygen
SourceForge.net Logo