Example of how to write an example custom data transmitter class for pysmurf, and how to use it.
This example's transmitter class defines a CustomTransmitter
device which is added to the pysmurf's SmurfProcessor
device (for more details see here). The CustomTransmitter
device has a variable called Debug
; when set to True
, the custom class will print some word of the header and some data points from the SmurfPacket every time a new packet is received.
To write a custom transmitter, which is described in the pysmurf repository here, you would:
- Write a C++ class which inherits from the pysmurf's BaseTransmitter class. In that class you should override the transmit method to process every new SMuRF packet according to your requirements. You can take a look in this repository to my_transmitter.cpp as an example.
- In your new C++ class you can add new variable and methods (as the
debug
flag, and thesetDebug
andgetDebug
in this example), - In you new C++ class you can expose methods to python if you want to expose then in the pysmurf's pysmurf tree (this example expose the
setDebug
andgetDebug
methods),
- In your new C++ class you can add new variable and methods (as the
- Write a python wrapper for your C++ class (see MyTransmitter.py as an example),
- Configure cmake to find Rogue, smurf and all other needed libraries (see CMakeLists.txt as an example),
- Finally, white a startup script where you call the appropriate pysmurf root device, attaching your new module (see cmb_eth.py and dev_board_eth.py as examples).
This example provides a Dockerfile as well as a script to build a docker image with this code. Once you have built your image, you can start the container, and call one of the server startup scripts. For more information about how to run pysmurf in docker container take a look here.