BootloaderInterface.h
Go to the documentation of this file.
00001 /*
00002         Aseba - an event-based framework for distributed robot control
00003         Copyright (C) 2007--2012:
00004                 Stephane Magnenat <stephane at magnenat dot net>
00005                 (http://stephane.magnenat.net)
00006                 and other contributors, see authors.txt for details
00007         
00008         This program is free software: you can redistribute it and/or modify
00009         it under the terms of the GNU Lesser General Public License as published
00010         by the Free Software Foundation, version 3 of the License.
00011         
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU Lesser General Public License for more details.
00016         
00017         You should have received a copy of the GNU Lesser General Public License
00018         along with this program. If not, see <http://www.gnu.org/licenses/>.
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         // TODO: change API to use HexFile instead of file names
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                 // main interface
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                 // reporting function
00081                 
00082                 // progress
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                 // non-fatal errors
00095                 
00097                 virtual void errorWritePageNonFatal(unsigned pageNumber) {}
00098                 
00099         protected:
00100                 // member variables
00101                 Dashel::Stream* stream;
00102                 int dest;
00103                 unsigned pageSize;
00104                 unsigned pagesStart;
00105                 unsigned pagesCount;
00106         };
00107 } // namespace Aseba
00108 
00109 #endif // ASEBA_BOOTLOADER_INTERFACE_H


aseba
Author(s): Stéphane Magnenat
autogenerated on Thu Jan 2 2014 11:17:16