Skip to content

PandABlocks/PandABlocks-server

Repository files navigation

Panda Server

Code CI Docs CI Apache License

The Panda socket server provides a bridge between the register interface to the FPGA firmware controlling the Panda hardware and users and other software. The interface provided by this server is designed to be simple and robust.

The Panda firmware is structured into numerous functional blocks, with each block configured via a number of fields. This structure is directly reflected in the functional interface provided by this server: most commands read or write specific fields.

The socket server publishes two socket end points, one for configuration control the other for streamed data capture. The configuration control socket accepts simple ASCII commands and returns all data in readable ASCII format. The data capture socket supports no commands and simply streams captured data in a lightly structured binary format.

Source code https://github.com/PandABlocks/PandABlocks-server
Documentation https://PandABlocks.github.io/PandABlocks-server
Changelog https://github.com/PandABlocks/PandABlocks-server/blob/master/CHANGELOG.rst

Configuration Interface

Configuration commands are sent as newline (ASCII character 0x0A) terminated strings and all responses are also newline terminated. Three basic forms of command are accepted:

Query commands.
These commands must be terminated by a single ? character. The three possible responses are: an error message, a single value, or a list of values.
Assignment commands.
These commands contain an = character, and are used for assigning values to fields. The two possible responses are an error message or OK.
Table assignment.
Any command containing a < character (not preceded by ? or =) is a table assignment command. The initial command may be followed by any number of lines of text, and must be terminated by an empty line. The two possible responses are an error message or OK.

The four possible responses are:

ERR error-message
An error response is always sent as ERR followed by an error message.
OK
Successful completion of either form of assignment command generates the OK response.
OK =value
Successful completion of a query command returning a single value returns the value preceded by OK =.
Multi-line response
Successful completion of a query command returning multiple values returns each value on a line by itself starting with ! and ends the sequence with a line containing only ..

Example Commands

In the examples below, the command sent is shown preceded by < and the response with >: this is the syntax used by the helper tool simulation/tcp_client.py:

Simple server identification command including version information:

< *IDN?
> OK =PandA SW: 330bd94-dirty FPGA: 0.1.9 d1275f61 00000000

Interrogate list of fields provided by the TTLIN block:

< TTLIN.*?
> !VAL 0 bit_out
> !TERM 1 param enum
> .

Interrogate input termination for TTLIN1:

< TTLIN1.TERM?
> OK =High-Z

Set input termination:

< TTLIN1.TERM=50-Ohm
> OK

Streaming Capture Interface

All bit and position values received and generated by PandA can be captured on an internally generated trigger and streamed to a data capture port. A variety of data capture, processing, and delivery options can be selected.

Building

Before running make first copy the file CONFIG.example to CONFIG and edit according to your needs. If you wish to build the server or the driver then a Zynq cross-compiler will be needed, and if you wish to build the driver then a pre-build kernel will be needed -- for this reference PandABlocks-rootfs and build the kernel target.

The panda-server Makefile supports four main build targets:

driver
This builds the kernel driver required by the target server to communicate with the FPGA hardware. This target can only be built if the cross-compiler is on the path or BINUTILS_DIR has been configured in CONFIG to point to the directory containing the cross-compiler, and if KERNEL_DIR has been set to the location of a cross-build of the kernel previously generated by PandABlocks-rootfs. The built driver is placed in $(BUILD_DIR)/driver/panda.ko.
server
This builds the PandA socket server to run on the target Zynq system. This target can only be built if the cross-compiler is installed as for driver, but there is no dependency on the kernel build. The built server is placed in $(BUILD_DIR)/server/server.
sim_server
This builds the simulation version version of the PandA socket server. To run the server run the script simserver in the root directory.
docs
This builds the documentation and places the results in $(BUILD_DIR)/docs/html.

See https://PandABlocks.github.io/PandABlocks-server for more detailed documentation