Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ASEBA_BOOTLOADER_INTERFACE_H
00022 #define ASEBA_BOOTLOADER_INTERFACE_H
00023
00024 #include <string>
00025 #include <stdexcept>
00026 #include "../common/types.h"
00027
00028
00029 namespace Dashel
00030 {
00031 class Stream;
00032 }
00033
00034 namespace Aseba
00035 {
00036
00037
00039
00046 class BootloaderInterface
00047 {
00048 public:
00050 struct Error:public std::runtime_error
00051 {
00052 Error(const std::string& what): std::runtime_error(what) {}
00053 };
00054
00055 public:
00056
00057
00059 BootloaderInterface(Dashel::Stream* stream, int dest);
00060
00062 int getPageSize() const { return pageSize; }
00063
00065 bool readPage(unsigned pageNumber, uint8* data);
00066
00068 bool readPageSimple(unsigned pageNumber, uint8 * data);
00069
00071 bool writePage(unsigned pageNumber, const uint8 *data, bool simple);
00072
00074 void writeHex(const std::string &fileName, bool reset, bool simple);
00075
00077 void readHex(const std::string &fileName);
00078
00079 protected:
00080
00081
00082
00083 virtual void writePageStart(unsigned pageNumber, const uint8* data, bool simple) {}
00084 virtual void writePageWaitAck() {}
00085 virtual void writePageSuccess() {}
00086 virtual void writePageFailure() {}
00087
00088 virtual void writeHexStart(const std::string &fileName, bool reset, bool simple) {}
00089 virtual void writeHexEnteringBootloader() {}
00090 virtual void writeHexGotDescription(unsigned pagesCount) {}
00091 virtual void writeHexWritten() {}
00092 virtual void writeHexExitingBootloader() {}
00093
00094
00095
00097 virtual void errorWritePageNonFatal(unsigned pageNumber) {}
00098
00099 protected:
00100
00101 Dashel::Stream* stream;
00102 int dest;
00103 unsigned pageSize;
00104 unsigned pagesStart;
00105 unsigned pagesCount;
00106 };
00107 }
00108
00109 #endif // ASEBA_BOOTLOADER_INTERFACE_H