rpc_rfsoc_handler 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rpc_rfsoc_handler-1.1.0/LICENCE.txt +22 -0
- rpc_rfsoc_handler-1.1.0/PKG-INFO +106 -0
- rpc_rfsoc_handler-1.1.0/README.md +93 -0
- rpc_rfsoc_handler-1.1.0/setup.cfg +4 -0
- rpc_rfsoc_handler-1.1.0/setup.py +23 -0
- rpc_rfsoc_handler-1.1.0/src/rpc_rfsoc_handler/__init__.py +3 -0
- rpc_rfsoc_handler-1.1.0/src/rpc_rfsoc_handler/devicecontrol_pb2.py +48 -0
- rpc_rfsoc_handler-1.1.0/src/rpc_rfsoc_handler/devicecontrol_pb2_grpc.py +183 -0
- rpc_rfsoc_handler-1.1.0/src/rpc_rfsoc_handler/interaction_handler.py +72 -0
- rpc_rfsoc_handler-1.1.0/src/rpc_rfsoc_handler.egg-info/PKG-INFO +106 -0
- rpc_rfsoc_handler-1.1.0/src/rpc_rfsoc_handler.egg-info/SOURCES.txt +12 -0
- rpc_rfsoc_handler-1.1.0/src/rpc_rfsoc_handler.egg-info/dependency_links.txt +1 -0
- rpc_rfsoc_handler-1.1.0/src/rpc_rfsoc_handler.egg-info/requires.txt +1 -0
- rpc_rfsoc_handler-1.1.0/src/rpc_rfsoc_handler.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2025
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the “Software”), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: rpc_rfsoc_handler
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: a pip-installable handler
|
|
5
|
+
Home-page:
|
|
6
|
+
Author: Pascal Stoever
|
|
7
|
+
Author-email:
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: example
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENCE.txt
|
|
12
|
+
Requires-Dist: grpcio-tools
|
|
13
|
+
|
|
14
|
+
# RfSoC Interaction Handler
|
|
15
|
+
|
|
16
|
+
Generic interface for interacting with the RfSoC.
|
|
17
|
+
|
|
18
|
+
## API Calls
|
|
19
|
+
|
|
20
|
+
### `InteractionHandler(ip_address)`
|
|
21
|
+
Creates an instance of the handler. Needs the IP address of the RfSoC to connect.
|
|
22
|
+
|
|
23
|
+
**Parameters:**
|
|
24
|
+
- `ip_address` *(str)* — IP address of the RfSoC.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
### `send_message(instruction, par)`
|
|
29
|
+
Sends a command message with the given instruction and parameter.
|
|
30
|
+
|
|
31
|
+
**Parameters:**
|
|
32
|
+
- `instruction` *(str)* — The instruction to be sent.
|
|
33
|
+
- `par` *(int)* — The parameter to send with the instruction.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### `send_start()`
|
|
38
|
+
Starts the streaming engines of the RfSoC.
|
|
39
|
+
Depending on the trigger setting it either:
|
|
40
|
+
- starts sending and generates a trigger, or
|
|
41
|
+
- waits for an incoming trigger.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### `send_stop()`
|
|
46
|
+
Stops the streaming engines and the DACs.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### `send_set_trigger_in()`
|
|
51
|
+
Configures the RfSoC to **receive** a trigger.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### `send_set_trigger_out()`
|
|
56
|
+
Configures the RfSoC to **send out** a trigger.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### `send_data(filepath)`
|
|
61
|
+
Sends a signal file to the board and stores it in the database.
|
|
62
|
+
The filename will be used for saving the file on the RfSoC.
|
|
63
|
+
|
|
64
|
+
**Parameters:**
|
|
65
|
+
- `filepath` *(str)* — Path to the file that should be sent.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
### `select_signal(channel_id, filename)`
|
|
70
|
+
Selects the signal for a given channel from a filename.
|
|
71
|
+
The file must be uploaded to the RfSoC first. Otherwise, this will throw an error.
|
|
72
|
+
|
|
73
|
+
**Parameters:**
|
|
74
|
+
- `channel_id` *(int)* — Channel ID to use (`0–7`).
|
|
75
|
+
- `filename` *(str)* — Name of the signal file to be loaded.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### `list_files()`
|
|
80
|
+
Prints a list with all files that are uploaded. The location on the RfSoC and the
|
|
81
|
+
creation time is given.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### `delete_signal(filename)`
|
|
86
|
+
Deletes the file from the database and from the drive.
|
|
87
|
+
|
|
88
|
+
**Parameters:**
|
|
89
|
+
- `filename` *(str)* — Name of the signal file to be deleted.
|
|
90
|
+
|
|
91
|
+
### `set_freq(frequency)`
|
|
92
|
+
Sets the sampling frequency of the DACs. Due to clock divider issues some frequencies are
|
|
93
|
+
not allowed but currently there is no sanity check (will be added in the future). The
|
|
94
|
+
maximum frequency is 168.75hz (for now).
|
|
95
|
+
|
|
96
|
+
**Parameters:**
|
|
97
|
+
- `frequency` *(int)* — The target frequency in Hz
|
|
98
|
+
|
|
99
|
+
### `set_sending_mode(mode)`
|
|
100
|
+
Sets the sending mode of the RfSoC. Currently it can be toggled between sending a single
|
|
101
|
+
transmission and stream out periodically.
|
|
102
|
+
|
|
103
|
+
**Parameters:**
|
|
104
|
+
- `mode` *(int)* — Allows changing between two modes for now:
|
|
105
|
+
0 -- Stream Mode
|
|
106
|
+
1 -- Single Transmission mode
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# RfSoC Interaction Handler
|
|
2
|
+
|
|
3
|
+
Generic interface for interacting with the RfSoC.
|
|
4
|
+
|
|
5
|
+
## API Calls
|
|
6
|
+
|
|
7
|
+
### `InteractionHandler(ip_address)`
|
|
8
|
+
Creates an instance of the handler. Needs the IP address of the RfSoC to connect.
|
|
9
|
+
|
|
10
|
+
**Parameters:**
|
|
11
|
+
- `ip_address` *(str)* — IP address of the RfSoC.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
### `send_message(instruction, par)`
|
|
16
|
+
Sends a command message with the given instruction and parameter.
|
|
17
|
+
|
|
18
|
+
**Parameters:**
|
|
19
|
+
- `instruction` *(str)* — The instruction to be sent.
|
|
20
|
+
- `par` *(int)* — The parameter to send with the instruction.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
### `send_start()`
|
|
25
|
+
Starts the streaming engines of the RfSoC.
|
|
26
|
+
Depending on the trigger setting it either:
|
|
27
|
+
- starts sending and generates a trigger, or
|
|
28
|
+
- waits for an incoming trigger.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### `send_stop()`
|
|
33
|
+
Stops the streaming engines and the DACs.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### `send_set_trigger_in()`
|
|
38
|
+
Configures the RfSoC to **receive** a trigger.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### `send_set_trigger_out()`
|
|
43
|
+
Configures the RfSoC to **send out** a trigger.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### `send_data(filepath)`
|
|
48
|
+
Sends a signal file to the board and stores it in the database.
|
|
49
|
+
The filename will be used for saving the file on the RfSoC.
|
|
50
|
+
|
|
51
|
+
**Parameters:**
|
|
52
|
+
- `filepath` *(str)* — Path to the file that should be sent.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### `select_signal(channel_id, filename)`
|
|
57
|
+
Selects the signal for a given channel from a filename.
|
|
58
|
+
The file must be uploaded to the RfSoC first. Otherwise, this will throw an error.
|
|
59
|
+
|
|
60
|
+
**Parameters:**
|
|
61
|
+
- `channel_id` *(int)* — Channel ID to use (`0–7`).
|
|
62
|
+
- `filename` *(str)* — Name of the signal file to be loaded.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### `list_files()`
|
|
67
|
+
Prints a list with all files that are uploaded. The location on the RfSoC and the
|
|
68
|
+
creation time is given.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### `delete_signal(filename)`
|
|
73
|
+
Deletes the file from the database and from the drive.
|
|
74
|
+
|
|
75
|
+
**Parameters:**
|
|
76
|
+
- `filename` *(str)* — Name of the signal file to be deleted.
|
|
77
|
+
|
|
78
|
+
### `set_freq(frequency)`
|
|
79
|
+
Sets the sampling frequency of the DACs. Due to clock divider issues some frequencies are
|
|
80
|
+
not allowed but currently there is no sanity check (will be added in the future). The
|
|
81
|
+
maximum frequency is 168.75hz (for now).
|
|
82
|
+
|
|
83
|
+
**Parameters:**
|
|
84
|
+
- `frequency` *(int)* — The target frequency in Hz
|
|
85
|
+
|
|
86
|
+
### `set_sending_mode(mode)`
|
|
87
|
+
Sets the sending mode of the RfSoC. Currently it can be toggled between sending a single
|
|
88
|
+
transmission and stream out periodically.
|
|
89
|
+
|
|
90
|
+
**Parameters:**
|
|
91
|
+
- `mode` *(int)* — Allows changing between two modes for now:
|
|
92
|
+
0 -- Stream Mode
|
|
93
|
+
1 -- Single Transmission mode
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
this_directory = Path(__file__).parent
|
|
5
|
+
long_description = (this_directory / "README.md").read_text()
|
|
6
|
+
|
|
7
|
+
setup(
|
|
8
|
+
name='rpc_rfsoc_handler',
|
|
9
|
+
version='1.1.0',
|
|
10
|
+
description='a pip-installable handler',
|
|
11
|
+
long_description=long_description,
|
|
12
|
+
long_description_content_type='text/markdown',
|
|
13
|
+
license='MIT',
|
|
14
|
+
packages=find_packages(where="src"),
|
|
15
|
+
package_dir={"": "src"},
|
|
16
|
+
author='Pascal Stoever',
|
|
17
|
+
author_email='',
|
|
18
|
+
keywords=['example'],
|
|
19
|
+
url='',
|
|
20
|
+
install_requires=[
|
|
21
|
+
"grpcio-tools",
|
|
22
|
+
],
|
|
23
|
+
)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: devicecontrol.proto
|
|
5
|
+
# Protobuf Python Version: 5.29.0
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
5,
|
|
15
|
+
29,
|
|
16
|
+
0,
|
|
17
|
+
'',
|
|
18
|
+
'devicecontrol.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x13\x64\x65vicecontrol.proto\x12\rdevicecontrol\"8\n\x07\x43ommand\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05\x12\x10\n\x08\x66ilename\x18\x03 \x01(\t\",\n\x08Response\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\x0f\n\x07message\x18\x02 \x01(\t\"9\n\x0b\x44\x61taMessage\x12\n\n\x02id\x18\x01 \x01(\t\x12\x10\n\x08\x66ilename\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"\x12\n\x10ListFilesRequest\"J\n\x08\x46ileInfo\x12\n\n\x02id\x18\x01 \x01(\t\x12\x10\n\x08\x66ilename\x18\x02 \x01(\t\x12\x0c\n\x04size\x18\x03 \x01(\x05\x12\x12\n\ncreated_at\x18\x04 \x01(\t\"2\n\x08\x46ileList\x12&\n\x05\x66iles\x18\x01 \x03(\x0b\x32\x17.devicecontrol.FileInfo2\xd7\x01\n\rDeviceService\x12>\n\x0bSendCommand\x12\x16.devicecontrol.Command\x1a\x17.devicecontrol.Response\x12?\n\x08SendData\x12\x1a.devicecontrol.DataMessage\x1a\x17.devicecontrol.Response\x12\x45\n\tListFiles\x12\x1f.devicecontrol.ListFilesRequest\x1a\x17.devicecontrol.FileListb\x06proto3')
|
|
28
|
+
|
|
29
|
+
_globals = globals()
|
|
30
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'devicecontrol_pb2', _globals)
|
|
32
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
+
DESCRIPTOR._loaded_options = None
|
|
34
|
+
_globals['_COMMAND']._serialized_start=38
|
|
35
|
+
_globals['_COMMAND']._serialized_end=94
|
|
36
|
+
_globals['_RESPONSE']._serialized_start=96
|
|
37
|
+
_globals['_RESPONSE']._serialized_end=140
|
|
38
|
+
_globals['_DATAMESSAGE']._serialized_start=142
|
|
39
|
+
_globals['_DATAMESSAGE']._serialized_end=199
|
|
40
|
+
_globals['_LISTFILESREQUEST']._serialized_start=201
|
|
41
|
+
_globals['_LISTFILESREQUEST']._serialized_end=219
|
|
42
|
+
_globals['_FILEINFO']._serialized_start=221
|
|
43
|
+
_globals['_FILEINFO']._serialized_end=295
|
|
44
|
+
_globals['_FILELIST']._serialized_start=297
|
|
45
|
+
_globals['_FILELIST']._serialized_end=347
|
|
46
|
+
_globals['_DEVICESERVICE']._serialized_start=350
|
|
47
|
+
_globals['_DEVICESERVICE']._serialized_end=565
|
|
48
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
|
|
2
|
+
"""Client and server classes corresponding to protobuf-defined services."""
|
|
3
|
+
import grpc
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
from . import devicecontrol_pb2 as devicecontrol__pb2
|
|
7
|
+
|
|
8
|
+
GRPC_GENERATED_VERSION = '1.70.0'
|
|
9
|
+
GRPC_VERSION = grpc.__version__
|
|
10
|
+
_version_not_supported = False
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from grpc._utilities import first_version_is_lower
|
|
14
|
+
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
|
|
15
|
+
except ImportError:
|
|
16
|
+
_version_not_supported = True
|
|
17
|
+
|
|
18
|
+
if _version_not_supported:
|
|
19
|
+
raise RuntimeError(
|
|
20
|
+
f'The grpc package installed is at version {GRPC_VERSION},'
|
|
21
|
+
+ f' but the generated code in devicecontrol_pb2_grpc.py depends on'
|
|
22
|
+
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
|
|
23
|
+
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
|
|
24
|
+
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class DeviceServiceStub(object):
|
|
29
|
+
"""Missing associated documentation comment in .proto file."""
|
|
30
|
+
|
|
31
|
+
def __init__(self, channel):
|
|
32
|
+
"""Constructor.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
channel: A grpc.Channel.
|
|
36
|
+
"""
|
|
37
|
+
self.SendCommand = channel.unary_unary(
|
|
38
|
+
'/devicecontrol.DeviceService/SendCommand',
|
|
39
|
+
request_serializer=devicecontrol__pb2.Command.SerializeToString,
|
|
40
|
+
response_deserializer=devicecontrol__pb2.Response.FromString,
|
|
41
|
+
_registered_method=True)
|
|
42
|
+
self.SendData = channel.unary_unary(
|
|
43
|
+
'/devicecontrol.DeviceService/SendData',
|
|
44
|
+
request_serializer=devicecontrol__pb2.DataMessage.SerializeToString,
|
|
45
|
+
response_deserializer=devicecontrol__pb2.Response.FromString,
|
|
46
|
+
_registered_method=True)
|
|
47
|
+
self.ListFiles = channel.unary_unary(
|
|
48
|
+
'/devicecontrol.DeviceService/ListFiles',
|
|
49
|
+
request_serializer=devicecontrol__pb2.ListFilesRequest.SerializeToString,
|
|
50
|
+
response_deserializer=devicecontrol__pb2.FileList.FromString,
|
|
51
|
+
_registered_method=True)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class DeviceServiceServicer(object):
|
|
55
|
+
"""Missing associated documentation comment in .proto file."""
|
|
56
|
+
|
|
57
|
+
def SendCommand(self, request, context):
|
|
58
|
+
"""Missing associated documentation comment in .proto file."""
|
|
59
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
60
|
+
context.set_details('Method not implemented!')
|
|
61
|
+
raise NotImplementedError('Method not implemented!')
|
|
62
|
+
|
|
63
|
+
def SendData(self, request, context):
|
|
64
|
+
"""Missing associated documentation comment in .proto file."""
|
|
65
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
66
|
+
context.set_details('Method not implemented!')
|
|
67
|
+
raise NotImplementedError('Method not implemented!')
|
|
68
|
+
|
|
69
|
+
def ListFiles(self, request, context):
|
|
70
|
+
"""Missing associated documentation comment in .proto file."""
|
|
71
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
72
|
+
context.set_details('Method not implemented!')
|
|
73
|
+
raise NotImplementedError('Method not implemented!')
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def add_DeviceServiceServicer_to_server(servicer, server):
|
|
77
|
+
rpc_method_handlers = {
|
|
78
|
+
'SendCommand': grpc.unary_unary_rpc_method_handler(
|
|
79
|
+
servicer.SendCommand,
|
|
80
|
+
request_deserializer=devicecontrol__pb2.Command.FromString,
|
|
81
|
+
response_serializer=devicecontrol__pb2.Response.SerializeToString,
|
|
82
|
+
),
|
|
83
|
+
'SendData': grpc.unary_unary_rpc_method_handler(
|
|
84
|
+
servicer.SendData,
|
|
85
|
+
request_deserializer=devicecontrol__pb2.DataMessage.FromString,
|
|
86
|
+
response_serializer=devicecontrol__pb2.Response.SerializeToString,
|
|
87
|
+
),
|
|
88
|
+
'ListFiles': grpc.unary_unary_rpc_method_handler(
|
|
89
|
+
servicer.ListFiles,
|
|
90
|
+
request_deserializer=devicecontrol__pb2.ListFilesRequest.FromString,
|
|
91
|
+
response_serializer=devicecontrol__pb2.FileList.SerializeToString,
|
|
92
|
+
),
|
|
93
|
+
}
|
|
94
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
95
|
+
'devicecontrol.DeviceService', rpc_method_handlers)
|
|
96
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
97
|
+
server.add_registered_method_handlers('devicecontrol.DeviceService', rpc_method_handlers)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# This class is part of an EXPERIMENTAL API.
|
|
101
|
+
class DeviceService(object):
|
|
102
|
+
"""Missing associated documentation comment in .proto file."""
|
|
103
|
+
|
|
104
|
+
@staticmethod
|
|
105
|
+
def SendCommand(request,
|
|
106
|
+
target,
|
|
107
|
+
options=(),
|
|
108
|
+
channel_credentials=None,
|
|
109
|
+
call_credentials=None,
|
|
110
|
+
insecure=False,
|
|
111
|
+
compression=None,
|
|
112
|
+
wait_for_ready=None,
|
|
113
|
+
timeout=None,
|
|
114
|
+
metadata=None):
|
|
115
|
+
return grpc.experimental.unary_unary(
|
|
116
|
+
request,
|
|
117
|
+
target,
|
|
118
|
+
'/devicecontrol.DeviceService/SendCommand',
|
|
119
|
+
devicecontrol__pb2.Command.SerializeToString,
|
|
120
|
+
devicecontrol__pb2.Response.FromString,
|
|
121
|
+
options,
|
|
122
|
+
channel_credentials,
|
|
123
|
+
insecure,
|
|
124
|
+
call_credentials,
|
|
125
|
+
compression,
|
|
126
|
+
wait_for_ready,
|
|
127
|
+
timeout,
|
|
128
|
+
metadata,
|
|
129
|
+
_registered_method=True)
|
|
130
|
+
|
|
131
|
+
@staticmethod
|
|
132
|
+
def SendData(request,
|
|
133
|
+
target,
|
|
134
|
+
options=(),
|
|
135
|
+
channel_credentials=None,
|
|
136
|
+
call_credentials=None,
|
|
137
|
+
insecure=False,
|
|
138
|
+
compression=None,
|
|
139
|
+
wait_for_ready=None,
|
|
140
|
+
timeout=None,
|
|
141
|
+
metadata=None):
|
|
142
|
+
return grpc.experimental.unary_unary(
|
|
143
|
+
request,
|
|
144
|
+
target,
|
|
145
|
+
'/devicecontrol.DeviceService/SendData',
|
|
146
|
+
devicecontrol__pb2.DataMessage.SerializeToString,
|
|
147
|
+
devicecontrol__pb2.Response.FromString,
|
|
148
|
+
options,
|
|
149
|
+
channel_credentials,
|
|
150
|
+
insecure,
|
|
151
|
+
call_credentials,
|
|
152
|
+
compression,
|
|
153
|
+
wait_for_ready,
|
|
154
|
+
timeout,
|
|
155
|
+
metadata,
|
|
156
|
+
_registered_method=True)
|
|
157
|
+
|
|
158
|
+
@staticmethod
|
|
159
|
+
def ListFiles(request,
|
|
160
|
+
target,
|
|
161
|
+
options=(),
|
|
162
|
+
channel_credentials=None,
|
|
163
|
+
call_credentials=None,
|
|
164
|
+
insecure=False,
|
|
165
|
+
compression=None,
|
|
166
|
+
wait_for_ready=None,
|
|
167
|
+
timeout=None,
|
|
168
|
+
metadata=None):
|
|
169
|
+
return grpc.experimental.unary_unary(
|
|
170
|
+
request,
|
|
171
|
+
target,
|
|
172
|
+
'/devicecontrol.DeviceService/ListFiles',
|
|
173
|
+
devicecontrol__pb2.ListFilesRequest.SerializeToString,
|
|
174
|
+
devicecontrol__pb2.FileList.FromString,
|
|
175
|
+
options,
|
|
176
|
+
channel_credentials,
|
|
177
|
+
insecure,
|
|
178
|
+
call_credentials,
|
|
179
|
+
compression,
|
|
180
|
+
wait_for_ready,
|
|
181
|
+
timeout,
|
|
182
|
+
metadata,
|
|
183
|
+
_registered_method=True)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import grpc
|
|
2
|
+
import os
|
|
3
|
+
from . import devicecontrol_pb2
|
|
4
|
+
from . import devicecontrol_pb2_grpc
|
|
5
|
+
|
|
6
|
+
class InteractionHandler:
|
|
7
|
+
def __init__(self, ip_address, timeout=2.0):
|
|
8
|
+
self.ip_address = ip_address
|
|
9
|
+
self.channel = grpc.insecure_channel(self.ip_address)
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
grpc.channel_ready_future(self.channel).result(timeout=timeout)
|
|
13
|
+
except grpc.FutureTimeoutError:
|
|
14
|
+
raise ConnectionError(
|
|
15
|
+
f"Couldn't connect to {self.ip_address}")
|
|
16
|
+
|
|
17
|
+
self.stub = devicecontrol_pb2_grpc.DeviceServiceStub(self.channel)
|
|
18
|
+
|
|
19
|
+
def send_message(self, instruction, par):
|
|
20
|
+
response = self.stub.SendCommand(devicecontrol_pb2.Command(name=instruction, value=par))
|
|
21
|
+
print("Response:", response.success, response.message)
|
|
22
|
+
|
|
23
|
+
def send_start(self):
|
|
24
|
+
response = self.stub.SendCommand(devicecontrol_pb2.Command(name="start_sending", value=1))
|
|
25
|
+
print("Response:", response.success, response.message)
|
|
26
|
+
|
|
27
|
+
def send_stop(self):
|
|
28
|
+
response = self.stub.SendCommand(devicecontrol_pb2.Command(name="stop_sending", value=1))
|
|
29
|
+
print("Response:", response.success, response.message)
|
|
30
|
+
|
|
31
|
+
def send_set_trigger_in(self):
|
|
32
|
+
response = self.stub.SendCommand(devicecontrol_pb2.Command(name="set_trigger", value=0))
|
|
33
|
+
print("Response:", response.success, response.message)
|
|
34
|
+
|
|
35
|
+
def send_set_trigger_out(self):
|
|
36
|
+
response = self.stub.SendCommand(devicecontrol_pb2.Command(name="set_trigger", value=1))
|
|
37
|
+
print("Response:", response.success, response.message)
|
|
38
|
+
|
|
39
|
+
def send_data(self, filepath):
|
|
40
|
+
filename = os.path.basename(filepath)
|
|
41
|
+
with open(filepath, "rb") as f:
|
|
42
|
+
data = f.read()
|
|
43
|
+
response = self.stub.SendData(
|
|
44
|
+
devicecontrol_pb2.DataMessage(
|
|
45
|
+
id=filename,
|
|
46
|
+
filename=filename,
|
|
47
|
+
data=data
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
print("Response:", response.success, response.message)
|
|
51
|
+
|
|
52
|
+
def list_files(self):
|
|
53
|
+
response = self.stub.ListFiles(devicecontrol_pb2.ListFilesRequest())
|
|
54
|
+
return [f.filename for f in response.files]
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def select_signal(self, channel_id, filename):
|
|
58
|
+
response = self.stub.SendCommand(devicecontrol_pb2.Command(name="load_signal", value=channel_id, filename=filename))
|
|
59
|
+
print("Response:", response.success, response.message)
|
|
60
|
+
|
|
61
|
+
def delete_signal(self, filename):
|
|
62
|
+
response = self.stub.SendCommand(devicecontrol_pb2.Command(name="delete_signal", value=0, filename=filename))
|
|
63
|
+
print("Response:", response.success, response.message)
|
|
64
|
+
|
|
65
|
+
def set_freq(self, frequency):
|
|
66
|
+
freq = int(frequency)
|
|
67
|
+
response = self.stub.SendCommand(devicecontrol_pb2.Command(name="set_sample_freq", value=freq))
|
|
68
|
+
print("Response:", response.success, response.message)
|
|
69
|
+
|
|
70
|
+
def set_sending_mode(self, mode):
|
|
71
|
+
response = self.stub.SendCommand(devicecontrol_pb2.Command(name="set_sending_mode", value=mode))
|
|
72
|
+
print("Response:", response.success, response.message)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: rpc_rfsoc_handler
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: a pip-installable handler
|
|
5
|
+
Home-page:
|
|
6
|
+
Author: Pascal Stoever
|
|
7
|
+
Author-email:
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: example
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENCE.txt
|
|
12
|
+
Requires-Dist: grpcio-tools
|
|
13
|
+
|
|
14
|
+
# RfSoC Interaction Handler
|
|
15
|
+
|
|
16
|
+
Generic interface for interacting with the RfSoC.
|
|
17
|
+
|
|
18
|
+
## API Calls
|
|
19
|
+
|
|
20
|
+
### `InteractionHandler(ip_address)`
|
|
21
|
+
Creates an instance of the handler. Needs the IP address of the RfSoC to connect.
|
|
22
|
+
|
|
23
|
+
**Parameters:**
|
|
24
|
+
- `ip_address` *(str)* — IP address of the RfSoC.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
### `send_message(instruction, par)`
|
|
29
|
+
Sends a command message with the given instruction and parameter.
|
|
30
|
+
|
|
31
|
+
**Parameters:**
|
|
32
|
+
- `instruction` *(str)* — The instruction to be sent.
|
|
33
|
+
- `par` *(int)* — The parameter to send with the instruction.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### `send_start()`
|
|
38
|
+
Starts the streaming engines of the RfSoC.
|
|
39
|
+
Depending on the trigger setting it either:
|
|
40
|
+
- starts sending and generates a trigger, or
|
|
41
|
+
- waits for an incoming trigger.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### `send_stop()`
|
|
46
|
+
Stops the streaming engines and the DACs.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### `send_set_trigger_in()`
|
|
51
|
+
Configures the RfSoC to **receive** a trigger.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### `send_set_trigger_out()`
|
|
56
|
+
Configures the RfSoC to **send out** a trigger.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### `send_data(filepath)`
|
|
61
|
+
Sends a signal file to the board and stores it in the database.
|
|
62
|
+
The filename will be used for saving the file on the RfSoC.
|
|
63
|
+
|
|
64
|
+
**Parameters:**
|
|
65
|
+
- `filepath` *(str)* — Path to the file that should be sent.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
### `select_signal(channel_id, filename)`
|
|
70
|
+
Selects the signal for a given channel from a filename.
|
|
71
|
+
The file must be uploaded to the RfSoC first. Otherwise, this will throw an error.
|
|
72
|
+
|
|
73
|
+
**Parameters:**
|
|
74
|
+
- `channel_id` *(int)* — Channel ID to use (`0–7`).
|
|
75
|
+
- `filename` *(str)* — Name of the signal file to be loaded.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### `list_files()`
|
|
80
|
+
Prints a list with all files that are uploaded. The location on the RfSoC and the
|
|
81
|
+
creation time is given.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### `delete_signal(filename)`
|
|
86
|
+
Deletes the file from the database and from the drive.
|
|
87
|
+
|
|
88
|
+
**Parameters:**
|
|
89
|
+
- `filename` *(str)* — Name of the signal file to be deleted.
|
|
90
|
+
|
|
91
|
+
### `set_freq(frequency)`
|
|
92
|
+
Sets the sampling frequency of the DACs. Due to clock divider issues some frequencies are
|
|
93
|
+
not allowed but currently there is no sanity check (will be added in the future). The
|
|
94
|
+
maximum frequency is 168.75hz (for now).
|
|
95
|
+
|
|
96
|
+
**Parameters:**
|
|
97
|
+
- `frequency` *(int)* — The target frequency in Hz
|
|
98
|
+
|
|
99
|
+
### `set_sending_mode(mode)`
|
|
100
|
+
Sets the sending mode of the RfSoC. Currently it can be toggled between sending a single
|
|
101
|
+
transmission and stream out periodically.
|
|
102
|
+
|
|
103
|
+
**Parameters:**
|
|
104
|
+
- `mode` *(int)* — Allows changing between two modes for now:
|
|
105
|
+
0 -- Stream Mode
|
|
106
|
+
1 -- Single Transmission mode
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENCE.txt
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
src/rpc_rfsoc_handler/__init__.py
|
|
5
|
+
src/rpc_rfsoc_handler/devicecontrol_pb2.py
|
|
6
|
+
src/rpc_rfsoc_handler/devicecontrol_pb2_grpc.py
|
|
7
|
+
src/rpc_rfsoc_handler/interaction_handler.py
|
|
8
|
+
src/rpc_rfsoc_handler.egg-info/PKG-INFO
|
|
9
|
+
src/rpc_rfsoc_handler.egg-info/SOURCES.txt
|
|
10
|
+
src/rpc_rfsoc_handler.egg-info/dependency_links.txt
|
|
11
|
+
src/rpc_rfsoc_handler.egg-info/requires.txt
|
|
12
|
+
src/rpc_rfsoc_handler.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
grpcio-tools
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rpc_rfsoc_handler
|