ocean.h
Go to the documentation of this file.
00001 #pragma once
00002 
00004 #include <string>
00005 #include <termios.h>
00006 #include <sys/types.h>
00007 #include <sys/stat.h>
00008 #include <time.h>
00009 #include <list>
00010 #include <utility>
00011 #include "pr2_msgs/BatteryServer2.h"
00012 
00013 namespace willowgarage
00014 {
00015   namespace ocean
00016   {
00017     class ocean
00018     {
00019     public:
00020       static const int NMEA_MAX = 120;
00021       static const int MAXTAGLEN = 8;
00022       static const int MAXCHANNELS = 16;
00023 
00024       static const int INPUT_BUF_SIZE = 128;
00025       static const int OUTPUT_BUF_SIZE = 128;
00026       static const unsigned int MAX_PACKET_LENGTH = 120;
00027       static const int BAD_PACKET = -1;
00028       static const int NO_PACKET = 0;
00029       static const int NMEA_PACKET = 1;
00030 
00031       struct regPair {
00032         const std::string name;
00033         const std::string unit;
00034         const unsigned address;
00035       };
00036 
00037 
00038       ocean (int id, int debug = 0);
00039       ~ocean ();
00040 
00041       int run ();
00042       void setDebugLevel (int);
00043       void initialize (const std::string &input_dev);
00044       void read_file (const std::string &input);
00045 
00046     private:
00047       long int convertStringBase16( const char* input );
00048       void flush (void);        //Flushes the serial buffer
00049       int get_speed (void);
00050       void set_speed (int speed);
00051       void report (int errlevel, const char *fmt, ...);
00052       char *gpsd_hexdump (void *binbuf, size_t binbuflen);
00053       void nextstate (unsigned char c);
00054       void packet_accept (int packet_type);
00055       void packet_discard ();
00056       void character_discard ();
00057       ssize_t packet_parse (size_t newdata);
00058       ssize_t packet_get ();
00059       void packet_reset ();
00060       int nmea_send (const char *fmt, ...);
00061       void nmea_add_checksum (char *sentence);
00062       time_t mkgmtime (register struct tm *t);
00063       unsigned int nmea_parse ();
00064       unsigned int processController (int count, char *field[]);
00065       unsigned int processSystem (int count, char *field[]);
00066       unsigned int processBattery (int count, char *field[]);
00067       int commTest();
00068       void resetOcean();
00069       int string_send (const char *fmt, ...);
00070 
00071     private:
00072       int inputDevice;
00073 #if (FILE_LOGGING > 0)
00074       int outputFile;
00075 #endif
00076       struct termios ttyset;
00077       int currentBaudRate;
00078       int currentBaudRateIndex;
00079       int currentPort;          //Port on GPS A=0, B=1, C=2
00080       char *idString;
00081       int debuglevel;
00082       int sentenceCount;
00083       int currentBattery;
00084 
00085       //Parsing stuff
00086       int packetState,          // Current statemachine location
00087         packetType;             // Type of packet just identified
00088       unsigned char inbuffer[INPUT_BUF_SIZE + 1];
00089       unsigned char outbuffer[OUTPUT_BUF_SIZE + 1];
00090       size_t inbuflen, outbuflen;
00091       unsigned char *inbufptr;
00092       unsigned long char_counter;
00093       char tag[MAXTAGLEN];
00094       int sentenceLength;
00095       int cycleComplete;
00096       int acknowledge;          // set this true when we receive a valid acnowledge
00097 
00098     public:                    //Expose this for easy access to results
00099       static const struct regPair regList[];
00100       static const unsigned regListLength;
00101 
00102       pr2_msgs::BatteryServer2 server;
00103     };
00104   }
00105 }


ocean_battery_driver
Author(s): Tully Foote, Curt Meyers
autogenerated on Tue Apr 22 2014 19:35:07