Hello
I have a pulse oximetry device which communicate via bluetooth
my c++ program can connect it via COM3, and tries to retrieve its data(pulse rate and oxygen sat.)
but the data format of device is confused. here is the remark of data format:
The 9560 includes 6 bytes of header information, a minimum of 14 bytes of spot-check data, and 2 bytes of footer information.
To determine the total length for the expandable Spot-check data, the host must capture the data length from bytes 5 and 6 of the header.
With the minimum data length of 14, the data length defined in bytes 5 and 6 will be
(0x00) (0x0E) (14 bytes decimal).
The Spot-check data consists of time of spot-check, SpO2, Pulse Rate, and status.
Byte# Data Information Format
1 00 NULL start Hex
2 02 STX start of pocket Hex
Header 3 00 Packet type MSB Hex
4 0D Packet type LSB Hex
5 00 *Data Length MSB (variable) Hex
6 0E *Data Length LSB (variable) Hex
7 20 Hundredths place of Year BCD
8 Year of Measurement Year of Measurement BCD
9 Month of Measurement Month of Measurement BCD
10 Day of Measurement Day of Measurement BCD
11 Hour of Measurement Hour of Measurement (00-23) BCD
expandable 12 Minute of Measurement Minute of Measurement (00-59) BCD
Spot-check 13 Second of Measurement Second of Measurement (00-59) BCD
data 14 00 Fraction of second BCD
15 STATUS MSB See STATUS specification below Hex
16 STATUS LSB See STATUS specification below Hex
17 Pulse Rate MSB See HR format below Hex
18 Pulse Rate LSB See HR format below Hex
19 00 to FF Reserved for future use Hex
20 SpO2 See SpO2 format below Hex
footer 21 Checksum LSB LSB of sum Footer of Spot-check Data Hex
22 03 ETX end of transmission Hex
part of my code:
char buf[22];
DWORD read = 0;
if (ReadFile(comport,&buf,22,&read,NULL)){
DWORD i;
for(i=0;i<read;i++){
printf(" %d\n", (unsigned char)buf[i]);
}
printf("\n");
}else {printf("cannot read...");}
I get output like this:
1 128 112 0 241 1 128 112 98 83 1 128 111 147 131 1 128 111 0 240 1 128
Could you please help me how to read and print data in correct format
thanks
i open the port with:
if ((comport = CreateFile("\\\\.\\COM3", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
0,
0)) == INVALID_HANDLE_VALUE)
{
printf("cannot open the port\n");
}