SELKIELogger  1.0.0
LPMSConnection.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 SELKIELoggerLPMS_Connection
22 #define SELKIELoggerLPMS_Connection
23 
24 #include <stdbool.h>
25 
26 #include "SELKIELoggerBase.h"
27 
28 #include "LPMSTypes.h"
29 
36 #define LPMS_BUFF 1024
37 
39 int lpms_openConnection(const char *device, const int baud);
40 
42 void lpms_closeConnection(int handle);
43 
45 bool lpms_readMessage(int handle, lpms_message *out);
46 
48 bool lpms_readMessage_buf(int handle, lpms_message *out, uint8_t buf[LPMS_BUFF], size_t *index, size_t *hw);
49 
51 bool lpms_find_messages(int handle, size_t numtypes, const uint8_t types[], int timeout, lpms_message *out,
52  uint8_t buf[LPMS_BUFF], size_t *index, size_t *hw);
53 
55 bool lpms_send_command(const int handle, lpms_message *m);
56 
58 bool lpms_send_command_mode(const int handle);
59 
61 bool lpms_send_stream_mode(const int handle);
62 
64 bool lpms_send_get_config(const int handle);
65 #endif
bool lpms_readMessage_buf(int handle, lpms_message *out, uint8_t buf[LPMS_BUFF], size_t *index, size_t *hw)
Read data from handle, and parse message if able.
bool lpms_send_command(const int handle, lpms_message *m)
Write command defined by structure to handle.
bool lpms_find_messages(int handle, size_t numtypes, const uint8_t types[], int timeout, lpms_message *out, uint8_t buf[LPMS_BUFF], size_t *index, size_t *hw)
Read data from handle until first of specified message types is found.
#define LPMS_BUFF
Default serial buffer allocation size.
bool lpms_readMessage(int handle, lpms_message *out)
Static wrapper around lpms_readMessage_buf.
bool lpms_send_get_config(const int handle)
Shortcut: Send LPMS_MSG_GET_OUTPUTS.
void lpms_closeConnection(int handle)
Close LPMS serial connection.
int lpms_openConnection(const char *device, const int baud)
Open connection to an LPMS serial device.
bool lpms_send_stream_mode(const int handle)
Shortcut: Send LPMS_MSG_MODE_STREAM.
bool lpms_send_command_mode(const int handle)
Shortcut: Send LPMS_MSG_MODE_CMD.
Represent LPMS message.
Definition: LPMSTypes.h:48