COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
i2c.h
Go to the documentation of this file.
1 /********************************************************************
2 * Copyright (C) 2015 by Interstel Technologies, Inc.
3 * and Hawaii Space Flight Laboratory.
4 *
5 * This file is part of the COSMOS/core that is the central
6 * module for COSMOS. For more information on COSMOS go to
7 * <http://cosmos-project.com>
8 *
9 * The COSMOS/core software is licenced under the
10 * GNU Lesser General Public License (LGPL) version 3 licence.
11 *
12 * You should have received a copy of the
13 * GNU Lesser General Public License
14 * If not, go to <http://www.gnu.org/licenses/>
15 *
16 * COSMOS/core is free software: you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public License
18 * as published by the Free Software Foundation, either version 3 of
19 * the License, or (at your option) any later version.
20 *
21 * COSMOS/core is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * Refer to the "licences" folder for further information on the
27 * condititons and terms to use this software.
28 ********************************************************************/
29 
30 #ifndef COSMOS_DEVICE_I2C_CLASS_H
31 #define COSMOS_DEVICE_I2C_CLASS_H
32 
33 #include "support/configCosmos.h"
34 //#include <linux/i2c-dev.h> /* for I2C_SLAVE */
35 #if !defined(COSMOS_WIN_OS)
37 #endif
38 
39 using std::cout;
40 using std::string;
41 
42 namespace Cosmos {
43  class I2C
44  {
45  public:
46  I2C(string bus, uint8_t address, double delay=2e-4);
47  ~I2C();
48  // int32_t set_params(size_t dbaud, size_t dbits, size_t dparity, size_t dstop);
49 
50  // int32_t put_char(uint8_t c);
51  // int32_t put_string(string data);
52  // int32_t put_data(vector <uint8_t> data);
53  // int32_t get_char();
54  // int32_t get_data(vector <uint8_t> &data, size_t size);
55 
56  // string name;
57 // int32_t connect();
58  int32_t get_funcs();
59  int32_t set_address(uint64_t address);
60  int32_t send(string data);
61  int32_t send(uint8_t *data, size_t len);
62  int32_t send(vector <uint8_t> data);
63  int32_t receive(string &data);
64  int32_t receive(uint8_t *data, size_t len);
65  int32_t receive(vector <uint8_t> &data);
66  int32_t get_error();
67  int32_t get_fh();
68 
69 
70 
71  private:
72  struct
73  {
74  string bus;
75  uint8_t address;
76  int fh = -1;
77  uint64_t funcs;
78  bool connected = false;
79  double delay = 1e-4;
80  } handle;
81 
82  int32_t error;
83 
84  };
85 
86 
87 } // end of namepsace Cosmos
88 #endif // COSMOS_DEVICE_I2C_CLASS_H
Definition: agentclass.cpp:54
Definition: eci2kep_test.cpp:33
Definition: i2c.h:43
I2C(string bus, uint8_t address, double delay=2e-4)
Definition: i2c.cpp:51
uint8_t address
Definition: i2c.h:75
int fh
Definition: i2c.h:76
int32_t send(string data)
Definition: i2c.cpp:123
~I2C()
Definition: i2c.cpp:100
int32_t error
Definition: i2c.h:82
uint64_t funcs
Definition: i2c.h:77
Headers and definitions common to all COSMOS.
string bus
Definition: i2c.h:74
int32_t get_funcs()
struct Cosmos::I2C::@29 handle
int32_t get_fh()
Definition: i2c.cpp:259
bool connected
Definition: i2c.h:78
int32_t get_error()
Definition: i2c.cpp:254
int32_t receive(string &data)
Definition: i2c.cpp:161
double delay
Definition: i2c.h:79
int32_t set_address(uint64_t address)