SELKIELogger  1.0.0
DWTypes.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Swansea University
3  *
4  * This file is part of the SELKIELogger suite of tools.
5  *
6  * SELKIELogger is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation, either version 3 of the License, or (at your option)
9  * any later version.
10  *
11  * SELKIELogger is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this SELKIELogger product.
18  * If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef SELKIELoggerDW_Types
22 #define SELKIELoggerDW_Types
23 
29 #include <stdbool.h>
30 #include <stddef.h>
31 #include <stdint.h>
32 
47 #define DW_CHAN_OK '-'
48 
50 #define DW_CHAN_REPAIRED '='
51 
53 #define DW_CHAN_BAD '!'
54 
56 
58 typedef enum dw_types {
61  DW_TYPE_HXV,
64 
72 typedef struct dw_hva {
73  uint8_t seq;
74  char rtStatus;
75  uint8_t rt[9];
76  char packStatus;
77  uint8_t pack[3];
79 
86 typedef struct dw_bva {
87  uint8_t rt[9];
88  uint8_t pack[3];
90 
99 typedef struct dw_hxv {
100  uint8_t status;
101  uint8_t lines;
102  uint8_t data[8];
104 
111 typedef struct {
112  uint8_t sysseq;
113  uint16_t sysword;
114  uint8_t frequencyBin[4];
115  float frequency[4];
116  float spread[4];
117  float direction[4];
118  float rpsd[4];
119  float m2[4];
120  float n2[4];
121  float K[4];
122 } dw_spectrum;
123 
130 typedef struct {
131  int number;
132  bool GPSfix;
133  float Hrms;
134  float fzero;
135  float PSD;
136  float refTemp;
137  float waterTemp;
138  int opTime;
140  float a_z_off;
141  float a_x_off;
142  float a_y_off;
143  float lat;
144  float lon;
145  float orient;
146  float incl;
147 } dw_system;
148 
150 bool hexpair_to_uint(const char *in, uint8_t *out);
151 
153 bool dw_string_hxv(const char *in, size_t *end, dw_hxv *out);
155 #endif
struct dw_hva dw_hva
Internal representation of a Datawell HVA message.
dw_types
DW Data format types.
Definition: DWTypes.h:58
struct dw_bva dw_bva
Internal representation of a Datawell BVA message.
struct dw_hxv dw_hxv
Internal representation of a Datawell HXV message.
bool hexpair_to_uint(const char *in, uint8_t *out)
Convert a string of hexadecimal characters to corresponding value.
Definition: DWTypes.c:34
bool dw_string_hxv(const char *in, size_t *end, dw_hxv *out)
Read a line of HXV data from string and convert.
Definition: DWTypes.c:92
@ DW_TYPE_BVA
HXV format data.
Definition: DWTypes.h:62
@ DW_TYPE_HVA
HVA format data.
Definition: DWTypes.h:60
@ DW_TYPE_UNKNOWN
Default - type not known.
Definition: DWTypes.h:59
Internal representation of a Datawell BVA message.
Definition: DWTypes.h:86
uint8_t pack[3]
Packet data.
Definition: DWTypes.h:88
uint8_t rt[9]
Real time data.
Definition: DWTypes.h:87
Internal representation of a Datawell HVA message.
Definition: DWTypes.h:72
uint8_t pack[3]
Packet data.
Definition: DWTypes.h:77
uint8_t rt[9]
Real time data.
Definition: DWTypes.h:75
char rtStatus
Real time channel status information.
Definition: DWTypes.h:74
uint8_t seq
Sequence number, transmitted as two hex characters.
Definition: DWTypes.h:73
char packStatus
Packet data status information.
Definition: DWTypes.h:76
Internal representation of a Datawell HXV message.
Definition: DWTypes.h:99
uint8_t data[8]
8 bytes of data
Definition: DWTypes.h:102
uint8_t status
Error count. 0 or 1 OK, 2+ error.
Definition: DWTypes.h:100
uint8_t lines
Transmitted line number.
Definition: DWTypes.h:101
Internal representation of HXV spectral messages.
Definition: DWTypes.h:111
uint16_t sysword
12 bits of system data
Definition: DWTypes.h:113
uint8_t sysseq
System data sequence number.
Definition: DWTypes.h:112
Internal representation of HXV system messages.
Definition: DWTypes.h:130
float a_z_off
Vertical accelerometer offset.
Definition: DWTypes.h:140
int battStatus
Battery status.
Definition: DWTypes.h:139
float fzero
Zero crossing frequency.
Definition: DWTypes.h:134
float Hrms
RMS Wave height.
Definition: DWTypes.h:133
bool GPSfix
Valid GPS fix available.
Definition: DWTypes.h:132
float waterTemp
Water Temperature.
Definition: DWTypes.h:137
float orient
Buoy orientation.
Definition: DWTypes.h:145
float a_x_off
X-axis accelerometer offset.
Definition: DWTypes.h:141
float refTemp
Reference Temperature.
Definition: DWTypes.h:136
float PSD
Peak Power Spectral Density.
Definition: DWTypes.h:135
int number
Sequence number.
Definition: DWTypes.h:131
float lat
GPS Latitude.
Definition: DWTypes.h:143
float incl
Buoy inclination.
Definition: DWTypes.h:146
float lon
GPS Longitude.
Definition: DWTypes.h:144
float a_y_off
Y-axis accelerometer offset.
Definition: DWTypes.h:142
int opTime
Weeks of battery life remaining.
Definition: DWTypes.h:138