liblabpro
Portable C library for data collection from Vernier LabPro devices
Internal functions, enums, etc.

Enumerations

enum  LabPro_Commands {
  LABPRO_RESET = 0, LABPRO_CHANNEL_SETUP = 1, LABPRO_DATACOLLECT_SETUP = 3, LABPRO_CONVERSION_EQN_SETUP = 4,
  LABPRO_DATA_CTL = 5, LABPRO_SYS_SETUP = 6, LABPRO_SYS_STATUS = 7, LABPRO_CHAN_STATUS = 8,
  LABPRO_REQUEST_CHAN_DATA = 9, LABPRO_ADVANCED_DATA_REDUCTION = 10, LABPRO_DIGITAL_DATA_CAPTURE = 12, LABPRO_QUERY_CHANNELS = 80,
  LABPRO_PORT_POWER_CTL = 102, LABPRO_REQUEST_SETUP_INFO = 115, LABPRO_REQUEST_LONG_SENSOR_NAME = 116, LABPRO_REQUEST_SHORT_SENSOR_NAME = 117,
  LABPRO_ARCHIVE = 201, LABPRO_ANALOG_OUT_SETUP = 401, LABPRO_LED_CTL = 1998, LABPRO_SOUND_CTL = 1999,
  LABPRO_DIGITAL_OUT_CTL = 2001
}
 Commands that can be sent to the LabPro. More...
 
enum  LabPro_Analog_Chan_Operations {
  LABPRO_CHANOP_OFF, LABPRO_CHANOP_AUTOID, LABPRO_CHANOP_VOLTAGE10V, LABPRO_CHANOP_CURRENT10A,
  LABPRO_CHANOP_RESISTANCE, LABPRO_CHANOP_VOLTAGE10V_PERIOD, LABPRO_CHANOP_VOLTAGE10V_FREQUENCY, LABPRO_CHANOP_VOLTAGE10V_TRANSITIONS_COUNT,
  LABPRO_CHANOP_TI_TEMP_C = 10, LABPRO_CHANOP_TI_TEMP_F = 11, LABPRO_CHANOP_TI_LIGHT = 12, LABPRO_CHANOP_VOLTAGE_ZERO_TO_FIVE = 14
}
 Operations for analog channels. More...
 
enum  LabPro_Sonic_Chan_Operations {
  LABPRO_CHANOP_RESET = 0, LABPRO_DISTANCE_AND_DT_METERS = 1, LABPRO_DISTANCE_AND_DT_FEET = 3, LABPRO_DISTANCE_VELOCITY_AND_DT_METERS = 4,
  LABPRO_DISTANCE_VELOCITY_AND_DT_FEET = 5, LABPRO_DISTANCE_VELOCITY_ACCEL_AND_DT_METERS = 6, LABPRO_DISTANCE_VELOCITY_ACCEL_AND_DT_FEET = 7
}
 Operations for sonic channels. More...
 
enum  LabPro_Analog_PostProc { LABPRO_POSTPROC_NONE, LABPRO_POSTPROC_DERIV1, LABPRO_POSTPROC_DERIV1_AND_2 }
 Post-processing performed on analog data. As with data collection from sonic channels, please calculate the derivatives in your application rather than making the LabPro compute them. The extra computations will raise the temperature of the LabPro and make its readings less accurate. More...
 
enum  LabPro_Sampling_Modes { LABPRO_SAMPMODE_NON_REALTIME, LABPRO_SAMPMODE_REALTIME }
 Sampling modes. More...
 

Functions

int LabPro_send_raw (LabPro *labpro, char *command, int *length_transferred)
 Send a raw command to the LabPro. More...
 
int LabPro_read_raw (LabPro *labpro, char **string, int *length)
 Read raw bytes from the LabPro. More...
 
int LabPro_trim_response (char *string)
 Trim trailing junk that the LabPro sent Since the LabPro always returns data in multiples of 64 bytes, the last packet is likely to contain junk following the actual data. This replaces the trailing carriage return character with a NULL character. More...
 

Detailed Description

Enumeration Type Documentation

◆ LabPro_Analog_Chan_Operations

Operations for analog channels.

Enumerator
LABPRO_CHANOP_OFF 

Turn the channel off.

LABPRO_CHANOP_AUTOID 

Auto-ID the sensor; units can be fetched from the sensor's description.

LABPRO_CHANOP_VOLTAGE10V 

Range from -10 V to +10 V.

LABPRO_CHANOP_CURRENT10A 

Presumably 0 Amps to 10 Amps.

LABPRO_CHANOP_RESISTANCE 

Measure resistance.

LABPRO_CHANOP_VOLTAGE10V_PERIOD 

Measure the signal period on a ±10 V signal. Channel 1 only.

LABPRO_CHANOP_VOLTAGE10V_FREQUENCY 

Measure the signal frequency on a ±10 V signal. Channel 1 only.

LABPRO_CHANOP_VOLTAGE10V_TRANSITIONS_COUNT 

Count signal transitions on a ±10 V signal. Channel 1 only.

LABPRO_CHANOP_TI_TEMP_C 

Measure temperature (Celsius) from the TI Temperature probe This is for measuring temperature in Celsius from the Texas Instruments Stainless Steel Temperature Probe. The CBL2 technical reference manual states that this probe supports Auto-ID, so I'm not sure what the purpose of this setting is. Maybe early revisions of the sensor didn't auto-ID...?

LABPRO_CHANOP_TI_TEMP_F 

Measure temperature (Fahrenheit) from the TI Temperature probe This is for measuring temperature in Fahrenheit from the Texas Instruments Stainless Steel Temperature Probe. The CBL2 technical reference manual states that this probe supports Auto-ID, so I'm not sure what the purpose of this setting is. Maybe early revisions of the sensor didn't auto-ID...?

LABPRO_CHANOP_TI_LIGHT 

Measure light from the TI Light Sensor This is for the Texas Instruments light sensor. (I think) it causes the LabPro to return units of milliwatts per square centimeter, since that is what the CBL2 technical manual says its units are. However, it also states that this sensor Auto-IDs, so I'm not sure this is necessary.

LABPRO_CHANOP_VOLTAGE_ZERO_TO_FIVE 

Higher-precision voltage measurement I assume this is just like the ±10 V measurement, but more precise due to the smaller range.

Definition at line 130 of file liblabpro.h.

◆ LabPro_Analog_PostProc

Post-processing performed on analog data. As with data collection from sonic channels, please calculate the derivatives in your application rather than making the LabPro compute them. The extra computations will raise the temperature of the LabPro and make its readings less accurate.

Enumerator
LABPRO_POSTPROC_NONE 

Perform no post-processing. This is the only acceptable value in real-time mode.

LABPRO_POSTPROC_DERIV1 

Calculate d/dt. Only allowed in non-real-time mode.

LABPRO_POSTPROC_DERIV1_AND_2 

Calculate d/dt and d^2/dt^2. Only allowed in non-real-time mode.

Definition at line 208 of file liblabpro.h.

◆ LabPro_Commands

Commands that can be sent to the LabPro.

Enumerator
LABPRO_RESET 

Clear RAM and reset the LabPro.

LABPRO_CHANNEL_SETUP 

Select channels and units for data collection.

LABPRO_DATACOLLECT_SETUP 

Set data collection rate and time, etc.

LABPRO_CONVERSION_EQN_SETUP 

Set up a manual conversion equation rather than one obtained by Auto-ID.

LABPRO_DATA_CTL 

Set parameters for what data points will be returned.

LABPRO_SYS_SETUP 

Set various settings for the LabPro itself.

LABPRO_SYS_STATUS 
LABPRO_CHAN_STATUS 

Get a data point during non-realtime collection.

LABPRO_REQUEST_CHAN_DATA 

Get a single point of data outside of active data collection.

LABPRO_ADVANCED_DATA_REDUCTION 
LABPRO_DIGITAL_DATA_CAPTURE 
LABPRO_QUERY_CHANNELS 

Return sensor IDs for each channel

LABPRO_PORT_POWER_CTL 
LABPRO_REQUEST_SETUP_INFO 
LABPRO_REQUEST_LONG_SENSOR_NAME 
LABPRO_REQUEST_SHORT_SENSOR_NAME 
LABPRO_ARCHIVE 
LABPRO_ANALOG_OUT_SETUP 
LABPRO_LED_CTL 
LABPRO_SOUND_CTL 
LABPRO_DIGITAL_OUT_CTL 

Definition at line 59 of file liblabpro.h.

◆ LabPro_Sampling_Modes

Sampling modes.

Enumerator
LABPRO_SAMPMODE_NON_REALTIME 

Have the LabPro store all the datapoints in RAM and wait for a "get" command to transfer them.

LABPRO_SAMPMODE_REALTIME 

Have the LabPro send datapoints as they're collected without storing them.

Definition at line 219 of file liblabpro.h.

◆ LabPro_Sonic_Chan_Operations

Operations for sonic channels.

Enumerator
LABPRO_CHANOP_RESET 
LABPRO_DISTANCE_AND_DT_METERS 

Return distance in meters and change in time since last measurement Fun fact: the manual states that sending a 2 will do the same thing.

LABPRO_DISTANCE_AND_DT_FEET 

Return distance in feet and change in time since last measurement.

LABPRO_DISTANCE_VELOCITY_AND_DT_METERS 

Return distance in meters, velocity in m/s, and delta t. If used with non-real-time mode sampling, this is the same as LABPRO_DISTANCE_AND_DT_METERS. It may be tempting to use this in your application and make the LabPro do the extra work, but please don't. The extra computations will mean the LabPro heats up more and loses accuracy.

LABPRO_DISTANCE_VELOCITY_AND_DT_FEET 

See LABPRO_DISTANCE_VELOCITY_AND_DT_METERS.

LABPRO_DISTANCE_VELOCITY_ACCEL_AND_DT_METERS 

Return distance, velocity, and acceleration in m, m/s, and m/(s^2), plus delta t. If used with non-real-time mode sampling, this is the same as LABPRO_DISTANCE_AND_DT_METERS. It may be tempting to use this in your application and make the LabPro do the extra work, but please don't. The extra computations will mean the LabPro heats up more and loses accuracy.

LABPRO_DISTANCE_VELOCITY_ACCEL_AND_DT_FEET 

See LABPRO_DISTANCE_VELOCITY_ACCEL_AND_DT_METERS.

Definition at line 177 of file liblabpro.h.

Function Documentation

◆ LabPro_read_raw()

int LabPro_read_raw ( LabPro labpro,
char **  string,
int *  length 
)

Read raw bytes from the LabPro.

This is for internal or console purposes; you shouldn't need to use it. It reads as many bytes as possible from the LabPro, then returns the string. If there is trailing garbage due to the LabPro's response not being a multiple of 64 bytes (the LabPro's USB packet size), it is NOT stripped (see LabPro_trim_response() for that purpose). If this function encounters six errors from libusb, it will assume that there is something wrong and abort with an error code from LabPro_USB_Errors.

Even if this function returns LABPRO_ERR_NO_MEM, some of the data may have been transferred, because this function calls realloc() after each 64-byte packet.

Parameters
labproThe LabPro to read from
stringPointer to char array that will hold the data
lengthThe number of bytes that were read. This will always be a multiple of 64. Maybe useful if you're requesting binary sample data.
Returns
One of the LabPro_Errors error codes, LABPRO_OK, or, if the return value is negative, it is one of the LabPro_USB_Errors errorcodes.

Definition at line 281 of file liblabpro.c.

◆ LabPro_send_raw()

int LabPro_send_raw ( LabPro labpro,
char *  command,
int *  length_transferred 
)

Send a raw command to the LabPro.

This is for internal or console purposes; you shouldn't need to use it. It sends the string specified by command directly to the LabPro, only modifying it by adding a trailing carriage return (CR) character. It does not check whether the LabPro is busy. It should not be used for anything but text data, because it uses string functions to get the length of the command string.

The memory pointed to by command is not freed by this function.

Parameters
labproThe LabPro to write to
commandFull command string to send to the LabPro
length_transferredThe actual bytes transferred (in case an error occurs)
Returns
One of the LabPro_Errors errocodes, LABPRO_OK, or, if the return value is negative, it is one of the LabPro_USB_Errors errorcodes.

Definition at line 225 of file liblabpro.c.

◆ LabPro_trim_response()

int LabPro_trim_response ( char *  string)

Trim trailing junk that the LabPro sent Since the LabPro always returns data in multiples of 64 bytes, the last packet is likely to contain junk following the actual data. This replaces the trailing carriage return character with a NULL character.

Parameters
stringThe string to trim
Returns
Zero if the string was properly NULL-ified, 1 if a CR character wasn't found.

Definition at line 350 of file liblabpro.c.