BMET9922/2922 Computational Analysis for Biomedical Signals Pulse Sensor Message Specification ed0.1 1 Pulse Sensor System Assignment 3 Message Specification Edition 1 1 Purpose When communicating between to different systems, or two components of the one system, the communications protocol must be specified and implemented in both communicating systems. The purpose of this document is to specify the format of the messages which will be sent from the ESP microcontroller to the Host system. 2 Message format The message format is shown in Figure 1. The definition of fields is presented in Table 1. Figure 1 – Pulse Sensor message format Table 1 – Message field definition Item Value Description flags 0xff or 25510 Mark beginning and end of message seq Binary number between 128 and 255 The sequence number is incremented each time a message is transmitted. type “B” for BPM message or “W” for waveform message A single character that specifies the type of message. A BPM message contains one data value. A waveform message contains 50 data values. data Each data value is represented as a sequence of four zero-padded characters. E.g. 10 is represented as “0010”, 1024 as “1024” etc. (note there is no nul (0) termination at the end of the four chars. The data payload containing either one value (4 bytes) or 50 values (200 bytes). chk 8 bit sum of all previous bytes in the message (i.e. flags, seq, type, data) ORed with 128. This last step is required to assure that a message does not contain a ‘n’ character. A checksum to verify the data values and message information have been received correctly. n 10 A newline character to mark the end of the message. BMET9922/2922 Computational Analysis for Biomedical Signals Pulse Sensor Message Specification ed0.1 2 The data values that are communicated in the message are encoded as four-character ASCII sequences. This format was chosen as it allows messages to be printed directly in a (mostly) readable form. The message end character (‘n’) was chosen to simplify some aspects of message reception and processing. Due to the encoding format specified the n character can never occur within a message. It can only occur at the end of a message. Notes: 1. The meaning of the four characters for each value in the data field is not defined beyond each value being exactly 4 characters and leading zero padded. To transmit a BPM value of 120.5, a “scaled integer” approach might be helpful as only 4 characters may be used. In this case the value “1205” could be transmitted. The host would then divide by 10 to get the required value.