repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / serialconnect / XModem.h
blobc576a52536912f989070c80c62f9cf854a86d48b
1 /*
2 * Copyright 2017, Adrien Destugues, pulkomandy@pulkomandy.tk
3 * Distributed under terms of the MIT license.
4 */
7 #ifndef XMODEM_H
8 #define XMODEM_H
10 #include "FileSender.h"
12 #include <Messenger.h>
13 #include <String.h>
16 class BDataIO;
17 class BHandler;
18 class BSerialPort;
21 class XModemSender: public FileSender {
22 public:
23 XModemSender(BDataIO* source, BSerialPort* sink,
24 BHandler* listener);
25 virtual ~XModemSender();
27 virtual bool BytesReceived(const uint8_t* data,
28 size_t length);
29 private:
31 void SendBlock();
32 status_t NextBlock();
34 uint16_t CRC(const uint8_t* buffer, size_t size);
36 private:
37 BDataIO* fSource;
38 BSerialPort* fSink;
39 BMessenger fListener;
40 off_t fBlockNumber;
41 off_t fSourceSize;
42 uint8_t fBuffer[128];
43 bool fEotSent;
44 bool fUseCRC;
45 BString fStatus;
49 #endif /* !XMODEM_H */