##// END OF EJS Templates
Protocole written but not tested yet.
kaveh -
r3:66fd6489c66a default
parent child
Show More
@@ -0,0 +1,352
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd">
3 <!--Created by yEd 3.12.2-->
4 <key for="graphml" id="d0" yfiles.type="resources"/>
5 <key for="port" id="d1" yfiles.type="portgraphics"/>
6 <key for="port" id="d2" yfiles.type="portgeometry"/>
7 <key for="port" id="d3" yfiles.type="portuserdata"/>
8 <key attr.name="url" attr.type="string" for="node" id="d4"/>
9 <key attr.name="description" attr.type="string" for="node" id="d5"/>
10 <key for="node" id="d6" yfiles.type="nodegraphics"/>
11 <key attr.name="Description" attr.type="string" for="graph" id="d7"/>
12 <key attr.name="url" attr.type="string" for="edge" id="d8"/>
13 <key attr.name="description" attr.type="string" for="edge" id="d9"/>
14 <key for="edge" id="d10" yfiles.type="edgegraphics"/>
15 <graph edgedefault="directed" id="G">
16 <data key="d7"/>
17 <node id="n0">
18 <data key="d5"/>
19 <data key="d6">
20 <y:ShapeNode>
21 <y:Geometry height="67.0" width="172.0" x="364.99999999999994" y="161.8"/>
22 <y:Fill color="#FFCC00" transparent="false"/>
23 <y:BorderStyle color="#000000" type="line" width="1.0"/>
24 <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="47.845703125" x="62.0771484375" y="24.515625">Default<y:LabelModel>
25 <y:SmartNodeLabelModel distance="4.0"/>
26 </y:LabelModel>
27 <y:ModelParameter>
28 <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
29 </y:ModelParameter>
30 </y:NodeLabel>
31 <y:Shape type="ellipse"/>
32 </y:ShapeNode>
33 </data>
34 </node>
35 <node id="n1">
36 <data key="d5"/>
37 <data key="d6">
38 <y:ShapeNode>
39 <y:Geometry height="67.0" width="160.0" x="175.0" y="316.205549621582"/>
40 <y:Fill color="#FFCC00" transparent="false"/>
41 <y:BorderStyle color="#000000" type="line" width="1.0"/>
42 <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="62.6640625" x="48.66796875" y="24.515625">MoreData<y:LabelModel>
43 <y:SmartNodeLabelModel distance="4.0"/>
44 </y:LabelModel>
45 <y:ModelParameter>
46 <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
47 </y:ModelParameter>
48 </y:NodeLabel>
49 <y:Shape type="ellipse"/>
50 </y:ShapeNode>
51 </data>
52 </node>
53 <node id="n2">
54 <data key="d5"/>
55 <data key="d6">
56 <y:ShapeNode>
57 <y:Geometry height="67.0" width="154.0" x="434.20000000000016" y="376.0"/>
58 <y:Fill color="#FFCC00" transparent="false"/>
59 <y:BorderStyle color="#000000" type="line" width="1.0"/>
60 <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="39.291015625" x="57.3544921875" y="24.515625">Sync?<y:LabelModel>
61 <y:SmartNodeLabelModel distance="4.0"/>
62 </y:LabelModel>
63 <y:ModelParameter>
64 <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
65 </y:ModelParameter>
66 </y:NodeLabel>
67 <y:Shape type="ellipse"/>
68 </y:ShapeNode>
69 </data>
70 </node>
71 <node id="n3">
72 <data key="d5"/>
73 <data key="d6">
74 <y:ShapeNode>
75 <y:Geometry height="67.0" width="165.0" x="434.20000000000016" y="489.4000000000001"/>
76 <y:Fill color="#FFCC00" transparent="false"/>
77 <y:BorderStyle color="#000000" type="line" width="1.0"/>
78 <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="112.568359375" x="26.2158203125" y="24.515625000000057">Header extraction<y:LabelModel>
79 <y:SmartNodeLabelModel distance="4.0"/>
80 </y:LabelModel>
81 <y:ModelParameter>
82 <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
83 </y:ModelParameter>
84 </y:NodeLabel>
85 <y:Shape type="ellipse"/>
86 </y:ShapeNode>
87 </data>
88 </node>
89 <node id="n4">
90 <data key="d5"/>
91 <data key="d6">
92 <y:ShapeNode>
93 <y:Geometry height="67.0" width="160.0" x="531.4375000000005" y="602.8000000000002"/>
94 <y:Fill color="#FFCC00" transparent="false"/>
95 <y:BorderStyle color="#000000" type="line" width="1.0"/>
96 <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="116.212890625" x="21.8935546875" y="24.515625">Payload extraction<y:LabelModel>
97 <y:SmartNodeLabelModel distance="4.0"/>
98 </y:LabelModel>
99 <y:ModelParameter>
100 <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
101 </y:ModelParameter>
102 </y:NodeLabel>
103 <y:Shape type="ellipse"/>
104 </y:ShapeNode>
105 </data>
106 </node>
107 <node id="n5">
108 <data key="d5"/>
109 <data key="d6">
110 <y:ShapeNode>
111 <y:Geometry height="67.0" width="154.0" x="237.0" y="503.4000000000001"/>
112 <y:Fill color="#FFCC00" transparent="false"/>
113 <y:BorderStyle color="#000000" type="line" width="1.0"/>
114 <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="62.6640625" x="45.66796875" y="24.515625">MoreData<y:LabelModel>
115 <y:SmartNodeLabelModel distance="4.0"/>
116 </y:LabelModel>
117 <y:ModelParameter>
118 <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
119 </y:ModelParameter>
120 </y:NodeLabel>
121 <y:Shape type="ellipse"/>
122 </y:ShapeNode>
123 </data>
124 </node>
125 <node id="n6">
126 <data key="d5"/>
127 <data key="d6">
128 <y:ShapeNode>
129 <y:Geometry height="55.0" width="124.0" x="720.4375000000005" y="501.4000000000001"/>
130 <y:Fill color="#FFCC00" transparent="false"/>
131 <y:BorderStyle color="#000000" type="line" width="1.0"/>
132 <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="35.46484375" x="44.267578125" y="18.515625">CRC?<y:LabelModel>
133 <y:SmartNodeLabelModel distance="4.0"/>
134 </y:LabelModel>
135 <y:ModelParameter>
136 <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
137 </y:ModelParameter>
138 </y:NodeLabel>
139 <y:Shape type="ellipse"/>
140 </y:ShapeNode>
141 </data>
142 </node>
143 <node id="n7">
144 <data key="d5"/>
145 <data key="d6">
146 <y:ShapeNode>
147 <y:Geometry height="67.0" width="133.0" x="806.9375000000005" y="376.0"/>
148 <y:Fill color="#FFCC00" transparent="false"/>
149 <y:BorderStyle color="#000000" type="line" width="1.0"/>
150 <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" textColor="#000000" visible="true" width="89.69921875" x="21.650390625" y="24.515625">Forward DATA<y:LabelModel>
151 <y:SmartNodeLabelModel distance="4.0"/>
152 </y:LabelModel>
153 <y:ModelParameter>
154 <y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
155 </y:ModelParameter>
156 </y:NodeLabel>
157 <y:Shape type="ellipse"/>
158 </y:ShapeNode>
159 </data>
160 </node>
161 <edge id="e0" source="n0" target="n0">
162 <data key="d9"/>
163 <data key="d10">
164 <y:BezierEdge>
165 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">
166 <y:Point x="520.1228820800782" y="117.70554962158204"/>
167 <y:Point x="433.99999999999994" y="56.105549621582014"/>
168 </y:Path>
169 <y:LineStyle color="#000000" type="line" width="1.0"/>
170 <y:Arrows source="none" target="standard"/>
171 </y:BezierEdge>
172 </data>
173 </edge>
174 <edge id="e1" source="n0" target="n1">
175 <data key="d9"/>
176 <data key="d10">
177 <y:BezierEdge>
178 <y:Path sx="0.0" sy="0.0" tx="53.92288208007818" ty="0.0"/>
179 <y:LineStyle color="#000000" type="line" width="1.0"/>
180 <y:Arrows source="none" target="standard"/>
181 <y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="77.939453125" x="-64.56540133956378" y="18.83230813201726">Out of DATA<y:LabelModel>
182 <y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/>
183 </y:LabelModel>
184 <y:ModelParameter>
185 <y:SmartEdgeLabelModelParameter angle="0.0" distance="30.0" distanceToCenter="true" position="center" ratio="0.19967019466603264" segment="0"/>
186 </y:ModelParameter>
187 <y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/>
188 </y:EdgeLabel>
189 </y:BezierEdge>
190 </data>
191 </edge>
192 <edge id="e2" source="n1" target="n0">
193 <data key="d9"/>
194 <data key="d10">
195 <y:BezierEdge>
196 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">
197 <y:Point x="116.92288208007818" y="222.50554962158205"/>
198 </y:Path>
199 <y:LineStyle color="#000000" type="line" width="1.0"/>
200 <y:Arrows source="none" target="standard"/>
201 </y:BezierEdge>
202 </data>
203 </edge>
204 <edge id="e3" source="n0" target="n2">
205 <data key="d9"/>
206 <data key="d10">
207 <y:BezierEdge>
208 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
209 <y:LineStyle color="#000000" type="line" width="1.0"/>
210 <y:Arrows source="none" target="standard"/>
211 <y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="59.875" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="120.63671875" x="-39.577459716796795" y="43.86147155761722">Found 0xA5
212 and
213 Have enough DATA
214 to read header<y:LabelModel>
215 <y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/>
216 </y:LabelModel>
217 <y:ModelParameter>
218 <y:SmartEdgeLabelModelParameter angle="0.0" distance="30.0" distanceToCenter="true" position="center" ratio="0.5" segment="0"/>
219 </y:ModelParameter>
220 <y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/>
221 </y:EdgeLabel>
222 </y:BezierEdge>
223 </data>
224 </edge>
225 <edge id="e4" source="n2" target="n0">
226 <data key="d9"/>
227 <data key="d10">
228 <y:BezierEdge>
229 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">
230 <y:Point x="651.322882080078" y="251.30554962158203"/>
231 <y:Point x="542.5228820800783" y="187.30554962158206"/>
232 </y:Path>
233 <y:LineStyle color="#000000" type="line" width="1.0"/>
234 <y:Arrows source="none" target="standard"/>
235 <y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="131.06640625" x="0.04811981072020899" y="-80.19417953491211">Next DATA isn't 0xF0<y:LabelModel>
236 <y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/>
237 </y:LabelModel>
238 <y:ModelParameter>
239 <y:SmartEdgeLabelModelParameter angle="6.283185307179586" distance="30.0" distanceToCenter="true" position="center" ratio="0.5" segment="0"/>
240 </y:ModelParameter>
241 <y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/>
242 </y:EdgeLabel>
243 </y:BezierEdge>
244 </data>
245 </edge>
246 <edge id="e5" source="n2" target="n3">
247 <data key="d9"/>
248 <data key="d10">
249 <y:BezierEdge>
250 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
251 <y:LineStyle color="#000000" type="line" width="1.0"/>
252 <y:Arrows source="none" target="standard"/>
253 <y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="111.12109375" x="1.67188904897057" y="8.463071289062498">Next Data is 0xF0<y:LabelModel>
254 <y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/>
255 </y:LabelModel>
256 <y:ModelParameter>
257 <y:SmartEdgeLabelModelParameter angle="6.283185307179586" distance="56.32000000000005" distanceToCenter="true" position="left" ratio="0.18748728382502497" segment="-1"/>
258 </y:ModelParameter>
259 <y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/>
260 </y:EdgeLabel>
261 </y:BezierEdge>
262 </data>
263 </edge>
264 <edge id="e6" source="n3" target="n5">
265 <data key="d9"/>
266 <data key="d10">
267 <y:BezierEdge>
268 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
269 <y:LineStyle color="#000000" type="line" width="1.0"/>
270 <y:Arrows source="none" target="standard"/>
271 </y:BezierEdge>
272 </data>
273 </edge>
274 <edge id="e7" source="n5" target="n3">
275 <data key="d9"/>
276 <data key="d10">
277 <y:BezierEdge>
278 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">
279 <y:Point x="372.98288208007807" y="469.67554962158215"/>
280 </y:Path>
281 <y:LineStyle color="#000000" type="line" width="1.0"/>
282 <y:Arrows source="none" target="standard"/>
283 </y:BezierEdge>
284 </data>
285 </edge>
286 <edge id="e8" source="n3" target="n4">
287 <data key="d9"/>
288 <data key="d10">
289 <y:BezierEdge>
290 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
291 <y:LineStyle color="#000000" type="line" width="1.0"/>
292 <y:Arrows source="none" target="standard"/>
293 </y:BezierEdge>
294 </data>
295 </edge>
296 <edge id="e9" source="n4" target="n6">
297 <data key="d9"/>
298 <data key="d10">
299 <y:BezierEdge>
300 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
301 <y:LineStyle color="#000000" type="line" width="1.0"/>
302 <y:Arrows source="none" target="standard"/>
303 </y:BezierEdge>
304 </data>
305 </edge>
306 <edge id="e10" source="n6" target="n7">
307 <data key="d9"/>
308 <data key="d10">
309 <y:BezierEdge>
310 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
311 <y:LineStyle color="#000000" type="line" width="1.0"/>
312 <y:Arrows source="none" target="standard"/>
313 </y:BezierEdge>
314 </data>
315 </edge>
316 <edge id="e11" source="n7" target="n0">
317 <data key="d9"/>
318 <data key="d10">
319 <y:BezierEdge>
320 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">
321 <y:Point x="749.403125" y="165.16200795491557"/>
322 </y:Path>
323 <y:LineStyle color="#000000" type="line" width="1.0"/>
324 <y:Arrows source="none" target="standard"/>
325 </y:BezierEdge>
326 </data>
327 </edge>
328 <edge id="e12" source="n6" target="n0">
329 <data key="d9"/>
330 <data key="d10">
331 <y:BezierEdge>
332 <y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">
333 <y:Point x="761.1325370507815" y="218.55285428694648"/>
334 </y:Path>
335 <y:LineStyle color="#000000" type="line" width="1.0"/>
336 <y:Arrows source="none" target="standard"/>
337 <y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="custom" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="56.11328125" x="-73.13897939476271" y="-230.014189590978">Bad CRC<y:LabelModel>
338 <y:SmartEdgeLabelModel autoRotationEnabled="false" defaultAngle="0.0" defaultDistance="10.0"/>
339 </y:LabelModel>
340 <y:ModelParameter>
341 <y:SmartEdgeLabelModelParameter angle="0.0" distance="30.0" distanceToCenter="true" position="left" ratio="0.7759995729810671" segment="0"/>
342 </y:ModelParameter>
343 <y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/>
344 </y:EdgeLabel>
345 </y:BezierEdge>
346 </data>
347 </edge>
348 </graph>
349 <data key="d0">
350 <y:Resources/>
351 </data>
352 </graphml>
@@ -44,6 +44,21 bool UComPort::open()
44 44 rs232setup(this->p_port,8,this->p_speed,rs232parityNo,rs232OneStop);
45 45 p_opened = true;
46 46 }
47 return p_opened;
48 }
49
50 bool UComPort::close()
51 {
52 if(p_opened)
53 {
54 p_opened = rs232close(this->p_port);
55 }
56 return !p_opened;
57 }
58
59 bool UComPort::opened()
60 {
61 return p_opened;
47 62 }
48 63
49 64 bool UComPort::open(const QString &name, int speed)
@@ -52,3 +67,22 bool UComPort::open(const QString &name,
52 67 setSpeed(speed);
53 68 return open();
54 69 }
70
71 int UComPort::availableBytes()
72 {
73 if(p_opened)
74 {
75 return rs232availablebytes(this->p_port);
76 }
77 return 0;
78 }
79
80 int UComPort::readBytes(char *data, int count)
81 {
82 return rs232read(this->p_port,data,count);
83 }
84
85 int UComPort::writeBytes(char *data, int count)
86 {
87 return rs232write(this->p_port,data,count);
88 }
@@ -10,13 +10,21 class UComPort
10 10 {
11 11 public:
12 12 explicit UComPort();
13
13 14 QString portName();
14 15 int speed();
15 16 virtual void setPortName(const QString& name);
16 17 virtual void setSpeed(int speed);
17 bool open();
18 bool open(const QString& name);
19 bool open(const QString& name,int speed);
18
19 virtual bool open();
20 virtual bool open(const QString& name,int speed);
21 virtual bool close();
22 bool opened();
23 int availableBytes();
24
25 int readBytes(char* data,int count);
26 int writeBytes(char* data,int count);
27
20 28 private:
21 29 rs232port_t p_port;
22 30 QString p_PortName;
@@ -8,10 +8,14 UProbe::UProbe(QObject *parent) :
8 8
9 9 bool UProbe::setPortName(const QString &name)
10 10 {
11
11 /* TODO implement this function */
12 Q_UNUSED(name)
13 return false;
12 14 }
13 15
14 16 bool UProbe::setPortSpeed(int speed)
15 17 {
16
18 /* TODO implement this function */
19 Q_UNUSED(speed)
20 return false;
17 21 }
@@ -14,9 +14,29 UProbeProtocol::~UProbeProtocol()
14 14
15 15 void UProbeProtocol::run()
16 16 {
17 p_buffer = (char*)malloc(bufferSize);
18 if(p_buffer==NULL)return;
17 19 while(!this->isInterruptionRequested())
18 20 {
21 getMoreData();
22 while(p_index<p_datacount)
23 {
24 if(p_buffer[p_index]==(char)0xA5)
25 {
26 //got to Sync state
27 while (p_datacount<(p_index+6))
28 {
29 getMoreData();
30 }
31 if(FSM_SyncState()==true)
32 {
33 p_index+=currentPacket->packetSize + 6;
34 //forward DATA
19 35
36 }
37 }
38 p_index++;
39 }
20 40 }
21 41 }
22 42
@@ -29,3 +49,111 void UProbeProtocol::setSpeed(int speed)
29 49 {
30 50 UComPort::setSpeed(speed);
31 51 }
52
53 bool UProbeProtocol::open()
54 {
55 return UComPort::open();
56 }
57
58 bool UProbeProtocol::open(const QString &name, int speed)
59 {
60 return UComPort::open(name,speed);
61 }
62
63 bool UProbeProtocol::close()
64 {
65 return UComPort::close();
66 }
67
68 void UProbeProtocol::getMoreData()
69 {
70 int avail;
71 int maxCount=(bufferSize-32)-p_datacount;
72 if(p_index>(bufferSize/2))
73 {
74 memcpy(p_buffer,p_buffer+p_index,p_datacount-p_index);
75 p_datacount = p_datacount-p_index;
76 p_index = 0;
77 }
78 if(opened())
79 {
80 avail=availableBytes();
81 if(avail)
82 {
83 if(maxCount>=avail)
84 {
85 p_datacount += readBytes(p_buffer+p_datacount,avail);
86 }
87 else
88 {
89 p_datacount += readBytes(p_buffer+p_datacount,maxCount);
90 }
91 }
92 }
93 }
94
95 bool UProbeProtocol::FSM_SyncState()
96 {
97 if(p_buffer[p_index+1]==(char)0x0F0)
98 {
99 return FSM_ExtractHeaderState();
100 }
101 else
102 {
103 return false;
104 }
105 }
106
107 bool UProbeProtocol::FSM_ExtractHeaderState()
108 {
109
110 currentPacket = new UProbeProtocolPacket();
111 currentPacket->packetNumber = p_buffer[p_index+2];
112 currentPacket->packetSize = ((unsigned int)p_buffer[p_index+3] + 1)*2;
113 currentPacket->channelCount = 0xF & (int)(p_buffer[p_index+4]>>4);
114 currentPacket->coding = (UProbeProtocol::UProbeProtocolPacket::PacketCoding)(0x3 & (int)(p_buffer[p_index+4]>>2));
115 currentPacket->resolution = (UProbeProtocol::UProbeProtocolPacket::PacketResolution)(0x3 & (int)(p_buffer[p_index+4]));
116 currentPacket->ID = (unsigned int)p_buffer[p_index+5];
117 while(p_datacount<(p_index+2+4+currentPacket->packetSize+1))
118 {
119 getMoreData();
120 }
121 return FSM_ExtractPayloadState();
122 }
123
124
125 bool UProbeProtocol::FSM_ExtractPayloadState()
126 {
127 if(!currentPacket || currentPacket->packetSize < 2 || (currentPacket->packetSize>UProbeProtocolMaxPacketSize))
128 return false;
129 currentPacket->data = (char*)malloc(currentPacket->packetSize);
130 if(currentPacket->data != NULL)
131 {
132 memcpy(currentPacket->data,p_buffer+p_index+6,currentPacket->packetSize);
133 return FSM_CheckCRCState();
134 }
135 return false;
136 }
137
138 bool UProbeProtocol::FSM_CheckCRCState()
139 {
140 currentPacket->receivedCRC = p_buffer[p_index+6+currentPacket->packetSize];
141 currentPacket->localCRC = spw_CRC(p_buffer+p_index,6+currentPacket->packetSize);
142 if(currentPacket->localCRC == currentPacket->receivedCRC)
143 {
144 currentPacket->correct = true;
145 return true;
146 }
147 currentPacket->correct = false;
148 return false;
149 }
150
151
152
153
154
155
156
157
158
159
@@ -6,10 +6,118
6 6 #include <QMutex>
7 7 #include <QSemaphore>
8 8 #include <ucomport.h>
9 #define UProbeProtocolMaxPacketSize 512
10 #define bufferSize (((UProbeProtocolMaxPacketSize+7)+6)*2+32)
11
12 /*
13 ===========================================================================================
14 ===========================================================================================
15 β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—
16 β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘
17 β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘
18 β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘
19 β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
20 β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β• β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β•
21 -------------------------------------------------------------------------------------------
22
23 || Sync (2Bytes) || Header(4 Bytes) || Payload Data (2 to 512 Bytes) || CRC(1 Byte) ||
24 || 0xA5 0xF0 || PCPT | (PSZ-1)*2 | SHAPE | ID || [...] || Uses SpaceWire CRC ||
25
26
27 Shape:
28 |msb lsb|
29 | Channel count -1 [7:4] | Coding [3:2] | Channel resolution[1:0] -1 |
30
31 Coding:
32 0 Unsigned integer
33 1 Signed integer (Two complement)
34 2 Signed integer (sign bit)
35 3 floating point
36
37 ===========================================================================================
38 */
39
40
41
42 static const unsigned char SPW_CRCTable[] = {
43 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75,
44 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b,
45 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69,
46 0x12, 0x83, 0xf1, 0x60, 0x15, 0x84, 0xf6, 0x67,
47 0x38, 0xa9, 0xdb, 0x4a, 0x3f, 0xae, 0xdc, 0x4d,
48 0x36, 0xa7, 0xd5, 0x44, 0x31, 0xa0, 0xd2, 0x43,
49 0x24, 0xb5, 0xc7, 0x56, 0x23, 0xb2, 0xc0, 0x51,
50 0x2a, 0xbb, 0xc9, 0x58, 0x2d, 0xbc, 0xce, 0x5f,
51 0x70, 0xe1, 0x93, 0x02, 0x77, 0xe6, 0x94, 0x05,
52 0x7e, 0xef, 0x9d, 0x0c, 0x79, 0xe8, 0x9a, 0x0b,
53 0x6c, 0xfd, 0x8f, 0x1e, 0x6b, 0xfa, 0x88, 0x19,
54 0x62, 0xf3, 0x81, 0x10, 0x65, 0xf4, 0x86, 0x17,
55 0x48, 0xd9, 0xab, 0x3a, 0x4f, 0xde, 0xac, 0x3d,
56 0x46, 0xd7, 0xa5, 0x34, 0x41, 0xd0, 0xa2, 0x33,
57 0x54, 0xc5, 0xb7, 0x26, 0x53, 0xc2, 0xb0, 0x21,
58 0x5a, 0xcb, 0xb9, 0x28, 0x5d, 0xcc, 0xbe, 0x2f,
59 0xe0, 0x71, 0x03, 0x92, 0xe7, 0x76, 0x04, 0x95,
60 0xee, 0x7f, 0x0d, 0x9c, 0xe9, 0x78, 0x0a, 0x9b,
61 0xfc, 0x6d, 0x1f, 0x8e, 0xfb, 0x6a, 0x18, 0x89,
62 0xf2, 0x63, 0x11, 0x80, 0xf5, 0x64, 0x16, 0x87,
63 0xd8, 0x49, 0x3b, 0xaa, 0xdf, 0x4e, 0x3c, 0xad,
64 0xd6, 0x47, 0x35, 0xa4, 0xd1, 0x40, 0x32, 0xa3,
65 0xc4, 0x55, 0x27, 0xb6, 0xc3, 0x52, 0x20, 0xb1,
66 0xca, 0x5b, 0x29, 0xb8, 0xcd, 0x5c, 0x2e, 0xbf,
67 0x90, 0x01, 0x73, 0xe2, 0x97, 0x06, 0x74, 0xe5,
68 0x9e, 0x0f, 0x7d, 0xec, 0x99, 0x08, 0x7a, 0xeb,
69 0x8c, 0x1d, 0x6f, 0xfe, 0x8b, 0x1a, 0x68, 0xf9,
70 0x82, 0x13, 0x61, 0xf0, 0x85, 0x14, 0x66, 0xf7,
71 0xa8, 0x39, 0x4b, 0xda, 0xaf, 0x3e, 0x4c, 0xdd,
72 0xa6, 0x37, 0x45, 0xd4, 0xa1, 0x30, 0x42, 0xd3,
73 0xb4, 0x25, 0x57, 0xc6, 0xb3, 0x22, 0x50, 0xc1,
74 0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf
75 };
76 inline unsigned char _spw_CRC_(unsigned char INCR, unsigned char INBYTE)
77 {
78 return SPW_CRCTable[INCR ^ INBYTE];
79 }
80
81 inline char spw_CRC(char* buffer, int size)
82 {
83 unsigned char CRC = 0;
84 for(int i=0;i<size;i++)
85 {
86 CRC = _spw_CRC_(CRC,(unsigned char)buffer[i]);
87 }
88 return CRC;
89 }
90
9 91
10 92 class UProbeProtocol : public QThread , public UComPort
11 93 {
94 class UProbeProtocolPacket
95 {
96 public:
97 typedef enum {UProbeUint=0,UProdeInt=1,UProbeSInt=2,UProbeFloat=3}PacketCoding;
98 typedef enum {res1Byte=0,res2Bytes=1,res3Bytes=2,res4Bytes=3}PacketResolution;
99
100 UProbeProtocolPacket()
101 :packetNumber(0),packetSize(0),channelCount(0),
102 coding(UProbeUint),resolution(res1Byte),ID(0),data(NULL),correct(false)
103 {
104
105 }
106
107 int packetNumber;
108 int packetSize;
109 int channelCount;
110 UProbeProtocolPacket::PacketCoding coding;
111 UProbeProtocolPacket::PacketResolution resolution;
112 int ID;
113 char* data;
114 bool correct;
115 char receivedCRC;
116 char localCRC;
117 };
118
12 119 Q_OBJECT
120
13 121 public:
14 122 explicit UProbeProtocol(QObject *parent = 0);
15 123 ~UProbeProtocol();
@@ -20,8 +128,28 signals:
20 128 public slots:
21 129 void setPortName(const QString& name);
22 130 void setSpeed(int speed);
131 bool open();
132 bool open(const QString& name,int speed);
133 bool close();
23 134
24 135 private:
136 void getMoreData();
137 bool FSM_SyncState();
138 bool FSM_ExtractHeaderState();
139 bool FSM_ExtractPayloadState();
140 bool FSM_CheckCRCState();
141 char* p_buffer;
142 int p_datacount;
143 int p_index;
144 UProbeProtocolPacket* currentPacket;
25 145 };
26 146
27 147 #endif // UPROBEPROTOCOL_H
148
149
150
151
152
153
154
155
General Comments 0
You need to be logged in to leave comments. Login now