-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: new VISA transport layer to talk to almost all lab devices with
different interfaces
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# ------------------------------------------------------------ | ||
# Copyright (c) All rights reserved | ||
# SiLab, Institute of Physics, University of Bonn | ||
# ------------------------------------------------------------ | ||
# | ||
import visa | ||
|
||
from basil.TL.TransferLayer import TransferLayer | ||
|
||
|
||
class SiVisa(TransferLayer): | ||
|
||
'''Transfer layer for a Virtual Instrument Software Architecture (VISA) provided by pyVisa. | ||
Several interfaces are available (GPIB, RS232, USB, Ethernet). To be able to use pyVisa without | ||
the proprietary NI-VISA driver a pyVisa backend pyVisa-py is used. | ||
GPIB under linux is not supported via pyVisa-py right now and linux-gpib does not | ||
compile on modern kernels right now. Thus no GPIB linux support on modern systems. | ||
''' | ||
|
||
def __init__(self, conf): | ||
super(TransferLayer, self).__init__(conf) | ||
self._port = None | ||
|
||
def init(self): | ||
''' | ||
Initialize the device. | ||
Parameters of visa.ResourceManager('@py').open_resource() | ||
''' | ||
rm = visa.ResourceManager('@py') | ||
self._resource = rm.open_resource(**self._init) | ||
|
||
def write(self, data): | ||
self._resource.write(data) | ||
|
||
def read(self): | ||
self._resource.read() | ||
|
||
def ask(self, data): | ||
return self._resource.query(data) |
9245d18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It somehow breaks the API: http://basil.readthedocs.org/en/latest/software.html#transfer-layer-tl
But maybe this is ok in this case?
Have to think about this. Use case?