propellerloader.h
1 #pragma once
2 
3 #include "../image/propellerimage.h"
4 #include "../session/propellersession.h"
5 #include "protocol.h"
6 
7 #include <QTimer>
8 #include <QElapsedTimer>
9 #include <QStateMachine>
10 #include <QFinalState>
11 #include <QState>
12 
44 class PropellerLoader : public QObject
45 {
46  Q_OBJECT
47  Q_PROPERTY(QString status MEMBER m_status NOTIFY statusChanged)
48  Q_PROPERTY(int stat MEMBER m_stat)
49 
50 public:
52  {
66  };
67 
68 private:
69  PropellerSession * session;
70  PropellerProtocol protocol;
71  PropellerImage _image;
72 
73  int _command;
74  int _completed;
75  QString m_status;
76  int m_stat;
77 
78  QByteArray _payload;
79 
80  QStateMachine machine;
81  QState * s_active;
82 
83  LoaderError _error;
84  QHash<LoaderError, QString> _errorstrings;
85 
86  int _version;
87  QHash<int, QString> _versionstrings;
88 
89  int _ack;
90  int _write, _run;
91 
92  QTimer totalTimeout;
93  QTimer handshakeTimeout;
94  QTimer resetTimer;
95  QTimer poll;
96  QElapsedTimer elapsedTimer;
97 
98  void writeLong(quint32 value);
99 
100 signals:
101  void finished();
102  void success();
103  void failure();
104 
105  void prepared();
106  void payload_sent();
107  void handshake_received();
108  void upload_completed();
109  void acknowledged();
110 
111  void statusChanged(const QString & message);
112 
113 private slots:
114 
115  void failure_entry();
116  void success_entry();
117 
118  void prepare_entry();
119 
120  void sendpayload_entry();
121  void sendpayload_exit();
122 
123  void sendpayload_write();
124  void handshake_read();
125 
126  void upload_status();
127 
128  void acknowledge_entry();
129  void acknowledge_exit();
130  void acknowledge_read();
131 
132  void calibrate();
133  void timeover();
134  void timestamp();
135 
136  void message(const QString & text);
137  void error(const QString & text);
138 
139 public:
141  const QString & portname = QString(),
142  QObject * parent = 0);
144 
145  int version();
146  QString versionString(int version);
147 
148  bool upload(PropellerImage image, bool write=false, bool run=true, bool wait=false);
149 // bool highSpeedUpload(PropellerImage image, bool write=false, bool run=true);
150 };
151 
Definition: propellerloader.h:58
Definition: propellerloader.h:57
void upload_completed()
Definition: propellerloader.h:55
Definition: propellerloader.h:53
Definition: propellerloader.h:61
bool upload(PropellerImage image, bool write=false, bool run=true, bool wait=false)
Definition: propellerloader.cpp:337
Definition: propellerloader.h:60
Definition: propellerloader.h:56
~PropellerLoader()
Definition: propellerloader.cpp:114
void handshake_received()
LoaderError
Definition: propellerloader.h:51
The PropellerManager class provides an abstraction layer between PropellerSession and PropellerDevice...
Definition: propellermanager.h:86
QString status
Definition: propellerloader.h:47
QString versionString(int version)
Definition: propellerloader.cpp:610
Definition: propellerloader.h:62
The PropellerSession class provides a persistent interface to Propeller hardware via PropellerManager...
Definition: propellersession.h:43
Definition: propellerloader.h:63
Definition: propellerloader.h:64
Definition: propellerloader.h:54
int version()
Definition: propellerloader.cpp:162
int stat
Definition: propellerloader.h:48
Definition: propellerloader.h:65
void statusChanged(const QString &message)
Definition: propellerloader.h:59
The PropellerLoader class provides an implementation of the Propeller download protocol.
Definition: propellerloader.h:44
The PropellerImage class encapsulates Propeller binary images.
Definition: propellerimage.h:54
PropellerLoader(PropellerManager *manager, const QString &portname=QString(), QObject *parent=0)
Definition: propellerloader.cpp:10