liblabpro
Portable C library for data collection from Vernier LabPro devices
liblabpro.h File Reference
#include <stdbool.h>
#include <libusb-1.0/libusb.h>

Go to the source code of this file.

Data Structures

struct  LabPro_Context
 Thin wrapper around libusb_context. More...
 
struct  LabPro
 Struct representing a LabPro device. More...
 
struct  LabPro_List
 Struct acting as an array of LabPros. More...
 
struct  LabPro_Data_Session
 Struct representing a "data session" Data sessions are an abstraction over the LabPro's command-oriented data collection system. You create a data session for each channel (running LabPro_check_data_session() every time the user modifies a value), then you "stage" the data sessions with LabPro_stage_data_session(), then run a final check for conflicts with LabPro_check_sessions_for_conflicts() before submitting the sessions to the LabPro with LabPro_start_data_collection(). More...
 

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_Battery_Level { LABPRO_BATTERY_OK, LABPRO_BATTERY_LOW_WHILE_SAMPLING, LABPRO_BATTERY_LOW }
 Battery levels reported by the LabPro. More...
 
enum  LabPro_Channels {
  LABPRO_CHAN_ALL = 0, LABPRO_CHAN_ANALOG_1 = 1, LABPRO_CHAN_ANALOG_2 = 2, LABPRO_CHAN_ANALOG_3 = 3,
  LABPRO_CHAN_ANALOG_4 = 4, LABPRO_CHAN_SONIC_1 = 11, LABPRO_CHAN_SONIC_2 = 12, LABPRO_CHAN_DIGITAL_1 = 21,
  LABPRO_CHAN_DIGITAL_2 = 22, LABPRO_CHAN_DIGITAL_OUT_1 = 31, LABPRO_CHAN_DIGITAL_OUT_2 = 32
}
 Channel ports on the LabPro interface. 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...
 
enum  LabPro_System_Status {
  LABPRO_SYSSTATUS_IDLE = 1, LABPRO_SYSSTATUS_ARMED = 2, LABPRO_SYSSTATUS_BUSY = 3, LABPRO_SYSSTATUS_DONE = 4,
  LABPRO_SYSSTATUS_SELFTEST = 5, LABPRO_SYSSTATUS_INIT = 99
}
 LabPro system status. More...
 
enum  LabPro_Errors {
  LABPRO_OK, LABPRO_ERR_NO_MEM, LABPRO_ERR_NOT_OPEN, LABPRO_ERR_BUSY,
  LABPRO_ERR_BUSY_COLLECT, LABPRO_ERR_BUSY_FASTMODE, LABPRO_ERR_OP_MISMATCH, LABPRO_ERR_POSTPROC_ON_SONIC,
  LABPRO_ERR_POSTPROC_ON_REALTIME
}
 Errors related to the "front-end" These errors are specific to use of the LabPro and are positive integers. For underlying errors arising from USB transfer errors, see LabPro_USB_Errors. More...
 
enum  LabPro_USB_Errors {
  LABPRO_ERR_USB_IO = LIBUSB_ERROR_IO, LABPRO_ERR_USB_ACCESS = LIBUSB_ERROR_ACCESS, LABPRO_ERR_USB_NO_DEVICE = LIBUSB_ERROR_NO_DEVICE, LABPRO_ERR_USB_PIPE = LIBUSB_ERROR_PIPE,
  LABPRO_ERR_USB_INTERRUPTED = LIBUSB_ERROR_INTERRUPTED, LABPRO_ERR_USB_NO_MEM = LIBUSB_ERROR_NO_MEM, LABPRO_ERR_USB_OTHER = LIBUSB_ERROR_OTHER
}
 Some errorcodes from libusb These are error codes that might be returned by LabPro_read_raw() or LabPro_send_raw(). You can tell that the errorcode is one of these if it is negative. More...
 

Functions

int LabPro_init (LabPro_Context *context)
 Initialize liblabpro. Currently just a wrapper around libusb_init(). More...
 
void LabPro_exit (LabPro_Context *context)
 De-initialize liblabpro. More...
 
LabPro_List LabPro_list_labpros (LabPro_Context *context)
 Obtain a list connected LabPro devices. More...
 
void LabPro_close_labpro (LabPro *labpro)
 Close the LabPro. More...
 
int LabPro_reset (LabPro *labpro, bool force)
 Send a reset command to the specified LabPro. More...
 
int LabPro_check_data_session (LabPro_Data_Session *session, int **errors)
 Check a data session for problems before running it on the LabPro. More...
 
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...
 
void LabPro_handle_device_disconnect (LabPro *labpro)
 

Function Documentation

◆ LabPro_handle_device_disconnect()

void LabPro_handle_device_disconnect ( LabPro labpro)

Definition at line 359 of file liblabpro.c.