1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
|
/*
* Video On Demand Samples
*
* Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You may also obtain this software under a propriety license from Microchip.
* Please contact Microchip for further information.
*
*/
/*----------------------------------------------------------*/
/*! \file
* \brief This file contains the CIndustrialStack class (API V3 commands).
*/
/*----------------------------------------------------------*/
#ifndef INDUSTRIAL_STACK_API_V3_H
#define INDUSTRIAL_STACK_API_V3_H
#include "IndustrialStack.h"
#include "Network.h"
#include "Types.h"
class CV3_OnMostRx : public CSInternalEvent
{
private:
CNetworkDevice *device;
public:
CV3_OnMostRx(CNetworkDevice *d) : device(d)
{
}
virtual ISReturn_t OnMostMessage(CIndustrialStack *iStack, CISMostMsg *r)
{
assert(NULL != device);
assert(r->IsValid);
if (0x0 == r->FBlock) //INIC Block
{
switch (r->Func)
{
case 0x520: //MOST Network Status
if (CISOpType_STATUS == r->OpType && r->PayloadLen == 11)
{
bool mpValChanged = ( 0 != ( r->Payload[1] & 0x1 ) ); //This is a 16 Bit value!!
bool systemNotOk = false; //Not transmitted any longer
bool mostAvailable = ( 0 != ( r->Payload[2] & 0x1 ) );
uint8_t availableSubState = r->Payload[3];
uint8_t availableTransition = r->Payload[4];
uint16_t nodeAddress = r->Payload[5] << 8
| r->Payload[6];
uint8_t nodePos = ( r->Payload[7] & 0x3F );
uint8_t maxPos = ( r->Payload[8] );
uint16_t packetBW = r->Payload[9] << 8
| r->Payload[10];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnNetworkState(device,
mpValChanged, systemNotOk, mostAvailable, availableSubState,
availableTransition, nodeAddress, nodePos, maxPos, packetBW);
}
break;
case 0x524: //MOST Network Startup
if (CISOpType_STATUS == r->OpType)
{
if (r->Payload[0] == 0x20 && r->Payload[1] == 0x04 && r->Payload[2] == 0x40)
return ISReturn_NoChange; //Startup was called, but we already have locked network, so ignore this error
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnNetworkStartupV3(device, (CISOpType_STATUS == r->OpType));
}
break;
case 0x527: //RBD Result
if (CISOpType_STATUS == r->OpType && r->PayloadLen == 5)
{
uint8_t result = r->Payload[0];
uint8_t position = r->Payload[1];
uint8_t status = r->Payload[2];
uint16_t id = r->Payload[3] << 8
| r->Payload[4];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnRbdResultV3(device, r->SourceAddress,
result, position, status, id);
}
break;
}
}
else if (0x1 == r->FBlock) //NetBlock FBlock
{
switch (r->Func)
{
case 0x004: //GroupAddress Changed
if (CISOpType_STATUS == r->OpType && r->PayloadLen >= 2)
{
uint16_t groupAddress = r->Payload[0] << 8
| r->Payload[1];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnMostDeviceType(device, true, r->SourceAddress, groupAddress );
}
else if (CISOpType_ERROR == r->OpType)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnMostDeviceType(device, false, r->SourceAddress, 0xFFFF );
}
break;
case 0x013: //NetBlock EUI48
if (CISOpType_STATUS == r->OpType && r->PayloadLen >= 6)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnMostMacAddress(device, true,
r->SourceAddress, r->Payload[0], r->Payload[1],
r->Payload[2], r->Payload[3], r->Payload[4], r->Payload[5]);
}
else if (CISOpType_ERROR == r->OpType)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnMostMacAddress(device, false,
r->SourceAddress, 0,0,0,0,0,0);
}
break;
}
}
return ISReturn_NoChange;
}
virtual void OnSyncStateChanged(CIndustrialStack *iStack, bool isSynced)
{
assert(NULL != device);
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnSync(device, isSynced );
}
};
class CV3_NetworkStartup : public CISSendMostMsgElement
{
private:
CNetworkDevice *device;
public:
CV3_NetworkStartup(CNetworkDevice *d, uint16_t autoForcedNotAvailable, uint16_t packetBW) : device(d)
{
ElementName = "CV3_NetworkStartup";
WaitForResponseOpType = CISOpType_RESULT;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = 0x1;
Request.FBlock = 0x0;
Request.Func = 0x524;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 4;
Request.Payload[0] = autoForcedNotAvailable / 256;
Request.Payload[1] = autoForcedNotAvailable % 256;
Request.Payload[2] = packetBW / 256;
Request.Payload[3] = packetBW % 256;
}
};
class CV3_MostNetworkConfiguration : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
public:
CV3_MostNetworkConfiguration(CNetworkDevice *d, uint16_t nodeAddress,
uint8_t macAddress1, uint8_t macAddress2, uint8_t macAddress3,
uint8_t macAddress4, uint8_t macAddress5, uint8_t macAddress6,
bool promiscuous) : device(d)
{
ElementName = "CV3_MostNetworkConfiguration";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_STATUS;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x521;
Request.Inst = 0x00;
Request.OpType = CISOpType_SETGET;
Request.PayloadLen = 24;
Request.Payload[0] = 0; // HB: MASK
Request.Payload[1] =
( 1 << 3 ) // LB: MASK: Packet Filter Mode is considered
| ( 1 << 5 ); // LB: MASK: PacketEUI is considered
Request.Payload[2] = 0x00; // HB: Node Address (ignored)
Request.Payload[3] = 0x08; // LB: Node Address (ignored)
Request.Payload[4] = 0x00; // HB: Group Address (ignored)
Request.Payload[5] = 0x00; // LB: Group Address (ignored)
Request.Payload[6] = 0x00; // Control LLR Block Count (ignored)
Request.Payload[7] = 0x00; // HB: FilterMode (reserved)
Request.Payload[8] = promiscuous ? 0x0A : 0x08; // LB: FilterMode (Allow all Multicast)
Request.Payload[9] = 0x00; // HB: PacketHash_63to48 (ignored)
Request.Payload[10] = 0x00; // LB: PacketHash_63to48 (ignored)
Request.Payload[11] = 0x00; // HB: PacketHash_47to32 (ignored)
Request.Payload[12] = 0x00; // LB: PacketHash_47to32 (ignored)
Request.Payload[13] = 0x00; // HB: PacketHash_31to16 (ignored)
Request.Payload[14] = 0x00; // LB: PacketHash_31to16 (ignored)
Request.Payload[15] = 0x00; // HB: PacketHash_15to0 (ignored)
Request.Payload[16] = 0x00; // LB: PacketHash_15to0 (ignored)
Request.Payload[17] = macAddress1; // HB: PacketEUI48_47to32
Request.Payload[18] = macAddress2; // LB: PacketEUI48_47to32
Request.Payload[19] = macAddress3; // HB: PacketEUI48_31to16
Request.Payload[20] = macAddress4; // LB: PacketEUI48_31to16
Request.Payload[21] = macAddress5; // HB: PacketEUI48_15to0
Request.Payload[22] = macAddress6; // LB: PacketEUI48_15to0
Request.Payload[23] = 0x00; // PacketLLRTime (ignored)
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
assert(this == element);
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 18;
if (success)
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnMostMacAddress(device, true,
Request.TargetAddress, Response.Payload[15],Response.Payload[16],
Response.Payload[17], Response.Payload[18], Response.Payload[19],
Response.Payload[20]);
else
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnMostMacAddress(device, false,
Request.TargetAddress, 0, 0, 0, 0, 0, 0);
}
};
class CV3_DeviceAttach : public CISSendMostMsgElement
{
public:
CV3_DeviceAttach()
{
ElementName = "CV3_DeviceAttach";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = 0x1;
Request.FBlock = 0x0;
Request.Func = 0x223;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
}
};
class CV3_Unsynchronize : public IISElement
{
public:
CV3_Unsynchronize()
{
ElementName = "CV3_Unsynchronize";
}
virtual ISReturn_t Service(CIndustrialStack *iStack, uint32_t time)
{
assert(NULL != iStack);
iStack->Unsynchronize();
return ISReturn_Success;
}
virtual ISReturn_t OnMostMessage(CIndustrialStack *iStack, CISMostMsg *r)
{
return ISReturn_NoChange;
}
};
class CV3_DeviceSync : public CISSendMostMsgElement
{
public:
CV3_DeviceSync(uint16_t nodeAddress, bool sync)
{
if (0x1 == nodeAddress)
{
ConsolePrintf(PRIO_ERROR, RED"CV3_DeviceSync was called with local" \
" node address, this will fail!"RESETCOLOR"\n");
}
ElementName = "CV3_DeviceSync";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x224;
Request.Inst = 0x01;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 1;
Request.Payload[0] = sync;
}
};
class CV3_NetworkShutdown : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
public:
CV3_NetworkShutdown(CNetworkDevice *d) : device(d)
{
ElementName = "CV3_NetworkShutdown";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = 0x1;
Request.FBlock = 0x0;
Request.Func = 0x525;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 0;
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnNetworkShutdownV3(device, (ISReturn_Success == result));
}
};
class CV3_MlbPortCreate : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
public:
CV3_MlbPortCreate(CNetworkDevice *d, uint16_t nodeAddress, MlbPortSpeed_t mlbSpeed) : device(d)
{
ElementName = "CV3_MlbPortCreate";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x621;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 2;
Request.Payload[0] = 0x00; //Index
Request.Payload[1] = mlbSpeed; //ClockConfig
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
uint16_t mlbPortHandle = 0xFFFF;
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 2;
if (success)
mlbPortHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnOpenMlbV3(device, success, Request.TargetAddress, mlbPortHandle);
}
};
class CV3_UsbSocketCreate : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
EPDataType_t epType;
EPDirection_t epDir;
uint8_t endPointAddress;
uint16_t packetsPerFrame;
uint32_t tag;
public:
CV3_UsbSocketCreate(CNetworkDevice *d, uint16_t nodeAddress, EPDataType_t ept,
EPDirection_t epd, uint8_t epa, uint16_t p, uint32_t t) : device(d), epType(ept),
epDir(epd), endPointAddress(epa), packetsPerFrame(p), tag(t)
{
ElementName = "CV3_UsbSocketCreate";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x671;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 7;
Request.Payload[0] = 0x12; // HB: UsbPortHandle
Request.Payload[1] = 0x00; // LB: UsbPortHandle
Request.Payload[2] = epDir; // Direction
Request.Payload[3] = epType; // DataType
Request.Payload[4] = endPointAddress; // EndpointAddress
Request.Payload[5] = packetsPerFrame / 256; // HB: Packets per USB frame
Request.Payload[6] = packetsPerFrame % 256; // LB: Packets per USB frame
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
uint16_t usbHandle = 0xFFFF;
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 2;
if (success)
usbHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateUsbSocketV3(device, success,
Request.TargetAddress, epType, epDir, endPointAddress, usbHandle, tag);
}
};
class CV3_SplittedUsbSocketCreate : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
EPDataType_t epType;
EPDirection_t epDir;
uint8_t endPointAddress;
uint16_t packetsPerUsbFrame;
uint16_t bytesPerPacket;
uint32_t tag;
uint16_t usbHandle;
public:
CV3_SplittedUsbSocketCreate(CNetworkDevice *d, uint16_t nodeAddress, EPDataType_t ept,
EPDirection_t epd, uint8_t epa, uint16_t p, uint16_t bp, uint32_t t) : device(d), epType(ept),
epDir(epd), endPointAddress(epa), packetsPerUsbFrame(p), bytesPerPacket(bp), tag(t),
usbHandle(0xFFFF)
{
ElementName = "CV3_SplittedUsbSocketCreate-USB";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x671;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 7;
Request.Payload[0] = 0x12; // HB: UsbPortHandle
Request.Payload[1] = 0x00; // LB: UsbPortHandle
Request.Payload[2] = epDir; // Direction
Request.Payload[3] = epType; // DataType
Request.Payload[4] = endPointAddress; // EndpointAddress
Request.Payload[5] = packetsPerUsbFrame / 256; // HB: Packets per USB frame
Request.Payload[6] = packetsPerUsbFrame % 256; // LB: Packets per USB frame
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 2;
if (!success)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateSplittedUsbSocketV3(device, false,
Request.TargetAddress, epType, epDir, endPointAddress, 0xFFFF, 0xFFFF, tag);
return;
}
if (0x671 == Response.Func)
{
usbHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
CreateSplitter(iStack);
}
else
{
uint16_t splitterHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateSplittedUsbSocketV3(device, success,
Request.TargetAddress, epType, epDir, endPointAddress, usbHandle, splitterHandle, tag);
}
}
private:
void CreateSplitter(CIndustrialStack *iStack)
{
assert(usbHandle != 0xFFFF);
ElementName = "CV3_SplittedUsbSocketCreate-Splitter";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
startTime = 0;
Request.FBlock = 0x0;
if( EPDIR_IN == epDir )
Request.Func = 0x911; //SplitterCreate
else
Request.Func = 0x901; //CombinerCreate
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 6;
Request.Payload[0] = usbHandle / 256; // HB: SocketHandle IN/OUT
Request.Payload[1] = usbHandle % 256; // LB: SocketHandle IN/OUT
Request.Payload[2] = 0x0D; // HB: MOSTPortHandle
Request.Payload[3] = 0x00; // LB: MOSTPortHandle
Request.Payload[4] = bytesPerPacket / 256; // HB: BytesPerFrame
Request.Payload[5] = bytesPerPacket % 256; // LB: BytesPerFrame
iStack->EnqueueElement(Request.TargetAddress, this);
}
};
class CV3_MlbSocketCreate : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
uint16_t mlbPortHandle;
EPDataType_t epType;
EPDirection_t epDir;
uint8_t mlbChannelAddress;
uint16_t blockWidthMlb;
uint32_t tag;
public:
CV3_MlbSocketCreate(CNetworkDevice *d, uint16_t nodeAddress, uint16_t mlb, EPDataType_t ept,
EPDirection_t epd, uint8_t eca, uint16_t bw, uint32_t t) : device(d), mlbPortHandle(mlb),
epType(ept), epDir(epd), mlbChannelAddress(eca), blockWidthMlb(bw), tag(t)
{
ElementName = "CV3_MlbSocketCreate";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x631;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 8;
Request.Payload[0] = mlbPortHandle / 256;
Request.Payload[1] = mlbPortHandle % 256;
Request.Payload[2] = epDir;
Request.Payload[3] = epType;
Request.Payload[4] = blockWidthMlb / 256;
Request.Payload[5] = blockWidthMlb % 256;
Request.Payload[6] = mlbChannelAddress / 256;
Request.Payload[7] = mlbChannelAddress % 256;
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
uint16_t mlbHandle = 0xFFFF;
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 2;
if (success)
mlbHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateMlbSocketV3(device, success,
Request.TargetAddress, epType, epDir, blockWidthMlb, mlbChannelAddress, mlbHandle, tag);
}
};
class CV3_SplittedMlbSocketCreate : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
uint16_t mlbPortHandle;
EPDataType_t epType;
EPDirection_t epDir;
uint8_t mlbChannelAddress;
uint16_t blockWidthMlb;
uint16_t bytesPerPacket;
uint16_t mlbHandle;
uint32_t tag;
public:
CV3_SplittedMlbSocketCreate(CNetworkDevice *d, uint16_t nodeAddress, uint16_t mlb, EPDataType_t ept,
EPDirection_t epd, uint8_t eca, uint16_t bw, uint16_t bp, uint32_t t) : device(d), mlbPortHandle(mlb),
epType(ept), epDir(epd), mlbChannelAddress(eca), blockWidthMlb(bw), bytesPerPacket(bp), tag(t)
{
ElementName = "CV3_SplittedMlbSocketCreate-MLB";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x631;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 8;
Request.Payload[0] = mlbPortHandle / 256;
Request.Payload[1] = mlbPortHandle % 256;
Request.Payload[2] = epDir;
Request.Payload[3] = epType;
Request.Payload[4] = blockWidthMlb / 256;
Request.Payload[5] = blockWidthMlb % 256;
Request.Payload[6] = mlbChannelAddress / 256;
Request.Payload[7] = mlbChannelAddress % 256;
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 2;
if (!success)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateSplittedMlbSocketV3(device, false,
Request.TargetAddress, epType, epDir, blockWidthMlb, mlbChannelAddress,
0xFFFF, 0xFFFF, tag);
return;
}
if (0x631 == Response.Func)
{
mlbHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
CreateSplitter(iStack);
}
else
{
uint16_t splitterHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateSplittedMlbSocketV3(device, success,
Request.TargetAddress, epType, epDir, blockWidthMlb, mlbChannelAddress,
mlbHandle, splitterHandle, tag);
}
}
private:
void CreateSplitter(CIndustrialStack *iStack)
{
assert(mlbHandle != 0xFFFF);
ElementName = "CV3_SplittedMlbSocketCreate-Splitter";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
startTime = 0;
Request.FBlock = 0x0;
if( EPDIR_IN == epDir )
Request.Func = 0x911; //SplitterCreate
else
Request.Func = 0x901; //CombinerCreate
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 6;
Request.Payload[0] = mlbHandle / 256; // HB: SocketHandle IN/OUT
Request.Payload[1] = mlbHandle % 256; // LB: SocketHandle IN/OUT
Request.Payload[2] = 0x0D; // HB: MOSTPortHandle
Request.Payload[3] = 0x00; // LB: MOSTPortHandle
Request.Payload[4] = bytesPerPacket / 256; // HB: BytesPerFrame
Request.Payload[5] = bytesPerPacket % 256; // LB: BytesPerFrame
iStack->EnqueueElement(Request.TargetAddress, this);
}
};
class CV3_MostSocketCreate : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
uint16_t nodeAddress;
EPDataType_t epType;
EPDirection_t epDir;
uint16_t connectionLabel;
uint16_t blockwidthMost;
uint32_t tag;
public:
CV3_MostSocketCreate(CNetworkDevice *d, uint16_t nodeAddress, EPDataType_t ep, EPDirection_t epd,
uint16_t cl, uint16_t bw, uint32_t t) : device(d), epType(ep),
epDir(epd), connectionLabel(cl), blockwidthMost(bw), tag(t)
{
ElementName = "CV3_MostSocketCreate";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x611;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 8;
Request.Payload[0] = 0x0D; // HB: MostPortHandle
Request.Payload[1] = 0x00; // LB: MostPortHandle
Request.Payload[2] = epDir; // Dir
Request.Payload[3] = epType; // DataType
Request.Payload[4] = blockwidthMost / 256; // HB: bandwidth
Request.Payload[5] = blockwidthMost % 256; // LB: bandwidth
Request.Payload[6] = connectionLabel / 256; // HB: ConnectionLabel
Request.Payload[7] = connectionLabel % 256; // LB: ConnectionLabel
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
uint16_t conHandle = 0xFFFF;
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 4;
if (success)
conHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
if (success && SCM_OUT == epDir && Response.PayloadLen >= 4)
connectionLabel = ( Response.Payload[2] << 8 ) | Response.Payload[3];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateMostSocketV3(device, success,
Request.TargetAddress, epType, epDir, blockwidthMost, connectionLabel, conHandle, tag);
}
};
class CV3_ConnectSockets : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
uint16_t nodeAddress;
EPDataType_t epType;
uint16_t inHandle;
uint16_t outHandle;
uint16_t offset;
uint32_t tag;
public:
CV3_ConnectSockets(CNetworkDevice *d, uint16_t nodeAddress, EPDataType_t ep, uint16_t iH,
uint16_t oH, uint16_t o, uint32_t t) : device(d), epType(ep), inHandle(iH),
outHandle(oH), offset(o), tag(t)
{
ElementName = "CV3_ConnectSockets";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
switch( epType )
{
case EP_Isochron:
Request.Func = 0x861; //AVPCreate
Request.PayloadLen = 6;
Request.Payload[0] = inHandle / 256; // HB: in handle (will be filled by decomposerHandleIn)
Request.Payload[1] = inHandle % 256; // LB: in handle (will be filled by decomposerHandleIn)
Request.Payload[2] = outHandle / 256; // HB: out handle (will be filled by decomposerHandleOut)
Request.Payload[3] = outHandle % 256; // LB: out handle (will be filled by decomposerHandleOut)
Request.Payload[4] = 0x00; // HB: IsoPacketSize
Request.Payload[5] = 188; // LB: IsoPacketSize
break;
case EP_Synchron:
Request.Func = 0x871; // SyncCreate
Request.PayloadLen = 8;
Request.Payload[0] = inHandle / 256; // HB: in handle (will be filled by decomposerHandleIn)
Request.Payload[1] = inHandle % 256; // LB: in handle (will be filled by decomposerHandleIn)
Request.Payload[2] = outHandle / 256; // HB: out handle (will be filled by decomposerHandleOut)
Request.Payload[3] = outHandle % 256; // LB: out handle (will be filled by decomposerHandleOut)
Request.Payload[4] = 0x00; // 0: not muted by default; 1: muted by default
Request.Payload[5] = 0x00; // 0: NoMuting, 1:MuteSignal, 2:AutoMute
Request.Payload[6] = offset / 256; // HB: Offset
Request.Payload[7] = offset % 256; // LB: Offset
break;
default:
WaitForResponse = false;
ConsolePrintf( PRIO_ERROR, RED"CV3_ConnectSockets: Unsupported Data type"RESETCOLOR"\n" );
return;
}
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
assert(this == element);
uint16_t conHandle = 0xFFFF;
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 2;
if (success)
conHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnConnectSocketsV3(device, success,
Request.TargetAddress, epType, inHandle, outHandle, conHandle, tag);
}
};
class CV3_ResourceDestroy : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
uint16_t nodeAddress;
uint8_t amountOfHandles;
uint32_t tag;
public:
CV3_ResourceDestroy(CNetworkDevice *d, int16_t nodeAddress,
uint8_t amount, const uint16_t *pHandle, uint32_t t) : device(d),
amountOfHandles(amount), tag(t)
{
ElementName = "CV3_ResourceDestroy";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x800;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
uint8_t index = 0;
Request.Payload[index++] = 0x00; // HB: SenderHandle
Request.Payload[index++] = 0x00; // LB: SenderHandle
for( uint8_t i = 0; i < amountOfHandles; i++ )
{
Request.Payload[index++] = pHandle[i] / 256; // HB: handle
Request.Payload[index++] = pHandle[i] % 256; // LB: handle
}
Request.PayloadLen = index;
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnResourceDestroyV3(device, true,
Request.TargetAddress, amountOfHandles, ( uint16_t * )&Request.Payload[2], tag);
}
};
class CV3_StreamPortConfig : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
uint8_t portInstance;
V3I2SPortOption_t option;
V3I2SClockMode_t mode;
V3I2SDelayMode_t delay;
uint32_t tag;
public:
CV3_StreamPortConfig(CNetworkDevice *d, uint16_t nodeAddress, uint8_t port,
V3I2SPortOption_t opt, V3I2SClockMode_t md, V3I2SDelayMode_t del, uint32_t t)
: device(d), portInstance(port), option(opt), mode(md), delay(del), tag(t)
{
ElementName = "CV3_StreamPortConfig";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x680;
Request.Inst = 0x00;
Request.OpType = CISOpType_SETGET;
Request.PayloadLen = 5;
Request.Payload[0] = portInstance;
Request.Payload[1] = 0x00; //Fixed operation mode 0 = Generic
Request.Payload[2] = option;
Request.Payload[3] = mode;
Request.Payload[4] = delay;
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnConfigureI2SPortV3(device, (ISReturn_Success == result),
Request.TargetAddress, portInstance, option, mode, delay, tag);
}
};
class CV3_StreamPortCreate : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
uint8_t portInstance;
V3I2SPortSpeed_t clock;
V3I2SAlignment_t align;
uint32_t tag;
public:
CV3_StreamPortCreate(CNetworkDevice *d, uint16_t nodeAddress, uint8_t port,
V3I2SPortSpeed_t cl, V3I2SAlignment_t al, uint32_t t)
: device(d), portInstance(port), clock(cl), align(al), tag(t)
{
ElementName = "CV3_StreamPortCreate";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x681;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 3;
Request.Payload[0] = portInstance;
Request.Payload[1] = clock;
Request.Payload[2] = align;
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateI2SPortV3(device, (ISReturn_Success == result),
Request.TargetAddress, portInstance, clock, align, tag);
}
};
class CV3_StreamSocketCreate : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
uint8_t portInstance;
EPDirection_t epDir;
uint16_t blockWidthI2S;
V3I2SPin_t pin;
uint32_t tag;
public:
CV3_StreamSocketCreate(CNetworkDevice *d, uint16_t nodeAddress, uint8_t pi, EPDirection_t epd,
uint16_t bw, V3I2SPin_t p, uint32_t t) : device(d), portInstance(pi),
epDir(epd), blockWidthI2S(bw), pin(p), tag(t)
{
ElementName = "CV3_StreamSocketCreate";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x691;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 7;
Request.Payload[0] = 0x16; //Fixed port handle for I2S
Request.Payload[1] = portInstance; //dynamic port handle for I2S (Port A or B)
Request.Payload[2] = epDir;
Request.Payload[3] = 0x00; //Data type (fixed 0 for sync)
Request.Payload[4] = blockWidthI2S / 256;
Request.Payload[5] = blockWidthI2S % 256;
Request.Payload[6] = pin;
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
uint16_t i2sHandle = 0xFFFF;
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 2;
if (success)
i2sHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateI2SSocketV3(device, success,
Request.TargetAddress, portInstance, epDir, blockWidthI2S, pin, i2sHandle, tag);
}
};
class CV3_SplittedStreamSocketCreate : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
uint8_t portInstance;
EPDirection_t epDir;
uint16_t blockWidthI2S;
V3I2SPin_t pin;
uint16_t bytesPerPacket;
uint32_t tag;
uint16_t i2sHandle;
public:
CV3_SplittedStreamSocketCreate(CNetworkDevice *d, uint16_t nodeAddress, uint8_t pi,
EPDirection_t epd, uint16_t bw, V3I2SPin_t p, uint16_t bp, uint32_t t) : device(d),
portInstance(pi), epDir(epd), blockWidthI2S(bw), pin(p), bytesPerPacket(bp), tag(t),
i2sHandle(0xFFFF)
{
ElementName = "CV3_SplittedStreamSocketCreate-Stream";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x691;
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 7;
Request.Payload[0] = 0x16; //Fixed port handle for I2S
Request.Payload[1] = portInstance; //dynamic port handle for I2S (Port A or B)
Request.Payload[2] = epDir;
Request.Payload[3] = 0x00; //Data type (fixed 0 for sync)
Request.Payload[4] = blockWidthI2S / 256;
Request.Payload[5] = blockWidthI2S % 256;
Request.Payload[6] = pin;
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 2;
if (!success)
{
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateSplittedI2SSocketV3(device, false,
Request.TargetAddress, portInstance, epDir, blockWidthI2S, pin,
0xFFFF, 0xFFFF, tag);
return;
}
if (0x691 == Response.Func)
{
i2sHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
CreateSplitter(iStack);
}
else
{
uint16_t splitterHandle = ( Response.Payload[0] << 8 ) | Response.Payload[1];
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnCreateSplittedI2SSocketV3(device, success,
Request.TargetAddress, portInstance, epDir, blockWidthI2S, pin,
i2sHandle, splitterHandle, tag);
}
}
private:
void CreateSplitter(CIndustrialStack *iStack)
{
assert(i2sHandle != 0xFFFF);
ElementName = "CV3_SplittedStreamSocketCreate-Splitter";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_RESULT;
Callback = this;
startTime = 0;
Request.FBlock = 0x0;
if( EPDIR_IN == epDir )
Request.Func = 0x911; //SplitterCreate
else
Request.Func = 0x901; //CombinerCreate
Request.Inst = 0x00;
Request.OpType = CISOpType_STARTRESULT;
Request.PayloadLen = 6;
Request.Payload[0] = i2sHandle / 256; // HB: SocketHandle IN/OUT
Request.Payload[1] = i2sHandle % 256; // LB: SocketHandle IN/OUT
Request.Payload[2] = 0x0D; // HB: MOSTPortHandle
Request.Payload[3] = 0x00; // LB: MOSTPortHandle
Request.Payload[4] = bytesPerPacket / 256; // HB: BytesPerFrame
Request.Payload[5] = bytesPerPacket % 256; // LB: BytesPerFrame
iStack->EnqueueElement(Request.TargetAddress, this);
}
};
class CV3_GetRbdResult : public CISSendMostMsgElement
{
public:
CV3_GetRbdResult(uint16_t nodeAddress)
{
ElementName = "CV3_GetRbdResult";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_STATUS;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Func = 0x527;
Request.Inst = 0x00;
Request.OpType = CISOpType_GET;
Request.PayloadLen = 0;
}
};
class CV3_DeviceVersion : public CISSendMostMsgElement, public IISElementCallback
{
private:
CNetworkDevice *device;
uint16_t nodeAddress;
EPDataType_t epType;
uint16_t inHandle;
uint16_t outHandle;
uint16_t offset;
uint32_t tag;
public:
CV3_DeviceVersion(CNetworkDevice *d, uint16_t nodeAddress, uint32_t t) : device(d), tag(t)
{
ElementName = "CV3_DeviceVersion";
WaitForResponse = true;
WaitForResponseOpType = CISOpType_STATUS;
Callback = this;
Request.IsValid = true;
Request.SourceAddress = 0x2;
Request.TargetAddress = nodeAddress;
Request.FBlock = 0x0;
Request.Inst = 0x00;
Request.Func = 0x221;
Request.OpType = CISOpType_GET;
Request.PayloadLen = 0;
}
virtual void ElementProcessed(CIndustrialStack *iStack, ISReturn_t result, IISElement *element)
{
assert(this == element);
bool success = (ISReturn_Success == result) && Response.PayloadLen >= 13;
uint32_t productId = 0xFFFFFFFF;
uint32_t fwVersion = 0xFFFFFFFF;
uint32_t buildVersion = 0xFFFFFFFF;
uint8_t hwVersion = 0xFF;
uint16_t diagnosisId = 0xFFFF;
if (success)
{
productId = ( Response.Payload[0] << 24 )
| ( Response.Payload[1] << 16 )
| ( Response.Payload[2] << 8 )
| Response.Payload[3];
fwVersion = ( Response.Payload[4] << 24 )
| ( Response.Payload[5] << 16 )
| ( Response.Payload[6] << 8 );
buildVersion = ( Response.Payload[7] << 24 )
| ( Response.Payload[8] << 16 )
| ( Response.Payload[9] << 8 )
| Response.Payload[10];
hwVersion = Response.Payload[10];
diagnosisId = ( Response.Payload[11] << 8 )
| Response.Payload[12];
}
for( uint32_t i = 0; NULL != device && i < device->GetAmountOfListners(); i++ )
device->GetListener( i )->OnDeviceVersion(device, success, Response.SourceAddress,
productId, fwVersion, buildVersion, hwVersion, diagnosisId, tag);
}
};
#endif //INDUSTRIAL_STACK_API_V3_H
|