MessageFrame

This is a message protocol to communicate with a fictional measurement device.

Structural Overview

Enumerations

Mode

The device supports two measurement modes.
Name Value Description
ModeLow 1 Sets sample rate to 50 Hz
ModeHigh 2 Sets sample rate to 100 Hz

Structures

ClientConnect

Message the client must send to the device to establish a connection.
Size: 1 Byte
Offset Size Name Type
0 Byte 1 Byte version uint8

ClientConnect.version

Client version
Size: 1 Byte

ClientDisconnect

Message the client must send to the device to disconnect.

ClientStart

Starts the measurement process.
Size: 5 Bytes
Offset Size Name Type
0 Byte 4 × 1 Byte channel bool[]
4 Bytes 1 Byte mode Mode

ClientStart.channel

Control array to activate measurement channels
Size: 4 × 1 Byte

ClientStart.mode

Measurement mode
Size: 1 Byte

ClientAbort

Each measurement process must be aborted by the client.
Size: 1 Byte
Offset Size Name Type
0 Byte 1 Byte reason int8

ClientAbort.reason

The reason why the measurement was cancled
Size: 1 Byte

DeviceData

Message which contains acquired measurement data.
Size: *
Offset Size Name Type
0 Byte 1 Byte channel uint8
1 Byte 8 Bytes timestamp uint64
9 Bytes 1 Byte Bitfield0
⬑ 0 Byte 1 Bit overheating bool
⬑ 0 Byte 3 Bits batterie int8
⬑ 0 Byte 4 Bits pendingFrames int8
10 Bytes 4 Bytes sampleCount int32
14 Bytes sampleCount × 4 Bytes samples float[]

DeviceData.channel

Channel the data belongs to (0..3)
Size: 1 Byte

DeviceData.timestamp

Timestamp of data acquisition
Size: 8 Bytes
Byteorder: BigEndian

DeviceData.Bitfield0

Size: 1 Byte

DeviceData.overheating

Flag which indicates if device is overheating
Size: 1 Bit

DeviceData.batterie

Value which indicates battery charge condition
Size: 3 Bits

DeviceData.pendingFrames

Value which indicates how many frames are pending
Size: 4 Bits

DeviceData.sampleCount

Measurement sample count
Size: 4 Bytes
Byteorder: BigEndian

DeviceData.samples

Array of measurement sample points
Size: sampleCount × 4 Bytes
Byteorder: BigEndian

MessageFrame

Frame structure which acts as container for messages. The containing message will be specified by a message id.
Size: *
Offset Size Name Type
0 Byte 1 Byte msgId int8
1 Byte |Type| Bytes msg { ClientConnect,
DeviceData,
ClientStart,
ClientDisconnect,
ClientAbort }

MessageFrame.msgId

Id of the protocol message

Referenced as type id by: MessageFrame.msg
Size: 1 Byte
Instances:
Name Value Type
MSG_CLIENTCONNECT 1 ClientConnect
MSG_CLIENTDISCONNECT 2 ClientDisconnect
MSG_CLIENTSTART 3 ClientStart
MSG_CLIENTABORT 4 ClientAbort
MSG_DEVICEDATA 5 DeviceData

MessageFrame.msg

Dynamic protocol message
Type Id: msgId