---
name: "sampler"
section: "9"
platform: "linux"
package: "linuxcnc-uspace"
version: "1:2.9.4-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sampler"
---

# sampler(9)

sample data from HAL in real time

## NAME

sampler - sample data from HAL in real time

## SYNOPSIS

**loadrt sampler** **depth=***depth1\[,depth2...\]* **cfg=***string1\[,string2...\]*

## DESCRIPTION

**sampler** and [**halsampler**(1)](/halsampler/1.md) are used together to sample HAL data in real time and store it in a file. **sampler** is a realtime HAL component that exports HAL pins and creates a FIFO in shared memory. It then begins sampling data from the HAL and storing it to the FIFO. **halsampler** is a non-realtime program that copies data from the FIFO to stdout, where it can be redirected to a file or piped to some other program.

## OPTIONS

- **depth=***depth1\[,depth2...\]*

  sets the depth of the realtime-\>non-realtime FIFO that **sampler** creates to buffer the realtime data.  Multiple values of *depth* (separated by commas) can be specified if you need more than one FIFO (for example if you want to sample data from two different realtime threads).

- **cfg=***string1\[,string2...\]*

  defines the set of HAL pins that **sampler** exports and later samples data from.  One  *string* must be supplied for each FIFO, separated by commas. **sampler** exports one pin for each character in *string.* Legal characters are:

-

  **F, f** (float pin)

-

  **B, b** (bit pin)

-

  **S, s** (s32 pin)

-

  **U, u** (u32 pin)

## FUNCTIONS

- **sampler.***N*

  One function is created per FIFO, numbered from zero.

## PINS

- **sampler.***N***.pin.***M* input

  Pin for the data that will wind up in column *M* of FIFO *N* (and in column *M* of the output file).  The pin type depends on the config string.

- **sampler.***N***.curr-depth** s32 output

  Current number of samples in the FIFO.  When this reaches *depth* new data will begin overwriting old data, and some samples will be lost.

- **sampler.***N***.full** bit output

  TRUE when the FIFO *N* is full, FALSE when there is room for another sample.

- **sampler.***N***.enable** bit input

  When TRUE, samples are captured and placed in FIFO *N*, when FALSE, no samples are acquired.  Defaults to TRUE.

## PARAMETERS

- **sampler.***N***.overruns** s32 read/write

  The number of times that **sampler** has tried to write data to the HAL pins but found no room in the FIFO.  It increments whenever **full** is true, and can be reset by the **setp** command.

- **sampler.***N***.sample-num** s32 read/write

  A number that identifies the sample.  It is automatically incremented for each sample, and can be reset using the **setp** command.  The sample number can optionally be printed in the first column of the output from **halsampler**, using the *-t* option (see **man 1 halsampler** ).

## SEE ALSO

[**halsampler**(1)](/halsampler/1.md), [**streamer**(9)](/streamer/9.md), [**halstreamer**(1)](/halstreamer/1.md)

## AUTHOR

Original version by John Kasunich, as part of the LinuxCNC project. Improvements by several other members of the LinuxCNC development team.

## REPORTING BUGS

Report bugs at https://github.com/LinuxCNC/linuxcnc/issues

## COPYRIGHT

Copyright © 2006 John Kasunich.\
 This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
