32 return (in->
data[0] << 8) + in->
data[1];
43 int16_t vert = ((in->
data[2] & 0x7F) << 4) + ((in->
data[3] & 0xF0) >> 4);
44 if (in->
data[2] & 0x80) { vert *= -1; }
53 int16_t north = ((in->
data[3] & 0x07) << 8) + in->
data[4];
54 if (in->
data[3] & 0x08) { north *= -1; }
63 int16_t west = ((in->
data[5] & 0x7F) << 4) + ((in->
data[6] & 0xF0) >> 4);
64 if (in->
data[5] & 0x80) { west *= -1; }
73 return ((in->
data[6] & 0x0F) << 8) + in->
data[7];
88 if (arr == NULL || out == NULL) {
return false; }
90 out->
sysseq = (arr[1] & 0xF000) >> 12;
91 out->
sysword = (arr[1] & 0x0FFF);
110 if (ix < 0 || ix > 3) {
return false; }
112 out->
frequencyBin[ix] = (arr[2 + 4 * ix] & 0x3F00) >> 8;
120 out->
direction[ix] = (arr[2 + 4 * ix] & 0x00FF) * 360.0 / 256.0;
121 out->
spread[ix] = 0.4476 * (((arr[4 + 4 * ix] & 0xFF00) >> 8) + ((arr[2 + 4 * ix] & 0xC000) >> 14) / 4.0);
122 out->
rpsd[ix] = expf(-((
float)(arr[3 + 4 * ix] & 0x00FF) / 200.0));
123 out->
m2[ix] = ((arr[4 + 4 * ix] & 0x00FF) + ((arr[3 + 4 * ix] & 0xC000) >> 14) / 4.0 - 128);
126 out->
n2[ix] = (((arr[5 + 4 * ix] & 0xFF00) >> 8) + ((arr[3 + 4 * ix] & 0x3000) >> 12) / 4.0 - 128);
129 out->
K[ix] = (arr[5 + 4 * ix] & 0x00FF) / 100.0;
142 if (arr == NULL || out == NULL) {
return false; }
144 out->
number = (arr[0] & 0x0007) + 1;
145 out->
GPSfix = (arr[0] & 0x0010);
146 out->
Hrms = (arr[1] & 0x0FFF) / 400.0;
147 out->
fzero = (arr[2] & 0x0FFF) / 400.0;
148 out->
PSD = 5000 * exp(-(arr[3] & 0x0FFF) / 200.0);
149 out->
refTemp = (arr[4] & 0x01FF) / 20.0 - 5;
150 out->
waterTemp = (arr[5] & 0x01FF) / 20.0 - 5;
151 out->
opTime = (arr[6] & 0x0FF0) >> 4;
153 out->
a_z_off = (arr[7] & 0x07FF) / 800.0 * ((arr[7] & 0x0800) ? -1 : 1);
154 out->
a_x_off = (arr[8] & 0x07FF) / 800.0 * ((arr[8] & 0x0800) ? -1 : 1);
155 out->
a_y_off = (arr[9] & 0x07FF) / 800.0 * ((arr[9] & 0x0800) ? -1 : 1);
156 out->
lat = ((arr[10] & 0x0800) ? -1 : 1) * 90.0 * ((arr[11] & 0x0FFF) + ((uint32_t)(arr[10] & 0x07FF) << 12)) /
158 out->
lon = ((arr[12] & 0x0800) ? -1 : 1) * 180.0 * ((arr[13] & 0x0FFF) + ((uint32_t)(arr[12] & 0x07FF) << 12)) /
160 out->
orient = (arr[14] & 0x0FF) * 360.0 / 256.0;
161 out->
incl = (90.0 / 128.0) * ((arr[15] & 0x00FF) - 128 + ((arr[15] & 0x0F00) >> 8) / 16);
int16_t dw_hxv_vertical(const dw_hxv *in)
Extract vertical displacement component from HXV input line.
bool dw_spectral_block(const uint16_t *arr, const int ix, dw_spectrum *out)
Populate a specific component of dw_spectrum from array of cyclic data words.
int16_t dw_hxv_west(const dw_hxv *in)
Extract west displacement component from HXV input line.
bool dw_spectrum_from_array(const uint16_t *arr, dw_spectrum *out)
Populate dw_spectrum from array of cyclic data words.
int16_t dw_hxv_north(const dw_hxv *in)
Extract north displacement component from HXV input line.
uint16_t dw_hxv_parity(const dw_hxv *in)
Extract parity word from HXV input line.
uint16_t dw_hxv_cycdat(const dw_hxv *in)
Extract cyclic data word from HXV input line.
bool dw_system_from_array(const uint16_t *arr, dw_system *out)
Extract system data from array of cyclic data words.
Internal representation of a Datawell HXV message.
uint8_t data[8]
8 bytes of data
Internal representation of HXV spectral messages.
uint8_t frequencyBin[4]
Index for each line of spectral data.
float frequency[4]
Frequency represented by each line.
float m2[4]
M2 Fourier coefficient for each line.
uint16_t sysword
12 bits of system data
float rpsd[4]
Relative power spectral density for each line.
float K[4]
Check factor for each line.
uint8_t sysseq
System data sequence number.
float spread[4]
Wave spread for each line.
float direction[4]
Direction for each line.
float n2[4]
N2 Fourier coefficient for each line.
Internal representation of HXV system messages.
float a_z_off
Vertical accelerometer offset.
int battStatus
Battery status.
float fzero
Zero crossing frequency.
float Hrms
RMS Wave height.
bool GPSfix
Valid GPS fix available.
float waterTemp
Water Temperature.
float orient
Buoy orientation.
float a_x_off
X-axis accelerometer offset.
float refTemp
Reference Temperature.
float PSD
Peak Power Spectral Density.
int number
Sequence number.
float incl
Buoy inclination.
float a_y_off
Y-axis accelerometer offset.
int opTime
Weeks of battery life remaining.