Back Midas Rome Roody Rootana
  Midas DAQ System, Page 135 of 142  Not logged in ELOG logo
ID Date Authordown Topic Subject
  1018   06 Aug 2014 Clemens SauerzopfForumAdding Interrupt handling to SIS3100 driver
Hello Pierre-Andre,

thank you for your help with the interrupt handling. To close this case I'll
attach my interrupt
handling code for the SIS 3100 to this post as a reference. Maybe someone wants
to do something
similar in the future. 

I've decide to go for a C++ frontend therefore it is a class that handles
everything. The user only
has to provide a function pointer to the constructor that handles the interrupt
bitmask. The
interrupt handling is done with a timedwait within a separate thread. 

Cheers,
Clemens

> Hello Clemens,
> 
> The hardware readout is triggered by the interrupt within this thread. The
main thread poll on  
> the data availability (from the rb) to filter/compose the frontend event.
> In a similar multi-threaded implementation presently used in a dark matter
experiment we start 
> as many thread as necessary to constantly poll on the hardware for "data
fragment" collection.
> The event composition is done in the main thread through polling on the RBs.
> 
> Depending on the trigger rate and readout time, we can afford to analyze the
data fragment at 
> the thread level and add computed/summary information to the ring buffer on a
event-by-event 
> basis. This facilitate the overall event filtering happening later on in our
event builder. 
> 
> "polling the trigger signal?", I don't understand. You can poll on the trigger
condition but 
> then you don't need interrupt.
> 
> The original Midas interrupt implementation was to let the interrupt function
set a acknowledge 
> flag which is picked up by the standard midas polling function (user code) for
triggering the 
> readout. This method ensure a minimal time spent in the IRQ and works fine for
a single thread.
> 
> In regards of the CAEN V1742, we do have a VME driver for it, but it hasn't
been added to the 
> Midas yet (quite recent), but please don't hesitate to send us a copy.
> 
> Cheers, PAA
> 
Attachment 1: sis3100.hh
/*! 
  \file sis3100.hh
  \brief provides an interface for interrupt handling with the Struck SIS3100 VME interface
  \author Clemens Sauerzopf <clemens.sauerzopf@oeaw.ac.at>  
  \date 06.08.2014
  \version 1.0
*/ 


#ifndef __SIS3100_HH__
#define __SIS3100_HH__

#include<stdint.h>
#include<sys/types.h>

 #if HAVE_MIDAS__
 extern "C" {
 #include "midas.h"
 #include "sis3100/linux/sis3100_vme_calls.h"
 #include "sis3100/linux/sis1100_var.h"
 }
 #else
 #include <pthread.h>
 #include "sis3100/linux/sis3100_vme_calls.h"
 #include "sis3100/linux/sis1100_var.h"
 #endif

//! interrupt frontend handling class for SIS 3100 VME interface with veto gate and trigger generation
/*!
  This class provides an easy to use interface for handling interrupts with the Stuck SIS3100 VME 
  interface. When using this class create an instance and pass an unused device number to the 
  constructor and a function pointer to handle the interrupt. 

  The interrupt handling is done in a separate thread that waits with a timeout of 500 ms for a 
  SIGUSR1 signal from the SIS kernel driver. In case of a timeout the loop checks if a thread stop 
  signal from midas is present and then waits again for an interrupt. If an interrupt occurs the
  interrupt vector is loaded and a veto gate is produced by the @ref startVeto function on the 
  NIM port 1. Afterwards a user supplied function that takes the interrupt bitask, the highest 
  interrupt level and its vector as arguments is executed. After that the interrupts get acknowledged
  and the veto gate is closed.

  This class uses a separate device to avoid race conditions and for the low level interface to the
  irq setup.
 */
class sis3100 {
public:
  sis3100(int sisDeviceNum,  bool (*eventFunction)(int,int,int));
  bool enableFrontInterrupts();
  bool disbaleFrontInterrupts();
  bool enableVMEInterrupts();
  bool disbaleVMEInterrupts();

  bool enableOutputs();
  bool disableOutputs();

  static inline void startVeto(int p)       {s3100_control_write(p, 0x80, 0x00000001);}
  static inline void stopVeto(int p)        {s3100_control_write(p, 0x80, 0x00010000);}
  static inline void startVeto2(int p)      {s3100_control_write(p, 0x80, 0x00000002);}
  static inline void stopVeto2(int p)       {s3100_control_write(p, 0x80, 0x00020000);}
  static inline void generateTrigger(int p) {s3100_control_write(p, 0x80, 0x02000000);}

  inline bool isOpen() const {return (p==-1 ? false : true);}

  inline void setIsRunning(bool isRun){isRunning = isRun;}
private:
  int p; // SIS3100 device handler

  u_int32_t iobits;
  struct sis1100_irq_ctl irqctl;
  struct sis1100_irq_get irqget;
  struct sis1100_irq_ack irqack; 
  sigset_t mask, old_mask;

  bool isRunning;

  // for testing
#if HAVE_MIDAS__
  midas_thread_t thread;
#else
  pthread_t thread;
#endif

  static 
#if HAVE_MIDAS__
  INT
#else
  void*
#endif
 interruptThread(void *param);

  struct threadInit {
    bool (*eventFunction)(int, int, int);
    bool *isRunning;
    int p; // SIS3100 device handler
    u_int32_t *iobits;
    struct sis1100_irq_ctl *irqctl;
    struct sis1100_irq_get *irqget;
    struct sis1100_irq_ack *irqack; 
    sigset_t mask;
    struct timespec waitTime;
  };

  threadInit threadData;
};

#endif // compile guard
Attachment 2: sis3100.hh
/*! 
  \file sis3100.hh
  \brief provides an interface for interrupt handling with the Struck SIS3100 VME interface
  \author Clemens Sauerzopf <clemens.sauerzopf@oeaw.ac.at>  
  \date 06.08.2014
  \version 1.0
*/ 


#ifndef __SIS3100_HH__
#define __SIS3100_HH__

#include<stdint.h>
#include<sys/types.h>

 #if HAVE_MIDAS__
 extern "C" {
 #include "midas.h"
 #include "sis3100/linux/sis3100_vme_calls.h"
 #include "sis3100/linux/sis1100_var.h"
 }
 #else
 #include <pthread.h>
 #include "sis3100/linux/sis3100_vme_calls.h"
 #include "sis3100/linux/sis1100_var.h"
 #endif

//! interrupt frontend handling class for SIS 3100 VME interface with veto gate and trigger generation
/*!
  This class provides an easy to use interface for handling interrupts with the Stuck SIS3100 VME 
  interface. When using this class create an instance and pass an unused device number to the 
  constructor and a function pointer to handle the interrupt. 

  The interrupt handling is done in a separate thread that waits with a timeout of 500 ms for a 
  SIGUSR1 signal from the SIS kernel driver. In case of a timeout the loop checks if a thread stop 
  signal from midas is present and then waits again for an interrupt. If an interrupt occurs the
  interrupt vector is loaded and a veto gate is produced by the @ref startVeto function on the 
  NIM port 1. Afterwards a user supplied function that takes the interrupt bitask, the highest 
  interrupt level and its vector as arguments is executed. After that the interrupts get acknowledged
  and the veto gate is closed.

  This class uses a separate device to avoid race conditions and for the low level interface to the
  irq setup.
 */
class sis3100 {
public:
  sis3100(int sisDeviceNum,  bool (*eventFunction)(int,int,int));
  bool enableFrontInterrupts();
  bool disbaleFrontInterrupts();
  bool enableVMEInterrupts();
  bool disbaleVMEInterrupts();

  bool enableOutputs();
  bool disableOutputs();

  static inline void startVeto(int p)       {s3100_control_write(p, 0x80, 0x00000001);}
  static inline void stopVeto(int p)        {s3100_control_write(p, 0x80, 0x00010000);}
  static inline void startVeto2(int p)      {s3100_control_write(p, 0x80, 0x00000002);}
  static inline void stopVeto2(int p)       {s3100_control_write(p, 0x80, 0x00020000);}
  static inline void generateTrigger(int p) {s3100_control_write(p, 0x80, 0x02000000);}

  inline bool isOpen() const {return (p==-1 ? false : true);}

  inline void setIsRunning(bool isRun){isRunning = isRun;}
private:
  int p; // SIS3100 device handler

  u_int32_t iobits;
  struct sis1100_irq_ctl irqctl;
  struct sis1100_irq_get irqget;
  struct sis1100_irq_ack irqack; 
  sigset_t mask, old_mask;

  bool isRunning;

  // for testing
#if HAVE_MIDAS__
  midas_thread_t thread;
#else
  pthread_t thread;
#endif

  static 
#if HAVE_MIDAS__
  INT
#else
  void*
#endif
 interruptThread(void *param);

  struct threadInit {
    bool (*eventFunction)(int, int, int);
    bool *isRunning;
    int p; // SIS3100 device handler
    u_int32_t *iobits;
    struct sis1100_irq_ctl *irqctl;
    struct sis1100_irq_get *irqget;
    struct sis1100_irq_ack *irqack; 
    sigset_t mask;
    struct timespec waitTime;
  };

  threadInit threadData;
};

#endif // compile guard
  1020   08 Sep 2014 Clemens SauerzopfForumCAEN V1742 midas driver
Hello all,

As an addition to the driver functions I uploaded in this thread I would also have a
C++ class that handles everything for the V1742 modules and can be directly used
integrated into a C++ frontend. 

I would like to ask if you have policy for user supplied code like this? It's not a low
level driver but a frontend module that reads and controls the module, creates odb
hotlinks and handles the bank creating and storing of the data.

Best regards,
Clemens

EDIT: the question is, do you like to have  codes like this collected somewhere for
example this forum or would you prefer if I would post a link to some online repository =
  1033   24 Oct 2014 Clemens SauerzopfForumRunning a frontend on Arduino Yun
Hello,

I'm currently trying to create a midas bank for basic temperature reading from the Arduino Yun, but when creating a bank the frontend crashed with a segfault, my
code currently looks like this:

INT read_event(char *pevent, INT off)
{
  WORD *data;
  //printf("before init\n");
  bk_init(pevent);
  //printf("after init\n");
  bk_create(pevent, "TEM0", TID_WORD, data); // <= we are dieing at this line
  //printf("after create\n");

  bk_close(pevent, data);

  return bk_size(pevent);
}

Does anyone have an Idea how to tackle this problem down? running a debugger is a little bit tricky on a this processor..

Thanks!
  822   27 Jul 2012 Cheng-Ju LinInfoMIDAS under Scientific Linux 6
Hi All,

I was wondering if anyone has attempted to install MIDAS under Scientific Linux 6?  I am planning to install 
Scientific Linux on one of the PCs in our lab to run MIDAS. I would like to know if anyone has been 
successful in getting MIDAS to run under SL6.  Thanks.

Cheng-Ju
  827   16 Aug 2012 Cheng-Ju LinBug Reportlaunching roody kills the analyzer
Hi All,

I've installed midas (Rev:5294) on SLC6.3 (64bit), along with recent trunk versions of rootana and roody. 
All the packages compiled OK. The example code in $MIDASSYS/examples/experiment also runs OK 
provided that I don't launch roody. If I try to launch roody, then it immediately crashes the analyzer with 
the following trace:

#6 root_server_thread (arg=ox7f54fc001150) at src/mana.c:5154
#7 0x0000003219a1e13a in TThread::Function(void*) () from /usr/lib64/root/libThread.so.5.28
#8 0x0000003dd1207851 in start_thread () from /lib64/libpthread.so.0
#9 0x0000003dd0ee76dd in clone () from /lib64/libc.so.6

The line src/mana.c:5154 points to the following:

TObject *obj;
            if (strncmp(request + 10, "Any", 3) == 0)
               obj = folder->FindObjectAny(request + 14);
            else
               obj = folder->FindObject(request + 11);    // LINE 5154


Any suggestions on what may be going on here?  Thanks.


Cheng-Ju
  828   16 Aug 2012 Cheng-Ju LinBug Fixlaunching roody kills the analyzer
OK, I've found the solution in the roody forum.  The solution for 64bit machine is to replace
   uint32_t p =0;
   with
   uintptr_t p =0;

in the roody header file roody/include/DataSourceTNetFolder.h

Cheng-Ju



> Hi All,
> 
> I've installed midas (Rev:5294) on SLC6.3 (64bit), along with recent trunk versions of rootana and roody. 
> All the packages compiled OK. The example code in $MIDASSYS/examples/experiment also runs OK 
> provided that I don't launch roody. If I try to launch roody, then it immediately crashes the analyzer with 
> the following trace:
> 
> #6 root_server_thread (arg=ox7f54fc001150) at src/mana.c:5154
> #7 0x0000003219a1e13a in TThread::Function(void*) () from /usr/lib64/root/libThread.so.5.28
> #8 0x0000003dd1207851 in start_thread () from /lib64/libpthread.so.0
> #9 0x0000003dd0ee76dd in clone () from /lib64/libc.so.6
> 
> The line src/mana.c:5154 points to the following:
> 
> TObject *obj;
>             if (strncmp(request + 10, "Any", 3) == 0)
>                obj = folder->FindObjectAny(request + 14);
>             else
>                obj = folder->FindObject(request + 11);    // LINE 5154
> 
> 
> Any suggestions on what may be going on here?  Thanks.
> 
> 
> Cheng-Ju
  830   17 Aug 2012 Cheng-Ju LinBug Reportlaunching roody kills the analyzer
Hi Konstantin,

Many thanks for your feedback.  I was able to keep the analyzer from exiting when launching roody by making some changes in the roody code. 
This at least allows me to keep moving forward. I will look into your suggestion of converting to ROOTANA based analyzer as well.

Regards,

Cheng-Ju


> > I've installed midas (Rev:5294) on SLC6.3 (64bit), along with recent trunk versions of rootana and roody. 
> >
> > #6 root_server_thread (arg=ox7f54fc001150) at src/mana.c:5154
> 
> You are connecting to mana, the old midas analyzer. The code for connecting to it is still present in roody,
> but I cannot support the matching server code in mana.c - it is 2 revolutions behind the current state of
> the ROOT object server (look in ROOTANA - the NetDirectory stuff and the latest is the XmlServer stuff).
> 
> I can offer 2 solutions - switch from mana.c to a ROOTANA based analyzer or graft the XmlServer code
> into your analyzer (it is very simple - you need to create an XmlServer object and tell it which ROOT
> containers you want to make visible to ROODY).
> 
> I guess you can also debug the old midas server code inside mana.c...
> 
> K.O.
  2465   15 Mar 2023 CaseyForumHaving trouble with MIDAS setup
Hi

I'm not sure if this is the right forum for this query (if it is not, I would truly appreciate it if someone could point me at the right forum). I'm having a little bit of trouble with the setup of a Midas system.

Now, this is a system that I inherited after the previous guy who was looking after it went to other employment. There was a point at which it was working. And then there was an unrelated issue in the electrical system which, as a side effect, meant that the building lost power for a time, and the entire system had to be rebooted.

No problem, I thought. I'll just reset and restart all of the software...

...and I can't seem to get it to work. I keep getting the error message "mvme_read_value: Could not perform read!: Bad address". So far as I can tell, this seems to be related to the idea that the base address being used to read from the boards is incorrect. The base addresses are hardcoded in the software (not autogenerated) and, aside from the power going down and up again, the hardware hasn't been touched since the system was working.

I imagine that there is something that needs to be set, twiddled, tweaked, or turned on in the driver. The output of 'lsmod | grep vme' is:

vmedriver             117742  0

so presumably the driver is at least *present*, even if I have no idea how to twiddle anything on it.

Could anyone perhaps suggest a way forward? Is there some way to gather the information that I need, perhaps, or some way to twiddle anything twiddle-able on the driver?

Casey
  324   22 Jan 2007 Carl MetelkoForumMidas on a x86_64
Hi,
   has anyone managed to get midas to work on a x86_64 processor. I followed the
instructions for the 64-bit opteron but i am getting runtime error when trying
the examples.

 When running example/basic/odb_test I getting errors like

[odb.c:6818:db_get_record] struct size mismatch for "/Alarms/Alarms/Demo ODB"
(464 instead of 452)
[odb.c:6818:db_get_record] struct size mismatch for "/Alarms/Alarms/Demo ODB"
(464 instead of 452)
[midas.c:16576:al_check] Cannot get alarm record

Any ideas what is wrong?
  331   26 Jan 2007 Carl MetelkoForumMidas on a x86_64
I upgraded from 1.9.5 to the latest on SVN an it works fine
  332   26 Jan 2007 Carl MetelkoForumFront end electronics broadcast data over ethernet, can midas read this in
Hi,
   the system I'm building will have data read into the frontend nodes
via ethernet (optic). Is this possible?>
  369   09 May 2007 Carl MetelkoForumSplitting data transfer and control onto different networks
Hi,
   I'm setting up a system with two networks with the intension of having
control info (odb, alarm) on the 192.168.0.x
and the frontend readout on 192.168.1.x

Is there any easy way of doing this?
I'm also trying to separate processes onto different machines, is there
any way to not have mserver,mhttpd and (mlogger,mevt) all run on the same
machine?
Thanks,
       Carl Metelko
  375   14 May 2007 Carl MetelkoForumSplitting data transfer and control onto different networks
Hi,
   thanks for the advice. We do have dual core Xeons so we'll try running
most things on the server. Unless it proves to be a problem we'll run all
MIDAS signals on one network and NFS etc on the other.

I do have one more query about running systems like Konstantin.
What we would like to do is have a 'mirror' server serving multiple
online monitoring machines so that the load on the server is constant nomatter
the demands on the mirror.

Is there a way to set this up? Or would it be best to have a remote analyser
making short (1min) root files shared with the online monitoring? 
  408   08 Oct 2007 Carl MetelkoBug ReportError in data format- ending blocks on 32bit boundary x86_64
Hi,
    I found that midas banks can be given an extra 32 bits of zeros when
trying to keep to 32bit boundary on my x86_64. 

This can be fixed by changing (in midas.h)
#define ALIGN8(x)  (((x)+7) & ~7)
to
#define ALIGN8(x)  (((x)+3) & ~3)

Is there any bad consequences doing this?
  824   10 Aug 2012 Carl BlaksleyForumProblem with CAMAC controlled by CES8210 and read out by CAEN V1718 VME controller
Hello all,

I am trying to put together a system to read out several camac adc. The camac is
read by a ces8210 camac to vme controller. The vme is then interfaced to a
computer through a CAEN v1718 usb control module. As anyone gotten the latter to
work?

Previous users seemed to indicate that they had here:

https://ladd00.triumf.ca/elog/Midas/493

but I am having problems to get this example frontend to compile. What is set as
the driver in the makefile for example? If I put v1718 there then I recieve
numerous errors from the CAENVMElib files. 

If someone else has gotten the V1718 running, I would be grateful for their
insight. 

Thanks, 
-Carl
  825   10 Aug 2012 Carl BlaksleyForumsimple example frontend for V1720

Jimmy Ngai wrote:

Jianglai Liu wrote:
Hi,

Who has a good example of a frontend program using CAEN V1718 VME-USB bridge and
V1720 FADC? I am trying to set up the DAQ for such a simple system.

I put together a frontend which talks to the VME. However it gets stuck at
"Calibrating" in initialize_equipment().

I'd appreciate some help!

Thanks,
Jianglai


Hi Jianglai,

I don't have an exmaple of using V1718 with V1720, but I have been using V1718 with V792N for a long time.

You may find in the attachment an example frontend program and my drivers for V1718 and V792N written in MVMESTD format. They have to be linked with the CAENVMELib library and other essential MIDAS stuffs.

Regards,
Jimmy


Jimmy,

How exactly did you link the CAENVMElib with your frontend? That is the part which I can not seem to replicate using your example frontend!

Thanks,
-Carl
  901   13 Sep 2013 Carl BlaksleyForumMIDAS CITATION
Dear MIDAS programmers,

I have been using your software in my lab (APC, Paris)
to run our data acqusition system. It is very robust and flexible.s

I would like to give you the large amount of credit which you are due.
How should I cite both MIDAS and ROODY? I have not been able to find any
information in the usual places.

Cheers, and thanks for the great program!
-Carl
  2566   02 Aug 2023 Caleb MarshallForumIssues with Universe II Driver

Hello,

At our lab we are currently in the process of migrating more of our systems over to Midas. However, all of our working systems are dependent on SBCs with the Tsi-148 chips of which we only have a handful. In order to have some backups and spares for testing, we have been attempting to get Midas working with some borrowed SBCs (Concurrent Technologies VX 40x/04x) with Universe-II chips. The SBC is running CentOS 7. I have tried to follow the instructions posted here. The universe-II kernel module appears to load correctly, dmesg gives:

[   32.384826] VME: Board is system controller
[   32.384875] VME: Driver compiled for SMP system
[   32.384877] VME: Installed VME Universe module version: 3.6.KO6
 

However, running vmescan.exe fails with a segfault. Running with gdb shows:

vmic_mmap: Mapped VME AM 0x0d addr 0x00000000 size 0x00ffffff at address 0x80a01000
mvme_open:
Bus handle              = 0x7
DMA handle              = 0x6045d0
DMA area size           = 1048576 bytes
DMA    physical address = 0x7ffff7eea000
vmic_mmap: Mapped VME AM 0x2d addr 0x00000000 size 0x0000ffff at address 0x86ff0000

Program received signal SIGSEGV, Segmentation fault.
mvme_read_value (mvme=0x604010, vme_addr=<optimized out>)
    at /home/jam/midas/packages/midas/drivers/vme/vmic/vmicvme.c:352
352        dst  = *((WORD *)addr);
 

With the pointer addr originating from a call to vmic_mapcheck within the  mvme_read_value functions in the vmicvme.c file. Help with where to go from here would be appreciated.

-Caleb 

 

  2570   03 Aug 2023 Caleb MarshallForumIssues with Universe II Driver
Here is the output:

vmic_mmap: Mapped VME AM 0x0d addr 0x00000000 size 0x00ffffff at address 0x80a01000
mvme_open:
Bus handle              = 0x3
DMA handle              = 0x158f5d0
DMA area size           = 1048576 bytes
DMA    physical address = 0x7f91db553000
vmic_mmap: Mapped VME AM 0x2d addr 0x00000000 size 0x0000ffff at address 0x86ff0000
vme addr: 00000000 
addr: db543000 
  2572   03 Aug 2023 Caleb MarshallForumIssues with Universe II Driver
I am looking into compiling the 32 bit midas.

In the meantime, here is the kernel info:

3.10.0-1160.11.1.el7.x86_64 

Thank you for the help.
-Caleb
ELOG V3.1.4-2e1708b5