Port manager: Difference between revisions

From SweepMe! Wiki
Jump to navigation Jump to search
No edit summary
(Formatting)
Line 4: Line 4:
=== Supported port types ===
=== Supported port types ===


[[COM]]: standard PC serial port using RS-232 protocol<br />
* [[COM]]: standard PC serial port using RS-232 protocol
 
* [[GPIB]]: an IEEE-488-Bus, a standard communication
[[GPIB]]: an IEEE-488-Bus, a standard communication <br />
* [[USB]]: plug and play USB test and measurement device as supported by pyvisa
 
* [[VB]]: a National Instrument VirtualBench device
[[USB]]: plug and play USB test and measurement device as supported by pyvisa<br />
 
[[VB]]: a National Instrument VirtualBench device<br />




=== Configuration ===
=== Configuration ===


The following variables have to be set within the __init__ function of a Device Class:
The following variables have to be set within the ''__init__'' function of a Device Class:


In order to get the available ports listed in the GUI of the corresponding [[Measurement Class]], choose desired port types by:
In order to get the available ports listed in the GUI of the corresponding [[Measurement Classes|Measurement Class]], choose desired port types by:
{{syntaxhighlight|lang=python|code=
     self.port_types = ["COM", "GPIB", "USB", "VB"]
     self.port_types = ["COM", "GPIB", "USB", "VB"]
}}


A port object is automatically created by
A port object is automatically created by
{{syntaxhighlight|lang=python|code=
   self.port_manager = True
   self.port_manager = True
 
}}
Further parameters can be changed through
Further parameters can be changed through
  self.port_properties = {"baudrate" : 9600, "EOL": "\n",...}
{{syntaxhighlight|lang=python|code=
self.port_properties = {
    "baudrate" : 9600,  
    "EOL": "\n",
    ...
}
}}


Get a list of all port_properties using
Get a list of all port_properties using
{{syntaxhighlight|lang=python|code=
   print self.port_properties
   print self.port_properties
 
}}


=== Communicating ===
=== Communicating ===


If the port manager is activated, the port is automatically available within all functions of the [[sequencer procedure]] as the variable
If the port manager is activated, the port is automatically available within all functions of the [[sequencer procedure]] as the variable
{{syntaxhighlight|lang=python|code=
   self.port
   self.port
}}


A message can be sent using
A message can be sent using
{{syntaxhighlight|lang=python|code=
   self.port.write("string of the message without end-of-line/terminator character")
   self.port.write("string of the message without end-of-line/terminator character")
}}


The answer of a device is acquired by
The answer of a device is acquired by
{{syntaxhighlight|lang=python|code=
   var = self.port.read()
   var = self.port.read()
}}

Revision as of 23:57, 24 May 2017

Creating and handling port objects for use in a Device Class can be done via the SweepMe! port manager.


Supported port types

  • COM: standard PC serial port using RS-232 protocol
  • GPIB: an IEEE-488-Bus, a standard communication
  • USB: plug and play USB test and measurement device as supported by pyvisa
  • VB: a National Instrument VirtualBench device


Configuration

The following variables have to be set within the __init__ function of a Device Class:

In order to get the available ports listed in the GUI of the corresponding Measurement Class, choose desired port types by:

self.port_types = ["COM", "GPIB", "USB", "VB"]

A port object is automatically created by

self.port_manager = True

Further parameters can be changed through

self.port_properties = {
    "baudrate" : 9600, 
    "EOL": "\n",
    ...
}

Get a list of all port_properties using

print self.port_properties

Communicating

If the port manager is activated, the port is automatically available within all functions of the sequencer procedure as the variable

self.port

A message can be sent using

self.port.write("string of the message without end-of-line/terminator character")

The answer of a device is acquired by

var = self.port.read()