Commit 896b686e authored by Federico Vaga's avatar Federico Vaga

Merge branch 'release/v2.6.0' into master

parents 536de938 80ec317c
......@@ -6,6 +6,17 @@
Changelog
=========
2.6.0 - 2020-12-09
==================
Added
-----
- lib: add temperature attribute
- lib: add buffer size attribue for FMC ADC 100M
Fixed
-----
- tst: major fixes in pytests that were preventing them from running
2.5.4 - 2020-10-07
==================
......
......@@ -57,10 +57,11 @@ class PyAdcConf(Structure):
ADC_CONF_BRD_N_TRG_EXT = 5
ADC_CONF_BRD_N_TRG_THR = 6
ADC_CONF_BRD_N_TRG_TIM = 7
ADC_CONF_UTC_TIMING_BASE_S = 8
ADC_CONF_UTC_TIMING_BASE_T = 9
ADC_CONF_UTC_TIMING_BASE_B = 10
__ADC_CONF_BRD_ATTRIBUTE_LAST_INDEX = 11
ADC_CONF_BRD_TEMPERATURE = 8
ADC_CONF_UTC_TIMING_BASE_S = 9
ADC_CONF_UTC_TIMING_BASE_T = 10
ADC_CONF_UTC_TIMING_BASE_B = 11
__ADC_CONF_BRD_ATTRIBUTE_LAST_INDEX = 12
# CHANNEL configuration
ADC_CONF_CHN_RANGE = 0
......
......@@ -58,6 +58,9 @@ enum adc_configuration_100m14b4cha {
in multi-shot mode (in samples) */
ADC_CONF_100M14B4CHA_BUF_SIZE_KB, /**< it manually sets the buffer size but
only for VMALLOC buffers */
ADC_CONF_100M14B4CHA_BUF_SIZE_LEN, /**< it manually sets the buffer
length, but only for KMALLOC
buffers */
__ADC_CONF_100M14B4CHA_LAST_INDEX, /**< It represents the the last index
of this enum. It can be useful for
some sort of automation */
......
......@@ -213,6 +213,7 @@ enum adc_configuration_board {
ADC_CONF_BRD_N_TRG_EXT, /**< Number of external triggers */
ADC_CONF_BRD_N_TRG_THR, /**< Number of threshold triggers */
ADC_CONF_BRD_N_TRG_TIM, /**< Number of timer triggers */
ADC_CONF_BRD_TEMPERATURE, /**< Temperature in milli-Celsius */
/* TODO seconds, ticks and bins are bit -> High - low */
ADC_CONF_UTC_TIMING_BASE_S, /**< Board internal time: seconds */
ADC_CONF_UTC_TIMING_BASE_T, /**< Board internal time: coarse
......
/*
* The ADC library for the specific card
*
......@@ -55,6 +56,7 @@
(1LL << ADC_CONF_BRD_N_TRG_EXT) | \
(1LL << ADC_CONF_BRD_N_TRG_THR) | \
(1LL << ADC_CONF_BRD_N_TRG_TIM) | \
(1LL << ADC_CONF_BRD_TEMPERATURE) | \
(1LL << ADC_CONF_UTC_TIMING_BASE_S) | \
(1LL << ADC_CONF_UTC_TIMING_BASE_T)
#define ADC_100M_4CH_14BIT_CUS_MASK (1ULL << ADC_CONF_100M14B4CHA_BUF_TYPE) | \
......@@ -356,6 +358,15 @@ static int adc_100m14b4cha_config_brd(struct adc_dev *adc,
*value = 1;
return 0;
}
case ADC_CONF_BRD_TEMPERATURE:
if (direction) {
errno = ADC_ENOSET;
return -1;
} else {
return adc_get_param(adc, "temperature",
NULL, (int *)value);
return 0;
}
case ADC_CONF_UTC_TIMING_BASE_S:
if (direction) {
errno = ADC_ENOSET;
......@@ -777,6 +788,9 @@ static int adc_100m14b4cha_config_cus(struct adc_dev *adc,
case ADC_CONF_100M14B4CHA_BUF_SIZE_KB:
return adc_param[direction](adc, "cset0/chani/buffer/max-buffer-kb",
NULL, (int *)value);
case ADC_CONF_100M14B4CHA_BUF_SIZE_LEN:
return adc_param[direction](adc, "cset0/chani/buffer/max-buffer-len",
NULL, (int *)value);
default:
errno = ADC_ENOCAP;
return -1;
......
......@@ -45,7 +45,7 @@ class TestAdcAcquisitionPattern(object):
adc_simple.acq_poll(0, timeout)
@pytest.mark.parametrize("pre_samples,post_samples",
[(10**x, 10**y) for x in range(1, 3) for y in range(1, 3)])
[(10**x, 10**y) for x in range(1, 3) for y in range(1, 4)])
@pytest.mark.parametrize("nshots", range(1, 10))
def test_adc_acq_basic(self, adc_simple_pattern,
pre_samples, post_samples, nshots):
......@@ -57,25 +57,26 @@ class TestAdcAcquisitionPattern(object):
adc_simple_pattern.apply_config(conf, 0)
nsamples = pre_samples + post_samples
buf = adc_simple_pattern.request_buffer(nsamples * nshots, None, 0)
buf = adc_simple_pattern.request_buffer(nsamples, None, 0)
adc_simple_pattern.acq_start(PyFmcAdc100m14b4ch.ADC_F_FLUSH,
timeval(0, 0))
for n in range(nshots):
time.sleep(1e-8 * pre_samples)
time.sleep(0.5 + 1e-8 * (pre_samples + post_samples))
adc_simple_pattern.trigger_fire()
adc_simple_pattern.acq_poll(0, timeval(10, 0))
adc_simple_pattern.fill_buffer(buf, 0, timeval(10, 0))
assert buf.contents.nsamples == nsamples
pattern = adc_simple_pattern.pattern_data
for n in range(nshots):
adc_simple_pattern.acq_poll(0, timeval(10, 0))
adc_simple_pattern.fill_buffer(buf, 0, timeval(10, 0))
assert buf.contents.nsamples == nsamples
for chan in range(4):
for s in range(nsamples):
sample = abs(buf.contents.get_sample(chan, s) >> 2)
if pattern >= 0x2000:
# for negative numbers
assert 0x4000 == pattern + sample, buf.contents.data[:nsamples]
assert 0x4000 == pattern + sample, str(buf.contents.data[:nsamples * 4])
else:
assert sample == pattern, buf.contents.data[:nsamples]
assert sample == pattern, str(buf.contents.data[:nsamples * 4])
adc_simple_pattern.release_buffer(buf, None)
......@@ -158,11 +158,11 @@ class TestAdcTriggerThreshold(object):
buf = adc_simple.request_buffer(1024, None, 0)
adc_simple.fill_buffer(buf, 0, timeval(10, 0))
assert buf.contents.nsamples == 3
assert buf.get_sample(channel, 0) == min_value, \
assert buf.contents.get_sample(channel, 0) == min_value, \
buf.contents.data[:3*4]
assert buf.get_sample(channel, 1) == value << 2, \
assert buf.contents.get_sample(channel, 1) == value << 2, \
buf.contents.data[:3*4]
assert buf.get_sample(channel, 2) == value << 2, \
assert buf.contents.get_sample(channel, 2) == value << 2, \
buf.contents.data[:3*4]
adc_simple.release_buffer(buf, None)
......@@ -206,11 +206,11 @@ class TestAdcTriggerThreshold(object):
buf = adc_simple.request_buffer(1024, None, 0)
adc_simple.fill_buffer(buf, 0, timeval(10, 0))
assert buf.contents.nsamples == 3
assert buf.get_sample(channel, 0) == max_value << 2, \
assert buf.contents.get_sample(channel, 0) == max_value, \
buf.contents.data[:3*4]
assert buf.get_sample(channel, 1) == value << 2, \
assert buf.contents.get_sample(channel, 1) == value << 2, \
buf.contents.data[:3*4]
assert buf.get_sample(channel, 2) == value << 2, \
assert buf.contents.get_sample(channel, 2) == value << 2, \
buf.contents.data[:3*4]
adc_simple.release_buffer(buf, None)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment