CMS50x Serial Programming Information

General Discussion on any topic relating to CPAP and/or Sleep Apnea.
User avatar
jedimark
Posts: 1300
Joined: Fri Feb 18, 2011 12:45 am
Location: Bundaberg, Australia
Contact:

CMS50x Serial Programming Information

Post by jedimark » Wed Jul 13, 2011 6:40 am

*** Warning - Nerdy Technical Stuff ***

I thought I'd document the CMS50 stuff here for anyone interested.. not finished yet, but I'll edit this post as I fully figure it out..

Serial Port Settings
19200 baud, 8 data bits, 1 stop bit, odd parity.

Live Mode
In default "live" mode it spews a stream of data out, in a repeating 5 byte pattern (split into 2 packets.)
Use an event driven handler to process this properly.. Polling code is possible but is a PITA (my original python one was used polling and sucked and had to resync all the time, but I didn't know about odd parity at the time..)

Code: Select all

[xx xx xx] [xx xx]
 00 01 02   03 04
00 contains "flow control" and error information bitfield (bit 8 is always set, can be used to sync if using polling mode)
01 simple heartbeat plethysomogram
02 even simpler pulse beat "thingy"
03 Pulse
04 SpO2

Pay attention to the sequence as sometimes it can group packets together. (eg 5 byte packets, in either order, occasionally larger packet groups, but always in correct sequence)

To get at the stored recordings:
write a 2 byte sequence containing the codes "0xf5, 0xf5"
read in 0x20 byte chunks until no more data, putting it all aside for later.
write a 3 byte sequence containing "0xf6, 0xf6, 0xf6" to switch back to live mode.

Processing the recording data
data begins with the remainder of any live data packet, followed by sequence "0xf2 0x80 0x00" three times, followed by 3 or 4 bytes, followed by "0xf0 80 00" 5 or so times, followed by the actual data in 3 byte triplets

Example:
>F5 F5
[cruft] [recording data selected] [can be short] [can be short this may just be normal empty data]
<[90 28 35 00] [F2 80 00 F2 80 00 F2 80 00] [80 81 72 00] [F0 80 00 F0 80 00 F0 80 00 F0 80 00 F0 80 00 F0 80 00]
< F0 C4 5F F0 C3 5F F0 C8 5F F0 D4 5F... All data Triplets start with 0xf0, second byte's high bit is set.
< lots more of the actual data... till it runs out.
>F6 F6 F6

EDIT: the 3 or 4 byte sequence after the "recording data selected" sequence is the length in bytes.. 7 bit values following the first 0x80.. flip the second bytes msb. high byte first.
I'm still not sure why there sometimes is 4 bytes.. it could simply be more bits of the length (the last 7bit byte would be the high byte, as the data sequence begins with F0 anyway.)

Recorded Data is stored 1 pulse+spo2 pair per second. ie 1Hz.

That's all I got for now..

_________________
Machine: ResMed AirSense™ 10 AutoSet™ CPAP Machine with HumidAir™ Heated Humidifier
Mask: Swift™ FX Nasal Pillow CPAP Mask with Headgear
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control
Additional Comments: CMS50D+/F Oximeter, S9 VPAP Auto/Adapt, PRS1 Auto, Intellipap Auto, SleepyHead :)
Author of the free, cross platform, open-source sleep tracking software SleepyHead.
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code

yrnkrn
Posts: 172
Joined: Sat Feb 12, 2011 1:07 pm

Re: CMS50x Serial Programming Information

Post by yrnkrn » Wed Jul 13, 2011 10:13 am

Thanks for your fine work!

_________________
Machine: AirCurve™ 10 VAuto BiLevel Machine with HumidAir™ Heated Humidifier
Mask: DreamWear Gel Nasal Pillow CPAP Mask with Headgear - Fit Pack (All Nasal Pillows with Medium Frame)
Additional Comments: OSCAR, CPAP=6, https://sites.google.com/view/palatal-prolapse/

User avatar
jedimark
Posts: 1300
Joined: Fri Feb 18, 2011 12:45 am
Location: Bundaberg, Australia
Contact:

Re: CMS50x Serial Programming Information

Post by jedimark » Wed Jul 13, 2011 12:12 pm

I just put this into practice, and added a CMS50 serial importer to SleepyHead GIT source.. Which means no more Windows only SPO2 Review, and no more hunting down it's data folder..

You can now just plug in the device and click the import button under the new oximetry tab.

_________________
Machine: ResMed AirSense™ 10 AutoSet™ CPAP Machine with HumidAir™ Heated Humidifier
Mask: Swift™ FX Nasal Pillow CPAP Mask with Headgear
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control
Additional Comments: CMS50D+/F Oximeter, S9 VPAP Auto/Adapt, PRS1 Auto, Intellipap Auto, SleepyHead :)
Author of the free, cross platform, open-source sleep tracking software SleepyHead.
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code

Gasping
Posts: 4
Joined: Sun Jul 21, 2013 5:48 pm
Location: Boulder, Colorado

Re: CMS50x Serial Programming Information

Post by Gasping » Fri Aug 02, 2013 7:51 am

[quote="jedimark"]I just put this into practice, and added a CMS50 [b]serial importer[/b] to SleepyHead GIT source.. Which means no more Windows only SPO2 Review, and no more hunting down it's data folder..

You can now just plug in the device and click the import button under the new oximetry tab. [/quote]

Mark,

I'm not able to get communication from my CMS to the computer via the Review software. I suspect it's a com port setting issue. I see you state
19200 bps
8 data bits
odd parity (rarely see that anymore!)
1 stop bit

But what about flow control? You make mention of it, but not what's required (or maybe doesn't matter?)
Also, should we use FIFO settings?

_________________
Mask: Quattro™ FX Full Face CPAP Mask with Headgear
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control
Additional Comments: CMS50FW wrist oximeter (not completely working yet)

User avatar
STL Mark
Posts: 950
Joined: Thu May 06, 2010 1:37 pm
Location: St. Louis, MO - USA

Re: CMS50x Serial Programming Information

Post by STL Mark » Fri Aug 02, 2013 9:14 am

jedimark wrote:I just put this into practice, and added a CMS50 serial importer to SleepyHead GIT source.. Which means no more Windows only SPO2 Review, and no more hunting down it's data folder..

You can now just plug in the device and click the import button under the new oximetry tab.
Thank you for all that you do! (From one of those odd OSx people)

_________________
Mask: AirFit™ F10 Full Face Mask with Headgear
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control
Additional Comments: Machine: S9 VPAP Adapt (eASV) 36037

Mode: ASVAuto, Min EPAP: 4, Max EPAP: 15, Min PS: 3, Max PS: 15, Ramp: Off - Original Titration: 18

Gasping
Posts: 4
Joined: Sun Jul 21, 2013 5:48 pm
Location: Boulder, Colorado

Re: CMS50x Serial Programming Information

Post by Gasping » Fri Aug 02, 2013 11:34 am

STL Mark wrote:
jedimark wrote:I just put this into practice, and added a CMS50 serial importer to SleepyHead GIT source.. Which means no more Windows only SPO2 Review, and no more hunting down it's data folder..

You can now just plug in the device and click the import button under the new oximetry tab.
Thank you for all that you do! (From one of those odd OSx people)

I apologize, I blurted out this question without giving you the props you deserve for undertaking this kind of investigation.
So many people benefit from this information generally without giving it a second thought, and it's not going to come from any other place. Yes, THANK YOU so much for your contribution! (and I love to learn more about what's going on "in there"!)

-D

_________________
Mask: Quattro™ FX Full Face CPAP Mask with Headgear
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control
Additional Comments: CMS50FW wrist oximeter (not completely working yet)