tdc: add more support for the python test program.

Fix issues to execute the code. Fix minor issues too.
Signed-off-by: Samuel Iglesias Gonsálvez's avatarSamuel Iglesias Gonsalvez <siglesias@igalia.com>
parent afa7f627
......@@ -266,7 +266,7 @@ int tdc_fmc_probe(struct fmc_device *dev)
/* Initialize DAC */
tdc_set_dac_word(tdc, 0xA8F5);
/* Initialize timestamp threshold */
tdc_set_irq_tstamp_thresh(tdc, 0x100);
tdc_set_irq_tstamp_thresh(tdc, 0x10);
/* Initialize time threshold */
tdc_set_irq_time_thresh(tdc, 0x10);
/* Prepare the irq work */
......
......@@ -53,7 +53,7 @@ extern int tdc_get_active_channels(struct tdc_board *b, uint32_t *config);
extern int tdc_activate_all_channels(struct tdc_board *b);
extern int tdc_deactivate_all_channels(struct tdc_board *b);
extern int tdc_get_circular_buffer_ptr(struct tdc_board *b, uint32_t *ptr);
extern int tdc_get_circular_buffer_pointer(struct tdc_board *b, uint32_t *ptr);
extern int tdc_clear_dacapo_flag(struct tdc_board *b);
......
......@@ -4,7 +4,7 @@
# Copyright CERN, 2012
# Author: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
# Website: http://www.ohwr.org/projects/fmc-tdc-sw
import sys
import cmd
......@@ -33,7 +33,7 @@ def print_header():
print ('Author: Samuel Iglesias Gonsalvez - Igalia S.L. ')
print ('Version: 1.0')
print ('License: GPLv2 or later')
print ('Website: http://www.ohwr.org')
print ('Website: http://www.ohwr.org/projects/fmc-tdc-sw')
print ('')
class Cli(cmd.Cmd):
......@@ -42,6 +42,7 @@ class Cli(cmd.Cmd):
self.ruler = ''
self.libtdc = arg
self.tdc_open = 0;
self.tdc = POINTER(tdc_dev)
def do_version(self, arg):
"print version, license and author of the test program"
......@@ -51,10 +52,15 @@ class Cli(cmd.Cmd):
def do_open(self, arg):
"open a TDC device: open <lun>"
self.lun = arg;
self.lun = int(arg);
if (self.lun < 0) or (self.lun > 15):
print "Bad lun number"
return
ptr = POINTER(tdc_dev);
# self.libtdc.tdc_open.restype = ptr;
self.tdc = self.libtdc.tdc_open(arg);
self.libtdc.tdc_open.restype = ptr;
self.tdc = self.libtdc.tdc_open(self.lun);
self.tdc_open = 1;
def do_close(self, arg):
......@@ -67,18 +73,129 @@ class Cli(cmd.Cmd):
self.libtdc.tdc_close(self.tdc);
self.tdc_open = 0;
def do_current_utc(self, arg):
"show current UTC time of the board in seconds"
def do_start_acq (self, arg):
"start acquisition"
if (self.tdc_open):
self.libtdc.tdc_start_acquisition(self.tdc)
else:
print "No device open"
def do_stop_acq (self, arg):
"stop acquisition"
if (self.tdc_open):
self.libtdc.tdc_stop_acquisition(self.tdc)
else:
print "No device open"
def do_set_host_utc_time (self, arg):
"set board's UTC time with localhost reference"
if (self.tdc_open):
self.libtdc.tdc_set_host_utc_time(self.tdc)
else:
print "No device open"
def do_get_circular_buffer_ptr (self, arg):
"get circular buffer pointer"
if (self.tdc_open):
val = c_uint32(0)
self.libtdc.tdc_get_circular_buffer_pointer(self.tdc, byref(val))
print val
else:
print "No device open"
def do_clear_dacapo_flag (self, arg):
"get clear dacapo flag"
if (self.tdc_open):
self.libtdc.tdc_clear_dacapo_flag(self.tdc)
else:
print "No device open"
def do_activate_all_channels (self, arg):
"Activate all channels"
if (self.tdc_open):
self.libtdc.tdc_activate_all_channels(self.tdc)
else:
print "No device open"
def do_deactivate_all_channels (self, arg):
"Deactivate all channels"
if (self.tdc_open):
val = c_uint(0)
print "Current utc time: ",
print val
self.libtdc.tdc_deactivate_all_channels(self.tdc)
else:
print "No device open"
def do_utc_time (self, arg):
"get/set UTC time in seconds from EPOC: utc_time [value]"
if (self.tdc_open == 0):
print "No device open"
return
if arg == "":
val = c_uint32(0)
self.libtdc.tdc_get_utc_time(self.tdc, byref(val))
print "Current utc time: ",
print val
else:
print val
else:
val = c_uint32(int(arg))
self.libtdc.tdc_set_utc_time(self.tdc, val)
def do_timestamp_threshold (self, arg):
"get/set timestamp threshold: timestamp_threshold [value]"
if (self.tdc_open == 0):
print "No device open"
return
if arg == "":
val = c_uint32(0)
self.libtdc.tdc_get_timestamp_threshold(self.tdc, byref(val))
print val
else:
val = c_uint32(int(arg))
if (val < 0) or (val > 127):
print "wrong timestamp value. Valid values [0-127]"
return
self.libtdc.tdc_set_timestamp_threshold(self.tdc, val)
def do_time_threshold (self, arg):
"get/set time threshold (in seconds): timestamp_threshold [value]"
if (self.tdc_open == 0):
print "No device open"
return
if arg == "":
val = c_uint32(0)
self.libtdc.tdc_get_time_threshold(self.tdc, byref(val))
print val
else:
val = c_uint32(int(arg))
self.libtdc.tdc_set_time_threshold(self.tdc, val)
def do_active_channels (self, arg):
"get/set active channels: active_channels [value]"
if (self.tdc_open == 0):
print "No device open"
return
if arg == "":
val = c_uint32(0)
self.libtdc.tdc_get_active_channels(self.tdc, byref(val))
print val
else:
val = c_uint32(int(arg))
self.libtdc.tdc_set_active_channels(self.tdc, val)
# -------------------------------------------
......@@ -123,7 +240,6 @@ def main():
s = options.lib + '/libtdc.so'
libtdc = cdll.LoadLibrary(s);
# Start the command line interface
s = Cli(libtdc)
s.__dict__.update(options.__dict__)
......
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