ymodem_tx.h

Go to the documentation of this file.
00001 /*
00002 This program is distributed under the terms of the 'MIT license'. The text
00003 of this licence follows...
00004 
00005 Copyright (c) 2006 J.D.Medhurst (a.k.a. Tixy)
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy
00008 of this software and associated documentation files (the "Software"), to deal
00009 in the Software without restriction, including without limitation the rights
00010 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011 copies of the Software, and to permit persons to whom the Software is
00012 furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00020 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00022 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00023 THE SOFTWARE.
00024 */
00025 
00032 #include "ymodem.h"
00033 
00038 class YModemTx : public YModem
00039     {
00040 public:
00046     YModemTx(SerialPort& port);
00047 
00051     class InStream
00052         {
00053     public:
00062         virtual int In(uint8_t* data, size_t size) =0;
00063 
00067         inline virtual ~InStream() {}
00068         };
00069 
00078     int SendX(InStream& in, unsigned timeout, bool kMode);
00079 
00090     int SendY(const char* fileName, size_t size, InStream& in, unsigned timeout);
00091 
00095     enum TxError
00096         {
00097         ErrorInputStreamError           = -300, 
00098         ErrorReceiverNotBehaving        = -301, 
00099         ErrorTranferTerminatedByReceiver= -302, 
00100         ErrorFileNameTooLong            = -303  
00101         };
00102 
00103 private:
00104     int SendInitialise(unsigned timeout);
00105     int SendBlock(const uint8_t* data, size_t size);
00106     int SendData(const uint8_t* data, size_t size);
00107     int SendAll(InStream& in);
00108     int MakeBlock0(uint8_t* buffer, const char* fileName, size_t fileSize);
00109     int ProcessResponse(int c);
00110 private:
00111     size_t BlockNumber;
00112     bool SendCRC;
00113     bool WaitForBlockACK;
00114     bool Use1KBlocks;
00115     uint8_t ModeChar;
00116     int CancelCount;
00117     };
00118 
00119 

Generated by  doxygen 1.6.1