ocean.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <string>
5 #include <termios.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <time.h>
9 #include <list>
10 #include <utility>
11 #include "pr2_msgs/BatteryServer2.h"
12 
13 namespace willowgarage
14 {
15  namespace ocean
16  {
17  class ocean
18  {
19  public:
20  static const int NMEA_MAX = 120;
21  static const int MAXTAGLEN = 8;
22  static const int MAXCHANNELS = 16;
23 
24  static const int INPUT_BUF_SIZE = 128;
25  static const int OUTPUT_BUF_SIZE = 128;
26  static const unsigned int MAX_PACKET_LENGTH = 120;
27  static const int BAD_PACKET = -1;
28  static const int NO_PACKET = 0;
29  static const int NMEA_PACKET = 1;
30 
31  struct regPair {
32  const std::string name;
33  const std::string unit;
34  const unsigned address;
35  };
36 
37 
38  ocean (int id, int debug = 0);
39  ~ocean ();
40 
41  int run ();
42  void setDebugLevel (int);
43  void initialize (const std::string &input_dev);
44  void read_file (const std::string &input);
45 
46  private:
47  long int convertStringBase16( const char* input );
48  void flush (void); //Flushes the serial buffer
49  int get_speed (void);
50  void set_speed (int speed);
51  void report (int errlevel, const char *fmt, ...);
52  char *gpsd_hexdump (void *binbuf, size_t binbuflen);
53  void nextstate (unsigned char c);
54  void packet_accept (int packet_type);
55  void packet_discard ();
56  void character_discard ();
57  ssize_t packet_parse (size_t newdata);
58  ssize_t packet_get ();
59  void packet_reset ();
60  int nmea_send (const char *fmt, ...);
61  void nmea_add_checksum (char *sentence);
62  time_t mkgmtime (register struct tm *t);
63  unsigned int nmea_parse ();
64  unsigned int processController (int count, char *field[]);
65  unsigned int processSystem (int count, char *field[]);
66  unsigned int processBattery (int count, char *field[]);
67  int commTest();
68  void resetOcean();
69  int string_send (const char *fmt, ...);
70 
71  private:
73 #if (FILE_LOGGING > 0)
74  int outputFile;
75 #endif
76  struct termios ttyset;
79  int currentPort; //Port on GPS A=0, B=1, C=2
80  char *idString;
84 
85  //Parsing stuff
86  int packetState, // Current statemachine location
87  packetType; // Type of packet just identified
88  unsigned char inbuffer[INPUT_BUF_SIZE + 1];
89  unsigned char outbuffer[OUTPUT_BUF_SIZE + 1];
91  unsigned char *inbufptr;
92  unsigned long char_counter;
93  char tag[MAXTAGLEN];
96  int acknowledge; // set this true when we receive a valid acnowledge
97 
98  public: //Expose this for easy access to results
99  static const struct regPair regList[];
100  static const unsigned regListLength;
101 
102  pr2_msgs::BatteryServer2 server;
103  };
104  }
105 }
static const unsigned regListLength
Definition: ocean.h:100
int nmea_send(const char *fmt,...)
Definition: ocean.cpp:979
const std::string name
Definition: ocean.h:32
void set_speed(int speed)
Definition: ocean.cpp:312
char * gpsd_hexdump(void *binbuf, size_t binbuflen)
Definition: ocean.cpp:394
pr2_msgs::BatteryServer2 server
Definition: ocean.h:102
unsigned char outbuffer[OUTPUT_BUF_SIZE+1]
Definition: ocean.h:89
static const int BAD_PACKET
Definition: ocean.h:27
static const unsigned int MAX_PACKET_LENGTH
Definition: ocean.h:26
unsigned int nmea_parse()
Definition: ocean.cpp:869
static const int OUTPUT_BUF_SIZE
Definition: ocean.h:25
unsigned char inbuffer[INPUT_BUF_SIZE+1]
Definition: ocean.h:88
unsigned char * inbufptr
Definition: ocean.h:91
time_t mkgmtime(register struct tm *t)
static const int NMEA_PACKET
Definition: ocean.h:29
static const int NO_PACKET
Definition: ocean.h:28
static const int MAXTAGLEN
Definition: ocean.h:21
int string_send(const char *fmt,...)
Definition: ocean.cpp:1009
unsigned long char_counter
Definition: ocean.h:92
void packet_accept(int packet_type)
Definition: ocean.cpp:481
void initialize(const std::string &input_dev)
Definition: ocean.cpp:98
const std::string unit
Definition: ocean.h:33
unsigned int processSystem(int count, char *field[])
Definition: ocean.cpp:641
ssize_t packet_parse(size_t newdata)
Definition: ocean.cpp:537
char tag[MAXTAGLEN]
Definition: ocean.h:93
void nextstate(unsigned char c)
Definition: ocean.cpp:418
static const int NMEA_MAX
Definition: ocean.h:20
static const int INPUT_BUF_SIZE
Definition: ocean.h:24
unsigned int processBattery(int count, char *field[])
Definition: ocean.cpp:803
struct termios ttyset
Definition: ocean.h:76
ocean(int id, int debug=0)
Definition: ocean.cpp:72
unsigned int processController(int count, char *field[])
Definition: ocean.cpp:688
void report(int errlevel, const char *fmt,...)
Definition: ocean.cpp:357
static const int MAXCHANNELS
Definition: ocean.h:22
void nmea_add_checksum(char *sentence)
Definition: ocean.cpp:955
void read_file(const std::string &input)
Definition: ocean.cpp:179
long int convertStringBase16(const char *input)
Definition: ocean.cpp:148
static const struct regPair regList[]
Definition: ocean.h:99


ocean_battery_driver
Author(s): Tully Foote, Curt Meyers
autogenerated on Wed Jun 5 2019 20:40:35