/
LeCroyOscilloscope.cpp
5469 lines (4707 loc) · 150 KB
/
LeCroyOscilloscope.cpp
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
/***********************************************************************************************************************
* *
* libscopehal *
* *
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/
#include "scopehal.h"
#include "LeCroyOscilloscope.h"
#include "base64.h"
#include "CDR8B10BTrigger.h"
#include "CDRNRZPatternTrigger.h"
#include "DropoutTrigger.h"
#include "EdgeTrigger.h"
#include "GlitchTrigger.h"
#include "PulseWidthTrigger.h"
#include "RuntTrigger.h"
#include "SlewRateTrigger.h"
#include "UartTrigger.h"
#include "WindowTrigger.h"
#include <cinttypes>
#include <locale>
#include <omp.h>
using namespace std;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction
LeCroyOscilloscope::LeCroyOscilloscope(SCPITransport* transport)
: SCPIDevice(transport)
, SCPIInstrument(transport)
, m_hasLA(false)
, m_hasDVM(false)
, m_hasFunctionGen(false)
, m_hasFastSampleRate(false)
, m_memoryDepthOption(0)
, m_hasI2cTrigger(false)
, m_hasSpiTrigger(false)
, m_hasUartTrigger(false)
, m_has8b10bTrigger(false)
, m_hasNrzTrigger(false)
, m_hasXdev(false)
, m_maxBandwidth(10000)
, m_triggerArmed(false)
, m_triggerReallyArmed(false)
, m_triggerOneShot(false)
, m_sampleRateValid(false)
, m_sampleRate(1)
, m_memoryDepthValid(false)
, m_memoryDepth(1)
, m_triggerOffsetValid(false)
, m_triggerOffset(0)
, m_interleaving(false)
, m_interleavingValid(false)
, m_meterMode(Multimeter::DC_VOLTAGE)
, m_meterModeValid(false)
, m_highDefinition(false)
{
//standard initialization
FlushConfigCache();
IdentifyHardware();
DetectAnalogChannels();
SharedCtorInit();
DetectOptions();
}
void LeCroyOscilloscope::SharedCtorInit()
{
m_digitalChannelCount = 0;
//Add the external trigger input
m_extTrigChannel = new OscilloscopeChannel(
this,
"Ext",
"#808080",
Unit(Unit::UNIT_FS),
Unit(Unit::UNIT_VOLTS),
Stream::STREAM_TYPE_TRIGGER,
m_channels.size());
m_channels.push_back(m_extTrigChannel);
//Add dummy channels for AC line and internal fast edge source
m_acLineChannel = new OscilloscopeChannel(
this,
"Line",
"#808080",
Unit(Unit::UNIT_FS),
Unit(Unit::UNIT_VOLTS),
Stream::STREAM_TYPE_TRIGGER,
m_channels.size());
m_acLineChannel->SetDisplayName("ACLine");
m_channels.push_back(m_acLineChannel);
m_fastEdgeChannel = new OscilloscopeChannel(
this,
"FastEdge",
"#808080",
Unit(Unit::UNIT_FS),
Unit(Unit::UNIT_VOLTS),
Stream::STREAM_TYPE_TRIGGER,
m_channels.size());
m_channels.push_back(m_fastEdgeChannel);
//Desired format for waveform data
//Only use increased bit depth if the scope actually puts content there!
if(m_highDefinition)
m_transport->SendCommandQueued("COMM_FORMAT DEF9,WORD,BIN");
else
m_transport->SendCommandQueued("COMM_FORMAT DEF9,BYTE,BIN");
//Always use "fixed sample rate" config for setting timebase
if(m_modelid != MODEL_WAVESURFER_3K)
m_transport->SendCommandQueued("VBS 'app.Acquisition.Horizontal.Maximize=\"FixedSampleRate\"'");
//If interleaving, disable the extra channels
if(IsInterleaving())
{
m_channelsEnabled[0] = false;
m_channelsEnabled[3] = false;
}
//Clear the state-change register to we get rid of any history we don't care about
PollTrigger();
}
void LeCroyOscilloscope::IdentifyHardware()
{
//Turn off headers (complicate parsing and add fluff to the packets)
m_transport->SendCommandQueued("CHDR OFF");
//Ask for the ID
string reply = m_transport->SendCommandQueuedWithReply("*IDN?");
char vendor[128] = "";
char model[128] = "";
char serial[128] = "";
char version[128] = "";
if(4 != sscanf(reply.c_str(), "%127[^,],%127[^,],%127[^,],%127s", vendor, model, serial, version))
{
LogError("Bad IDN response %s\n", reply.c_str());
return;
}
m_vendor = vendor;
m_model = model;
m_serial = serial;
m_fwVersion = version;
//Look up model info
m_modelid = MODEL_UNKNOWN;
m_maxBandwidth = 0;
if(m_model.find("DDA5") == 0)
{
m_modelid = MODEL_DDA_5K;
m_maxBandwidth = 5000;
}
else if( (m_model.find("HDO4") == 0) && (m_model.find("A") != string::npos) )
{
m_modelid = MODEL_HDO_4KA;
m_maxBandwidth = stoi(m_model.substr(4, 2)) * 100;
}
else if( (m_model.find("HDO6") == 0) && (m_model.find("A") != string::npos) )
{
m_modelid = MODEL_HDO_6KA;
m_maxBandwidth = stoi(m_model.substr(4, 2)) * 100;
}
else if(m_model.find("HDO9") == 0)
{
m_modelid = MODEL_HDO_9K;
m_maxBandwidth = stoi(m_model.substr(4, 1)) * 1000;
}
else if(m_model == "MCM-ZI-A")
{
m_modelid = MODEL_LABMASTER_ZI_A;
//For now assume 100 GHz bandwidth.
//TODO: ID acquisition modules
m_maxBandwidth = 100000;
}
else if(m_model.find("MDA8") == 0)
{
m_modelid = MODEL_MDA_800;
m_highDefinition = true; //Doesn't have "HD" in the name but is still 12 bit resolution
m_maxBandwidth = stoi(m_model.substr(4, 2)) * 100;
}
else if(m_model.find("SDA3") == 0)
{
m_modelid = MODEL_SDA_3K;
m_maxBandwidth = 3000;
}
else if(m_model.find("WM8") == 0)
{
if(m_model.find("ZI-B") != string::npos)
m_modelid = MODEL_WAVEMASTER_8ZI_B;
m_maxBandwidth = stoi(m_model.substr(3, 2)) * 1000;
}
else if(m_model.find("SDA8") == 0)
{
if(m_model.find("ZI-B") != string::npos)
m_modelid = MODEL_SDA_8ZI_B;
else if(m_model.find("ZI-A") != string::npos)
m_modelid = MODEL_SDA_8ZI_A;
else
m_modelid = MODEL_SDA_8ZI;
m_maxBandwidth = stoi(m_model.substr(4, 2)) * 1000;
}
else if(m_model.find("WAVERUNNER8") == 0)
{
m_modelid = MODEL_WAVERUNNER_8K;
m_maxBandwidth = stoi(m_model.substr(11, 2)) * 100;
if(m_model.find("HD") != string::npos)
m_modelid = MODEL_WAVERUNNER_8K_HD;
}
else if(m_model.find("WP") == 0)
{
if(m_model.find("HD") != string::npos)
m_modelid = MODEL_WAVEPRO_HD;
}
else if(m_model.find("WAVERUNNER9") == 0)
{
m_modelid = MODEL_WAVERUNNER_9K;
m_maxBandwidth = stoi(m_model.substr(11, 2)) * 100;
}
else if(m_model.find("WS3") == 0)
{
m_modelid = MODEL_WAVESURFER_3K;
m_maxBandwidth = stoi(m_model.substr(3, 2)) * 100;
}
else
{
LogWarning("Model \"%s\" is unknown, available sample rates/memory depths may not be properly detected\n",
m_model.c_str());
}
//Enable HD mode by default if model name contains "HD" at any point
if(m_model.find("HD") != string::npos)
m_highDefinition = true;
//300 MHz bandwidth doesn't exist on any known scope.
//It's always 350, but is normally coded in the model ID as if it were 300.
if(m_maxBandwidth == 300)
m_maxBandwidth = 350;
}
void LeCroyOscilloscope::DetectOptions()
{
LogDebug("\n");
auto reply = m_transport->SendCommandQueuedWithReply("*OPT?");
if(reply.length() > 3)
{
//Read options until we hit a null
vector<string> options;
string opt;
for(unsigned int i=0; i<reply.length(); i++)
{
if(reply[i] == 0)
{
options.push_back(opt);
break;
}
else if(reply[i] == ',')
{
options.push_back(opt);
opt = "";
}
//skip newlines
else if(reply[i] == '\n')
continue;
else
opt += reply[i];
}
if(opt != "")
options.push_back(opt);
//Print out the option list and do processing for each
LogDebug("Installed options:\n");
LogDebug(" %-20s %-25s %-35s %-20s\n", "Code", "Type", "Description", "Action");
if(options.empty())
LogDebug("* None\n");
for(auto o : options)
{
string type = "Unknown";
string desc = "Unknown";
string action = "Ignoring";
//Default types
if(o.find("_TDME") != string::npos)
type = "Trig/decode/measure/eye";
else if(o.find("_TDG") != string::npos)
type = "Trig/decode/graph";
else if(o.find("_TD") != string::npos)
type = "Trig/decode";
else if( (o.find("_D") != string::npos) || (o.find("-DECODE") != string::npos) )
type = "Protocol Decode";
//If we have an LA module installed, add the digital channels
if( (o == "MSXX") && !m_hasLA)
{
type = "Hardware";
desc = "16-channel MSO probe";
action = "Enabled";
AddDigitalChannels(16);
}
//If we have the voltmeter installed, make a note of that
else if(o == "DVM")
{
m_hasDVM = true;
type = "Hardware";
desc = "Digital multimeter";
action = "Enabled";
SetMeterAutoRange(false);
}
//If we have the function generator installed, remember that
else if(o == "AFG")
{
m_hasFunctionGen = true;
type = "Hardware";
desc = "Function generator";
action = "Enabled";
}
//Extra sample rate and memory for WaveRunner 8000
else if(o == "-M")
{
m_hasFastSampleRate = true;
m_memoryDepthOption = 128;
type = "Hardware";
desc = "Extra sample rate and memory";
action = "Enabled";
}
//Extra memory depth for WaveRunner 8000HD and WavePro HD
else if(o == "100MS")
{
m_memoryDepthOption = 100;
type = "Hardware";
desc = "100M point memory";
action = "Enabled";
}
else if(o == "200MS")
{
m_memoryDepthOption = 200;
type = "Hardware";
desc = "200M point memory";
action = "Enabled";
}
else if(o == "500MS")
{
m_memoryDepthOption = 500;
type = "Hardware";
desc = "500M point memory";
action = "Enabled";
}
else if(o == "1000MS")
{
m_memoryDepthOption = 1000;
type = "Hardware";
desc = "1000M point memory";
action = "Enabled";
}
else if(o == "2000MS")
{
m_memoryDepthOption = 2000;
type = "Hardware";
desc = "2000M point memory";
action = "Enabled";
}
else if(o == "5000MS")
{
m_memoryDepthOption = 5000;
type = "Hardware";
desc = "5000M point memory";
action = "Enabled";
}
//Memory capacity options for WaveMaster/SDA/DDA 8Zi/Zi-A/Zi-B family
else if(o == "-S")
{
type = "Hardware";
desc = "Small (32M point) memory";
m_memoryDepthOption = 32;
action = "Enabled";
}
else if(o == "-S")
{
type = "Hardware";
desc = "Medium (64M point) memory";
m_memoryDepthOption = 64;
action = "Enabled";
}
else if(o == "-L")
{
type = "Hardware";
desc = "Large (128M point) memory";
m_memoryDepthOption = 128;
action = "Enabled";
}
else if(o == "-V")
{
type = "Hardware";
desc = "Very large (256M point) memory";
m_memoryDepthOption = 256;
action = "Enabled";
}
//Print out full names for protocol trigger options and enable trigger mode.
//Note that many of these options don't have _TD in the base (non-TDME) option code!
else if(o.find("I2C") == 0)
{
m_hasI2cTrigger = true;
desc = "I2C"; //seems like UTF-8 characters mess up printf width specifiers
action = "Enabling trigger";
if(o == "I2C")
type = "Trig/decode";
}
else if(o.find("SPI") == 0)
{
m_hasSpiTrigger = true;
desc = "SPI";
action = "Enabling trigger";
if(o == "SPI")
type = "Trig/decode";
}
else if(o.find("UART") == 0)
{
m_hasUartTrigger = true;
desc = "UART";
action = "Enabling trigger";
if(o == "UART")
type = "Trig/decode";
}
else if(o.find("SMBUS") == 0)
{
m_hasI2cTrigger = true;
desc = "SMBus";
//TODO: enable any SMBus specific stuff
if(o == "SMBUS")
type = "Trig/decode";
}
//High speed serial trigger
else if(o == "SERIALPAT_T")
{
type = "Trigger";
desc = "Serial Pattern (8b10b/64b66b/NRZ)";
action = "Enabling trigger";
m_has8b10bTrigger = true;
m_hasNrzTrigger = true;
}
//Currently unsupported protocol decode with trigger capability, but no _TD in the option code
//Print out names but ignore for now
else if(o.find("FLX") == 0)
{
type = "Trig/decode";
desc = "FlexRay";
}
else if(o.find("LIN") == 0)
{
type = "Trig/decode";
desc = "LIN";
}
else if(o.find("MIL1553") == 0)
{
type = "Trig/decode";
desc = "MIL-STD-1553";
}
//Decode only, not a trigger.
//Has to be before USB2 to match properly.
else if(o == "USB2-HSIC-BUS")
{
type = "Protocol Decode";
desc = "USB2 HSIC";
}
//What is DECODE_MEASURE? (with no protocol name)
//Currently unsupported trigger/decodes, to be added in the future
else if(o.find("CAN_FD") == 0) //CAN_FD_TD, CAN_FD_TDM, CAN_FD_TD_SYMB
desc = "CAN FD";
else if(o.find("FIBER_CH") == 0)
desc = "Fibre Channel";
else if(o.find("I2S") == 0)
desc = "I2S";
else if(o.find("I3C") == 0)
desc = "I3C";
else if(o.find("SENT") == 0)
desc = "SENT";
else if(o.find("SPMI") == 0)
desc = "SPMI";
else if(o.find("USB2") == 0)
desc = "USB2";
else if(o.find("USB3") == 0)
desc = "USB3";
else if(o.find("SATA") == 0)
desc = "Serial ATA";
else if(o.find("SAS") == 0)
desc = "Serial Attached SCSI";
else if(o == "HDTV")
{
type = "Trigger"; //FIXME: Is this just 1080p analog trigger support?
desc = "HD analog TV";
}
//QualiPHY
else if(o.find("QPHY-") == 0)
{
type = "Protocol Compliance";
desc = "QualiPHY";
}
else if(o == "HDMI")
{
type = "Protocol Compliance";
desc = "HDMI";
}
//Protocol decodes without trigger capability
//Print out name but otherwise ignore
else if(o == "10-100M-ENET-BUS")
{
type = "Protocol Decode";
desc = "10/100 Ethernet";
}
else if(o == "ENET")
{
type = "Protocol Decode";
desc = "Ethernet"; //TODO: What speed?
}
else if(o == "ENET100G")
{
type = "Protocol Decode";
desc = "100G Ethernet";
}
else if(o == "10G-ENET-BUS")
{
type = "Protocol Decode";
desc = "10G Ethernet";
}
else if(o == "8B10B-BUS")
{
type = "Protocol Decode";
desc = "8B/10B";
}
else if(o == "64B66B-BUS")
{
type = "Protocol Decode";
desc = "64B/66B";
}
else if(
(o == "ARINC429") ||
(o == "ARINC429_DME_SYMB") )
{
type = "Protocol Decode";
desc = "ARINC 429";
}
else if(o == "AUTOENETDEBUG")
{
type = "Protocol Decode";
desc = "Automotive Ethernet";
}
else if(o == "DIGRF_3G_D")
desc = "DigRF (3G)";
else if(o == "DIGRF_V4_D")
desc = "DigRF (V4)";
else if(o == "DPHY-DECODE")
desc = "MIPI D-PHY";
else if(o == "ET")
{
type = "Protocol Decode";
desc = "Electrical Telecom";
}
else if(o == "MANCHESTER-BUS")
{
type = "Protocol Decode";
desc = "Manchester";
}
else if(o == "MDIO")
{
type = "Protocol Decode";
desc = "Ethernet MDIO";
}
else if(o == "MPHY-DECODE")
desc = "MIPI M-PHY";
else if(o == "PCIE")
{
desc = "PCIe";
type = "Protocol Decode"; //TODO: What's difference between PCIE and PCIE_D
}
else if(o == "PCIE_D")
{
desc = "PCIe";
type = "Protocol Decode";
}
else if( (o == "SAS") || (o == "SAS_TD" ) )
{
desc = "Serial Attached SCSI";
type = "Protocol Decode"; //TODO: What's difference between SAS and SAS_TD
}
else if(o == "SPACEWIRE")
{
type = "Protocol Decode";
desc = "SpaceWire";
}
else if(o == "NRZ-BUS")
{
desc = "NRZ";
type = "Protocol Decode";
}
else if(o == "UNIPRO-DECODE")
desc = "UniPro";
//Miscellaneous software option
//Print out name but otherwise ignore
else if(o == "CBL_DBED")
{
type = "Math";
desc = "Cable De-Embedding";
}
else if(o == "DDA")
{
type = "Protocol Decode";
desc = "Disk Drive Analysis";
}
else if(o == "DDM2")
{
type = "Math";
desc = "Disk Drive Measurement";
}
else if(o == "DDR2DEBUG")
{
type = "Signal Integrity";
desc = "DDR2 Debug";
}
else if(o == "DDR3DEBUG")
{
type = "Signal Integrity";
desc = "DDR3 Debug";
}
else if(o == "DDR4DEBUG")
{
type = "Signal Integrity";
desc = "DDR4 Debug";
}
else if(o == "DPHY-PHY")
{
type = "Signal Integrity";
desc = "MIPI D-PHY";
}
else if(o == "MPHY-PHY")
{
type = "Signal Integrity";
desc = "MIPI M-PHY";
}
else if(o == "EYEDR2")
{
type = "Signal Integrity";
desc = "Eye Doctor";
}
else if(o == "EYEDR_EQ")
{
type = "Signal Integrity";
desc = "Eye Doctor Equalization";
}
else if(o == "EYEDR_VP")
{
type = "Signal Integrity";
desc = "Eye Doctor Virtual Probe";
}
else if(o == "VPROBE")
{
type = "Signal Integrity";
desc = "Virtual Probe";
}
else if(o == "XTALK")
{
type = "Signal Integrity";
desc = "Crosstalk Analysis";
}
else if(o == "DFP2")
{
type = "Math";
desc = "DSP Filter";
}
else if(o == "DIGPWRMGMT")
{
type = "Miscellaneous";
desc = "Power Management";
}
else if(o == "EMC")
{
type = "Miscellaneous";
desc = "EMC Pulse Analysis";
}
else if( (o == "JITKIT") || (o == "JTA2") )
{
type = "Miscellaneous";
desc = "Jitter/Timing Analysis";
}
else if(o == "PWR_ANALYSIS")
{
type = "Miscellaneous";
desc = "Power Analysis";
}
else if( (o == "SDA") || (o == "SDA2") || (o == "SDA3") || (o == "SDA3-LINQ") || (o == "ASDA") )
{
type = "Signal Integrity";
desc = "Serial Data Analysis";
}
else if( (o == "THREEPHASEHARMONICS") || (o == "THREEPHASEPOWER") )
{
type = "Miscellaneous";
desc = "3-Phase Power Analysis";
}
else if(o == "AORM")
{
type = "Measurement";
desc = "Advanced Optical Recording Measurements";
}
else if(o == "PMA2")
{
type = "Miscellaneous";
desc = "PowerMeasure Analysis";
}
else if(o == "CROSS-SYNC-PHY")
{
type = "Miscellaneous";
desc = "Protocol analyzer cross-trigger";
}
//UI etc options
else if(o == "SPECTRUM")
{
type = "Math";
desc = "Spectrum analyzer";
}
else if(o == "XWEB")
{
type = "UI";
desc = "Processing web";
}
else if(o == "QSCAPE")
{
type = "UI";
desc = "Tabbed display";
}
else if(o == "XDEV")
{
type = "SDK";
desc = "Software development kit";
action = "FastWavePort waveform download available";
m_hasXdev = true;
}
//Ignore meta-options
else if(o == "DEMO-BUNDLE")
{
type = "Informational";
desc = "Software licenses are demo/trial";
}
else if(o == "DEMOSCOPE")
{
type = "Informational";
desc = "Scope is a demo unit";
}
else if(o == "SIM")
{
type = "Informational";
desc = "Instrument is a simulation";
}
LogDebug("* %-20s %-25s %-35s %-20s\n", o.c_str(), type.c_str(), desc.c_str(), action.c_str());
}
}
//If we don't have a code for the LA software option, but are a -MS scope, add the LA
if(!m_hasLA && (m_model.find("-MS") != string::npos))
AddDigitalChannels(16);
if(m_hasFunctionGen)
{
m_awgChannel = new FunctionGeneratorChannel(this, "AWG", "#808080", m_channels.size());
m_channels.push_back(m_awgChannel);
}
else
m_awgChannel = nullptr;
LogDebug("\n");
}
/**
@brief Creates digital channels for the oscilloscope
*/
void LeCroyOscilloscope::AddDigitalChannels(unsigned int count)
{
m_hasLA = true;
LogIndenter li;
m_digitalChannelCount = count;
m_digitalChannelBase = m_channels.size();
char chn[32];
for(unsigned int i=0; i<count; i++)
{
snprintf(chn, sizeof(chn), "D%u", i);
auto chan = new OscilloscopeChannel(
this,
chn,
GetDefaultChannelColor(m_channels.size()),
Unit(Unit::UNIT_FS),
Unit(Unit::UNIT_COUNTS),
Stream::STREAM_TYPE_DIGITAL,
m_channels.size());
m_channels.push_back(chan);
m_digitalChannels.push_back(chan);
}
//Set the threshold to "user defined" vs using a canned family
m_transport->SendCommandQueued("VBS? 'app.LogicAnalyzer.MSxxLogicFamily0 = \"USERDEFINED\" '");
m_transport->SendCommandQueued("VBS? 'app.LogicAnalyzer.MSxxLogicFamily1 = \"USERDEFINED\" '");
//Select display to be "CUSTOM" so we can assign nicknames to the bits
m_transport->SendCommandQueued("VBS 'app.LogicAnalyzer.Digital1.Labels=\"CUSTOM\"'");
}
/**
@brief Figures out how many analog channels we have, and add them to the device
If you're lucky, the last digit of the model number will be the number of channels (HDO9204)
But, since we can't have nice things, theres are plenty of exceptions. Known formats so far:
* WAVERUNNER8104-MS has 4 channels (plus 16 digital)
* DDA5005 / DDA5005A have 4 channels
* SDA3010 have 4 channels
* SDA8xxZi have 4 channels
* LabMaster just calls itself "MCM-Zi-A" and there's no information on the number of modules!
*/
void LeCroyOscilloscope::DetectAnalogChannels()
{
int nchans = 1;
switch(m_modelid)
{
//DDA5005 and similar have 4 channels despite a model number ending in 5
//SDA3010 have 4 channels despite a model number ending in 0
case MODEL_DDA_5K:
case MODEL_SDA_3K:
nchans = 4;
break;
//All SDA / WaveMaster 8Zi have 4 channels
case MODEL_SDA_8ZI:
case MODEL_SDA_8ZI_A:
case MODEL_SDA_8ZI_B:
case MODEL_WAVEMASTER_8ZI_B:
nchans = 4;
break;
//MDA800 models all have 8 channels
case MODEL_MDA_800:
nchans = 8;
break;
//LabMaster MCM could have any number of channels.
//This is ugly and produces errors in the remote log each time we start up, but does work.
case MODEL_LABMASTER_ZI_A:
{
char tmp[128];
for(int i=1; i<80; i++)
{
snprintf(tmp, sizeof(tmp), "VBS? 'return=IsObject(app.Acquisition.C%d)'", i);
auto reply = m_transport->SendCommandQueuedWithReply(tmp);
//All good
if(Trim(reply) == "-1")
nchans = i;
//Anything else is probably an error:
//Object doesn't support this property or method: 'app.Acquisition.C5'
else
break;
}
}
break;
//General model format is family, number, suffix. Not all are always present.
default:
{
//Trim off alphabetic characters from the start of the model number
size_t pos;
for(pos=0; pos < m_model.length(); pos++)
{
if(isalpha(m_model[pos]))
continue;
else if(isdigit(m_model[pos]))
break;
else
{
LogError("Unrecognized character (not alphanumeric) in model number %s\n", m_model.c_str());
return;
}
}
//Now we should be able to read the model number
int modelNum = atoi(m_model.c_str() + pos);
//Last digit of the model number is normally the number of channels (WAVESURFER3022, HDO8108)
nchans = modelNum % 10;
}
break;
}
for(int i=0; i<nchans; i++)
{
//Hardware name of the channel
string chname = string("C1");
chname[1] += i;
//Color the channels based on LeCroy's standard color sequence
//yellow-pink-cyan-green-lightgreen-purple-red-brown
//After that, for LabMaster, repeat the same colors
string color = "#ffffff";
switch(i % 8)
{
case 0:
color = "#ffff00";
break;
case 1:
color = "#ff6abc";
break;
case 2:
color = "#00ffff";
break;
case 3:
color = "#00c100";
break;
case 4:
color = "#d7ffd7";
break;
case 5:
color = "#8482ff";
break;
case 6:
color = "#ff0000";
break;
case 7:
color = "#ff8000";
break;
}
//Create the channel
m_channels.push_back(
new OscilloscopeChannel(