C client for GEX. bare-bones, low level access
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

// Created by MightyPork on 2017/12/15.
#include <stdint.h>
#include <stdbool.h>
#include "gex_client.h"
#ifndef MAX
#define MAX(a, b) ((a)>(b)?(a):(b))
#ifndef MIN
#define MIN(a, b) ((a)<(b)?(a):(b))
struct gex_client {
TinyFrame *tf; //!< TinyFrame instance
const char *acm_device; //!< Comport device name, might be used to reconnect (?)
int acm_fd; //!< Open comport file descriptor
bool connected; //!< Flag that we're currently connected to the comport
bool units_loaded; //!< Units loaded flag for poll
uint32_t ser_timeout; //!< Timeout for read()/write()
// synchronous query "hacks"
bool squery_ok; //!< flag that the query response was received
GexMsg squery_msg; //!< response message, copied here
uint8_t squery_buffer[TF_MAX_PAYLOAD_RX]; //!< buffer for the rx payload to be copied here
GexEventListener fallback_report_handler;
GexUnit *ulu_head; //!< Units look-up linked list
GexUnit system_unit; //!< System unit, used as dummy for raw queries