-
Notifications
You must be signed in to change notification settings - Fork 3
/
Sony9PinRemote.h
1169 lines (992 loc) · 43.9 KB
/
Sony9PinRemote.h
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
#ifndef HT_RS422_SONY9PINREMOTE_H
#define HT_RS422_SONY9PINREMOTE_H
#ifdef ARDUINO
#include <Arduino.h>
#endif
#include <stdint.h>
#if defined(ARDUINO) || defined(OF_VERSION_MAJOR) || defined(QT_VERSION)
#define SONY9PINREMOTE_ENABLE_STREAM
#endif
#include "Sony9PinRemote/Types.h"
#include "Sony9PinRemote/Encoder.h"
#include "Sony9PinRemote/Decoder.h"
#ifdef SONY9PINREMOTE_DEBUGLOG_ENABLE
#include <DebugLogEnable.h>
#else
#include <DebugLogDisable.h>
#endif
namespace sony9pin {
#ifdef SONY9PINREMOTE_ENABLE_STREAM
// Arduino
#ifdef ARDUINO
using StreamType = Stream;
#define SONY9PINREMOTE_STREAM_WRITE(data, size) \
if (size > 0) { \
if (b_force_send || !b_wait_for_response) { \
stream->write(data, size); \
b_wait_for_response = true; \
} \
}
#define SONY9PINREMOTE_STREAM_READ(data, size) stream->readBytes(data, size)
#define SONY9PINREMOTE_STREAM_AVAILABLE() stream->available()
#define SONY9PINREMOTE_STREAM_FLUSH() stream->flush()
#define SONY9PINREMOTE_ELAPSED_MILLIS() millis()
namespace serial {
static constexpr size_t BAUDRATE {38400};
static constexpr size_t CONFIG {SERIAL_8O1};
} // namespace serial
// openFrameworks
#elif defined(OF_VERSION_MAJOR)
using StreamType = ofSerial;
#define SONY9PINREMOTE_STREAM_WRITE(data, size) \
if (size > 0) { \
if (b_force_send || !b_wait_for_response) { \
stream->writeBytes(data, size); \
b_wait_for_response = true; \
} \
}
#define SONY9PINREMOTE_STREAM_READ(data, size) stream->readBytes(data, size)
#define SONY9PINREMOTE_STREAM_AVAILABLE() stream->available()
#define SONY9PINREMOTE_STREAM_FLUSH() stream->flush()
#define SONY9PINREMOTE_ELAPSED_MILLIS() ofGetElapsedTimeMillis()
namespace serial {
static constexpr size_t BAUDRATE {38400};
// static constexpr size_t CONFIG {SERIAL_8O1};
} // namespace serial
// Qt
#elif defined(QT_VERSION)
#include <time.h>
using StreamType = QSerialPort;
#define SONY9PINREMOTE_STREAM_WRITE(data, size) \
if (size > 0) { \
if (b_force_send || !b_wait_for_response) { \
stream->write((const char*)data, size); \
if (!stream->waitForBytesWritten()) { \
LOG_ERROR("Writing to serial FAILED"); \
} \
b_wait_for_response = true; \
} \
}
#define SONY9PINREMOTE_STREAM_READ(data, size) stream->read((char*)data, size)
#define SONY9PINREMOTE_STREAM_AVAILABLE() stream->waitForReadyRead(1) ? stream->bytesAvailable() : 0
#define SONY9PINREMOTE_STREAM_FLUSH() stream->flush()
#define SONY9PINREMOTE_ELAPSED_MILLIS() uint32_t((double)(clock()) / (CLOCKS_PER_SEC / 1000))
namespace serial {
static constexpr size_t BAUDRATE {QSerialPort::Baud38400};
// static constexpr size_t CONFIG {SERIAL_8O1};
} // namespace serial
#endif // ARDUINO / OF_VERSION_MAIJOR / QT_VERSION
// Not Supported
#else // SONY9PINREMOTE_ENABLE_STREAM
#error THIS PLATFORM IS NOT SUPPORTED
#endif // SONY9PINREMOTE_ENABLE_STREAM
class Controller {
// reference
// https://en.wikipedia.org/wiki/9-Pin_Protocol
// https://www.drastic.tv/support-59/legacysoftwarehardware/37-miscellaneous-legacy/180-vvcr-422-serial-protocol
StreamType* stream;
Encoder encoder;
Decoder decoder;
uint16_t dev_type {0xFFFF};
Status sts;
Errors err;
size_t err_count {0};
uint8_t status_start {0};
uint8_t status_size {10};
bool b_force_send {false};
bool b_wait_for_response {false};
public:
void attach(StreamType& s, const bool force_send = false) {
b_force_send = force_send;
stream = &s;
SONY9PINREMOTE_STREAM_FLUSH();
while (const size_t size = SONY9PINREMOTE_STREAM_AVAILABLE()) {
uint8_t* data = new uint8_t[size];
SONY9PINREMOTE_STREAM_READ(data, size);
delete[] data;
}
}
bool parse() {
while (const size_t size = SONY9PINREMOTE_STREAM_AVAILABLE()) {
uint8_t* data = new uint8_t[size];
SONY9PINREMOTE_STREAM_READ(data, size);
for (size_t i = 0; i < size; ++i) {
if (decoder.feed(data[i])) {
// store the data which is useful if it can be referred anytime we want
switch (decoder.cmd1()) {
case Cmd1::SYSTEM_CONTROL_RETURN: {
switch (decoder.cmd2()) {
case SystemControlReturn::NAK: {
err_count++;
err = decoder.nak();
break;
}
case SystemControlReturn::DEVICE_TYPE: {
dev_type = decoder.device_type();
break;
}
}
}
// Fallthrough
case Cmd1::SENSE_RETURN: {
if (decoder.cmd2() == SenseReturn::STATUS_DATA) {
// decode status based on requested range by `status_sense()`
sts = decoder.status_sense(status_start, status_size);
}
break;
}
default:
break;
}
b_wait_for_response = false;
delete[] data;
return true;
}
}
delete[] data;
}
return false;
}
bool parse_until(const uint32_t timeout_ms) {
const uint32_t begin_ms = SONY9PINREMOTE_ELAPSED_MILLIS();
while (true) {
if (parse())
return true;
if (SONY9PINREMOTE_ELAPSED_MILLIS() > begin_ms + timeout_ms)
return false;
}
}
bool ready() const { return b_force_send ? true : (!decoder.busy() && !b_wait_for_response); }
bool available() const { return decoder.available(); }
uint16_t device_type() const { return dev_type; }
const Status& status() const { return sts; }
const Errors& errors() const { return err; }
size_t error_count() const { return err_count; }
// =============== 0 - System Control ===============
void local_disable() {
auto packet = encoder.local_disable();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void device_type_request() {
auto packet = encoder.device_type_request();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void local_enable() {
auto packet = encoder.local_enable();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
// =============== 2 - Transport Control ===============
void stop() {
auto packet = encoder.stop();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void play() {
auto packet = encoder.play();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void record() {
auto packet = encoder.record();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void standby_off() {
auto packet = encoder.standby_off();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void standby_on() {
auto packet = encoder.standby_on();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void eject() {
auto packet = encoder.eject();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void fast_forward() {
auto packet = encoder.fast_forward();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void jog_forward(const uint8_t data1, const uint8_t data2 = 0) {
auto packet = encoder.jog_forward(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void var_forward(const uint8_t data1, const uint8_t data2 = 0) {
auto packet = encoder.var_forward(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void shuttle_forward(const uint8_t data1, const uint8_t data2 = 0) {
auto packet = encoder.shuttle_forward(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void frame_step_forward() {
auto packet = encoder.frame_step_forward();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void fast_reverse() {
auto packet = encoder.fast_reverse();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void rewind() {
auto packet = encoder.rewind();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void jog_reverse(const uint8_t data1, const uint8_t data2 = 0) {
auto packet = encoder.jog_reverse(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void var_reverse(const uint8_t data1, const uint8_t data2 = 0) {
auto packet = encoder.var_reverse(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void shuttle_reverse(const uint8_t data1, const uint8_t data2 = 0) {
auto packet = encoder.shuttle_reverse(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void frame_step_reverse() {
auto packet = encoder.frame_step_reverse();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void preroll() {
auto packet = encoder.preroll();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void cue_up_with_data(const uint8_t hh, const uint8_t mm, const uint8_t ss, const uint8_t ff) {
auto packet = encoder.cue_up_with_data(hh, mm, ss, ff);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void sync_play() {
auto packet = encoder.sync_play();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void prog_speed_play_plus(const uint8_t v) {
auto packet = encoder.prog_speed_play_plus(v);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void prog_speed_play_minus(const uint8_t v) {
auto packet = encoder.prog_speed_play_minus(v);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void preview() {
auto packet = encoder.preview();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void review() {
auto packet = encoder.review();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void auto_edit() {
auto packet = encoder.auto_edit();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void outpoint_preview() {
auto packet = encoder.outpoint_preview();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void anti_clog_timer_disable() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.anti_clog_timer_disable();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void anti_clog_timer_enable() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.anti_clog_timer_enable();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void dmc_set_fwd(const uint8_t data1, const uint8_t data2) {
auto packet = encoder.dmc_set_fwd(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void dmc_set_rev(const uint8_t data1, const uint8_t data2) {
auto packet = encoder.dmc_set_rev(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void full_ee_off() {
auto packet = encoder.full_ee_off();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void full_ee_on() {
auto packet = encoder.full_ee_on();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void select_ee_on() {
auto packet = encoder.select_ee_on();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void edit_off() {
auto packet = encoder.edit_off();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void edit_on() {
auto packet = encoder.edit_on();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void freeze_off() {
auto packet = encoder.freeze_off();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void freeze_on() {
auto packet = encoder.freeze_on();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
// =============== 4 - Preset/Select Control ===============
void timer1_preset(const uint8_t hh, const uint8_t mm, const uint8_t ss, const uint8_t ff, const bool is_df) {
auto packet = encoder.timer1_preset(hh, mm, ss, ff, is_df);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void time_code_preset(const uint8_t hh, const uint8_t mm, const uint8_t ss, const uint8_t ff, const bool is_df) {
auto packet = encoder.time_code_preset(hh, mm, ss, ff, is_df);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void user_bit_preset(const uint8_t data1, const uint8_t data2, const uint8_t data3, const uint8_t data4) {
auto packet = encoder.user_bit_preset(data1, data2, data3, data4);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void timer1_reset() {
auto packet = encoder.timer1_reset();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void in_entry() {
auto packet = encoder.in_entry();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void out_entry() {
auto packet = encoder.out_entry();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_in_entry() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.audio_in_entry();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_out_entry() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.audio_out_entry();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void in_data_preset(const uint8_t hh, const uint8_t mm, const uint8_t ss, const uint8_t ff) {
auto packet = encoder.in_data_preset(hh, mm, ss, ff);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void out_data_preset(const uint8_t hh, const uint8_t mm, const uint8_t ss, const uint8_t ff) {
auto packet = encoder.out_data_preset(hh, mm, ss, ff);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_in_data_preset() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.audio_in_data_preset();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_out_data_preset() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.audio_out_data_preset();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void in_shift_plus() {
auto packet = encoder.in_shift_plus();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void in_shift_minus() {
auto packet = encoder.in_shift_minus();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void out_shift_plus() {
auto packet = encoder.out_shift_plus();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void out_shift_minus() {
auto packet = encoder.out_shift_minus();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_in_shift_plus() {
auto packet = encoder.audio_in_shift_plus();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_in_shift_minus() {
auto packet = encoder.audio_in_shift_minus();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_out_shift_plus() {
auto packet = encoder.audio_out_shift_plus();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_out_shift_minus() {
auto packet = encoder.audio_out_shift_minus();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void in_flag_reset() {
auto packet = encoder.in_flag_reset();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void out_flag_reset() {
auto packet = encoder.out_flag_reset();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_in_flag_reset() {
auto packet = encoder.audio_in_flag_reset();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_out_flag_reset() {
auto packet = encoder.audio_out_flag_reset();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void in_recall() {
auto packet = encoder.in_recall();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void out_recall() {
auto packet = encoder.out_recall();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_in_recall() {
auto packet = encoder.audio_in_recall();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_out_recall() {
auto packet = encoder.audio_out_recall();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void lost_lock_reset() {
auto packet = encoder.lost_lock_reset();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void edit_preset(const uint8_t data1, const uint8_t data2) {
// TODO: more user-friendly arguments?
auto packet = encoder.edit_preset(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void preroll_preset(const uint8_t hh, const uint8_t mm, const uint8_t ss, const uint8_t ff) {
auto packet = encoder.preroll_preset(hh, mm, ss, ff);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void tape_audio_select(const uint8_t v) {
auto packet = encoder.tape_audio_select(v);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void servo_ref_select(const uint8_t v) {
auto packet = encoder.servo_ref_select(v);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void head_select(const uint8_t v) {
auto packet = encoder.head_select(v);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void color_frame_select(const uint8_t v) {
auto packet = encoder.color_frame_select(v);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void timer_mode_select(const TimerMode tm) {
auto packet = encoder.timer_mode_select(tm);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void input_check(const uint8_t v) {
auto packet = encoder.input_check(v);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void edit_field_select(const uint8_t v) {
auto packet = encoder.edit_field_select(v);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void freeze_mode_select(const uint8_t v) {
auto packet = encoder.freeze_mode_select(v);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void record_inhibit() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.record_inhibit();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void auto_mode_off() {
auto packet = encoder.auto_mode_off();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void auto_mode_on() {
auto packet = encoder.auto_mode_on();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void spot_erase_off() {
auto packet = encoder.spot_erase_off();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void spot_erase_on() {
auto packet = encoder.spot_erase_on();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_split_off() {
auto packet = encoder.audio_split_off();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_split_on() {
auto packet = encoder.audio_split_on();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void output_h_phase() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.output_h_phase();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void output_video_phase() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.output_video_phase();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_input_level() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.audio_input_level();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_output_level() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.audio_output_level();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_adv_level() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.audio_adv_level();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_output_phase() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.audio_output_phase();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_adv_output_phase() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.audio_adv_output_phase();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void cross_fade_time_preset() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.cross_fade_time_preset();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void local_key_map() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.local_key_map();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void still_off_time(const uint8_t data1, const uint8_t data2) {
// TODO: more user-friendly arguments?
auto packet = encoder.still_off_time(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void stby_off_time(const uint8_t data1, const uint8_t data2) {
// TODO: more user-friendly arguments?
auto packet = encoder.stby_off_time(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
// =============== 6 - Sense Request ===============
void tc_gen_sense(const uint8_t data1) {
auto packet = encoder.tc_gen_sense(data1);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void tc_gen_sense_tc() {
tc_gen_sense(TcGenData::TC);
}
void tc_gen_sense_ub() {
tc_gen_sense(TcGenData::UB);
}
void tc_ub_gen_sense_tc_and_ub() {
tc_gen_sense(TcGenData::TC_UB);
}
void current_time_sense(const uint8_t data1) {
auto packet = encoder.current_time_sense(data1);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void current_time_sense_timer1() {
using namespace CurrentTimeSenseFlag;
current_time_sense(TIMER_1);
}
void current_time_sense_timer2() {
using namespace CurrentTimeSenseFlag;
current_time_sense(TIMER_2);
}
void current_time_sense_ltc_tc_ub() {
using namespace CurrentTimeSenseFlag;
current_time_sense(LTC_UB | LTC_TC);
}
void current_time_sense_ltc_tc() {
using namespace CurrentTimeSenseFlag;
current_time_sense(LTC_TC);
}
void current_time_sense_ltc_ub() {
using namespace CurrentTimeSenseFlag;
current_time_sense(LTC_UB);
}
void current_time_sense_vitc_tc_ub() {
using namespace CurrentTimeSenseFlag;
current_time_sense(VITC_UB | VITC_TC);
}
void current_time_sense_vitc_tc() {
using namespace CurrentTimeSenseFlag;
current_time_sense(VITC_TC);
}
void current_time_sense_vitc_ub() {
using namespace CurrentTimeSenseFlag;
current_time_sense(VITC_UB);
}
// TODO: should confirm if ltc interpolated flag, currently same as LTC
void current_time_sense_ltc_interpolated_tc_ub() {
using namespace CurrentTimeSenseFlag;
current_time_sense(LTC_UB | LTC_TC);
}
void current_time_sense_ltc_interpolated_tc() {
using namespace CurrentTimeSenseFlag;
current_time_sense(LTC_TC);
}
void current_time_sense_ltc_interpolated_ub() {
using namespace CurrentTimeSenseFlag;
current_time_sense(LTC_UB);
}
void in_data_sense() {
auto packet = encoder.in_data_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void out_data_sense() {
auto packet = encoder.out_data_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_in_data_sense() {
auto packet = encoder.audio_in_data_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void audio_out_data_sense() {
auto packet = encoder.audio_out_data_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void status_sense(const uint8_t start = 0, const uint8_t size = 10) {
status_start = start;
status_size = size;
auto packet = encoder.status_sense(start, size);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void extended_vtr_status(const uint8_t data1) {
auto packet = encoder.extended_vtr_status(data1);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void signal_control_sense(const uint8_t data1, const uint8_t data2) {
auto packet = encoder.signal_control_sense(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void local_keymap_sense() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.local_keymap_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void head_meter_sense(const uint8_t data1) {
auto packet = encoder.head_meter_sense(data1);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void remaining_time_sense() {
auto packet = encoder.remaining_time_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void cmd_speed_sense() {
auto packet = encoder.cmd_speed_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void edit_preset_sense(const uint8_t data1) {
auto packet = encoder.edit_preset_sense(data1);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void preroll_time_sense() {
auto packet = encoder.preroll_time_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void timer_mode_sense() {
auto packet = encoder.timer_mode_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void record_inhibit_sense() {
auto packet = encoder.record_inhibit_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void da_inp_emph_sense() {
auto packet = encoder.da_inp_emph_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void da_pb_emph_sense() {
auto packet = encoder.da_pb_emph_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void da_samp_freq_sense() {
auto packet = encoder.da_samp_freq_sense();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void cross_fade_time_sense(const uint8_t data1) {
auto packet = encoder.cross_fade_time_sense(data1);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
// =============== A - BlackMagic Advanced Media Protocol ===============
void bmd_seek_to_timeline_pos(const uint8_t data1, const uint8_t data2) {
// TODO: more user-friendly arguments?
auto packet = encoder.bmd_seek_to_timeline_pos(data1, data2);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void clear_playlist() {
auto packet = encoder.clear_playlist();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void append_preset() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.append_preset();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void set_playback_loop(const bool b_enable, const uint8_t mode = LoopMode::SINGLE_CLIP) {
auto packet = encoder.set_playback_loop(b_enable, mode);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void set_stop_mode(const uint8_t stop_mode) {
auto packet = encoder.set_stop_mode(stop_mode);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void bmd_seek_relative_clip(const int8_t index) {
auto packet = encoder.bmd_seek_relative_clip(index);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void auto_skip(const int8_t n) {
auto packet = encoder.auto_skip(n);
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
void list_next_id() {
// TODO: NOT IMPLEMENTED
auto packet = encoder.list_next_id();
SONY9PINREMOTE_STREAM_WRITE(packet.data(), packet.size());
}
// =============== 1 - System Control Return ===============
bool ack() const { return decoder.ack(); }
Errors nak() const { return decoder.nak(); }
uint16_t device_tpe() const { return decoder.device_type(); }
// =============== 7 - Sense Return ===============
// Generic timecode/userbits response without packet check
TimeCodeAndUserBits timecode_userbits() const { return decoder.timecode_userbits(); }
TimeCode timecode() const { return decoder.timecode(); }
UserBits userbits() const { return decoder.userbits(); }
// Responses to 61.0A Gen Time Sense (with packet check)
TimeCodeAndUserBits gen_tc_ub() const { return decoder.gen_tc_ub(); }
TimeCode gen_tc() const { return decoder.gen_tc(); }
UserBits gen_ub() const { return decoder.gen_ub(); }
// Responses to 61.0C Current Time Sense (with packet check)
TimeCodeAndUserBits timer1_tc_ub() const { return decoder.timer1_tc_ub(); }
TimeCode timer1_tc() const { return decoder.timer1_tc(); }
TimeCodeAndUserBits timer2_tc_ub() const { return decoder.timer2_tc_ub(); }
TimeCode timer2_tc() const { return decoder.timer2_tc(); }
TimeCodeAndUserBits ltc_tc_ub() const { return decoder.ltc_tc_ub(); }
TimeCode ltc_tc() const { return decoder.ltc_tc(); }
UserBits ltc_ub() const { return decoder.ltc_ub(); }
TimeCodeAndUserBits vitc_tc_ub() const { return decoder.vitc_tc_ub(); }
TimeCode vitc_tc() const { return decoder.vitc_tc(); }
UserBits vitc_ub() const { return decoder.vitc_ub(); }
TimeCodeAndUserBits ltc_interpolated_tc_ub() const { return decoder.ltc_interpolated_tc_ub(); }
TimeCode ltc_interpolated_tc() const { return decoder.ltc_interpolated_tc(); }
UserBits ltc_interpolated_ub() const { return decoder.ltc_interpolated_ub(); }
TimeCodeAndUserBits hold_vitc_tc_ub() const { return decoder.hold_vitc_tc_ub(); }
TimeCode hold_vitc_tc() const { return decoder.hold_vitc_tc(); }
UserBits hold_vitc_ub() const { return decoder.hold_vitc_ub(); }
// Responses to other sense requests
TimeCode in_data() const { return decoder.in_data(); }
TimeCode out_data() const { return decoder.out_data(); }
Status status_sense() const { return decoder.status_sense(status_start, status_size); }
TimeCode preroll_time() const { return decoder.preroll_time(); }
TimerMode timer_mode() const { return decoder.timer_mode(); }
// =============== Nak Checker ===============
bool is_nak_unknown_command() const { return err.b_unknown_cmd; }
bool is_nak_checksum_error() const { return err.b_checksum_error; }
bool is_nak_parity_error() const { return err.b_parity_error; }
bool is_nak_buffer_overrun() const { return err.b_buffer_overrun; }
bool is_nak_framing_error() const { return err.b_framing_error; }
bool is_nak_timeout() const { return err.b_timeout; }
// =============== Status Checker ===============
// byte 0
bool is_media_exist() const { return !sts.b_cassette_out; } // set if no ssd is present
bool is_servo_ref_exist() const { return !sts.b_servo_ref_missing; } // set if servo reference is absent
bool is_remote_enabled() const { return !sts.b_local; } // set if remote is disabled (local control)
// byte 1
bool is_disk_available() const { return sts.b_standby; } // set if a disk is available
bool is_stopping() const { return sts.b_stop; } // When the machine is in full stop, this is 1. The thread state depends on the tape/ee and standby settings.
bool is_ejecting() const { return sts.b_eject; } // When the tape is ejecting this is 1.
bool is_fast_reverse() const { return sts.b_rewind; } // When the machine is in fast reverse this is 1.
bool is_fast_forward() const { return sts.b_forward; } // When the machine is in fast forward this is 1.
bool is_recoding() const { return sts.b_record; } // This bit goes from 0 to 1 some number of frames after the machine starts recording. For the DVR2000 we measured 5 frames. Others have varying delays on the record status.
bool is_playing() const { return sts.b_play; } // This bit goes from 0 to 1 some number of frames after the machine starts playing. For the DVR2000 we measured 5 frames. Others have varying delays on the play status.
// byte 2
bool is_servo_locked() const { return sts.b_servo_lock; } // 1 indicates servos are locked. This is a necessary condition for an edit to occur correctly.
bool is_tso_mode() const { return sts.b_tso_mode; } // Bit is 1 in tape speed override: in this mode, audio and video are still locked though speed is off play speed by +/- up to 15%.
bool is_shuttle() const { return sts.b_shuttle; }
bool is_jog() const { return sts.b_jog; }
bool is_var() const { return sts.b_var; }
bool is_reverse() const { return sts.b_direction; } // clear if playback is forwarding, set if playback is reversing
bool is_paused() const { return sts.b_still; } // set if playback is paused, or if in input preview mode
bool is_cue_up() const { return sts.b_cue_up; }
// byte 3
bool is_auto_mode() const { return sts.b_auto_mode; } // set if in Auto Mode
bool is_freezing() const { return sts.b_freeze_on; }
bool is_cf_mode() const { return sts.b_cf_mode; }
bool is_audio_out_set() const { return sts.b_audio_out_set; }
bool is_audio_in_set() const { return sts.b_audio_in_set; }
bool is_out_set() const { return sts.b_out_set; }
bool is_in_set() const { return sts.b_in_set; }
// byte 4
bool is_select_ee() const { return sts.b_select_ee; } // set if in input preview mode
bool is_full_ee() const { return sts.b_full_ee; }
bool is_edit() const { return sts.b_edit; }
bool is_review() const { return sts.b_review; }
bool is_auto_edit() const { return sts.b_auto_edit; }
bool is_preview() const { return sts.b_preview; }
bool is_preroll() const { return sts.b_preroll; }
// byte 5
bool is_insert() const { return sts.b_insert; }
bool is_assemble() const { return sts.b_assemble; }