Page 2 of 2

Re: [Software] CPAP+ Control Panel

Posted: Wed Apr 01, 2020 9:13 pm
by pdu

Is help still needed?

Btw, you can think of adding some checksum bytes at the end of the frame.

Re: [Software] CPAP+ Control Panel

Posted: Thu Apr 02, 2020 6:12 am
by Maciej Zarnowski
eketh wrote:
Wed Apr 01, 2020 1:38 pm

Just letting you know I had a free moment today and I wrote a simple C model of your communication messages and I will be glad to send it to your repository if you think it is useful - I think it is. Not sure in which language you are going to write later (C++ probably?), but it will be easier to adjust this small part later on than to write all this boilerplate from scratch :)
Hi, yes, I'd like to see what it is and than I'll upload it to the repository. Could you please send it to me via email?
pdu wrote:
Wed Apr 01, 2020 9:13 pm

Is help still needed?

Btw, you can think of adding some checksum bytes at the end of the frame.
Checksum will be added at next steps, as we have to develop working-but-not-as-reliable version first to test it with medical team, than, if it works, we'll do it bulletproof.

For we do not need any more help in that topic, I think next steps are coming after weekend!
Thank you all for your support and stay tuned!

Re: [Software] CPAP+ Control Panel

Posted: Thu Apr 02, 2020 8:01 am
by bruno

If you need someone to do the software safety analysis (functional safety, NOT cybersafety) or the FMEA, FTA or any type of the functional safety analysis -> just let me know.
Also, if you need someone to setup the workflow or actually execute the static code analysis of the control software - again - just let me know.

I'm not sure which programming language have you selected for the control software, but - based on professional my experience - I would recommend: C or C++.


Re: [Software] CPAP+ Control Panel

Posted: Tue Apr 07, 2020 5:38 am
by Maciej Zarnowski
Minor update time!
Krzysztof wrote a simple front-panel application for our hardware. You can check out the look on attached pics. We're using it to debug and setup algorythms in our control device. We'll soon need more help in embedded software and hardware development. I'll post details soon.

Main window:
Debug window:

Re: [Software] CPAP+ Control Panel

Posted: Tue Apr 07, 2020 11:46 pm
by bruno

I propose to start with SW Architecture for the control software.
I now that it may be perceived to be an overhead, but I assure that later it is going to pay off.
Have you maybe already started with at least some basic SW arch? I was trying to find anything in git, but with no success.

One more thing - is the device designed to be fault-tolerant / fail-operational or fail-safe. Between those two options there is the giant difference which is impacting practically every aspect of the design.


Re: [Software] CPAP+ Control Panel

Posted: Mon Apr 13, 2020 11:54 pm
by lukaszjok
Hello :)

I have written to you on Facebook Fanpage and somebody replied me that you are interested in my software, so...
I created three applications that provide mock CPAP, control center board and presenting data in real time. I drew (big word xD ) at A4 paper my approach (in attachment below). I believe that my code will explain itself :) ... I really hope. all variables, object, functions, methods, classes and comments were written in english.

1) ARDUINO (my is arduino uno, ATMEGA 328P) - this code is written for mock data in your data frame protocol by UART. There are used 3 serial connection - hardware serial for debug and user-friendly display data frame in terminal; software serial 0 for generate error frames; software serial 1 for generate status data frames. I manually switch wires into my arduino ports for software serial. There is also simple LCD Display handling for display values sends from ANDROID APP. This code is very simple because it is mock and it only helps me in getting data from some hardware device like simulator.

2) PYTHON APP. It can be used on different platform - I tested with success on Lenovo Z-51 with Windows 10 and intel Core i5, Toshiba Satellite C55 with Ubuntu Mate and Raspberry Pi Zero W (!!!). Here I receive data from UART in infinite loop; wait for some data on UART; run webservice via flask framework -> this three main branch in three independent thread. Web service is used to provide two-way communication between Raspberry and ANDROID app. We can call http method for run some part of code into Raspberry.

When raspberry receive some bytes on UART - it parse this data, and retransmit by http into ANDROID app. There ANDROID app receive data and display on chart.

If we want to call some method on Raspberry, we must call HTTP request from some device (here from ANDROID app, but you can call from web browser, curl from terminal - so it can be next feature).

If you or somebody can and are able to code some GUI for python you can us my program as backend - feel free :) I can't :( so it is why I created android app.

3) ANDROID APP - it us as a VIEWER - it is some like user interface. It can not do something itself but can send call request to Raspberry to do something. Here I implemented scanning Serial port - both for linux and windows, setting Serial connection, setting webservice(Raspberry) and webserver(ANDROID), display 4 independent graph in real time at chart, send 5 seting value from ANDROID APP into CPAP device - entered by input text and slider. If you want it is possible to display e.g. some current values in text view indicator - but now I do not know how you handle this.

4) At Raspberry I implemented also possibility to connection with database and store data in tables to have historical data, but I do not know how many information will CPAP generate in what time interval. It is more important because inserting a lot of small rows into table in narrow time range is very time consuming so the appropriateness of this function in correlated with yours requirements and device features.

I do not know that you or somebody will you some of my applications or part of code but perhaps it will help someone to create something better and more efficient.

ALL CODE are for free, NON COMMERCIAL use only, only for win the battle with COVID19, it can not be used even as part of COMMERCIAL CASES!
If you want please ask me here or by mail

ANDROID APK FILE for install application on your smartphone: ... -debug.apk (minimum Android 7.0 (API level 24))

Sorry for my not optimal code but this idea, solution approach, three programs were created less than 10 days after professional working hours in my small rented room by one person:) I used what I know and which was quick to implement.But with unlimited pasta, rice, toilet paper and black coffee :)

Re: [Software] CPAP+ Control Panel

Posted: Wed Apr 15, 2020 5:39 am
by dilip
Great effort!!!

Re: [Software] CPAP+ Control Panel

Posted: Wed Apr 15, 2020 6:15 am
by cheng
Current protocol using 0x0F0 as start mark, 0xAA as end mark.
This means any data contents (byte 2 till byte 19] might be conflict with end mark by same value of 0xAA. Problem will occur when receiving program always assume 0xAA as last byte of data packet.
This can be overcome when the protocol length is always fix to 20bytes, but also come a restriction in future as packet has to be always 20bytes.

One idea would be add a new field to indicate number of bytes in current data packet. This allow for variable data length protocol in future