Using Joulescope in other programming languages than Python

Hi all,

I am planning to integrate Joulescope into my hand-made Scope app which I had written for the Mac some years ago. Unfortunately my app is written in C/C++ and it looks like there are no libraries available for language other than Python.

What are my options here? Should I call the Python code from within my app via the ’ The Very High Level Layer’ pf Pythomn or is there any other more native option to use it in C/C++?

Any help would be very much appreciated!

Stefan

1 Like

Hi @sbs and welcome to the forum!

You are right that the Joulescope “driver” pyjoulescope is only available for Python.

I see a few possible approaches to integrate the driver with your C/C++ code, ordered from most recommended to least recommended:

  1. Use pyjoulescope_server, which is still under development. The basics work, but I have not yet implemented streaming sample data since the person who wanted this didn’t initially need streaming sample data. I can certainly add it. Your C/C++ code would communicate with pyjoulescope through a socket.

  2. Call into your oscilloscope C/C++ code from Python. You can either use Cython (recommended) or ctypes. You can see the .pxd, .pyx, and .pxi files in pyjoulescope for some Cython examples.

  3. Call into python from your C/C++ app. See Embedding Python in Another Application. I am not sure how well this will work with all the DLLs needed by Python and the pyjoulescope Cython modules.

  4. Rewrite pyjoulescope in C/C++. I don’t really recommend this, but it’s an option. Be aware that you need to read the device calibration, apply the calibration, and perform raw_processor.

What do you think?

2 Likes

Hi @mliberty
wow, this was extremely fast response. And also very informative!

I totally missed the pyjulescope_server thingie. For me this looks like the perfect solution.
Would it be possible for you to add the streaming data sample? I would integrate it in my app right away because for me this looks like a quite low-hanging thing :smile:

I am not surprised that you didn’t see pyjoulescope_server. It’s so new, I haven’t really mentioned it yet!

I just implemented the streaming data and slightly expanding the documentation in server.py. The client.py file is hopefully a good example for how to use the server. The documentation is still a little lacking, but I am out of time for today. If anything doesn’t make sense, let me know, and I will improve the docs!

1 Like

So I had a look at the server code. It looks quite useful but it turned out that integrating Python into my app would be a lot of work. So I decided to go with your option 4 and already have everything in place except for the ‘workaround’ when the i_range changes. But otherwise it looks good so far.

1 Like

Hi @sbs,

Great to hear you have something working! For (1) the thought is that you would write the client in your own language (C/C++) to communicate with the server in Python that runs as a separate process. However, if you are happy with (4), that works, too.

Is your oscilloscope code open source or available in any form?

Well, the problem was not really using Python to communicate with the server but more the fact that you depend on the server running when you use the app. So ideally one would integrate the Python server code in the app bundle and start it when needed. But this would have been more work than directly talking to the device via USB.

Unfortunately the code is not open source because it is part of an in-house tool for the company I work for and therefore the copyright is theirs. So I cannot publish it in any way.

1 Like