Topics

Adding a new samplesource plugin

wd8rde
 

Hi, I am trying to add a new samplesource plugin to the code base, but I am having trouble with the swagger files. The files in sdrangel/swagger/sdrangel/code/qt5/client/ say they were autogenerated by swagger, but I haven't figured out how to add my plugin to get it generated. Can anyone offer some help with this?

Edouard Griffiths
 

Hello,

only very recently I have added files to create a pair of Docker images and a compose file to start a stack to run the code generator. Pls check: https://github.com/f4exb/sdrangel/tree/master/swagger/docker

Brgds,
Edouard.

wd8rde
 

What I am having trouble with is the generation of the .cpp and .h files in swagger/sdrangel/code/qt5/client/

I do not see how to generate the CPP and H files. Where did the files in swagger/sdrangel/code/qt5/client/ come from?

I have attached a diff, please understand this is not complete - I am merely trying to get a boiler-plate to compile, so that I may continue my work. But I am getting the error,

/opt/build/sdrangel/plugins/samplesource/g59input/g59input.cpp:26:10: fatal error: SWGg59InputSettings.h: No such file or directory
 #include "SWGg59InputSettings.h"

Edouard Griffiths
 

Hello,

files are generated by a code generator. This code generator can be buil into a Docker image. To make the generation work the .yaml files must be served by a http server. This server is built into another Docker image. It is a simple node http-server. Of course you need docker and docker-compose installed in your system as a prerequisite.

Once properly installed the first thing is to build the Docker images. All necessary files are in the swagger/docker subfolder of the repository.
  - cd to swagger/docker/server and run build.sh to build the server image
   -cd to swagger/docker/codegen and run build,sh to build the code generator image.

You end up with two images like this:
docker images
REPOSITORY                 TAG                    IMAGE ID            CREATED             SIZE
sdrangel/swagger/codegen   latest                 22abad2112e8        9 days ago          884MB
sdrangel/swagger/server    latest                 ea9780c00118        10 days ago         124MB
 
Now to run the code generator go to swagger/docker/codegen and run run.sh. Since you have SDRangel code in /opt/build/sdrangel this is the default so you don need any parameter. The compose stack will fire up two images like this:
docker ps 
CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS              PORTS                                                                                        NAMES
d3433d1dea4f        sdrangel/swagger/codegen:latest   "/bin/bash"              2 hours ago         Up 2 hours                                                                                                       sdrangel_swgcodegen
8cbcebf228f1        sdrangel/swagger/server:latest    "http-server '-p 808…"   2 hours ago         Up 2 hours          8081/tcp                                                                                     sdrangel_swgserver
 
Now you need to start a shell  in the sdrangel_swgcodegen container this is done with the login.sh script. 

Lastly at the prompt just run generate.sh The generated code used for compilation is expected in /opt/build/sdrangel/swagger/sdrangel/code/qt5/client

To make it work you need to reference the g59input.yaml in DeviceSettings.yaml and DeviceReport.yaml you just have to take an example on what was done for an existing plugin. Else g59input.yaml will be ignored.

Brgds,
Edouard.


  

wd8rde
 

Thank you Edouard, this was exactly what I was looking for. I will work on this and see if I have any more issues. Thanks again !

wd8rde
 

Just a small correction for anyone reading this thread in the future, there is no DeviceReport.yaml that is done in sdrangel/swagger/sdrangel/api/swagger/swagger.yaml .