fztatCtrl.h
00001 #ifndef FZTAT_CTRL_H
00002 #define FZTAT_CTRL_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <string>
00011 #include "serialDevice.h"
00012 #include "sformatCtrl.h"
00013
00014
00015 class FZTAT_Ctrl {
00016 enum {
00017 NotInitialized,
00018 BaudrateAdjusted,
00019 ProgramSended,
00020 Writed,
00021 Invalid,
00022 Timeout = 100,
00023 RetryMax = 3,
00024 LineMax = 80,
00025 };
00026 std::string error_message;
00027 SerialDevice* con;
00028 int debug_level;
00029
00030 public:
00031 typedef void (*progressView_t)(int, int);
00032
00033 private:
00034 progressView_t view_callback;
00035
00036 const char* con_device;
00037 long write_baudrate;
00038 int mode;
00039
00040 int connect(long baudrate);
00041 void disconnect(void);
00042 bool isLF(const char ch);
00043 bool fillSendBuffer(int* sended, char* buffer, const char* code, int left);
00044 long setDataBuffer(char* buffer, SFormat_Ctrl::srec_t* srec);
00045 FZTAT_Ctrl(void);
00046
00047 public:
00048 enum {
00049 WriteBaudrate = 115200,
00050 };
00051
00052 FZTAT_Ctrl(const char* device, long writeBaudrate = WriteBaudrate);
00053 ~FZTAT_Ctrl(void);
00054 const char* what(void);
00055 bool adjustBaudrate(void);
00056 bool sendWriteProgram(char* code, int size);
00057 bool writeRom(char* code, int size, long baudrate);
00058 void setProgressCallback(progressView_t func);
00059 };
00060
00061 #endif