SurgSim::Devices::LabJack Namespace Reference

A collection of checksum functions specifically tailored for the labjackusb driver. More...

## Classes

struct | AnalogInputSettings
| A struct holding the data to be associated with the positive channel for an analog input. More...
struct | TimerSettings
| A struct holding the data to be associated with a Timer. More...

## Enumerations

enum | Model { MODEL_SEARCH = -1, MODEL_UE9 = 9, MODEL_U3 = 3, MODEL_U6 = 6 }
| The models of LabJack devices. Numbers come from LabJackUD.h. More...
enum | Connection { CONNECTION_SEARCH = -1, CONNECTION_USB = 1, CONNECTION_ETHERNET = 2, CONNECTION_ETHERNET_MB = 3, CONNECTION_ETHERNET_DATA_ONLY = 4 }
| The connection (i.e., communication media) for LabJacks. Numbers come from LabJackUD.h. More...
enum | TimerBase { TIMERBASE_DEFAULT = -1, TIMERBASE_0 = 0, TIMERBASE_1 = 1, TIMERBASE_2 = 2, TIMERBASE_3 = 3, TIMERBASE_4 = 4, TIMERBASE_5 = 5, TIMERBASE_6 = 6, TIMERBASE_20 = 20, TIMERBASE_21 = 21, TIMERBASE_22 = 22, TIMERBASE_23 = 23, TIMERBASE_24 = 24, TIMERBASE_25 = 25, TIMERBASE_26 = 26 }
| The timer base frequencies for LabJacks. More...

enum

TimerMode {
TIMERMODE_PWM_16BIT = 0, TIMERMODE_PWM_8BIT = 1, TIMERMODE_RISING_EDGES_32BIT = 2, TIMERMODE_FALLING_EDGES_32BIT = 3,
TIMERMODE_DUTY_CYCLE = 4, TIMERMODE_FIRMWARE_COUNTER = 5, TIMERMODE_FIRMWARE_COUNTER_DEBOUNCED = 6, TIMERMODE_FREQUENCY_OUTPUT = 7,
TIMERMODE_QUADRATURE = 8, TIMERMODE_TIMER_STOP = 9, TIMERMODE_SYSTEM_TIMER_LOWER_32BITS = 10, TIMERMODE_SYSTEM_TIMER_UPPR_32BITS = 11,
TIMERMODE_RISING_EDGES_16BIT = 12, TIMERMODE_FALLING_EDGES_16BIT = 13, TIMERMODE_LINE_TO_LINE = 14
}

| The timer modes. More...
enum | Range { RANGE_20 = 1, RANGE_10 = 2, RANGE_5 = 3, RANGE_4 = 4, RANGE_2_POINT_5 = 5, RANGE_2 = 6, RANGE_1_POINT_25 = 7, RANGE_1 = 8, RANGE_0_POINT_625 = 9, RANGE_0_POINT_1 = 10, RANGE_0_POINT_01 = 11 }
| The analog input ranges. Equivalent to gain. Ignored for Linux scaffold, which auto-ranges. More...
enum | TIMER { TIMER0, TIMER1, TIMER2, TIMER3, TIMER4, TIMER5 }
enum | FIO_LINE { FIO0, FIO1, FIO2, FIO3, FIO4, FIO5, FIO6, FIO7 }
enum | EIO_LINE { EIO0 = 8, EIO1, EIO2, EIO3, EIO4, EIO5, EIO6, EIO7 }
enum | CIO_LINE { CIO0 = 16, CIO1, CIO2, CIO3 }
enum | MIO_LINE { MIO0 = 20, MIO1, MIO2 }
enum | AIN { AIN0, AIN1, AIN2, AIN3, AIN4, AIN5, AIN6, AIN7, AIN8, AIN9, AIN10, AIN11, AIN12, AIN13, AIN14, AIN15 }
enum | DAC { DAC0, DAC1 }

## Functions

unsigned char | normalChecksum8 (const std::array< unsigned char, MAXIMUM_BUFFER > &bytes, int count)
| Calculates an 8-bit 1's complement unsigned checksum specifically for normal command communication with the low-level LabJack driver. More...
uint16_t | extendedChecksum16 (const std::array< unsigned char, MAXIMUM_BUFFER > &bytes, int count)
| Calculates a 16-bit 1's complement unsigned checksum specifically for extended command communication with the low-level LabJack driver. More...
unsigned char | extendedChecksum8 (const std::array< unsigned char, MAXIMUM_BUFFER > &bytes)
| Calculates an 8-bit 1's complement unsigned checksum specifically for extended command communication with the low-level LabJack driver. More...
void | normalChecksum (std::array< unsigned char, MAXIMUM_BUFFER > *bytes, int count)
| Performs the 8-bit 1's complement unsigned checksum required for normal command communication with the low-level LabJack driver, and stores the result in the buffer. More...
void | extendedChecksum (std::array< unsigned char, MAXIMUM_BUFFER > *bytes, int count)
| Performs the 1's complement unsigned checksums required for extended command communication with the low-level LabJack driver, and stores the results in the buffer. More...
double | doubleFromChars (const std::array< unsigned char, MAXIMUM_BUFFER > &bytes, int startIndex)
| Converts an eight byte array to a floating point double value. More...
uint32_t | uint32FromChars (const std::array< unsigned char, LabJack::MAXIMUM_BUFFER > &bytes, int startIndex, int count)
| Converts an array of bytes to a uint32_t, with the least significant byte at startIndex, and the most significant byte at startIndex + byteCount - 1. More...
uint16_t | uint16FromChars (const std::array< unsigned char, LabJack::MAXIMUM_BUFFER > &bytes, int startIndex, int count)
| Converts an array of bytes to a uint16_t, with the least significant byte at startIndex. More...

## Detailed Description

A collection of checksum functions specifically tailored for the labjackusb driver.

These functions are based off the description in the LabJack User's Guide, and the examples provided with labjackusb.

## Enumeration Type Documentation

## AIN

enum SurgSim::Devices::LabJack::AIN

The timer or channel number that corresponds with the descriptive name used by the LabJack. Use these for the arguments to the enable* functions.

Enumerator
AIN0 |
AIN1 |
AIN2 |
AIN3 |
AIN4 |
AIN5 |
AIN6 |
AIN7 |
AIN8 |
AIN9 |
AIN10 |
AIN11 |
AIN12 |
AIN13 |
AIN14 |
AIN15 |

## CIO_LINE

enum SurgSim::Devices::LabJack::CIO_LINE

The timer or channel number that corresponds with the descriptive name used by the LabJack. Use these for the arguments to the enable* functions.

Enumerator
CIO0 |
CIO1 |
CIO2 |
CIO3 |

## Connection

enum SurgSim::Devices::LabJack::Connection

The connection (i.e., communication media) for LabJacks. Numbers come from LabJackUD.h.

Enumerator
CONNECTION_SEARCH |
CONNECTION_USB |
CONNECTION_ETHERNET |
CONNECTION_ETHERNET_MB |
CONNECTION_ETHERNET_DATA_ONLY |

## DAC

enum SurgSim::Devices::LabJack::DAC

The timer or channel number that corresponds with the descriptive name used by the LabJack. Use these for the arguments to the enable* functions.

Enumerator
DAC0 |
DAC1 |

## EIO_LINE

enum SurgSim::Devices::LabJack::EIO_LINE

The timer or channel number that corresponds with the descriptive name used by the LabJack. Use these for the arguments to the enable* functions.

Enumerator
EIO0 |
EIO1 |
EIO2 |
EIO3 |
EIO4 |
EIO5 |
EIO6 |
EIO7 |

## FIO_LINE

enum SurgSim::Devices::LabJack::FIO_LINE

The timer or channel number that corresponds with the descriptive name used by the LabJack. Use these for the arguments to the enable* functions.

Enumerator
FIO0 |
FIO1 |
FIO2 |
FIO3 |
FIO4 |
FIO5 |
FIO6 |
FIO7 |

## MIO_LINE

enum SurgSim::Devices::LabJack::MIO_LINE

The timer or channel number that corresponds with the descriptive name used by the LabJack. Use these for the arguments to the enable* functions.

Enumerator
MIO0 |
MIO1 |
MIO2 |

## Model

enum SurgSim::Devices::LabJack::Model

The models of LabJack devices. Numbers come from LabJackUD.h.

Enumerator
MODEL_SEARCH |
MODEL_UE9 |
MODEL_U3 |
MODEL_U6 |

## Range

enum SurgSim::Devices::LabJack::Range

The analog input ranges. Equivalent to gain. Ignored for Linux scaffold, which auto-ranges.

Enumerator
RANGE_20 |
RANGE_10 |
RANGE_5 |
RANGE_4 |
RANGE_2_POINT_5 |
RANGE_2 |
RANGE_1_POINT_25 |
RANGE_1 |
RANGE_0_POINT_625 |
RANGE_0_POINT_1 |
RANGE_0_POINT_01 |

## TIMER

enum SurgSim::Devices::LabJack::TIMER

The timer or channel number that corresponds with the descriptive name used by the LabJack. Use these for the arguments to the enable* functions.

Enumerator
TIMER0 |
TIMER1 |
TIMER2 |
TIMER3 |
TIMER4 |
TIMER5 |

## TimerBase

enum SurgSim::Devices::LabJack::TimerBase

The timer base frequencies for LabJacks.

A given value can correspond to different clock frequencies for different LabJack models. The same clock frequency corresponds to different values depending on whether the high- or low-level driver is used. See section 2.10 - Timers/Counters in the respective model's User's Guide.

Enumerator
TIMERBASE_DEFAULT |
TIMERBASE_0 |
TIMERBASE_1 |
TIMERBASE_2 |
TIMERBASE_3 |
TIMERBASE_4 |
TIMERBASE_5 |
TIMERBASE_6 |
TIMERBASE_20 |
TIMERBASE_21 |
TIMERBASE_22 |
TIMERBASE_23 |
TIMERBASE_24 |
TIMERBASE_25 |
TIMERBASE_26 |

## TimerMode

enum SurgSim::Devices::LabJack::TimerMode

The timer modes.

Numbers come from LabJackUD.h. Note that edge-counting modes require processing time: see the LabJack manual for restrictions on number of edges counted per second over all timers (e.g., 30,000/second for U3 or U6).

Enumerator
TIMERMODE_PWM_16BIT |
TIMERMODE_PWM_8BIT |
TIMERMODE_RISING_EDGES_32BIT |
TIMERMODE_FALLING_EDGES_32BIT |
TIMERMODE_DUTY_CYCLE |
TIMERMODE_FIRMWARE_COUNTER |
TIMERMODE_FIRMWARE_COUNTER_DEBOUNCED |
TIMERMODE_FREQUENCY_OUTPUT |
TIMERMODE_QUADRATURE |
TIMERMODE_TIMER_STOP |
TIMERMODE_SYSTEM_TIMER_LOWER_32BITS |
TIMERMODE_SYSTEM_TIMER_UPPR_32BITS |
TIMERMODE_RISING_EDGES_16BIT |
TIMERMODE_FALLING_EDGES_16BIT |
TIMERMODE_LINE_TO_LINE |

## Function Documentation

## doubleFromChars()

double SurgSim::Devices::LabJack::doubleFromChars | ( | const std::array< unsigned char, MAXIMUM_BUFFER > & | bytes,
|  | int | startIndex
| ) |  |

Converts an eight byte array to a floating point double value.

This function is necessary for communication with the low-level driver for the LabJack, which passes all data via unsigned char. The expected format is: the first four bytes store the truncated absolute value of the decimal portion times 4294967296, the last four bytes store the signed whole-number portion, and the bytes are stored in little endian order.

Parameters

  bytes | The array.
  startIndex | The index of the first element.

Returns
  The double.

## extendedChecksum()

void SurgSim::Devices::LabJack::extendedChecksum | ( | std::array< unsigned char, MAXIMUM_BUFFER > * | bytes,
|  | int | count
| ) |  |

Performs the 1's complement unsigned checksums required for extended command communication with the low-level LabJack driver, and stores the results in the buffer.

This function is called prior to writing data to the device for an "extended" command, so that the device can do a checksum.

Parameters

  [in,out] | bytes | The buffer of bytes.
  | count | The number of bytes to check.

## extendedChecksum16()

uint16_t SurgSim::Devices::LabJack::extendedChecksum16 | ( | const std::array< unsigned char, MAXIMUM_BUFFER > & | bytes,
|  | int | count
| ) |  |

Calculates a 16-bit 1's complement unsigned checksum specifically for extended command communication with the low-level LabJack driver.

Parameters

  bytes | The buffer of bytes.
  count | The number of bytes to check.

Returns
  The checksum byte.

## extendedChecksum8()

unsigned char SurgSim::Devices::LabJack::extendedChecksum8 | ( | const std::array< unsigned char, MAXIMUM_BUFFER > & | bytes | ) |

Calculates an 8-bit 1's complement unsigned checksum specifically for extended command communication with the low-level LabJack driver.

Parameters

  bytes | The buffer of bytes.

Returns
  The checksum byte.

## normalChecksum()

void SurgSim::Devices::LabJack::normalChecksum | ( | std::array< unsigned char, MAXIMUM_BUFFER > * | bytes,
|  | int | count
| ) |  |

Performs the 8-bit 1's complement unsigned checksum required for normal command communication with the low-level LabJack driver, and stores the result in the buffer.

This function is called prior to writing data to the device for a "normal" command, so that the device can do a checksum.

Parameters

  [in,out] | bytes | The buffer of bytes.
  | count | The number of bytes to check.

## normalChecksum8()

unsigned char SurgSim::Devices::LabJack::normalChecksum8 | ( | const std::array< unsigned char, MAXIMUM_BUFFER > & | bytes,
|  | int | count
| ) |  |

Calculates an 8-bit 1's complement unsigned checksum specifically for normal command communication with the low-level LabJack driver.

Parameters

  bytes | The buffer of bytes.
  count | The number of bytes to check.

Returns
  The checksum byte.

## uint16FromChars()

uint16_t SurgSim::Devices::LabJack::uint16FromChars | ( | const std::array< unsigned char, LabJack::MAXIMUM_BUFFER > & | bytes,
|  | int | startIndex,
|  | int | count
| ) |  |

Converts an array of bytes to a uint16_t, with the least significant byte at startIndex.

Parameters

  bytes | The array.
  startIndex | The index in the array of the first byte to use.
  count | The number of bytes to convert.

Returns
  A uint16_t.

Exceptions

  Asserts | if byteCount is greater than 2, or it attempts to access beyond the end of the byte array.

## uint32FromChars()

uint32_t SurgSim::Devices::LabJack::uint32FromChars | ( | const std::array< unsigned char, LabJack::MAXIMUM_BUFFER > & | bytes,
|  | int | startIndex,
|  | int | count
| ) |  |

Converts an array of bytes to a uint32_t, with the least significant byte at startIndex, and the most significant byte at startIndex + byteCount - 1.

Parameters

  bytes | The array.
  startIndex | The index in the array of the first byte to use.
  count | The number of bytes to convert.

Returns
  A uint32_t.

Exceptions

  Asserts | if byteCount is greater than 4, or it attempts to access beyond the end of the byte array.