| | |
- exceptions.Exception
-
- VlabBitfileException
- VlabException
-
- ConnectException
- VlabErrorException
- processor.Twisted
-
- VlabChannel
- VlabClientFactory
- VlabClientSSHConnection
- VlabClientTransport
- VlabClientUserAuth
- VlabUARTProtocol
- VlabAuthorisation
- VlabBitInfo
- VlabUserInfo
- VlabVersion
class VlabChannel(processor.Twisted) |
| |
A Protocol for interacting with virtual lab services.
Instances of this class are created by VlabClientSSHConnection objects. |
| |
Methods defined here:
- __init__(self, register_fn=None, debug=False, fail_fn=None, **args2)
- Create a new VlabChannel with the specified register_fn.
This __init__ method is normally called from the SSHConnection
serviceStarted method.
- awaitEndMessage(self)
- Creates a Deferred that will be called when an "end" message
is received.
"end" messages indicate that a command has been processed by the
server. The "end" messages are: ok, endlist, usinguart, error.
- connect(self, board_name)
- Connect to a board. This is only possible
when you have a connection to a relay shell.
Returns a Deferred. The callback will be called when the
connection is made; its parameter will be True.
- disconnect(self)
- Disconnect from a board or relay server.
This method doesn't return anything.
- getBitInfo(self)
- Request a list of bit file buffers on the board server.
Returns a Deferred. The callback will be called with a list
of VlabBitInfo objects, one for each bit file buffer.
- getBoardUserInfo(self, board_name)
- Request a list of users of the specified board_name.
Returns a Deferred. The callback will be called with a list
of VlabUserInfo objects, one for each instance of board_name.
- jtagDirectCommand(self, jdw_cmd, *params)
- Use the JTAG Direct Write module to execute a JTAG commmand.
Returns a Deferred. The callback will be called with a Boolean
that is True if the command was successful, False otherwise.
- jtagDirectShift(self, readback, last, data, num_bits)
- Shift data using the JTAG Direct Write module.
Returns a Deferred. If readback=True, then the callback
will be called with the received data. If not, then the callback
will be called with True.
- openUART(self, uart_num, protocol)
- Connect the specified Protocol object to UART uart_num.
Returns a Deferred. The callback will be called with parameter
True once the action has completed.
openUART is only possible when the channel is connected to a
board server. It can only be done once. Once it is done,
other commands are no longer possible. This means you will
normally need a control connection (for commands) and a
data connection (for UART data).
- programFPGA(self, fpga_num, bid)
- Schedule programming the specified bit file (bid) onto FPGA fpga_num.
Returns a Deferred. The callback will be called with True
as its parameter on success. The errback is called on failure.
- programFPGAopenUART(self, fpga_num, bid, uart_num, protocol)
- Schedule programming a bit file and open a UART.
This method combines the functionality of programFPGA and
openUART. The UART is opened during FPGA programming, so that
(1) no data is captured from the previous configuration, and
(2) no data is lost due to a gap between configuration completion
and a call to openUART. Like openUART, this method returns
a Deferred that is called with parameter True once the action
is completed. The method can only be called
when the channel is connected to a
board server, and it can only be called once. Once it is called,
other commands are no longer possible. This means you will
normally need a control connection (for commands) and a
data connection (for UART data).
- sendBitfile(self, bits, compress_level=9)
- Send a bit file to the board server.
Returns a Deferred. The callback will be called with the bid
(bit file id), which is an integer. To load the bit file onto an
FPGA, you must call programFPGA with the bid.
- setRelay(self, relay_number, state)
- Set the state of the specified relay.
Returns a Deferred. The callback will be called with the OK
message unless the specified relay does not exist.
- setUART(self, uart_number, baud)
- Set the baud rate for the specified UART.
Returns a Deferred. The callback will be called with the OK
message. The baud rate can be any of the standard RS232 baud rates,
e.g. 9600, 38400, 115200.
Data and other attributes defined here:
- name = 'session'
|
class VlabClientFactory(processor.Twisted) |
| |
Create new virtual lab clients.
The purpose of this class is to connect to a virtual lab
service (a relay shell, to be exact) and then provide access
to the VlabChannel object that has been created during the
connection. The VlabChannel object is used to interact with
the relay shell and board server.
A typical usage of VlabClientFactory is as follows:
>>> factory = VlabClientFactory(VlabAuthorisation())
>>> factory.getChannel().addCallback(GotChannel).addErrback(Fail)
>>> reactor.connectTCP('foobar.cs.york.ac.uk', 22, factory)
In this example, your method GotChannel will be called when the
channel is available. The errback function Fail is called if there
is a connection error.
An alternative usage allows connections via SOCKS.
>>> factory = vlab.VlabClientFactory(auth_data=VlabAuthorisation(),
socks_connect_address='foobar.cs.york.ac.uk',
socks_connect_port=22)
>>> factory.getChannel().addCallback(GotChannel).addErrback(Fail)
>>> reactor.connectTCP('socksserver.example.com', 1080, factory)
In this example, the connection is made via the SOCKS service
at socksserver.example.com. |
| |
Methods defined here:
- __init__(self, auth_data, socks_connect_address=None, socks_connect_port=None, debug=False)
- abort(self)
- Abort all scheduled connection attempts.
- getChannel(self)
- Get the VlabChannel object representing the connection.
Returns a Deferred. The callback will be called with the VlabChannel
object.
|
class VlabUARTProtocol(processor.Twisted) |
| |
A Protocol for communication with a virtual lab UART.
The typical usage for this class is, given a VlabClientFactory vlf:
>>> vl = yield vlf.getChannel()
>>> yield vl.connect("boardname")
>>> uart = VlabUARTProtocol()
>>> yield vl.openUART(0, uart)
The protocol automatically buffers incoming data, so you can
wait for data using:
>>> data = yield vlabuart.read(10)
Outgoing data is not buffered. You can send data using:
>>> vlabuart.write(data)
Any type of Protocol can be connected to a UART using openUART.
You may also be interested in vlab.terminal.DumbTerminal, which
opens an interactive session, and in the vlabif module, which
implements a higher-level communications protocol for debugging. |
| |
Methods defined here:
- __init__(self)
- consume(self)
- Send received data to consumers, if possible.
- dataReceived(self, data)
- This method is called by the transport when data is
received.
- discard(self)
- Discards incoming data buffer contents.
- flush(self)
- Ignored: exists for compatibility.
- makeConnection(self, transport)
- This method is called automatically when a connection
is made.
- read(self, request_nbytes)
- Read a number of bytes from the virtual lab UART.
Returns a Deferred. The callback will be called with a
string containing the specified number of bytes,
once they are received.
- write(self, data)
- Write data to the virtual lab UART.
|
class VlabVersion |
| |
Holds information about the software versions of various parts
of the virtual lab. Available as the "version" field of VlabChannel. |
| |
Methods defined here:
- __init__(self)
- __str__(self)
- lowest(self)
- Returns the lowest software version currently in use
within the virtual lab.
| |